documentation.d.ts 3.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * 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.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * 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.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. }
  1053. }
  1054. declare module BABYLON {
  1055. /**
  1056. * This represents the required contract to create a new type of texture loader.
  1057. */
  1058. export interface IInternalTextureLoader {
  1059. /**
  1060. * Defines wether the loader supports cascade loading the different faces.
  1061. */
  1062. supportCascades: boolean;
  1063. /**
  1064. * This returns if the loader support the current file information.
  1065. * @param extension defines the file extension of the file being loaded
  1066. * @returns true if the loader can load the specified file
  1067. */
  1068. canLoad(extension: string): boolean;
  1069. /**
  1070. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1071. * @param data contains the texture data
  1072. * @param texture defines the BabylonJS internal texture
  1073. * @param createPolynomials will be true if polynomials have been requested
  1074. * @param onLoad defines the callback to trigger once the texture is ready
  1075. * @param onError defines the callback to trigger in case of error
  1076. */
  1077. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1078. /**
  1079. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param callback defines the method to call once ready to upload
  1083. */
  1084. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1085. }
  1086. }
  1087. declare module BABYLON {
  1088. /**
  1089. * Class used to store and describe the pipeline context associated with an effect
  1090. */
  1091. export interface IPipelineContext {
  1092. /**
  1093. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1094. */
  1095. isAsync: boolean;
  1096. /**
  1097. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1098. */
  1099. isReady: boolean;
  1100. /** @hidden */
  1101. _getVertexShaderCode(): string | null;
  1102. /** @hidden */
  1103. _getFragmentShaderCode(): string | null;
  1104. /** @hidden */
  1105. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1106. }
  1107. }
  1108. declare module BABYLON {
  1109. /**
  1110. * Class used to store gfx data (like WebGLBuffer)
  1111. */
  1112. export class DataBuffer {
  1113. /**
  1114. * Gets or sets the number of objects referencing this buffer
  1115. */
  1116. references: number;
  1117. /** Gets or sets the size of the underlying buffer */
  1118. capacity: number;
  1119. /**
  1120. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1121. */
  1122. is32Bits: boolean;
  1123. /**
  1124. * Gets the underlying buffer
  1125. */
  1126. get underlyingResource(): any;
  1127. }
  1128. }
  1129. declare module BABYLON {
  1130. /** @hidden */
  1131. export interface IShaderProcessor {
  1132. attributeProcessor?: (attribute: string) => string;
  1133. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1134. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1135. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1136. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1137. lineProcessor?: (line: string, isFragment: boolean) => string;
  1138. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1139. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1140. }
  1141. }
  1142. declare module BABYLON {
  1143. /** @hidden */
  1144. export interface ProcessingOptions {
  1145. defines: string[];
  1146. indexParameters: any;
  1147. isFragment: boolean;
  1148. shouldUseHighPrecisionShader: boolean;
  1149. supportsUniformBuffers: boolean;
  1150. shadersRepository: string;
  1151. includesShadersStore: {
  1152. [key: string]: string;
  1153. };
  1154. processor?: IShaderProcessor;
  1155. version: string;
  1156. platformName: string;
  1157. lookForClosingBracketForUniformBuffer?: boolean;
  1158. }
  1159. }
  1160. declare module BABYLON {
  1161. /** @hidden */
  1162. export class ShaderCodeNode {
  1163. line: string;
  1164. children: ShaderCodeNode[];
  1165. additionalDefineKey?: string;
  1166. additionalDefineValue?: string;
  1167. isValid(preprocessors: {
  1168. [key: string]: string;
  1169. }): boolean;
  1170. process(preprocessors: {
  1171. [key: string]: string;
  1172. }, options: ProcessingOptions): string;
  1173. }
  1174. }
  1175. declare module BABYLON {
  1176. /** @hidden */
  1177. export class ShaderCodeCursor {
  1178. private _lines;
  1179. lineIndex: number;
  1180. get currentLine(): string;
  1181. get canRead(): boolean;
  1182. set lines(value: string[]);
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1188. process(preprocessors: {
  1189. [key: string]: string;
  1190. }, options: ProcessingOptions): string;
  1191. }
  1192. }
  1193. declare module BABYLON {
  1194. /** @hidden */
  1195. export class ShaderDefineExpression {
  1196. isTrue(preprocessors: {
  1197. [key: string]: string;
  1198. }): boolean;
  1199. private static _OperatorPriority;
  1200. private static _Stack;
  1201. static postfixToInfix(postfix: string[]): string;
  1202. static infixToPostfix(infix: string): string[];
  1203. }
  1204. }
  1205. declare module BABYLON {
  1206. /** @hidden */
  1207. export class ShaderCodeTestNode extends ShaderCodeNode {
  1208. testExpression: ShaderDefineExpression;
  1209. isValid(preprocessors: {
  1210. [key: string]: string;
  1211. }): boolean;
  1212. }
  1213. }
  1214. declare module BABYLON {
  1215. /** @hidden */
  1216. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1217. define: string;
  1218. not: boolean;
  1219. constructor(define: string, not?: boolean);
  1220. isTrue(preprocessors: {
  1221. [key: string]: string;
  1222. }): boolean;
  1223. }
  1224. }
  1225. declare module BABYLON {
  1226. /** @hidden */
  1227. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1228. leftOperand: ShaderDefineExpression;
  1229. rightOperand: ShaderDefineExpression;
  1230. isTrue(preprocessors: {
  1231. [key: string]: string;
  1232. }): boolean;
  1233. }
  1234. }
  1235. declare module BABYLON {
  1236. /** @hidden */
  1237. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1238. leftOperand: ShaderDefineExpression;
  1239. rightOperand: ShaderDefineExpression;
  1240. isTrue(preprocessors: {
  1241. [key: string]: string;
  1242. }): boolean;
  1243. }
  1244. }
  1245. declare module BABYLON {
  1246. /** @hidden */
  1247. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1248. define: string;
  1249. operand: string;
  1250. testValue: string;
  1251. constructor(define: string, operand: string, testValue: string);
  1252. isTrue(preprocessors: {
  1253. [key: string]: string;
  1254. }): boolean;
  1255. }
  1256. }
  1257. declare module BABYLON {
  1258. /**
  1259. * Class used to enable access to offline support
  1260. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1261. */
  1262. export interface IOfflineProvider {
  1263. /**
  1264. * Gets a boolean indicating if scene must be saved in the database
  1265. */
  1266. enableSceneOffline: boolean;
  1267. /**
  1268. * Gets a boolean indicating if textures must be saved in the database
  1269. */
  1270. enableTexturesOffline: boolean;
  1271. /**
  1272. * Open the offline support and make it available
  1273. * @param successCallback defines the callback to call on success
  1274. * @param errorCallback defines the callback to call on error
  1275. */
  1276. open(successCallback: () => void, errorCallback: () => void): void;
  1277. /**
  1278. * Loads an image from the offline support
  1279. * @param url defines the url to load from
  1280. * @param image defines the target DOM image
  1281. */
  1282. loadImage(url: string, image: HTMLImageElement): void;
  1283. /**
  1284. * Loads a file from offline support
  1285. * @param url defines the URL to load from
  1286. * @param sceneLoaded defines a callback to call on success
  1287. * @param progressCallBack defines a callback to call when progress changed
  1288. * @param errorCallback defines a callback to call on error
  1289. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1290. */
  1291. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * Class used to help managing file picking and drag'n'drop
  1297. * File Storage
  1298. */
  1299. export class FilesInputStore {
  1300. /**
  1301. * List of files ready to be loaded
  1302. */
  1303. static FilesToLoad: {
  1304. [key: string]: File;
  1305. };
  1306. }
  1307. }
  1308. declare module BABYLON {
  1309. /**
  1310. * Class used to define a retry strategy when error happens while loading assets
  1311. */
  1312. export class RetryStrategy {
  1313. /**
  1314. * Function used to defines an exponential back off strategy
  1315. * @param maxRetries defines the maximum number of retries (3 by default)
  1316. * @param baseInterval defines the interval between retries
  1317. * @returns the strategy function to use
  1318. */
  1319. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1320. }
  1321. }
  1322. declare module BABYLON {
  1323. /**
  1324. * @ignore
  1325. * Application error to support additional information when loading a file
  1326. */
  1327. export abstract class BaseError extends Error {
  1328. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1329. }
  1330. }
  1331. declare module BABYLON {
  1332. /** @ignore */
  1333. export class LoadFileError extends BaseError {
  1334. request?: WebRequest;
  1335. file?: File;
  1336. /**
  1337. * Creates a new LoadFileError
  1338. * @param message defines the message of the error
  1339. * @param request defines the optional web request
  1340. * @param file defines the optional file
  1341. */
  1342. constructor(message: string, object?: WebRequest | File);
  1343. }
  1344. /** @ignore */
  1345. export class RequestFileError extends BaseError {
  1346. request: WebRequest;
  1347. /**
  1348. * Creates a new LoadFileError
  1349. * @param message defines the message of the error
  1350. * @param request defines the optional web request
  1351. */
  1352. constructor(message: string, request: WebRequest);
  1353. }
  1354. /** @ignore */
  1355. export class ReadFileError extends BaseError {
  1356. file: File;
  1357. /**
  1358. * Creates a new ReadFileError
  1359. * @param message defines the message of the error
  1360. * @param file defines the optional file
  1361. */
  1362. constructor(message: string, file: File);
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export class FileTools {
  1368. /**
  1369. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1370. */
  1371. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1372. /**
  1373. * Gets or sets the base URL to use to load assets
  1374. */
  1375. static BaseUrl: string;
  1376. /**
  1377. * Default behaviour for cors in the application.
  1378. * It can be a string if the expected behavior is identical in the entire app.
  1379. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1380. */
  1381. static CorsBehavior: string | ((url: string | string[]) => string);
  1382. /**
  1383. * Gets or sets a function used to pre-process url before using them to load assets
  1384. */
  1385. static PreprocessUrl: (url: string) => string;
  1386. /**
  1387. * Removes unwanted characters from an url
  1388. * @param url defines the url to clean
  1389. * @returns the cleaned url
  1390. */
  1391. private static _CleanUrl;
  1392. /**
  1393. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1394. * @param url define the url we are trying
  1395. * @param element define the dom element where to configure the cors policy
  1396. */
  1397. static SetCorsBehavior(url: string | string[], element: {
  1398. crossOrigin: string | null;
  1399. }): void;
  1400. /**
  1401. * Loads an image as an HTMLImageElement.
  1402. * @param input url string, ArrayBuffer, or Blob to load
  1403. * @param onLoad callback called when the image successfully loads
  1404. * @param onError callback called when the image fails to load
  1405. * @param offlineProvider offline provider for caching
  1406. * @param mimeType optional mime type
  1407. * @returns the HTMLImageElement of the loaded image
  1408. */
  1409. 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>;
  1410. /**
  1411. * Reads a file from a File object
  1412. * @param file defines the file to load
  1413. * @param onSuccess defines the callback to call when data is loaded
  1414. * @param onProgress defines the callback to call during loading process
  1415. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1416. * @param onError defines the callback to call when an error occurs
  1417. * @returns a file request object
  1418. */
  1419. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1420. /**
  1421. * Loads a file from a url
  1422. * @param url url to load
  1423. * @param onSuccess callback called when the file successfully loads
  1424. * @param onProgress callback called while file is loading (if the server supports this mode)
  1425. * @param offlineProvider defines the offline provider for caching
  1426. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1427. * @param onError callback called when the file fails to load
  1428. * @returns a file request object
  1429. */
  1430. 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;
  1431. /**
  1432. * Loads a file
  1433. * @param url url to load
  1434. * @param onSuccess callback called when the file successfully loads
  1435. * @param onProgress callback called while file is loading (if the server supports this mode)
  1436. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1437. * @param onError callback called when the file fails to load
  1438. * @param onOpened callback called when the web request is opened
  1439. * @returns a file request object
  1440. */
  1441. 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;
  1442. /**
  1443. * Checks if the loaded document was accessed via `file:`-Protocol.
  1444. * @returns boolean
  1445. */
  1446. static IsFileURL(): boolean;
  1447. }
  1448. }
  1449. declare module BABYLON {
  1450. /** @hidden */
  1451. export class ShaderProcessor {
  1452. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1453. private static _ProcessPrecision;
  1454. private static _ExtractOperation;
  1455. private static _BuildSubExpression;
  1456. private static _BuildExpression;
  1457. private static _MoveCursorWithinIf;
  1458. private static _MoveCursor;
  1459. private static _EvaluatePreProcessors;
  1460. private static _PreparePreProcessors;
  1461. private static _ProcessShaderConversion;
  1462. private static _ProcessIncludes;
  1463. /**
  1464. * Loads a file from a url
  1465. * @param url url to load
  1466. * @param onSuccess callback called when the file successfully loads
  1467. * @param onProgress callback called while file is loading (if the server supports this mode)
  1468. * @param offlineProvider defines the offline provider for caching
  1469. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1470. * @param onError callback called when the file fails to load
  1471. * @returns a file request object
  1472. * @hidden
  1473. */
  1474. 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;
  1475. }
  1476. }
  1477. declare module BABYLON {
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IColor4Like {
  1482. r: float;
  1483. g: float;
  1484. b: float;
  1485. a: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IColor3Like {
  1491. r: float;
  1492. g: float;
  1493. b: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector4Like {
  1499. x: float;
  1500. y: float;
  1501. z: float;
  1502. w: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector3Like {
  1508. x: float;
  1509. y: float;
  1510. z: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector2Like {
  1516. x: float;
  1517. y: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IMatrixLike {
  1523. toArray(): DeepImmutable<Float32Array>;
  1524. updateFlag: int;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IViewportLike {
  1530. x: float;
  1531. y: float;
  1532. width: float;
  1533. height: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IPlaneLike {
  1539. normal: IVector3Like;
  1540. d: float;
  1541. normalize(): void;
  1542. }
  1543. }
  1544. declare module BABYLON {
  1545. /**
  1546. * Interface used to define common properties for effect fallbacks
  1547. */
  1548. export interface IEffectFallbacks {
  1549. /**
  1550. * Removes the defines that should be removed when falling back.
  1551. * @param currentDefines defines the current define statements for the shader.
  1552. * @param effect defines the current effect we try to compile
  1553. * @returns The resulting defines with defines of the current rank removed.
  1554. */
  1555. reduce(currentDefines: string, effect: Effect): string;
  1556. /**
  1557. * Removes the fallback from the bound mesh.
  1558. */
  1559. unBindMesh(): void;
  1560. /**
  1561. * Checks to see if more fallbacks are still availible.
  1562. */
  1563. hasMoreFallbacks: boolean;
  1564. }
  1565. }
  1566. declare module BABYLON {
  1567. /**
  1568. * Class used to evalaute queries containing `and` and `or` operators
  1569. */
  1570. export class AndOrNotEvaluator {
  1571. /**
  1572. * Evaluate a query
  1573. * @param query defines the query to evaluate
  1574. * @param evaluateCallback defines the callback used to filter result
  1575. * @returns true if the query matches
  1576. */
  1577. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1578. private static _HandleParenthesisContent;
  1579. private static _SimplifyNegation;
  1580. }
  1581. }
  1582. declare module BABYLON {
  1583. /**
  1584. * Class used to store custom tags
  1585. */
  1586. export class Tags {
  1587. /**
  1588. * Adds support for tags on the given object
  1589. * @param obj defines the object to use
  1590. */
  1591. static EnableFor(obj: any): void;
  1592. /**
  1593. * Removes tags support
  1594. * @param obj defines the object to use
  1595. */
  1596. static DisableFor(obj: any): void;
  1597. /**
  1598. * Gets a boolean indicating if the given object has tags
  1599. * @param obj defines the object to use
  1600. * @returns a boolean
  1601. */
  1602. static HasTags(obj: any): boolean;
  1603. /**
  1604. * Gets the tags available on a given object
  1605. * @param obj defines the object to use
  1606. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1607. * @returns the tags
  1608. */
  1609. static GetTags(obj: any, asString?: boolean): any;
  1610. /**
  1611. * Adds tags to an object
  1612. * @param obj defines the object to use
  1613. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1614. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1615. */
  1616. static AddTagsTo(obj: any, tagsString: string): void;
  1617. /**
  1618. * @hidden
  1619. */
  1620. static _AddTagTo(obj: any, tag: string): void;
  1621. /**
  1622. * Removes specific tags from a specific object
  1623. * @param obj defines the object to use
  1624. * @param tagsString defines the tags to remove
  1625. */
  1626. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1627. /**
  1628. * @hidden
  1629. */
  1630. static _RemoveTagFrom(obj: any, tag: string): void;
  1631. /**
  1632. * Defines if tags hosted on an object match a given query
  1633. * @param obj defines the object to use
  1634. * @param tagsQuery defines the tag query
  1635. * @returns a boolean
  1636. */
  1637. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1638. }
  1639. }
  1640. declare module BABYLON {
  1641. /**
  1642. * Scalar computation library
  1643. */
  1644. export class Scalar {
  1645. /**
  1646. * Two pi constants convenient for computation.
  1647. */
  1648. static TwoPi: number;
  1649. /**
  1650. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1651. * @param a number
  1652. * @param b number
  1653. * @param epsilon (default = 1.401298E-45)
  1654. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1655. */
  1656. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1657. /**
  1658. * Returns a string : the upper case translation of the number i to hexadecimal.
  1659. * @param i number
  1660. * @returns the upper case translation of the number i to hexadecimal.
  1661. */
  1662. static ToHex(i: number): string;
  1663. /**
  1664. * Returns -1 if value is negative and +1 is value is positive.
  1665. * @param value the value
  1666. * @returns the value itself if it's equal to zero.
  1667. */
  1668. static Sign(value: number): number;
  1669. /**
  1670. * Returns the value itself if it's between min and max.
  1671. * Returns min if the value is lower than min.
  1672. * Returns max if the value is greater than max.
  1673. * @param value the value to clmap
  1674. * @param min the min value to clamp to (default: 0)
  1675. * @param max the max value to clamp to (default: 1)
  1676. * @returns the clamped value
  1677. */
  1678. static Clamp(value: number, min?: number, max?: number): number;
  1679. /**
  1680. * the log2 of value.
  1681. * @param value the value to compute log2 of
  1682. * @returns the log2 of value.
  1683. */
  1684. static Log2(value: number): number;
  1685. /**
  1686. * Loops the value, so that it is never larger than length and never smaller than 0.
  1687. *
  1688. * This is similar to the modulo operator but it works with floating point numbers.
  1689. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1690. * With t = 5 and length = 2.5, the result would be 0.0.
  1691. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1692. * @param value the value
  1693. * @param length the length
  1694. * @returns the looped value
  1695. */
  1696. static Repeat(value: number, length: number): number;
  1697. /**
  1698. * Normalize the value between 0.0 and 1.0 using min and max values
  1699. * @param value value to normalize
  1700. * @param min max to normalize between
  1701. * @param max min to normalize between
  1702. * @returns the normalized value
  1703. */
  1704. static Normalize(value: number, min: number, max: number): number;
  1705. /**
  1706. * Denormalize the value from 0.0 and 1.0 using min and max values
  1707. * @param normalized value to denormalize
  1708. * @param min max to denormalize between
  1709. * @param max min to denormalize between
  1710. * @returns the denormalized value
  1711. */
  1712. static Denormalize(normalized: number, min: number, max: number): number;
  1713. /**
  1714. * Calculates the shortest difference between two given angles given in degrees.
  1715. * @param current current angle in degrees
  1716. * @param target target angle in degrees
  1717. * @returns the delta
  1718. */
  1719. static DeltaAngle(current: number, target: number): number;
  1720. /**
  1721. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1722. * @param tx value
  1723. * @param length length
  1724. * @returns The returned value will move back and forth between 0 and length
  1725. */
  1726. static PingPong(tx: number, length: number): number;
  1727. /**
  1728. * Interpolates between min and max with smoothing at the limits.
  1729. *
  1730. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1731. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1732. * @param from from
  1733. * @param to to
  1734. * @param tx value
  1735. * @returns the smooth stepped value
  1736. */
  1737. static SmoothStep(from: number, to: number, tx: number): number;
  1738. /**
  1739. * Moves a value current towards target.
  1740. *
  1741. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1742. * Negative values of maxDelta pushes the value away from target.
  1743. * @param current current value
  1744. * @param target target value
  1745. * @param maxDelta max distance to move
  1746. * @returns resulting value
  1747. */
  1748. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1749. /**
  1750. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1751. *
  1752. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1753. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1754. * @param current current value
  1755. * @param target target value
  1756. * @param maxDelta max distance to move
  1757. * @returns resulting angle
  1758. */
  1759. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1760. /**
  1761. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1762. * @param start start value
  1763. * @param end target value
  1764. * @param amount amount to lerp between
  1765. * @returns the lerped value
  1766. */
  1767. static Lerp(start: number, end: number, amount: number): number;
  1768. /**
  1769. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1770. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1771. * @param start start value
  1772. * @param end target value
  1773. * @param amount amount to lerp between
  1774. * @returns the lerped value
  1775. */
  1776. static LerpAngle(start: number, end: number, amount: number): number;
  1777. /**
  1778. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1779. * @param a start value
  1780. * @param b target value
  1781. * @param value value between a and b
  1782. * @returns the inverseLerp value
  1783. */
  1784. static InverseLerp(a: number, b: number, value: number): number;
  1785. /**
  1786. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1787. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1788. * @param value1 spline value
  1789. * @param tangent1 spline value
  1790. * @param value2 spline value
  1791. * @param tangent2 spline value
  1792. * @param amount input value
  1793. * @returns hermite result
  1794. */
  1795. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1796. /**
  1797. * Returns a random float number between and min and max values
  1798. * @param min min value of random
  1799. * @param max max value of random
  1800. * @returns random value
  1801. */
  1802. static RandomRange(min: number, max: number): number;
  1803. /**
  1804. * This function returns percentage of a number in a given range.
  1805. *
  1806. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1807. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1808. * @param number to convert to percentage
  1809. * @param min min range
  1810. * @param max max range
  1811. * @returns the percentage
  1812. */
  1813. static RangeToPercent(number: number, min: number, max: number): number;
  1814. /**
  1815. * This function returns number that corresponds to the percentage in a given range.
  1816. *
  1817. * PercentToRange(0.34,0,100) will return 34.
  1818. * @param percent to convert to number
  1819. * @param min min range
  1820. * @param max max range
  1821. * @returns the number
  1822. */
  1823. static PercentToRange(percent: number, min: number, max: number): number;
  1824. /**
  1825. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1826. * @param angle The angle to normalize in radian.
  1827. * @return The converted angle.
  1828. */
  1829. static NormalizeRadians(angle: number): number;
  1830. }
  1831. }
  1832. declare module BABYLON {
  1833. /**
  1834. * Constant used to convert a value to gamma space
  1835. * @ignorenaming
  1836. */
  1837. export const ToGammaSpace: number;
  1838. /**
  1839. * Constant used to convert a value to linear space
  1840. * @ignorenaming
  1841. */
  1842. export const ToLinearSpace = 2.2;
  1843. /**
  1844. * Constant used to define the minimal number value in Babylon.js
  1845. * @ignorenaming
  1846. */
  1847. let Epsilon: number;
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Class used to represent a viewport on screen
  1852. */
  1853. export class Viewport {
  1854. /** viewport left coordinate */
  1855. x: number;
  1856. /** viewport top coordinate */
  1857. y: number;
  1858. /**viewport width */
  1859. width: number;
  1860. /** viewport height */
  1861. height: number;
  1862. /**
  1863. * Creates a Viewport object located at (x, y) and sized (width, height)
  1864. * @param x defines viewport left coordinate
  1865. * @param y defines viewport top coordinate
  1866. * @param width defines the viewport width
  1867. * @param height defines the viewport height
  1868. */
  1869. constructor(
  1870. /** viewport left coordinate */
  1871. x: number,
  1872. /** viewport top coordinate */
  1873. y: number,
  1874. /**viewport width */
  1875. width: number,
  1876. /** viewport height */
  1877. height: number);
  1878. /**
  1879. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1880. * @param renderWidth defines the rendering width
  1881. * @param renderHeight defines the rendering height
  1882. * @returns a new Viewport
  1883. */
  1884. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1885. /**
  1886. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1887. * @param renderWidth defines the rendering width
  1888. * @param renderHeight defines the rendering height
  1889. * @param ref defines the target viewport
  1890. * @returns the current viewport
  1891. */
  1892. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1893. /**
  1894. * Returns a new Viewport copied from the current one
  1895. * @returns a new Viewport
  1896. */
  1897. clone(): Viewport;
  1898. }
  1899. }
  1900. declare module BABYLON {
  1901. /**
  1902. * Class containing a set of static utilities functions for arrays.
  1903. */
  1904. export class ArrayTools {
  1905. /**
  1906. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1907. * @param size the number of element to construct and put in the array
  1908. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1909. * @returns a new array filled with new objects
  1910. */
  1911. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1912. }
  1913. }
  1914. declare module BABYLON {
  1915. /**
  1916. * Represens a plane by the equation ax + by + cz + d = 0
  1917. */
  1918. export class Plane {
  1919. private static _TmpMatrix;
  1920. /**
  1921. * Normal of the plane (a,b,c)
  1922. */
  1923. normal: Vector3;
  1924. /**
  1925. * d component of the plane
  1926. */
  1927. d: number;
  1928. /**
  1929. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1930. * @param a a component of the plane
  1931. * @param b b component of the plane
  1932. * @param c c component of the plane
  1933. * @param d d component of the plane
  1934. */
  1935. constructor(a: number, b: number, c: number, d: number);
  1936. /**
  1937. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1938. */
  1939. asArray(): number[];
  1940. /**
  1941. * @returns a new plane copied from the current Plane.
  1942. */
  1943. clone(): Plane;
  1944. /**
  1945. * @returns the string "Plane".
  1946. */
  1947. getClassName(): string;
  1948. /**
  1949. * @returns the Plane hash code.
  1950. */
  1951. getHashCode(): number;
  1952. /**
  1953. * Normalize the current Plane in place.
  1954. * @returns the updated Plane.
  1955. */
  1956. normalize(): Plane;
  1957. /**
  1958. * Applies a transformation the plane and returns the result
  1959. * @param transformation the transformation matrix to be applied to the plane
  1960. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1961. */
  1962. transform(transformation: DeepImmutable<Matrix>): Plane;
  1963. /**
  1964. * Compute the dot product between the point and the plane normal
  1965. * @param point point to calculate the dot product with
  1966. * @returns the dot product (float) of the point coordinates and the plane normal.
  1967. */
  1968. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1969. /**
  1970. * Updates the current Plane from the plane defined by the three given points.
  1971. * @param point1 one of the points used to contruct the plane
  1972. * @param point2 one of the points used to contruct the plane
  1973. * @param point3 one of the points used to contruct the plane
  1974. * @returns the updated Plane.
  1975. */
  1976. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1977. /**
  1978. * Checks if the plane is facing a given direction
  1979. * @param direction the direction to check if the plane is facing
  1980. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1981. * @returns True is the vector "direction" is the same side than the plane normal.
  1982. */
  1983. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  1984. /**
  1985. * Calculates the distance to a point
  1986. * @param point point to calculate distance to
  1987. * @returns the signed distance (float) from the given point to the Plane.
  1988. */
  1989. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  1990. /**
  1991. * Creates a plane from an array
  1992. * @param array the array to create a plane from
  1993. * @returns a new Plane from the given array.
  1994. */
  1995. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  1996. /**
  1997. * Creates a plane from three points
  1998. * @param point1 point used to create the plane
  1999. * @param point2 point used to create the plane
  2000. * @param point3 point used to create the plane
  2001. * @returns a new Plane defined by the three given points.
  2002. */
  2003. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2004. /**
  2005. * Creates a plane from an origin point and a normal
  2006. * @param origin origin of the plane to be constructed
  2007. * @param normal normal of the plane to be constructed
  2008. * @returns a new Plane the normal vector to this plane at the given origin point.
  2009. * Note : the vector "normal" is updated because normalized.
  2010. */
  2011. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2012. /**
  2013. * Calculates the distance from a plane and a point
  2014. * @param origin origin of the plane to be constructed
  2015. * @param normal normal of the plane to be constructed
  2016. * @param point point to calculate distance to
  2017. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2018. */
  2019. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2020. }
  2021. }
  2022. declare module BABYLON {
  2023. /**
  2024. * Class representing a vector containing 2 coordinates
  2025. */
  2026. export class Vector2 {
  2027. /** defines the first coordinate */
  2028. x: number;
  2029. /** defines the second coordinate */
  2030. y: number;
  2031. /**
  2032. * Creates a new Vector2 from the given x and y coordinates
  2033. * @param x defines the first coordinate
  2034. * @param y defines the second coordinate
  2035. */
  2036. constructor(
  2037. /** defines the first coordinate */
  2038. x?: number,
  2039. /** defines the second coordinate */
  2040. y?: number);
  2041. /**
  2042. * Gets a string with the Vector2 coordinates
  2043. * @returns a string with the Vector2 coordinates
  2044. */
  2045. toString(): string;
  2046. /**
  2047. * Gets class name
  2048. * @returns the string "Vector2"
  2049. */
  2050. getClassName(): string;
  2051. /**
  2052. * Gets current vector hash code
  2053. * @returns the Vector2 hash code as a number
  2054. */
  2055. getHashCode(): number;
  2056. /**
  2057. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2058. * @param array defines the source array
  2059. * @param index defines the offset in source array
  2060. * @returns the current Vector2
  2061. */
  2062. toArray(array: FloatArray, index?: number): Vector2;
  2063. /**
  2064. * Copy the current vector to an array
  2065. * @returns a new array with 2 elements: the Vector2 coordinates.
  2066. */
  2067. asArray(): number[];
  2068. /**
  2069. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2070. * @param source defines the source Vector2
  2071. * @returns the current updated Vector2
  2072. */
  2073. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2074. /**
  2075. * Sets the Vector2 coordinates with the given floats
  2076. * @param x defines the first coordinate
  2077. * @param y defines the second coordinate
  2078. * @returns the current updated Vector2
  2079. */
  2080. copyFromFloats(x: number, y: number): Vector2;
  2081. /**
  2082. * Sets the Vector2 coordinates with the given floats
  2083. * @param x defines the first coordinate
  2084. * @param y defines the second coordinate
  2085. * @returns the current updated Vector2
  2086. */
  2087. set(x: number, y: number): Vector2;
  2088. /**
  2089. * Add another vector with the current one
  2090. * @param otherVector defines the other vector
  2091. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2092. */
  2093. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2094. /**
  2095. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2096. * @param otherVector defines the other vector
  2097. * @param result defines the target vector
  2098. * @returns the unmodified current Vector2
  2099. */
  2100. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2101. /**
  2102. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2103. * @param otherVector defines the other vector
  2104. * @returns the current updated Vector2
  2105. */
  2106. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2107. /**
  2108. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2109. * @param otherVector defines the other vector
  2110. * @returns a new Vector2
  2111. */
  2112. addVector3(otherVector: Vector3): Vector2;
  2113. /**
  2114. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2115. * @param otherVector defines the other vector
  2116. * @returns a new Vector2
  2117. */
  2118. subtract(otherVector: Vector2): Vector2;
  2119. /**
  2120. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2121. * @param otherVector defines the other vector
  2122. * @param result defines the target vector
  2123. * @returns the unmodified current Vector2
  2124. */
  2125. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2126. /**
  2127. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2128. * @param otherVector defines the other vector
  2129. * @returns the current updated Vector2
  2130. */
  2131. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2132. /**
  2133. * Multiplies in place the current Vector2 coordinates by the given ones
  2134. * @param otherVector defines the other vector
  2135. * @returns the current updated Vector2
  2136. */
  2137. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2138. /**
  2139. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2140. * @param otherVector defines the other vector
  2141. * @returns a new Vector2
  2142. */
  2143. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2146. * @param otherVector defines the other vector
  2147. * @param result defines the target vector
  2148. * @returns the unmodified current Vector2
  2149. */
  2150. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2151. /**
  2152. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2153. * @param x defines the first coordinate
  2154. * @param y defines the second coordinate
  2155. * @returns a new Vector2
  2156. */
  2157. multiplyByFloats(x: number, y: number): Vector2;
  2158. /**
  2159. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2160. * @param otherVector defines the other vector
  2161. * @returns a new Vector2
  2162. */
  2163. divide(otherVector: Vector2): Vector2;
  2164. /**
  2165. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2166. * @param otherVector defines the other vector
  2167. * @param result defines the target vector
  2168. * @returns the unmodified current Vector2
  2169. */
  2170. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2171. /**
  2172. * Divides the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Gets a new Vector2 with current Vector2 negated coordinates
  2179. * @returns a new Vector2
  2180. */
  2181. negate(): Vector2;
  2182. /**
  2183. * Negate this vector in place
  2184. * @returns this
  2185. */
  2186. negateInPlace(): Vector2;
  2187. /**
  2188. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2189. * @param result defines the Vector3 object where to store the result
  2190. * @returns the current Vector2
  2191. */
  2192. negateToRef(result: Vector2): Vector2;
  2193. /**
  2194. * Multiply the Vector2 coordinates by scale
  2195. * @param scale defines the scaling factor
  2196. * @returns the current updated Vector2
  2197. */
  2198. scaleInPlace(scale: number): Vector2;
  2199. /**
  2200. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2201. * @param scale defines the scaling factor
  2202. * @returns a new Vector2
  2203. */
  2204. scale(scale: number): Vector2;
  2205. /**
  2206. * Scale the current Vector2 values by a factor to a given Vector2
  2207. * @param scale defines the scale factor
  2208. * @param result defines the Vector2 object where to store the result
  2209. * @returns the unmodified current Vector2
  2210. */
  2211. scaleToRef(scale: number, result: Vector2): Vector2;
  2212. /**
  2213. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2214. * @param scale defines the scale factor
  2215. * @param result defines the Vector2 object where to store the result
  2216. * @returns the unmodified current Vector2
  2217. */
  2218. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2219. /**
  2220. * Gets a boolean if two vectors are equals
  2221. * @param otherVector defines the other vector
  2222. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2223. */
  2224. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2225. /**
  2226. * Gets a boolean if two vectors are equals (using an epsilon value)
  2227. * @param otherVector defines the other vector
  2228. * @param epsilon defines the minimal distance to consider equality
  2229. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2230. */
  2231. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2232. /**
  2233. * Gets a new Vector2 from current Vector2 floored values
  2234. * @returns a new Vector2
  2235. */
  2236. floor(): Vector2;
  2237. /**
  2238. * Gets a new Vector2 from current Vector2 floored values
  2239. * @returns a new Vector2
  2240. */
  2241. fract(): Vector2;
  2242. /**
  2243. * Gets the length of the vector
  2244. * @returns the vector length (float)
  2245. */
  2246. length(): number;
  2247. /**
  2248. * Gets the vector squared length
  2249. * @returns the vector squared length (float)
  2250. */
  2251. lengthSquared(): number;
  2252. /**
  2253. * Normalize the vector
  2254. * @returns the current updated Vector2
  2255. */
  2256. normalize(): Vector2;
  2257. /**
  2258. * Gets a new Vector2 copied from the Vector2
  2259. * @returns a new Vector2
  2260. */
  2261. clone(): Vector2;
  2262. /**
  2263. * Gets a new Vector2(0, 0)
  2264. * @returns a new Vector2
  2265. */
  2266. static Zero(): Vector2;
  2267. /**
  2268. * Gets a new Vector2(1, 1)
  2269. * @returns a new Vector2
  2270. */
  2271. static One(): Vector2;
  2272. /**
  2273. * Gets a new Vector2 set from the given index element of the given array
  2274. * @param array defines the data source
  2275. * @param offset defines the offset in the data source
  2276. * @returns a new Vector2
  2277. */
  2278. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2279. /**
  2280. * Sets "result" from the given index element of the given array
  2281. * @param array defines the data source
  2282. * @param offset defines the offset in the data source
  2283. * @param result defines the target vector
  2284. */
  2285. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2286. /**
  2287. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2288. * @param value1 defines 1st point of control
  2289. * @param value2 defines 2nd point of control
  2290. * @param value3 defines 3rd point of control
  2291. * @param value4 defines 4th point of control
  2292. * @param amount defines the interpolation factor
  2293. * @returns a new Vector2
  2294. */
  2295. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2296. /**
  2297. * 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".
  2298. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2299. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2300. * @param value defines the value to clamp
  2301. * @param min defines the lower limit
  2302. * @param max defines the upper limit
  2303. * @returns a new Vector2
  2304. */
  2305. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2306. /**
  2307. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2308. * @param value1 defines the 1st control point
  2309. * @param tangent1 defines the outgoing tangent
  2310. * @param value2 defines the 2nd control point
  2311. * @param tangent2 defines the incoming tangent
  2312. * @param amount defines the interpolation factor
  2313. * @returns a new Vector2
  2314. */
  2315. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2316. /**
  2317. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2318. * @param start defines the start vector
  2319. * @param end defines the end vector
  2320. * @param amount defines the interpolation factor
  2321. * @returns a new Vector2
  2322. */
  2323. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2324. /**
  2325. * Gets the dot product of the vector "left" and the vector "right"
  2326. * @param left defines first vector
  2327. * @param right defines second vector
  2328. * @returns the dot product (float)
  2329. */
  2330. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2331. /**
  2332. * Returns a new Vector2 equal to the normalized given vector
  2333. * @param vector defines the vector to normalize
  2334. * @returns a new Vector2
  2335. */
  2336. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2337. /**
  2338. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2339. * @param left defines 1st vector
  2340. * @param right defines 2nd vector
  2341. * @returns a new Vector2
  2342. */
  2343. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2344. /**
  2345. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2346. * @param left defines 1st vector
  2347. * @param right defines 2nd vector
  2348. * @returns a new Vector2
  2349. */
  2350. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2351. /**
  2352. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2353. * @param vector defines the vector to transform
  2354. * @param transformation defines the matrix to apply
  2355. * @returns a new Vector2
  2356. */
  2357. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2358. /**
  2359. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2360. * @param vector defines the vector to transform
  2361. * @param transformation defines the matrix to apply
  2362. * @param result defines the target vector
  2363. */
  2364. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2365. /**
  2366. * Determines if a given vector is included in a triangle
  2367. * @param p defines the vector to test
  2368. * @param p0 defines 1st triangle point
  2369. * @param p1 defines 2nd triangle point
  2370. * @param p2 defines 3rd triangle point
  2371. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2372. */
  2373. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2374. /**
  2375. * Gets the distance between the vectors "value1" and "value2"
  2376. * @param value1 defines first vector
  2377. * @param value2 defines second vector
  2378. * @returns the distance between vectors
  2379. */
  2380. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2381. /**
  2382. * Returns the squared distance between the vectors "value1" and "value2"
  2383. * @param value1 defines first vector
  2384. * @param value2 defines second vector
  2385. * @returns the squared distance between vectors
  2386. */
  2387. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2388. /**
  2389. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2390. * @param value1 defines first vector
  2391. * @param value2 defines second vector
  2392. * @returns a new Vector2
  2393. */
  2394. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2395. /**
  2396. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2397. * @param p defines the middle point
  2398. * @param segA defines one point of the segment
  2399. * @param segB defines the other point of the segment
  2400. * @returns the shortest distance
  2401. */
  2402. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2403. }
  2404. /**
  2405. * Class used to store (x,y,z) vector representation
  2406. * A Vector3 is the main object used in 3D geometry
  2407. * It can represent etiher the coordinates of a point the space, either a direction
  2408. * Reminder: js uses a left handed forward facing system
  2409. */
  2410. export class Vector3 {
  2411. /**
  2412. * Defines the first coordinates (on X axis)
  2413. */
  2414. x: number;
  2415. /**
  2416. * Defines the second coordinates (on Y axis)
  2417. */
  2418. y: number;
  2419. /**
  2420. * Defines the third coordinates (on Z axis)
  2421. */
  2422. z: number;
  2423. private static _UpReadOnly;
  2424. private static _ZeroReadOnly;
  2425. /**
  2426. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2427. * @param x defines the first coordinates (on X axis)
  2428. * @param y defines the second coordinates (on Y axis)
  2429. * @param z defines the third coordinates (on Z axis)
  2430. */
  2431. constructor(
  2432. /**
  2433. * Defines the first coordinates (on X axis)
  2434. */
  2435. x?: number,
  2436. /**
  2437. * Defines the second coordinates (on Y axis)
  2438. */
  2439. y?: number,
  2440. /**
  2441. * Defines the third coordinates (on Z axis)
  2442. */
  2443. z?: number);
  2444. /**
  2445. * Creates a string representation of the Vector3
  2446. * @returns a string with the Vector3 coordinates.
  2447. */
  2448. toString(): string;
  2449. /**
  2450. * Gets the class name
  2451. * @returns the string "Vector3"
  2452. */
  2453. getClassName(): string;
  2454. /**
  2455. * Creates the Vector3 hash code
  2456. * @returns a number which tends to be unique between Vector3 instances
  2457. */
  2458. getHashCode(): number;
  2459. /**
  2460. * Creates an array containing three elements : the coordinates of the Vector3
  2461. * @returns a new array of numbers
  2462. */
  2463. asArray(): number[];
  2464. /**
  2465. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2466. * @param array defines the destination array
  2467. * @param index defines the offset in the destination array
  2468. * @returns the current Vector3
  2469. */
  2470. toArray(array: FloatArray, index?: number): Vector3;
  2471. /**
  2472. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2473. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2474. */
  2475. toQuaternion(): Quaternion;
  2476. /**
  2477. * Adds the given vector to the current Vector3
  2478. * @param otherVector defines the second operand
  2479. * @returns the current updated Vector3
  2480. */
  2481. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Adds the given coordinates to the current Vector3
  2484. * @param x defines the x coordinate of the operand
  2485. * @param y defines the y coordinate of the operand
  2486. * @param z defines the z coordinate of the operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2490. /**
  2491. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the resulting Vector3
  2494. */
  2495. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Subtract the given vector from the current Vector3
  2505. * @param otherVector defines the second operand
  2506. * @returns the current updated Vector3
  2507. */
  2508. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2509. /**
  2510. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2511. * @param otherVector defines the second operand
  2512. * @returns the resulting Vector3
  2513. */
  2514. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2515. /**
  2516. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2517. * @param otherVector defines the second operand
  2518. * @param result defines the Vector3 object where to store the result
  2519. * @returns the current Vector3
  2520. */
  2521. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2522. /**
  2523. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2524. * @param x defines the x coordinate of the operand
  2525. * @param y defines the y coordinate of the operand
  2526. * @param z defines the z coordinate of the operand
  2527. * @returns the resulting Vector3
  2528. */
  2529. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2530. /**
  2531. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2532. * @param x defines the x coordinate of the operand
  2533. * @param y defines the y coordinate of the operand
  2534. * @param z defines the z coordinate of the operand
  2535. * @param result defines the Vector3 object where to store the result
  2536. * @returns the current Vector3
  2537. */
  2538. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2539. /**
  2540. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2541. * @returns a new Vector3
  2542. */
  2543. negate(): Vector3;
  2544. /**
  2545. * Negate this vector in place
  2546. * @returns this
  2547. */
  2548. negateInPlace(): Vector3;
  2549. /**
  2550. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2551. * @param result defines the Vector3 object where to store the result
  2552. * @returns the current Vector3
  2553. */
  2554. negateToRef(result: Vector3): Vector3;
  2555. /**
  2556. * Multiplies the Vector3 coordinates by the float "scale"
  2557. * @param scale defines the multiplier factor
  2558. * @returns the current updated Vector3
  2559. */
  2560. scaleInPlace(scale: number): Vector3;
  2561. /**
  2562. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2563. * @param scale defines the multiplier factor
  2564. * @returns a new Vector3
  2565. */
  2566. scale(scale: number): Vector3;
  2567. /**
  2568. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2569. * @param scale defines the multiplier factor
  2570. * @param result defines the Vector3 object where to store the result
  2571. * @returns the current Vector3
  2572. */
  2573. scaleToRef(scale: number, result: Vector3): Vector3;
  2574. /**
  2575. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2576. * @param scale defines the scale factor
  2577. * @param result defines the Vector3 object where to store the result
  2578. * @returns the unmodified current Vector3
  2579. */
  2580. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2581. /**
  2582. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2583. * @param origin defines the origin of the projection ray
  2584. * @param plane defines the plane to project to
  2585. * @returns the projected vector3
  2586. */
  2587. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2588. /**
  2589. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2590. * @param origin defines the origin of the projection ray
  2591. * @param plane defines the plane to project to
  2592. * @param result defines the Vector3 where to store the result
  2593. */
  2594. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2595. /**
  2596. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2597. * @param otherVector defines the second operand
  2598. * @returns true if both vectors are equals
  2599. */
  2600. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2601. /**
  2602. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2603. * @param otherVector defines the second operand
  2604. * @param epsilon defines the minimal distance to define values as equals
  2605. * @returns true if both vectors are distant less than epsilon
  2606. */
  2607. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2608. /**
  2609. * Returns true if the current Vector3 coordinates equals the given floats
  2610. * @param x defines the x coordinate of the operand
  2611. * @param y defines the y coordinate of the operand
  2612. * @param z defines the z coordinate of the operand
  2613. * @returns true if both vectors are equals
  2614. */
  2615. equalsToFloats(x: number, y: number, z: number): boolean;
  2616. /**
  2617. * Multiplies the current Vector3 coordinates by the given ones
  2618. * @param otherVector defines the second operand
  2619. * @returns the current updated Vector3
  2620. */
  2621. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2622. /**
  2623. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2624. * @param otherVector defines the second operand
  2625. * @returns the new Vector3
  2626. */
  2627. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2628. /**
  2629. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2630. * @param otherVector defines the second operand
  2631. * @param result defines the Vector3 object where to store the result
  2632. * @returns the current Vector3
  2633. */
  2634. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2635. /**
  2636. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2637. * @param x defines the x coordinate of the operand
  2638. * @param y defines the y coordinate of the operand
  2639. * @param z defines the z coordinate of the operand
  2640. * @returns the new Vector3
  2641. */
  2642. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2643. /**
  2644. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2645. * @param otherVector defines the second operand
  2646. * @returns the new Vector3
  2647. */
  2648. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2649. /**
  2650. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2651. * @param otherVector defines the second operand
  2652. * @param result defines the Vector3 object where to store the result
  2653. * @returns the current Vector3
  2654. */
  2655. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2656. /**
  2657. * Divides the current Vector3 coordinates by the given ones.
  2658. * @param otherVector defines the second operand
  2659. * @returns the current updated Vector3
  2660. */
  2661. divideInPlace(otherVector: Vector3): Vector3;
  2662. /**
  2663. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2664. * @param other defines the second operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2668. /**
  2669. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2670. * @param other defines the second operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2674. /**
  2675. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the current updated Vector3
  2680. */
  2681. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2684. * @param x defines the x coordinate of the operand
  2685. * @param y defines the y coordinate of the operand
  2686. * @param z defines the z coordinate of the operand
  2687. * @returns the current updated Vector3
  2688. */
  2689. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2690. /**
  2691. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2692. * Check if is non uniform within a certain amount of decimal places to account for this
  2693. * @param epsilon the amount the values can differ
  2694. * @returns if the the vector is non uniform to a certain number of decimal places
  2695. */
  2696. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2697. /**
  2698. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2699. */
  2700. get isNonUniform(): boolean;
  2701. /**
  2702. * Gets a new Vector3 from current Vector3 floored values
  2703. * @returns a new Vector3
  2704. */
  2705. floor(): Vector3;
  2706. /**
  2707. * Gets a new Vector3 from current Vector3 floored values
  2708. * @returns a new Vector3
  2709. */
  2710. fract(): Vector3;
  2711. /**
  2712. * Gets the length of the Vector3
  2713. * @returns the length of the Vector3
  2714. */
  2715. length(): number;
  2716. /**
  2717. * Gets the squared length of the Vector3
  2718. * @returns squared length of the Vector3
  2719. */
  2720. lengthSquared(): number;
  2721. /**
  2722. * Normalize the current Vector3.
  2723. * Please note that this is an in place operation.
  2724. * @returns the current updated Vector3
  2725. */
  2726. normalize(): Vector3;
  2727. /**
  2728. * Reorders the x y z properties of the vector in place
  2729. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2730. * @returns the current updated vector
  2731. */
  2732. reorderInPlace(order: string): this;
  2733. /**
  2734. * Rotates the vector around 0,0,0 by a quaternion
  2735. * @param quaternion the rotation quaternion
  2736. * @param result vector to store the result
  2737. * @returns the resulting vector
  2738. */
  2739. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2740. /**
  2741. * Rotates a vector around a given point
  2742. * @param quaternion the rotation quaternion
  2743. * @param point the point to rotate around
  2744. * @param result vector to store the result
  2745. * @returns the resulting vector
  2746. */
  2747. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2748. /**
  2749. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2750. * The cross product is then orthogonal to both current and "other"
  2751. * @param other defines the right operand
  2752. * @returns the cross product
  2753. */
  2754. cross(other: Vector3): Vector3;
  2755. /**
  2756. * Normalize the current Vector3 with the given input length.
  2757. * Please note that this is an in place operation.
  2758. * @param len the length of the vector
  2759. * @returns the current updated Vector3
  2760. */
  2761. normalizeFromLength(len: number): Vector3;
  2762. /**
  2763. * Normalize the current Vector3 to a new vector
  2764. * @returns the new Vector3
  2765. */
  2766. normalizeToNew(): Vector3;
  2767. /**
  2768. * Normalize the current Vector3 to the reference
  2769. * @param reference define the Vector3 to update
  2770. * @returns the updated Vector3
  2771. */
  2772. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2773. /**
  2774. * Creates a new Vector3 copied from the current Vector3
  2775. * @returns the new Vector3
  2776. */
  2777. clone(): Vector3;
  2778. /**
  2779. * Copies the given vector coordinates to the current Vector3 ones
  2780. * @param source defines the source Vector3
  2781. * @returns the current updated Vector3
  2782. */
  2783. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2784. /**
  2785. * Copies the given floats to the current Vector3 coordinates
  2786. * @param x defines the x coordinate of the operand
  2787. * @param y defines the y coordinate of the operand
  2788. * @param z defines the z coordinate of the operand
  2789. * @returns the current updated Vector3
  2790. */
  2791. copyFromFloats(x: number, y: number, z: number): Vector3;
  2792. /**
  2793. * Copies the given floats to the current Vector3 coordinates
  2794. * @param x defines the x coordinate of the operand
  2795. * @param y defines the y coordinate of the operand
  2796. * @param z defines the z coordinate of the operand
  2797. * @returns the current updated Vector3
  2798. */
  2799. set(x: number, y: number, z: number): Vector3;
  2800. /**
  2801. * Copies the given float to the current Vector3 coordinates
  2802. * @param v defines the x, y and z coordinates of the operand
  2803. * @returns the current updated Vector3
  2804. */
  2805. setAll(v: number): Vector3;
  2806. /**
  2807. * Get the clip factor between two vectors
  2808. * @param vector0 defines the first operand
  2809. * @param vector1 defines the second operand
  2810. * @param axis defines the axis to use
  2811. * @param size defines the size along the axis
  2812. * @returns the clip factor
  2813. */
  2814. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2815. /**
  2816. * Get angle between two vectors
  2817. * @param vector0 angle between vector0 and vector1
  2818. * @param vector1 angle between vector0 and vector1
  2819. * @param normal direction of the normal
  2820. * @return the angle between vector0 and vector1
  2821. */
  2822. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2823. /**
  2824. * Returns a new Vector3 set from the index "offset" of the given array
  2825. * @param array defines the source array
  2826. * @param offset defines the offset in the source array
  2827. * @returns the new Vector3
  2828. */
  2829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2830. /**
  2831. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2832. * @param array defines the source array
  2833. * @param offset defines the offset in the source array
  2834. * @returns the new Vector3
  2835. * @deprecated Please use FromArray instead.
  2836. */
  2837. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2838. /**
  2839. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2840. * @param array defines the source array
  2841. * @param offset defines the offset in the source array
  2842. * @param result defines the Vector3 where to store the result
  2843. */
  2844. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2845. /**
  2846. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2847. * @param array defines the source array
  2848. * @param offset defines the offset in the source array
  2849. * @param result defines the Vector3 where to store the result
  2850. * @deprecated Please use FromArrayToRef instead.
  2851. */
  2852. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2853. /**
  2854. * Sets the given vector "result" with the given floats.
  2855. * @param x defines the x coordinate of the source
  2856. * @param y defines the y coordinate of the source
  2857. * @param z defines the z coordinate of the source
  2858. * @param result defines the Vector3 where to store the result
  2859. */
  2860. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2861. /**
  2862. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2863. * @returns a new empty Vector3
  2864. */
  2865. static Zero(): Vector3;
  2866. /**
  2867. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2868. * @returns a new unit Vector3
  2869. */
  2870. static One(): Vector3;
  2871. /**
  2872. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2873. * @returns a new up Vector3
  2874. */
  2875. static Up(): Vector3;
  2876. /**
  2877. * Gets a up Vector3 that must not be updated
  2878. */
  2879. static get UpReadOnly(): DeepImmutable<Vector3>;
  2880. /**
  2881. * Gets a zero Vector3 that must not be updated
  2882. */
  2883. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2884. /**
  2885. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2886. * @returns a new down Vector3
  2887. */
  2888. static Down(): Vector3;
  2889. /**
  2890. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2891. * @param rightHandedSystem is the scene right-handed (negative z)
  2892. * @returns a new forward Vector3
  2893. */
  2894. static Forward(rightHandedSystem?: boolean): Vector3;
  2895. /**
  2896. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2897. * @param rightHandedSystem is the scene right-handed (negative-z)
  2898. * @returns a new forward Vector3
  2899. */
  2900. static Backward(rightHandedSystem?: boolean): Vector3;
  2901. /**
  2902. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2903. * @returns a new right Vector3
  2904. */
  2905. static Right(): Vector3;
  2906. /**
  2907. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2908. * @returns a new left Vector3
  2909. */
  2910. static Left(): Vector3;
  2911. /**
  2912. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2913. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2914. * @param vector defines the Vector3 to transform
  2915. * @param transformation defines the transformation matrix
  2916. * @returns the transformed Vector3
  2917. */
  2918. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2919. /**
  2920. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2921. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2922. * @param vector defines the Vector3 to transform
  2923. * @param transformation defines the transformation matrix
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2927. /**
  2928. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2929. * This method computes tranformed coordinates only, not transformed direction vectors
  2930. * @param x define the x coordinate of the source vector
  2931. * @param y define the y coordinate of the source vector
  2932. * @param z define the z coordinate of the source vector
  2933. * @param transformation defines the transformation matrix
  2934. * @param result defines the Vector3 where to store the result
  2935. */
  2936. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2937. /**
  2938. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2939. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2940. * @param vector defines the Vector3 to transform
  2941. * @param transformation defines the transformation matrix
  2942. * @returns the new Vector3
  2943. */
  2944. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2945. /**
  2946. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2947. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2948. * @param vector defines the Vector3 to transform
  2949. * @param transformation defines the transformation matrix
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2953. /**
  2954. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2955. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2956. * @param x define the x coordinate of the source vector
  2957. * @param y define the y coordinate of the source vector
  2958. * @param z define the z coordinate of the source vector
  2959. * @param transformation defines the transformation matrix
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2965. * @param value1 defines the first control point
  2966. * @param value2 defines the second control point
  2967. * @param value3 defines the third control point
  2968. * @param value4 defines the fourth control point
  2969. * @param amount defines the amount on the spline to use
  2970. * @returns the new Vector3
  2971. */
  2972. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2973. /**
  2974. * 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"
  2975. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2976. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2977. * @param value defines the current value
  2978. * @param min defines the lower range value
  2979. * @param max defines the upper range value
  2980. * @returns the new Vector3
  2981. */
  2982. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * 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"
  2985. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2986. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2987. * @param value defines the current value
  2988. * @param min defines the lower range value
  2989. * @param max defines the upper range value
  2990. * @param result defines the Vector3 where to store the result
  2991. */
  2992. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2993. /**
  2994. * Checks if a given vector is inside a specific range
  2995. * @param v defines the vector to test
  2996. * @param min defines the minimum range
  2997. * @param max defines the maximum range
  2998. */
  2999. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3000. /**
  3001. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3002. * @param value1 defines the first control point
  3003. * @param tangent1 defines the first tangent vector
  3004. * @param value2 defines the second control point
  3005. * @param tangent2 defines the second tangent vector
  3006. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3007. * @returns the new Vector3
  3008. */
  3009. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3010. /**
  3011. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3012. * @param start defines the start value
  3013. * @param end defines the end value
  3014. * @param amount max defines amount between both (between 0 and 1)
  3015. * @returns the new Vector3
  3016. */
  3017. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3018. /**
  3019. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3020. * @param start defines the start value
  3021. * @param end defines the end value
  3022. * @param amount max defines amount between both (between 0 and 1)
  3023. * @param result defines the Vector3 where to store the result
  3024. */
  3025. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3026. /**
  3027. * Returns the dot product (float) between the vectors "left" and "right"
  3028. * @param left defines the left operand
  3029. * @param right defines the right operand
  3030. * @returns the dot product
  3031. */
  3032. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3033. /**
  3034. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3035. * The cross product is then orthogonal to both "left" and "right"
  3036. * @param left defines the left operand
  3037. * @param right defines the right operand
  3038. * @returns the cross product
  3039. */
  3040. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3041. /**
  3042. * Sets the given vector "result" with the cross product of "left" and "right"
  3043. * The cross product is then orthogonal to both "left" and "right"
  3044. * @param left defines the left operand
  3045. * @param right defines the right operand
  3046. * @param result defines the Vector3 where to store the result
  3047. */
  3048. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3049. /**
  3050. * Returns a new Vector3 as the normalization of the given vector
  3051. * @param vector defines the Vector3 to normalize
  3052. * @returns the new Vector3
  3053. */
  3054. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3055. /**
  3056. * Sets the given vector "result" with the normalization of the given first vector
  3057. * @param vector defines the Vector3 to normalize
  3058. * @param result defines the Vector3 where to store the result
  3059. */
  3060. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3061. /**
  3062. * Project a Vector3 onto screen space
  3063. * @param vector defines the Vector3 to project
  3064. * @param world defines the world matrix to use
  3065. * @param transform defines the transform (view x projection) matrix to use
  3066. * @param viewport defines the screen viewport to use
  3067. * @returns the new Vector3
  3068. */
  3069. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3070. /** @hidden */
  3071. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3072. /**
  3073. * Unproject from screen space to object space
  3074. * @param source defines the screen space Vector3 to use
  3075. * @param viewportWidth defines the current width of the viewport
  3076. * @param viewportHeight defines the current height of the viewport
  3077. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3078. * @param transform defines the transform (view x projection) matrix to use
  3079. * @returns the new Vector3
  3080. */
  3081. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3082. /**
  3083. * Unproject from screen space to object space
  3084. * @param source defines the screen space Vector3 to use
  3085. * @param viewportWidth defines the current width of the viewport
  3086. * @param viewportHeight defines the current height of the viewport
  3087. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3088. * @param view defines the view matrix to use
  3089. * @param projection defines the projection matrix to use
  3090. * @returns the new Vector3
  3091. */
  3092. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3093. /**
  3094. * Unproject from screen space to object space
  3095. * @param source defines the screen space Vector3 to use
  3096. * @param viewportWidth defines the current width of the viewport
  3097. * @param viewportHeight defines the current height of the viewport
  3098. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3099. * @param view defines the view matrix to use
  3100. * @param projection defines the projection matrix to use
  3101. * @param result defines the Vector3 where to store the result
  3102. */
  3103. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3104. /**
  3105. * Unproject from screen space to object space
  3106. * @param sourceX defines the screen space x coordinate to use
  3107. * @param sourceY defines the screen space y coordinate to use
  3108. * @param sourceZ defines the screen space z coordinate to use
  3109. * @param viewportWidth defines the current width of the viewport
  3110. * @param viewportHeight defines the current height of the viewport
  3111. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3112. * @param view defines the view matrix to use
  3113. * @param projection defines the projection matrix to use
  3114. * @param result defines the Vector3 where to store the result
  3115. */
  3116. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3117. /**
  3118. * Gets the minimal coordinate values between two Vector3
  3119. * @param left defines the first operand
  3120. * @param right defines the second operand
  3121. * @returns the new Vector3
  3122. */
  3123. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3124. /**
  3125. * Gets the maximal coordinate values between two Vector3
  3126. * @param left defines the first operand
  3127. * @param right defines the second operand
  3128. * @returns the new Vector3
  3129. */
  3130. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3131. /**
  3132. * Returns the distance between the vectors "value1" and "value2"
  3133. * @param value1 defines the first operand
  3134. * @param value2 defines the second operand
  3135. * @returns the distance
  3136. */
  3137. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3138. /**
  3139. * Returns the squared distance between the vectors "value1" and "value2"
  3140. * @param value1 defines the first operand
  3141. * @param value2 defines the second operand
  3142. * @returns the squared distance
  3143. */
  3144. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3145. /**
  3146. * Returns a new Vector3 located at the center between "value1" and "value2"
  3147. * @param value1 defines the first operand
  3148. * @param value2 defines the second operand
  3149. * @returns the new Vector3
  3150. */
  3151. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3152. /**
  3153. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3154. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3155. * to something in order to rotate it from its local system to the given target system
  3156. * Note: axis1, axis2 and axis3 are normalized during this operation
  3157. * @param axis1 defines the first axis
  3158. * @param axis2 defines the second axis
  3159. * @param axis3 defines the third axis
  3160. * @returns a new Vector3
  3161. */
  3162. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3165. * @param axis1 defines the first axis
  3166. * @param axis2 defines the second axis
  3167. * @param axis3 defines the third axis
  3168. * @param ref defines the Vector3 where to store the result
  3169. */
  3170. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3171. }
  3172. /**
  3173. * Vector4 class created for EulerAngle class conversion to Quaternion
  3174. */
  3175. export class Vector4 {
  3176. /** x value of the vector */
  3177. x: number;
  3178. /** y value of the vector */
  3179. y: number;
  3180. /** z value of the vector */
  3181. z: number;
  3182. /** w value of the vector */
  3183. w: number;
  3184. /**
  3185. * Creates a Vector4 object from the given floats.
  3186. * @param x x value of the vector
  3187. * @param y y value of the vector
  3188. * @param z z value of the vector
  3189. * @param w w value of the vector
  3190. */
  3191. constructor(
  3192. /** x value of the vector */
  3193. x: number,
  3194. /** y value of the vector */
  3195. y: number,
  3196. /** z value of the vector */
  3197. z: number,
  3198. /** w value of the vector */
  3199. w: number);
  3200. /**
  3201. * Returns the string with the Vector4 coordinates.
  3202. * @returns a string containing all the vector values
  3203. */
  3204. toString(): string;
  3205. /**
  3206. * Returns the string "Vector4".
  3207. * @returns "Vector4"
  3208. */
  3209. getClassName(): string;
  3210. /**
  3211. * Returns the Vector4 hash code.
  3212. * @returns a unique hash code
  3213. */
  3214. getHashCode(): number;
  3215. /**
  3216. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3217. * @returns the resulting array
  3218. */
  3219. asArray(): number[];
  3220. /**
  3221. * Populates the given array from the given index with the Vector4 coordinates.
  3222. * @param array array to populate
  3223. * @param index index of the array to start at (default: 0)
  3224. * @returns the Vector4.
  3225. */
  3226. toArray(array: FloatArray, index?: number): Vector4;
  3227. /**
  3228. * Adds the given vector to the current Vector4.
  3229. * @param otherVector the vector to add
  3230. * @returns the updated Vector4.
  3231. */
  3232. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3233. /**
  3234. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3235. * @param otherVector the vector to add
  3236. * @returns the resulting vector
  3237. */
  3238. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3239. /**
  3240. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3241. * @param otherVector the vector to add
  3242. * @param result the vector to store the result
  3243. * @returns the current Vector4.
  3244. */
  3245. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3246. /**
  3247. * Subtract in place the given vector from the current Vector4.
  3248. * @param otherVector the vector to subtract
  3249. * @returns the updated Vector4.
  3250. */
  3251. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3252. /**
  3253. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3254. * @param otherVector the vector to add
  3255. * @returns the new vector with the result
  3256. */
  3257. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3258. /**
  3259. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3260. * @param otherVector the vector to subtract
  3261. * @param result the vector to store the result
  3262. * @returns the current Vector4.
  3263. */
  3264. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3265. /**
  3266. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3267. */
  3268. /**
  3269. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3270. * @param x value to subtract
  3271. * @param y value to subtract
  3272. * @param z value to subtract
  3273. * @param w value to subtract
  3274. * @returns new vector containing the result
  3275. */
  3276. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3277. /**
  3278. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3279. * @param x value to subtract
  3280. * @param y value to subtract
  3281. * @param z value to subtract
  3282. * @param w value to subtract
  3283. * @param result the vector to store the result in
  3284. * @returns the current Vector4.
  3285. */
  3286. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3287. /**
  3288. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3289. * @returns a new vector with the negated values
  3290. */
  3291. negate(): Vector4;
  3292. /**
  3293. * Negate this vector in place
  3294. * @returns this
  3295. */
  3296. negateInPlace(): Vector4;
  3297. /**
  3298. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3299. * @param result defines the Vector3 object where to store the result
  3300. * @returns the current Vector4
  3301. */
  3302. negateToRef(result: Vector4): Vector4;
  3303. /**
  3304. * Multiplies the current Vector4 coordinates by scale (float).
  3305. * @param scale the number to scale with
  3306. * @returns the updated Vector4.
  3307. */
  3308. scaleInPlace(scale: number): Vector4;
  3309. /**
  3310. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3311. * @param scale the number to scale with
  3312. * @returns a new vector with the result
  3313. */
  3314. scale(scale: number): Vector4;
  3315. /**
  3316. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3317. * @param scale the number to scale with
  3318. * @param result a vector to store the result in
  3319. * @returns the current Vector4.
  3320. */
  3321. scaleToRef(scale: number, result: Vector4): Vector4;
  3322. /**
  3323. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3324. * @param scale defines the scale factor
  3325. * @param result defines the Vector4 object where to store the result
  3326. * @returns the unmodified current Vector4
  3327. */
  3328. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3329. /**
  3330. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3331. * @param otherVector the vector to compare against
  3332. * @returns true if they are equal
  3333. */
  3334. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3335. /**
  3336. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3337. * @param otherVector vector to compare against
  3338. * @param epsilon (Default: very small number)
  3339. * @returns true if they are equal
  3340. */
  3341. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3342. /**
  3343. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3344. * @param x x value to compare against
  3345. * @param y y value to compare against
  3346. * @param z z value to compare against
  3347. * @param w w value to compare against
  3348. * @returns true if equal
  3349. */
  3350. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3351. /**
  3352. * Multiplies in place the current Vector4 by the given one.
  3353. * @param otherVector vector to multiple with
  3354. * @returns the updated Vector4.
  3355. */
  3356. multiplyInPlace(otherVector: Vector4): Vector4;
  3357. /**
  3358. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3359. * @param otherVector vector to multiple with
  3360. * @returns resulting new vector
  3361. */
  3362. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3363. /**
  3364. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3365. * @param otherVector vector to multiple with
  3366. * @param result vector to store the result
  3367. * @returns the current Vector4.
  3368. */
  3369. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3370. /**
  3371. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3372. * @param x x value multiply with
  3373. * @param y y value multiply with
  3374. * @param z z value multiply with
  3375. * @param w w value multiply with
  3376. * @returns resulting new vector
  3377. */
  3378. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3379. /**
  3380. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3381. * @param otherVector vector to devide with
  3382. * @returns resulting new vector
  3383. */
  3384. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3385. /**
  3386. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3387. * @param otherVector vector to devide with
  3388. * @param result vector to store the result
  3389. * @returns the current Vector4.
  3390. */
  3391. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3392. /**
  3393. * Divides the current Vector3 coordinates by the given ones.
  3394. * @param otherVector vector to devide with
  3395. * @returns the updated Vector3.
  3396. */
  3397. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3398. /**
  3399. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3400. * @param other defines the second operand
  3401. * @returns the current updated Vector4
  3402. */
  3403. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3404. /**
  3405. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3406. * @param other defines the second operand
  3407. * @returns the current updated Vector4
  3408. */
  3409. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3410. /**
  3411. * Gets a new Vector4 from current Vector4 floored values
  3412. * @returns a new Vector4
  3413. */
  3414. floor(): Vector4;
  3415. /**
  3416. * Gets a new Vector4 from current Vector3 floored values
  3417. * @returns a new Vector4
  3418. */
  3419. fract(): Vector4;
  3420. /**
  3421. * Returns the Vector4 length (float).
  3422. * @returns the length
  3423. */
  3424. length(): number;
  3425. /**
  3426. * Returns the Vector4 squared length (float).
  3427. * @returns the length squared
  3428. */
  3429. lengthSquared(): number;
  3430. /**
  3431. * Normalizes in place the Vector4.
  3432. * @returns the updated Vector4.
  3433. */
  3434. normalize(): Vector4;
  3435. /**
  3436. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3437. * @returns this converted to a new vector3
  3438. */
  3439. toVector3(): Vector3;
  3440. /**
  3441. * Returns a new Vector4 copied from the current one.
  3442. * @returns the new cloned vector
  3443. */
  3444. clone(): Vector4;
  3445. /**
  3446. * Updates the current Vector4 with the given one coordinates.
  3447. * @param source the source vector to copy from
  3448. * @returns the updated Vector4.
  3449. */
  3450. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3451. /**
  3452. * Updates the current Vector4 coordinates with the given floats.
  3453. * @param x float to copy from
  3454. * @param y float to copy from
  3455. * @param z float to copy from
  3456. * @param w float to copy from
  3457. * @returns the updated Vector4.
  3458. */
  3459. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3460. /**
  3461. * Updates the current Vector4 coordinates with the given floats.
  3462. * @param x float to set from
  3463. * @param y float to set from
  3464. * @param z float to set from
  3465. * @param w float to set from
  3466. * @returns the updated Vector4.
  3467. */
  3468. set(x: number, y: number, z: number, w: number): Vector4;
  3469. /**
  3470. * Copies the given float to the current Vector3 coordinates
  3471. * @param v defines the x, y, z and w coordinates of the operand
  3472. * @returns the current updated Vector3
  3473. */
  3474. setAll(v: number): Vector4;
  3475. /**
  3476. * Returns a new Vector4 set from the starting index of the given array.
  3477. * @param array the array to pull values from
  3478. * @param offset the offset into the array to start at
  3479. * @returns the new vector
  3480. */
  3481. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3482. /**
  3483. * Updates the given vector "result" from the starting index of the given array.
  3484. * @param array the array to pull values from
  3485. * @param offset the offset into the array to start at
  3486. * @param result the vector to store the result in
  3487. */
  3488. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3489. /**
  3490. * Updates the given vector "result" from the starting index of the given Float32Array.
  3491. * @param array the array to pull values from
  3492. * @param offset the offset into the array to start at
  3493. * @param result the vector to store the result in
  3494. */
  3495. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3496. /**
  3497. * Updates the given vector "result" coordinates from the given floats.
  3498. * @param x float to set from
  3499. * @param y float to set from
  3500. * @param z float to set from
  3501. * @param w float to set from
  3502. * @param result the vector to the floats in
  3503. */
  3504. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3505. /**
  3506. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3507. * @returns the new vector
  3508. */
  3509. static Zero(): Vector4;
  3510. /**
  3511. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3512. * @returns the new vector
  3513. */
  3514. static One(): Vector4;
  3515. /**
  3516. * Returns a new normalized Vector4 from the given one.
  3517. * @param vector the vector to normalize
  3518. * @returns the vector
  3519. */
  3520. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3521. /**
  3522. * Updates the given vector "result" from the normalization of the given one.
  3523. * @param vector the vector to normalize
  3524. * @param result the vector to store the result in
  3525. */
  3526. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3527. /**
  3528. * Returns a vector with the minimum values from the left and right vectors
  3529. * @param left left vector to minimize
  3530. * @param right right vector to minimize
  3531. * @returns a new vector with the minimum of the left and right vector values
  3532. */
  3533. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3534. /**
  3535. * Returns a vector with the maximum values from the left and right vectors
  3536. * @param left left vector to maximize
  3537. * @param right right vector to maximize
  3538. * @returns a new vector with the maximum of the left and right vector values
  3539. */
  3540. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3541. /**
  3542. * Returns the distance (float) between the vectors "value1" and "value2".
  3543. * @param value1 value to calulate the distance between
  3544. * @param value2 value to calulate the distance between
  3545. * @return the distance between the two vectors
  3546. */
  3547. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3548. /**
  3549. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3550. * @param value1 value to calulate the distance between
  3551. * @param value2 value to calulate the distance between
  3552. * @return the distance between the two vectors squared
  3553. */
  3554. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3555. /**
  3556. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3557. * @param value1 value to calulate the center between
  3558. * @param value2 value to calulate the center between
  3559. * @return the center between the two vectors
  3560. */
  3561. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3562. /**
  3563. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3564. * This methods computes transformed normalized direction vectors only.
  3565. * @param vector the vector to transform
  3566. * @param transformation the transformation matrix to apply
  3567. * @returns the new vector
  3568. */
  3569. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3570. /**
  3571. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3572. * This methods computes transformed normalized direction vectors only.
  3573. * @param vector the vector to transform
  3574. * @param transformation the transformation matrix to apply
  3575. * @param result the vector to store the result in
  3576. */
  3577. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3578. /**
  3579. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3580. * This methods computes transformed normalized direction vectors only.
  3581. * @param x value to transform
  3582. * @param y value to transform
  3583. * @param z value to transform
  3584. * @param w value to transform
  3585. * @param transformation the transformation matrix to apply
  3586. * @param result the vector to store the results in
  3587. */
  3588. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3589. /**
  3590. * Creates a new Vector4 from a Vector3
  3591. * @param source defines the source data
  3592. * @param w defines the 4th component (default is 0)
  3593. * @returns a new Vector4
  3594. */
  3595. static FromVector3(source: Vector3, w?: number): Vector4;
  3596. }
  3597. /**
  3598. * Class used to store quaternion data
  3599. * @see https://en.wikipedia.org/wiki/Quaternion
  3600. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3601. */
  3602. export class Quaternion {
  3603. /** defines the first component (0 by default) */
  3604. x: number;
  3605. /** defines the second component (0 by default) */
  3606. y: number;
  3607. /** defines the third component (0 by default) */
  3608. z: number;
  3609. /** defines the fourth component (1.0 by default) */
  3610. w: number;
  3611. /**
  3612. * Creates a new Quaternion from the given floats
  3613. * @param x defines the first component (0 by default)
  3614. * @param y defines the second component (0 by default)
  3615. * @param z defines the third component (0 by default)
  3616. * @param w defines the fourth component (1.0 by default)
  3617. */
  3618. constructor(
  3619. /** defines the first component (0 by default) */
  3620. x?: number,
  3621. /** defines the second component (0 by default) */
  3622. y?: number,
  3623. /** defines the third component (0 by default) */
  3624. z?: number,
  3625. /** defines the fourth component (1.0 by default) */
  3626. w?: number);
  3627. /**
  3628. * Gets a string representation for the current quaternion
  3629. * @returns a string with the Quaternion coordinates
  3630. */
  3631. toString(): string;
  3632. /**
  3633. * Gets the class name of the quaternion
  3634. * @returns the string "Quaternion"
  3635. */
  3636. getClassName(): string;
  3637. /**
  3638. * Gets a hash code for this quaternion
  3639. * @returns the quaternion hash code
  3640. */
  3641. getHashCode(): number;
  3642. /**
  3643. * Copy the quaternion to an array
  3644. * @returns a new array populated with 4 elements from the quaternion coordinates
  3645. */
  3646. asArray(): number[];
  3647. /**
  3648. * Check if two quaternions are equals
  3649. * @param otherQuaternion defines the second operand
  3650. * @return true if the current quaternion and the given one coordinates are strictly equals
  3651. */
  3652. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3653. /**
  3654. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3655. * @param otherQuaternion defines the other quaternion
  3656. * @param epsilon defines the minimal distance to consider equality
  3657. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3658. */
  3659. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3660. /**
  3661. * Clone the current quaternion
  3662. * @returns a new quaternion copied from the current one
  3663. */
  3664. clone(): Quaternion;
  3665. /**
  3666. * Copy a quaternion to the current one
  3667. * @param other defines the other quaternion
  3668. * @returns the updated current quaternion
  3669. */
  3670. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3671. /**
  3672. * Updates the current quaternion with the given float coordinates
  3673. * @param x defines the x coordinate
  3674. * @param y defines the y coordinate
  3675. * @param z defines the z coordinate
  3676. * @param w defines the w coordinate
  3677. * @returns the updated current quaternion
  3678. */
  3679. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3680. /**
  3681. * Updates the current quaternion from the given float coordinates
  3682. * @param x defines the x coordinate
  3683. * @param y defines the y coordinate
  3684. * @param z defines the z coordinate
  3685. * @param w defines the w coordinate
  3686. * @returns the updated current quaternion
  3687. */
  3688. set(x: number, y: number, z: number, w: number): Quaternion;
  3689. /**
  3690. * Adds two quaternions
  3691. * @param other defines the second operand
  3692. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3693. */
  3694. add(other: DeepImmutable<Quaternion>): Quaternion;
  3695. /**
  3696. * Add a quaternion to the current one
  3697. * @param other defines the quaternion to add
  3698. * @returns the current quaternion
  3699. */
  3700. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3701. /**
  3702. * Subtract two quaternions
  3703. * @param other defines the second operand
  3704. * @returns a new quaternion as the subtraction result of the given one from the current one
  3705. */
  3706. subtract(other: Quaternion): Quaternion;
  3707. /**
  3708. * Multiplies the current quaternion by a scale factor
  3709. * @param value defines the scale factor
  3710. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3711. */
  3712. scale(value: number): Quaternion;
  3713. /**
  3714. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3715. * @param scale defines the scale factor
  3716. * @param result defines the Quaternion object where to store the result
  3717. * @returns the unmodified current quaternion
  3718. */
  3719. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3720. /**
  3721. * Multiplies in place the current quaternion by a scale factor
  3722. * @param value defines the scale factor
  3723. * @returns the current modified quaternion
  3724. */
  3725. scaleInPlace(value: number): Quaternion;
  3726. /**
  3727. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3728. * @param scale defines the scale factor
  3729. * @param result defines the Quaternion object where to store the result
  3730. * @returns the unmodified current quaternion
  3731. */
  3732. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3733. /**
  3734. * Multiplies two quaternions
  3735. * @param q1 defines the second operand
  3736. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3737. */
  3738. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3739. /**
  3740. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3741. * @param q1 defines the second operand
  3742. * @param result defines the target quaternion
  3743. * @returns the current quaternion
  3744. */
  3745. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3746. /**
  3747. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3748. * @param q1 defines the second operand
  3749. * @returns the currentupdated quaternion
  3750. */
  3751. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3752. /**
  3753. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3754. * @param ref defines the target quaternion
  3755. * @returns the current quaternion
  3756. */
  3757. conjugateToRef(ref: Quaternion): Quaternion;
  3758. /**
  3759. * Conjugates in place (1-q) the current quaternion
  3760. * @returns the current updated quaternion
  3761. */
  3762. conjugateInPlace(): Quaternion;
  3763. /**
  3764. * Conjugates in place (1-q) the current quaternion
  3765. * @returns a new quaternion
  3766. */
  3767. conjugate(): Quaternion;
  3768. /**
  3769. * Gets length of current quaternion
  3770. * @returns the quaternion length (float)
  3771. */
  3772. length(): number;
  3773. /**
  3774. * Normalize in place the current quaternion
  3775. * @returns the current updated quaternion
  3776. */
  3777. normalize(): Quaternion;
  3778. /**
  3779. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3780. * @param order is a reserved parameter and is ignore for now
  3781. * @returns a new Vector3 containing the Euler angles
  3782. */
  3783. toEulerAngles(order?: string): Vector3;
  3784. /**
  3785. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3786. * @param result defines the vector which will be filled with the Euler angles
  3787. * @param order is a reserved parameter and is ignore for now
  3788. * @returns the current unchanged quaternion
  3789. */
  3790. toEulerAnglesToRef(result: Vector3): Quaternion;
  3791. /**
  3792. * Updates the given rotation matrix with the current quaternion values
  3793. * @param result defines the target matrix
  3794. * @returns the current unchanged quaternion
  3795. */
  3796. toRotationMatrix(result: Matrix): Quaternion;
  3797. /**
  3798. * Updates the current quaternion from the given rotation matrix values
  3799. * @param matrix defines the source matrix
  3800. * @returns the current updated quaternion
  3801. */
  3802. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3803. /**
  3804. * Creates a new quaternion from a rotation matrix
  3805. * @param matrix defines the source matrix
  3806. * @returns a new quaternion created from the given rotation matrix values
  3807. */
  3808. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3809. /**
  3810. * Updates the given quaternion with the given rotation matrix values
  3811. * @param matrix defines the source matrix
  3812. * @param result defines the target quaternion
  3813. */
  3814. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3815. /**
  3816. * Returns the dot product (float) between the quaternions "left" and "right"
  3817. * @param left defines the left operand
  3818. * @param right defines the right operand
  3819. * @returns the dot product
  3820. */
  3821. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3822. /**
  3823. * Checks if the two quaternions are close to each other
  3824. * @param quat0 defines the first quaternion to check
  3825. * @param quat1 defines the second quaternion to check
  3826. * @returns true if the two quaternions are close to each other
  3827. */
  3828. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3829. /**
  3830. * Creates an empty quaternion
  3831. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3832. */
  3833. static Zero(): Quaternion;
  3834. /**
  3835. * Inverse a given quaternion
  3836. * @param q defines the source quaternion
  3837. * @returns a new quaternion as the inverted current quaternion
  3838. */
  3839. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3840. /**
  3841. * Inverse a given quaternion
  3842. * @param q defines the source quaternion
  3843. * @param result the quaternion the result will be stored in
  3844. * @returns the result quaternion
  3845. */
  3846. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3847. /**
  3848. * Creates an identity quaternion
  3849. * @returns the identity quaternion
  3850. */
  3851. static Identity(): Quaternion;
  3852. /**
  3853. * Gets a boolean indicating if the given quaternion is identity
  3854. * @param quaternion defines the quaternion to check
  3855. * @returns true if the quaternion is identity
  3856. */
  3857. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3858. /**
  3859. * Creates a quaternion from a rotation around an axis
  3860. * @param axis defines the axis to use
  3861. * @param angle defines the angle to use
  3862. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3863. */
  3864. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3865. /**
  3866. * Creates a rotation around an axis and stores it into the given quaternion
  3867. * @param axis defines the axis to use
  3868. * @param angle defines the angle to use
  3869. * @param result defines the target quaternion
  3870. * @returns the target quaternion
  3871. */
  3872. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3873. /**
  3874. * Creates a new quaternion from data stored into an array
  3875. * @param array defines the data source
  3876. * @param offset defines the offset in the source array where the data starts
  3877. * @returns a new quaternion
  3878. */
  3879. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3880. /**
  3881. * Updates the given quaternion "result" from the starting index of the given array.
  3882. * @param array the array to pull values from
  3883. * @param offset the offset into the array to start at
  3884. * @param result the quaternion to store the result in
  3885. */
  3886. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3887. /**
  3888. * Create a quaternion from Euler rotation angles
  3889. * @param x Pitch
  3890. * @param y Yaw
  3891. * @param z Roll
  3892. * @returns the new Quaternion
  3893. */
  3894. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3895. /**
  3896. * Updates a quaternion from Euler rotation angles
  3897. * @param x Pitch
  3898. * @param y Yaw
  3899. * @param z Roll
  3900. * @param result the quaternion to store the result
  3901. * @returns the updated quaternion
  3902. */
  3903. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3904. /**
  3905. * Create a quaternion from Euler rotation vector
  3906. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3907. * @returns the new Quaternion
  3908. */
  3909. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3910. /**
  3911. * Updates a quaternion from Euler rotation vector
  3912. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3913. * @param result the quaternion to store the result
  3914. * @returns the updated quaternion
  3915. */
  3916. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3917. /**
  3918. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3919. * @param yaw defines the rotation around Y axis
  3920. * @param pitch defines the rotation around X axis
  3921. * @param roll defines the rotation around Z axis
  3922. * @returns the new quaternion
  3923. */
  3924. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3925. /**
  3926. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3927. * @param yaw defines the rotation around Y axis
  3928. * @param pitch defines the rotation around X axis
  3929. * @param roll defines the rotation around Z axis
  3930. * @param result defines the target quaternion
  3931. */
  3932. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3933. /**
  3934. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3935. * @param alpha defines the rotation around first axis
  3936. * @param beta defines the rotation around second axis
  3937. * @param gamma defines the rotation around third axis
  3938. * @returns the new quaternion
  3939. */
  3940. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3941. /**
  3942. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3943. * @param alpha defines the rotation around first axis
  3944. * @param beta defines the rotation around second axis
  3945. * @param gamma defines the rotation around third axis
  3946. * @param result defines the target quaternion
  3947. */
  3948. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3949. /**
  3950. * 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)
  3951. * @param axis1 defines the first axis
  3952. * @param axis2 defines the second axis
  3953. * @param axis3 defines the third axis
  3954. * @returns the new quaternion
  3955. */
  3956. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3957. /**
  3958. * 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
  3959. * @param axis1 defines the first axis
  3960. * @param axis2 defines the second axis
  3961. * @param axis3 defines the third axis
  3962. * @param ref defines the target quaternion
  3963. */
  3964. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3965. /**
  3966. * Interpolates between two quaternions
  3967. * @param left defines first quaternion
  3968. * @param right defines second quaternion
  3969. * @param amount defines the gradient to use
  3970. * @returns the new interpolated quaternion
  3971. */
  3972. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3973. /**
  3974. * Interpolates between two quaternions and stores it into a target quaternion
  3975. * @param left defines first quaternion
  3976. * @param right defines second quaternion
  3977. * @param amount defines the gradient to use
  3978. * @param result defines the target quaternion
  3979. */
  3980. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3981. /**
  3982. * Interpolate between two quaternions using Hermite interpolation
  3983. * @param value1 defines first quaternion
  3984. * @param tangent1 defines the incoming tangent
  3985. * @param value2 defines second quaternion
  3986. * @param tangent2 defines the outgoing tangent
  3987. * @param amount defines the target quaternion
  3988. * @returns the new interpolated quaternion
  3989. */
  3990. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3991. }
  3992. /**
  3993. * Class used to store matrix data (4x4)
  3994. */
  3995. export class Matrix {
  3996. private static _updateFlagSeed;
  3997. private static _identityReadOnly;
  3998. private _isIdentity;
  3999. private _isIdentityDirty;
  4000. private _isIdentity3x2;
  4001. private _isIdentity3x2Dirty;
  4002. /**
  4003. * Gets the update flag of the matrix which is an unique number for the matrix.
  4004. * It will be incremented every time the matrix data change.
  4005. * You can use it to speed the comparison between two versions of the same matrix.
  4006. */
  4007. updateFlag: number;
  4008. private readonly _m;
  4009. /**
  4010. * Gets the internal data of the matrix
  4011. */
  4012. get m(): DeepImmutable<Float32Array>;
  4013. /** @hidden */
  4014. _markAsUpdated(): void;
  4015. /** @hidden */
  4016. private _updateIdentityStatus;
  4017. /**
  4018. * Creates an empty matrix (filled with zeros)
  4019. */
  4020. constructor();
  4021. /**
  4022. * Check if the current matrix is identity
  4023. * @returns true is the matrix is the identity matrix
  4024. */
  4025. isIdentity(): boolean;
  4026. /**
  4027. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4028. * @returns true is the matrix is the identity matrix
  4029. */
  4030. isIdentityAs3x2(): boolean;
  4031. /**
  4032. * Gets the determinant of the matrix
  4033. * @returns the matrix determinant
  4034. */
  4035. determinant(): number;
  4036. /**
  4037. * Returns the matrix as a Float32Array
  4038. * @returns the matrix underlying array
  4039. */
  4040. toArray(): DeepImmutable<Float32Array>;
  4041. /**
  4042. * Returns the matrix as a Float32Array
  4043. * @returns the matrix underlying array.
  4044. */
  4045. asArray(): DeepImmutable<Float32Array>;
  4046. /**
  4047. * Inverts the current matrix in place
  4048. * @returns the current inverted matrix
  4049. */
  4050. invert(): Matrix;
  4051. /**
  4052. * Sets all the matrix elements to zero
  4053. * @returns the current matrix
  4054. */
  4055. reset(): Matrix;
  4056. /**
  4057. * Adds the current matrix with a second one
  4058. * @param other defines the matrix to add
  4059. * @returns a new matrix as the addition of the current matrix and the given one
  4060. */
  4061. add(other: DeepImmutable<Matrix>): Matrix;
  4062. /**
  4063. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4064. * @param other defines the matrix to add
  4065. * @param result defines the target matrix
  4066. * @returns the current matrix
  4067. */
  4068. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4069. /**
  4070. * Adds in place the given matrix to the current matrix
  4071. * @param other defines the second operand
  4072. * @returns the current updated matrix
  4073. */
  4074. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4075. /**
  4076. * Sets the given matrix to the current inverted Matrix
  4077. * @param other defines the target matrix
  4078. * @returns the unmodified current matrix
  4079. */
  4080. invertToRef(other: Matrix): Matrix;
  4081. /**
  4082. * add a value at the specified position in the current Matrix
  4083. * @param index the index of the value within the matrix. between 0 and 15.
  4084. * @param value the value to be added
  4085. * @returns the current updated matrix
  4086. */
  4087. addAtIndex(index: number, value: number): Matrix;
  4088. /**
  4089. * mutiply the specified position in the current Matrix by a value
  4090. * @param index the index of the value within the matrix. between 0 and 15.
  4091. * @param value the value to be added
  4092. * @returns the current updated matrix
  4093. */
  4094. multiplyAtIndex(index: number, value: number): Matrix;
  4095. /**
  4096. * Inserts the translation vector (using 3 floats) in the current matrix
  4097. * @param x defines the 1st component of the translation
  4098. * @param y defines the 2nd component of the translation
  4099. * @param z defines the 3rd component of the translation
  4100. * @returns the current updated matrix
  4101. */
  4102. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4103. /**
  4104. * Adds the translation vector (using 3 floats) in the current matrix
  4105. * @param x defines the 1st component of the translation
  4106. * @param y defines the 2nd component of the translation
  4107. * @param z defines the 3rd component of the translation
  4108. * @returns the current updated matrix
  4109. */
  4110. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4111. /**
  4112. * Inserts the translation vector in the current matrix
  4113. * @param vector3 defines the translation to insert
  4114. * @returns the current updated matrix
  4115. */
  4116. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4117. /**
  4118. * Gets the translation value of the current matrix
  4119. * @returns a new Vector3 as the extracted translation from the matrix
  4120. */
  4121. getTranslation(): Vector3;
  4122. /**
  4123. * Fill a Vector3 with the extracted translation from the matrix
  4124. * @param result defines the Vector3 where to store the translation
  4125. * @returns the current matrix
  4126. */
  4127. getTranslationToRef(result: Vector3): Matrix;
  4128. /**
  4129. * Remove rotation and scaling part from the matrix
  4130. * @returns the updated matrix
  4131. */
  4132. removeRotationAndScaling(): Matrix;
  4133. /**
  4134. * Multiply two matrices
  4135. * @param other defines the second operand
  4136. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4137. */
  4138. multiply(other: DeepImmutable<Matrix>): Matrix;
  4139. /**
  4140. * Copy the current matrix from the given one
  4141. * @param other defines the source matrix
  4142. * @returns the current updated matrix
  4143. */
  4144. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4145. /**
  4146. * Populates the given array from the starting index with the current matrix values
  4147. * @param array defines the target array
  4148. * @param offset defines the offset in the target array where to start storing values
  4149. * @returns the current matrix
  4150. */
  4151. copyToArray(array: Float32Array, offset?: number): Matrix;
  4152. /**
  4153. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4154. * @param other defines the second operand
  4155. * @param result defines the matrix where to store the multiplication
  4156. * @returns the current matrix
  4157. */
  4158. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4159. /**
  4160. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4161. * @param other defines the second operand
  4162. * @param result defines the array where to store the multiplication
  4163. * @param offset defines the offset in the target array where to start storing values
  4164. * @returns the current matrix
  4165. */
  4166. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4167. /**
  4168. * Check equality between this matrix and a second one
  4169. * @param value defines the second matrix to compare
  4170. * @returns true is the current matrix and the given one values are strictly equal
  4171. */
  4172. equals(value: DeepImmutable<Matrix>): boolean;
  4173. /**
  4174. * Clone the current matrix
  4175. * @returns a new matrix from the current matrix
  4176. */
  4177. clone(): Matrix;
  4178. /**
  4179. * Returns the name of the current matrix class
  4180. * @returns the string "Matrix"
  4181. */
  4182. getClassName(): string;
  4183. /**
  4184. * Gets the hash code of the current matrix
  4185. * @returns the hash code
  4186. */
  4187. getHashCode(): number;
  4188. /**
  4189. * Decomposes the current Matrix into a translation, rotation and scaling components
  4190. * @param scale defines the scale vector3 given as a reference to update
  4191. * @param rotation defines the rotation quaternion given as a reference to update
  4192. * @param translation defines the translation vector3 given as a reference to update
  4193. * @returns true if operation was successful
  4194. */
  4195. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4196. /**
  4197. * Gets specific row of the matrix
  4198. * @param index defines the number of the row to get
  4199. * @returns the index-th row of the current matrix as a new Vector4
  4200. */
  4201. getRow(index: number): Nullable<Vector4>;
  4202. /**
  4203. * Sets the index-th row of the current matrix to the vector4 values
  4204. * @param index defines the number of the row to set
  4205. * @param row defines the target vector4
  4206. * @returns the updated current matrix
  4207. */
  4208. setRow(index: number, row: Vector4): Matrix;
  4209. /**
  4210. * Compute the transpose of the matrix
  4211. * @returns the new transposed matrix
  4212. */
  4213. transpose(): Matrix;
  4214. /**
  4215. * Compute the transpose of the matrix and store it in a given matrix
  4216. * @param result defines the target matrix
  4217. * @returns the current matrix
  4218. */
  4219. transposeToRef(result: Matrix): Matrix;
  4220. /**
  4221. * Sets the index-th row of the current matrix with the given 4 x float values
  4222. * @param index defines the row index
  4223. * @param x defines the x component to set
  4224. * @param y defines the y component to set
  4225. * @param z defines the z component to set
  4226. * @param w defines the w component to set
  4227. * @returns the updated current matrix
  4228. */
  4229. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4230. /**
  4231. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4232. * @param scale defines the scale factor
  4233. * @returns a new matrix
  4234. */
  4235. scale(scale: number): Matrix;
  4236. /**
  4237. * Scale the current matrix values by a factor to a given result matrix
  4238. * @param scale defines the scale factor
  4239. * @param result defines the matrix to store the result
  4240. * @returns the current matrix
  4241. */
  4242. scaleToRef(scale: number, result: Matrix): Matrix;
  4243. /**
  4244. * Scale the current matrix values by a factor and add the result to a given matrix
  4245. * @param scale defines the scale factor
  4246. * @param result defines the Matrix to store the result
  4247. * @returns the current matrix
  4248. */
  4249. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4250. /**
  4251. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4252. * @param ref matrix to store the result
  4253. */
  4254. toNormalMatrix(ref: Matrix): void;
  4255. /**
  4256. * Gets only rotation part of the current matrix
  4257. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4258. */
  4259. getRotationMatrix(): Matrix;
  4260. /**
  4261. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4262. * @param result defines the target matrix to store data to
  4263. * @returns the current matrix
  4264. */
  4265. getRotationMatrixToRef(result: Matrix): Matrix;
  4266. /**
  4267. * Toggles model matrix from being right handed to left handed in place and vice versa
  4268. */
  4269. toggleModelMatrixHandInPlace(): void;
  4270. /**
  4271. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4272. */
  4273. toggleProjectionMatrixHandInPlace(): void;
  4274. /**
  4275. * Creates a matrix from an array
  4276. * @param array defines the source array
  4277. * @param offset defines an offset in the source array
  4278. * @returns a new Matrix set from the starting index of the given array
  4279. */
  4280. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4281. /**
  4282. * Copy the content of an array into a given matrix
  4283. * @param array defines the source array
  4284. * @param offset defines an offset in the source array
  4285. * @param result defines the target matrix
  4286. */
  4287. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4288. /**
  4289. * Stores an array into a matrix after having multiplied each component by a given factor
  4290. * @param array defines the source array
  4291. * @param offset defines the offset in the source array
  4292. * @param scale defines the scaling factor
  4293. * @param result defines the target matrix
  4294. */
  4295. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4296. /**
  4297. * Gets an identity matrix that must not be updated
  4298. */
  4299. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4300. /**
  4301. * Stores a list of values (16) inside a given matrix
  4302. * @param initialM11 defines 1st value of 1st row
  4303. * @param initialM12 defines 2nd value of 1st row
  4304. * @param initialM13 defines 3rd value of 1st row
  4305. * @param initialM14 defines 4th value of 1st row
  4306. * @param initialM21 defines 1st value of 2nd row
  4307. * @param initialM22 defines 2nd value of 2nd row
  4308. * @param initialM23 defines 3rd value of 2nd row
  4309. * @param initialM24 defines 4th value of 2nd row
  4310. * @param initialM31 defines 1st value of 3rd row
  4311. * @param initialM32 defines 2nd value of 3rd row
  4312. * @param initialM33 defines 3rd value of 3rd row
  4313. * @param initialM34 defines 4th value of 3rd row
  4314. * @param initialM41 defines 1st value of 4th row
  4315. * @param initialM42 defines 2nd value of 4th row
  4316. * @param initialM43 defines 3rd value of 4th row
  4317. * @param initialM44 defines 4th value of 4th row
  4318. * @param result defines the target matrix
  4319. */
  4320. 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;
  4321. /**
  4322. * Creates new matrix from a list of values (16)
  4323. * @param initialM11 defines 1st value of 1st row
  4324. * @param initialM12 defines 2nd value of 1st row
  4325. * @param initialM13 defines 3rd value of 1st row
  4326. * @param initialM14 defines 4th value of 1st row
  4327. * @param initialM21 defines 1st value of 2nd row
  4328. * @param initialM22 defines 2nd value of 2nd row
  4329. * @param initialM23 defines 3rd value of 2nd row
  4330. * @param initialM24 defines 4th value of 2nd row
  4331. * @param initialM31 defines 1st value of 3rd row
  4332. * @param initialM32 defines 2nd value of 3rd row
  4333. * @param initialM33 defines 3rd value of 3rd row
  4334. * @param initialM34 defines 4th value of 3rd row
  4335. * @param initialM41 defines 1st value of 4th row
  4336. * @param initialM42 defines 2nd value of 4th row
  4337. * @param initialM43 defines 3rd value of 4th row
  4338. * @param initialM44 defines 4th value of 4th row
  4339. * @returns the new matrix
  4340. */
  4341. 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;
  4342. /**
  4343. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4344. * @param scale defines the scale vector3
  4345. * @param rotation defines the rotation quaternion
  4346. * @param translation defines the translation vector3
  4347. * @returns a new matrix
  4348. */
  4349. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4350. /**
  4351. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4352. * @param scale defines the scale vector3
  4353. * @param rotation defines the rotation quaternion
  4354. * @param translation defines the translation vector3
  4355. * @param result defines the target matrix
  4356. */
  4357. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4358. /**
  4359. * Creates a new identity matrix
  4360. * @returns a new identity matrix
  4361. */
  4362. static Identity(): Matrix;
  4363. /**
  4364. * Creates a new identity matrix and stores the result in a given matrix
  4365. * @param result defines the target matrix
  4366. */
  4367. static IdentityToRef(result: Matrix): void;
  4368. /**
  4369. * Creates a new zero matrix
  4370. * @returns a new zero matrix
  4371. */
  4372. static Zero(): Matrix;
  4373. /**
  4374. * Creates a new rotation matrix for "angle" radians around the X axis
  4375. * @param angle defines the angle (in radians) to use
  4376. * @return the new matrix
  4377. */
  4378. static RotationX(angle: number): Matrix;
  4379. /**
  4380. * Creates a new matrix as the invert of a given matrix
  4381. * @param source defines the source matrix
  4382. * @returns the new matrix
  4383. */
  4384. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4385. /**
  4386. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4387. * @param angle defines the angle (in radians) to use
  4388. * @param result defines the target matrix
  4389. */
  4390. static RotationXToRef(angle: number, result: Matrix): void;
  4391. /**
  4392. * Creates a new rotation matrix for "angle" radians around the Y axis
  4393. * @param angle defines the angle (in radians) to use
  4394. * @return the new matrix
  4395. */
  4396. static RotationY(angle: number): Matrix;
  4397. /**
  4398. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4399. * @param angle defines the angle (in radians) to use
  4400. * @param result defines the target matrix
  4401. */
  4402. static RotationYToRef(angle: number, result: Matrix): void;
  4403. /**
  4404. * Creates a new rotation matrix for "angle" radians around the Z axis
  4405. * @param angle defines the angle (in radians) to use
  4406. * @return the new matrix
  4407. */
  4408. static RotationZ(angle: number): Matrix;
  4409. /**
  4410. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4411. * @param angle defines the angle (in radians) to use
  4412. * @param result defines the target matrix
  4413. */
  4414. static RotationZToRef(angle: number, result: Matrix): void;
  4415. /**
  4416. * Creates a new rotation matrix for "angle" radians around the given axis
  4417. * @param axis defines the axis to use
  4418. * @param angle defines the angle (in radians) to use
  4419. * @return the new matrix
  4420. */
  4421. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4422. /**
  4423. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4424. * @param axis defines the axis to use
  4425. * @param angle defines the angle (in radians) to use
  4426. * @param result defines the target matrix
  4427. */
  4428. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4429. /**
  4430. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4431. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4432. * @param from defines the vector to align
  4433. * @param to defines the vector to align to
  4434. * @param result defines the target matrix
  4435. */
  4436. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4437. /**
  4438. * Creates a rotation matrix
  4439. * @param yaw defines the yaw angle in radians (Y axis)
  4440. * @param pitch defines the pitch angle in radians (X axis)
  4441. * @param roll defines the roll angle in radians (X axis)
  4442. * @returns the new rotation matrix
  4443. */
  4444. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4445. /**
  4446. * Creates a rotation matrix and stores it in a given matrix
  4447. * @param yaw defines the yaw angle in radians (Y axis)
  4448. * @param pitch defines the pitch angle in radians (X axis)
  4449. * @param roll defines the roll angle in radians (X axis)
  4450. * @param result defines the target matrix
  4451. */
  4452. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4453. /**
  4454. * Creates a scaling matrix
  4455. * @param x defines the scale factor on X axis
  4456. * @param y defines the scale factor on Y axis
  4457. * @param z defines the scale factor on Z axis
  4458. * @returns the new matrix
  4459. */
  4460. static Scaling(x: number, y: number, z: number): Matrix;
  4461. /**
  4462. * Creates a scaling matrix and stores it in a given matrix
  4463. * @param x defines the scale factor on X axis
  4464. * @param y defines the scale factor on Y axis
  4465. * @param z defines the scale factor on Z axis
  4466. * @param result defines the target matrix
  4467. */
  4468. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4469. /**
  4470. * Creates a translation matrix
  4471. * @param x defines the translation on X axis
  4472. * @param y defines the translation on Y axis
  4473. * @param z defines the translationon Z axis
  4474. * @returns the new matrix
  4475. */
  4476. static Translation(x: number, y: number, z: number): Matrix;
  4477. /**
  4478. * Creates a translation matrix and stores it in a given matrix
  4479. * @param x defines the translation on X axis
  4480. * @param y defines the translation on Y axis
  4481. * @param z defines the translationon Z axis
  4482. * @param result defines the target matrix
  4483. */
  4484. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4485. /**
  4486. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4487. * @param startValue defines the start value
  4488. * @param endValue defines the end value
  4489. * @param gradient defines the gradient factor
  4490. * @returns the new matrix
  4491. */
  4492. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4493. /**
  4494. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4495. * @param startValue defines the start value
  4496. * @param endValue defines the end value
  4497. * @param gradient defines the gradient factor
  4498. * @param result defines the Matrix object where to store data
  4499. */
  4500. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4501. /**
  4502. * Builds a new matrix whose values are computed by:
  4503. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4504. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4505. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4506. * @param startValue defines the first matrix
  4507. * @param endValue defines the second matrix
  4508. * @param gradient defines the gradient between the two matrices
  4509. * @returns the new matrix
  4510. */
  4511. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4512. /**
  4513. * Update a matrix to values which are computed by:
  4514. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4515. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4516. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4517. * @param startValue defines the first matrix
  4518. * @param endValue defines the second matrix
  4519. * @param gradient defines the gradient between the two matrices
  4520. * @param result defines the target matrix
  4521. */
  4522. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4523. /**
  4524. * 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"
  4525. * This function works in left handed mode
  4526. * @param eye defines the final position of the entity
  4527. * @param target defines where the entity should look at
  4528. * @param up defines the up vector for the entity
  4529. * @returns the new matrix
  4530. */
  4531. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4532. /**
  4533. * 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".
  4534. * This function works in left handed mode
  4535. * @param eye defines the final position of the entity
  4536. * @param target defines where the entity should look at
  4537. * @param up defines the up vector for the entity
  4538. * @param result defines the target matrix
  4539. */
  4540. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4541. /**
  4542. * 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"
  4543. * This function works in right handed mode
  4544. * @param eye defines the final position of the entity
  4545. * @param target defines where the entity should look at
  4546. * @param up defines the up vector for the entity
  4547. * @returns the new matrix
  4548. */
  4549. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4550. /**
  4551. * 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".
  4552. * This function works in right handed mode
  4553. * @param eye defines the final position of the entity
  4554. * @param target defines where the entity should look at
  4555. * @param up defines the up vector for the entity
  4556. * @param result defines the target matrix
  4557. */
  4558. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4559. /**
  4560. * Create a left-handed orthographic projection matrix
  4561. * @param width defines the viewport width
  4562. * @param height defines the viewport height
  4563. * @param znear defines the near clip plane
  4564. * @param zfar defines the far clip plane
  4565. * @returns a new matrix as a left-handed orthographic projection matrix
  4566. */
  4567. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4568. /**
  4569. * Store a left-handed orthographic projection to a given matrix
  4570. * @param width defines the viewport width
  4571. * @param height defines the viewport height
  4572. * @param znear defines the near clip plane
  4573. * @param zfar defines the far clip plane
  4574. * @param result defines the target matrix
  4575. */
  4576. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4577. /**
  4578. * Create a left-handed orthographic projection matrix
  4579. * @param left defines the viewport left coordinate
  4580. * @param right defines the viewport right coordinate
  4581. * @param bottom defines the viewport bottom coordinate
  4582. * @param top defines the viewport top coordinate
  4583. * @param znear defines the near clip plane
  4584. * @param zfar defines the far clip plane
  4585. * @returns a new matrix as a left-handed orthographic projection matrix
  4586. */
  4587. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4588. /**
  4589. * Stores a left-handed orthographic projection into a given matrix
  4590. * @param left defines the viewport left coordinate
  4591. * @param right defines the viewport right coordinate
  4592. * @param bottom defines the viewport bottom coordinate
  4593. * @param top defines the viewport top coordinate
  4594. * @param znear defines the near clip plane
  4595. * @param zfar defines the far clip plane
  4596. * @param result defines the target matrix
  4597. */
  4598. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4599. /**
  4600. * Creates a right-handed orthographic projection matrix
  4601. * @param left defines the viewport left coordinate
  4602. * @param right defines the viewport right coordinate
  4603. * @param bottom defines the viewport bottom coordinate
  4604. * @param top defines the viewport top coordinate
  4605. * @param znear defines the near clip plane
  4606. * @param zfar defines the far clip plane
  4607. * @returns a new matrix as a right-handed orthographic projection matrix
  4608. */
  4609. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4610. /**
  4611. * Stores a right-handed orthographic projection into a given matrix
  4612. * @param left defines the viewport left coordinate
  4613. * @param right defines the viewport right coordinate
  4614. * @param bottom defines the viewport bottom coordinate
  4615. * @param top defines the viewport top coordinate
  4616. * @param znear defines the near clip plane
  4617. * @param zfar defines the far clip plane
  4618. * @param result defines the target matrix
  4619. */
  4620. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4621. /**
  4622. * Creates a left-handed perspective projection matrix
  4623. * @param width defines the viewport width
  4624. * @param height defines the viewport height
  4625. * @param znear defines the near clip plane
  4626. * @param zfar defines the far clip plane
  4627. * @returns a new matrix as a left-handed perspective projection matrix
  4628. */
  4629. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4630. /**
  4631. * Creates a left-handed perspective projection matrix
  4632. * @param fov defines the horizontal field of view
  4633. * @param aspect defines the aspect ratio
  4634. * @param znear defines the near clip plane
  4635. * @param zfar defines the far clip plane
  4636. * @returns a new matrix as a left-handed perspective projection matrix
  4637. */
  4638. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4639. /**
  4640. * Stores a left-handed perspective projection into a given matrix
  4641. * @param fov defines the horizontal field of view
  4642. * @param aspect defines the aspect ratio
  4643. * @param znear defines the near clip plane
  4644. * @param zfar defines the far clip plane
  4645. * @param result defines the target matrix
  4646. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4647. */
  4648. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4649. /**
  4650. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4651. * @param fov defines the horizontal field of view
  4652. * @param aspect defines the aspect ratio
  4653. * @param znear defines the near clip plane
  4654. * @param zfar not used as infinity is used as far clip
  4655. * @param result defines the target matrix
  4656. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4657. */
  4658. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4659. /**
  4660. * Creates a right-handed perspective projection matrix
  4661. * @param fov defines the horizontal field of view
  4662. * @param aspect defines the aspect ratio
  4663. * @param znear defines the near clip plane
  4664. * @param zfar defines the far clip plane
  4665. * @returns a new matrix as a right-handed perspective projection matrix
  4666. */
  4667. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4668. /**
  4669. * Stores a right-handed perspective projection into a given matrix
  4670. * @param fov defines the horizontal field of view
  4671. * @param aspect defines the aspect ratio
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4676. */
  4677. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4678. /**
  4679. * Stores a right-handed perspective projection into a given matrix
  4680. * @param fov defines the horizontal field of view
  4681. * @param aspect defines the aspect ratio
  4682. * @param znear defines the near clip plane
  4683. * @param zfar not used as infinity is used as far clip
  4684. * @param result defines the target matrix
  4685. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4686. */
  4687. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4688. /**
  4689. * Stores a perspective projection for WebVR info a given matrix
  4690. * @param fov defines the field of view
  4691. * @param znear defines the near clip plane
  4692. * @param zfar defines the far clip plane
  4693. * @param result defines the target matrix
  4694. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4695. */
  4696. static PerspectiveFovWebVRToRef(fov: {
  4697. upDegrees: number;
  4698. downDegrees: number;
  4699. leftDegrees: number;
  4700. rightDegrees: number;
  4701. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4702. /**
  4703. * Computes a complete transformation matrix
  4704. * @param viewport defines the viewport to use
  4705. * @param world defines the world matrix
  4706. * @param view defines the view matrix
  4707. * @param projection defines the projection matrix
  4708. * @param zmin defines the near clip plane
  4709. * @param zmax defines the far clip plane
  4710. * @returns the transformation matrix
  4711. */
  4712. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4713. /**
  4714. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4715. * @param matrix defines the matrix to use
  4716. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4717. */
  4718. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4719. /**
  4720. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4721. * @param matrix defines the matrix to use
  4722. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4723. */
  4724. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4725. /**
  4726. * Compute the transpose of a given matrix
  4727. * @param matrix defines the matrix to transpose
  4728. * @returns the new matrix
  4729. */
  4730. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4731. /**
  4732. * Compute the transpose of a matrix and store it in a target matrix
  4733. * @param matrix defines the matrix to transpose
  4734. * @param result defines the target matrix
  4735. */
  4736. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4737. /**
  4738. * Computes a reflection matrix from a plane
  4739. * @param plane defines the reflection plane
  4740. * @returns a new matrix
  4741. */
  4742. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4743. /**
  4744. * Computes a reflection matrix from a plane
  4745. * @param plane defines the reflection plane
  4746. * @param result defines the target matrix
  4747. */
  4748. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4749. /**
  4750. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4751. * @param xaxis defines the value of the 1st axis
  4752. * @param yaxis defines the value of the 2nd axis
  4753. * @param zaxis defines the value of the 3rd axis
  4754. * @param result defines the target matrix
  4755. */
  4756. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4757. /**
  4758. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4759. * @param quat defines the quaternion to use
  4760. * @param result defines the target matrix
  4761. */
  4762. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4763. }
  4764. /**
  4765. * @hidden
  4766. */
  4767. export class TmpVectors {
  4768. static Vector2: Vector2[];
  4769. static Vector3: Vector3[];
  4770. static Vector4: Vector4[];
  4771. static Quaternion: Quaternion[];
  4772. static Matrix: Matrix[];
  4773. }
  4774. }
  4775. declare module BABYLON {
  4776. /**
  4777. * Defines potential orientation for back face culling
  4778. */
  4779. export enum Orientation {
  4780. /**
  4781. * Clockwise
  4782. */
  4783. CW = 0,
  4784. /** Counter clockwise */
  4785. CCW = 1
  4786. }
  4787. /** Class used to represent a Bezier curve */
  4788. export class BezierCurve {
  4789. /**
  4790. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4791. * @param t defines the time
  4792. * @param x1 defines the left coordinate on X axis
  4793. * @param y1 defines the left coordinate on Y axis
  4794. * @param x2 defines the right coordinate on X axis
  4795. * @param y2 defines the right coordinate on Y axis
  4796. * @returns the interpolated value
  4797. */
  4798. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4799. }
  4800. /**
  4801. * Defines angle representation
  4802. */
  4803. export class Angle {
  4804. private _radians;
  4805. /**
  4806. * Creates an Angle object of "radians" radians (float).
  4807. * @param radians the angle in radians
  4808. */
  4809. constructor(radians: number);
  4810. /**
  4811. * Get value in degrees
  4812. * @returns the Angle value in degrees (float)
  4813. */
  4814. degrees(): number;
  4815. /**
  4816. * Get value in radians
  4817. * @returns the Angle value in radians (float)
  4818. */
  4819. radians(): number;
  4820. /**
  4821. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4822. * @param a defines first vector
  4823. * @param b defines second vector
  4824. * @returns a new Angle
  4825. */
  4826. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4827. /**
  4828. * Gets a new Angle object from the given float in radians
  4829. * @param radians defines the angle value in radians
  4830. * @returns a new Angle
  4831. */
  4832. static FromRadians(radians: number): Angle;
  4833. /**
  4834. * Gets a new Angle object from the given float in degrees
  4835. * @param degrees defines the angle value in degrees
  4836. * @returns a new Angle
  4837. */
  4838. static FromDegrees(degrees: number): Angle;
  4839. }
  4840. /**
  4841. * This represents an arc in a 2d space.
  4842. */
  4843. export class Arc2 {
  4844. /** Defines the start point of the arc */
  4845. startPoint: Vector2;
  4846. /** Defines the mid point of the arc */
  4847. midPoint: Vector2;
  4848. /** Defines the end point of the arc */
  4849. endPoint: Vector2;
  4850. /**
  4851. * Defines the center point of the arc.
  4852. */
  4853. centerPoint: Vector2;
  4854. /**
  4855. * Defines the radius of the arc.
  4856. */
  4857. radius: number;
  4858. /**
  4859. * Defines the angle of the arc (from mid point to end point).
  4860. */
  4861. angle: Angle;
  4862. /**
  4863. * Defines the start angle of the arc (from start point to middle point).
  4864. */
  4865. startAngle: Angle;
  4866. /**
  4867. * Defines the orientation of the arc (clock wise/counter clock wise).
  4868. */
  4869. orientation: Orientation;
  4870. /**
  4871. * Creates an Arc object from the three given points : start, middle and end.
  4872. * @param startPoint Defines the start point of the arc
  4873. * @param midPoint Defines the midlle point of the arc
  4874. * @param endPoint Defines the end point of the arc
  4875. */
  4876. constructor(
  4877. /** Defines the start point of the arc */
  4878. startPoint: Vector2,
  4879. /** Defines the mid point of the arc */
  4880. midPoint: Vector2,
  4881. /** Defines the end point of the arc */
  4882. endPoint: Vector2);
  4883. }
  4884. /**
  4885. * Represents a 2D path made up of multiple 2D points
  4886. */
  4887. export class Path2 {
  4888. private _points;
  4889. private _length;
  4890. /**
  4891. * If the path start and end point are the same
  4892. */
  4893. closed: boolean;
  4894. /**
  4895. * Creates a Path2 object from the starting 2D coordinates x and y.
  4896. * @param x the starting points x value
  4897. * @param y the starting points y value
  4898. */
  4899. constructor(x: number, y: number);
  4900. /**
  4901. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4902. * @param x the added points x value
  4903. * @param y the added points y value
  4904. * @returns the updated Path2.
  4905. */
  4906. addLineTo(x: number, y: number): Path2;
  4907. /**
  4908. * 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.
  4909. * @param midX middle point x value
  4910. * @param midY middle point y value
  4911. * @param endX end point x value
  4912. * @param endY end point y value
  4913. * @param numberOfSegments (default: 36)
  4914. * @returns the updated Path2.
  4915. */
  4916. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4917. /**
  4918. * Closes the Path2.
  4919. * @returns the Path2.
  4920. */
  4921. close(): Path2;
  4922. /**
  4923. * Gets the sum of the distance between each sequential point in the path
  4924. * @returns the Path2 total length (float).
  4925. */
  4926. length(): number;
  4927. /**
  4928. * Gets the points which construct the path
  4929. * @returns the Path2 internal array of points.
  4930. */
  4931. getPoints(): Vector2[];
  4932. /**
  4933. * Retreives the point at the distance aways from the starting point
  4934. * @param normalizedLengthPosition the length along the path to retreive the point from
  4935. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4936. */
  4937. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4938. /**
  4939. * Creates a new path starting from an x and y position
  4940. * @param x starting x value
  4941. * @param y starting y value
  4942. * @returns a new Path2 starting at the coordinates (x, y).
  4943. */
  4944. static StartingAt(x: number, y: number): Path2;
  4945. }
  4946. /**
  4947. * Represents a 3D path made up of multiple 3D points
  4948. */
  4949. export class Path3D {
  4950. /**
  4951. * an array of Vector3, the curve axis of the Path3D
  4952. */
  4953. path: Vector3[];
  4954. private _curve;
  4955. private _distances;
  4956. private _tangents;
  4957. private _normals;
  4958. private _binormals;
  4959. private _raw;
  4960. private _alignTangentsWithPath;
  4961. private readonly _pointAtData;
  4962. /**
  4963. * new Path3D(path, normal, raw)
  4964. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4965. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4966. * @param path an array of Vector3, the curve axis of the Path3D
  4967. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4968. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4969. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4970. */
  4971. constructor(
  4972. /**
  4973. * an array of Vector3, the curve axis of the Path3D
  4974. */
  4975. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4976. /**
  4977. * Returns the Path3D array of successive Vector3 designing its curve.
  4978. * @returns the Path3D array of successive Vector3 designing its curve.
  4979. */
  4980. getCurve(): Vector3[];
  4981. /**
  4982. * Returns the Path3D array of successive Vector3 designing its curve.
  4983. * @returns the Path3D array of successive Vector3 designing its curve.
  4984. */
  4985. getPoints(): Vector3[];
  4986. /**
  4987. * @returns the computed length (float) of the path.
  4988. */
  4989. length(): number;
  4990. /**
  4991. * Returns an array populated with tangent vectors on each Path3D curve point.
  4992. * @returns an array populated with tangent vectors on each Path3D curve point.
  4993. */
  4994. getTangents(): Vector3[];
  4995. /**
  4996. * Returns an array populated with normal vectors on each Path3D curve point.
  4997. * @returns an array populated with normal vectors on each Path3D curve point.
  4998. */
  4999. getNormals(): Vector3[];
  5000. /**
  5001. * Returns an array populated with binormal vectors on each Path3D curve point.
  5002. * @returns an array populated with binormal vectors on each Path3D curve point.
  5003. */
  5004. getBinormals(): Vector3[];
  5005. /**
  5006. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5007. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5008. */
  5009. getDistances(): number[];
  5010. /**
  5011. * Returns an interpolated point along this path
  5012. * @param position the position of the point along this path, from 0.0 to 1.0
  5013. * @returns a new Vector3 as the point
  5014. */
  5015. getPointAt(position: number): Vector3;
  5016. /**
  5017. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5018. * @param position the position of the point along this path, from 0.0 to 1.0
  5019. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5020. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5021. */
  5022. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5023. /**
  5024. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5025. * @param position the position of the point along this path, from 0.0 to 1.0
  5026. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5027. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5028. */
  5029. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5030. /**
  5031. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5032. * @param position the position of the point along this path, from 0.0 to 1.0
  5033. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5034. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5035. */
  5036. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5037. /**
  5038. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5039. * @param position the position of the point along this path, from 0.0 to 1.0
  5040. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5041. */
  5042. getDistanceAt(position: number): number;
  5043. /**
  5044. * Returns the array index of the previous point of an interpolated point along this path
  5045. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5046. * @returns the array index
  5047. */
  5048. getPreviousPointIndexAt(position: number): number;
  5049. /**
  5050. * 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)
  5051. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5052. * @returns the sub position
  5053. */
  5054. getSubPositionAt(position: number): number;
  5055. /**
  5056. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5057. * @param target the vector of which to get the closest position to
  5058. * @returns the position of the closest virtual point on this path to the target vector
  5059. */
  5060. getClosestPositionTo(target: Vector3): number;
  5061. /**
  5062. * Returns a sub path (slice) of this path
  5063. * @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
  5064. * @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
  5065. * @returns a sub path (slice) of this path
  5066. */
  5067. slice(start?: number, end?: number): Path3D;
  5068. /**
  5069. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5070. * @param path path which all values are copied into the curves points
  5071. * @param firstNormal which should be projected onto the curve
  5072. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5073. * @returns the same object updated.
  5074. */
  5075. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5076. private _compute;
  5077. private _getFirstNonNullVector;
  5078. private _getLastNonNullVector;
  5079. private _normalVector;
  5080. /**
  5081. * Updates the point at data for an interpolated point along this curve
  5082. * @param position the position of the point along this curve, from 0.0 to 1.0
  5083. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5084. * @returns the (updated) point at data
  5085. */
  5086. private _updatePointAtData;
  5087. /**
  5088. * Updates the point at data from the specified parameters
  5089. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5090. * @param point the interpolated point
  5091. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5092. */
  5093. private _setPointAtData;
  5094. /**
  5095. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5096. */
  5097. private _updateInterpolationMatrix;
  5098. }
  5099. /**
  5100. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5101. * A Curve3 is designed from a series of successive Vector3.
  5102. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5103. */
  5104. export class Curve3 {
  5105. private _points;
  5106. private _length;
  5107. /**
  5108. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5109. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5110. * @param v1 (Vector3) the control point
  5111. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5112. * @param nbPoints (integer) the wanted number of points in the curve
  5113. * @returns the created Curve3
  5114. */
  5115. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5116. /**
  5117. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5118. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5119. * @param v1 (Vector3) the first control point
  5120. * @param v2 (Vector3) the second control point
  5121. * @param v3 (Vector3) the end point of the Cubic Bezier
  5122. * @param nbPoints (integer) the wanted number of points in the curve
  5123. * @returns the created Curve3
  5124. */
  5125. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5126. /**
  5127. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5128. * @param p1 (Vector3) the origin point of the Hermite Spline
  5129. * @param t1 (Vector3) the tangent vector at the origin point
  5130. * @param p2 (Vector3) the end point of the Hermite Spline
  5131. * @param t2 (Vector3) the tangent vector at the end point
  5132. * @param nbPoints (integer) the wanted number of points in the curve
  5133. * @returns the created Curve3
  5134. */
  5135. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5136. /**
  5137. * Returns a Curve3 object along a CatmullRom Spline curve :
  5138. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5139. * @param nbPoints (integer) the wanted number of points between each curve control points
  5140. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5141. * @returns the created Curve3
  5142. */
  5143. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5144. /**
  5145. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5146. * A Curve3 is designed from a series of successive Vector3.
  5147. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5148. * @param points points which make up the curve
  5149. */
  5150. constructor(points: Vector3[]);
  5151. /**
  5152. * @returns the Curve3 stored array of successive Vector3
  5153. */
  5154. getPoints(): Vector3[];
  5155. /**
  5156. * @returns the computed length (float) of the curve.
  5157. */
  5158. length(): number;
  5159. /**
  5160. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5161. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5162. * curveA and curveB keep unchanged.
  5163. * @param curve the curve to continue from this curve
  5164. * @returns the newly constructed curve
  5165. */
  5166. continue(curve: DeepImmutable<Curve3>): Curve3;
  5167. private _computeLength;
  5168. }
  5169. }
  5170. declare module BABYLON {
  5171. /**
  5172. * This represents the main contract an easing function should follow.
  5173. * Easing functions are used throughout the animation system.
  5174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5175. */
  5176. export interface IEasingFunction {
  5177. /**
  5178. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5179. * of the easing function.
  5180. * The link below provides some of the most common examples of easing functions.
  5181. * @see https://easings.net/
  5182. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5183. * @returns the corresponding value on the curve defined by the easing function
  5184. */
  5185. ease(gradient: number): number;
  5186. }
  5187. /**
  5188. * Base class used for every default easing function.
  5189. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5190. */
  5191. export class EasingFunction implements IEasingFunction {
  5192. /**
  5193. * Interpolation follows the mathematical formula associated with the easing function.
  5194. */
  5195. static readonly EASINGMODE_EASEIN: number;
  5196. /**
  5197. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5198. */
  5199. static readonly EASINGMODE_EASEOUT: number;
  5200. /**
  5201. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5202. */
  5203. static readonly EASINGMODE_EASEINOUT: number;
  5204. private _easingMode;
  5205. /**
  5206. * Sets the easing mode of the current function.
  5207. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5208. */
  5209. setEasingMode(easingMode: number): void;
  5210. /**
  5211. * Gets the current easing mode.
  5212. * @returns the easing mode
  5213. */
  5214. getEasingMode(): number;
  5215. /**
  5216. * @hidden
  5217. */
  5218. easeInCore(gradient: number): number;
  5219. /**
  5220. * Given an input gradient between 0 and 1, this returns the corresponding value
  5221. * of the easing function.
  5222. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5223. * @returns the corresponding value on the curve defined by the easing function
  5224. */
  5225. ease(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a circle shape (see link below).
  5229. * @see https://easings.net/#easeInCirc
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class CircleEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a ease back shape (see link below).
  5238. * @see https://easings.net/#easeInBack
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class BackEase extends EasingFunction implements IEasingFunction {
  5242. /** Defines the amplitude of the function */
  5243. amplitude: number;
  5244. /**
  5245. * Instantiates a back ease easing
  5246. * @see https://easings.net/#easeInBack
  5247. * @param amplitude Defines the amplitude of the function
  5248. */
  5249. constructor(
  5250. /** Defines the amplitude of the function */
  5251. amplitude?: number);
  5252. /** @hidden */
  5253. easeInCore(gradient: number): number;
  5254. }
  5255. /**
  5256. * Easing function with a bouncing shape (see link below).
  5257. * @see https://easings.net/#easeInBounce
  5258. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5259. */
  5260. export class BounceEase extends EasingFunction implements IEasingFunction {
  5261. /** Defines the number of bounces */
  5262. bounces: number;
  5263. /** Defines the amplitude of the bounce */
  5264. bounciness: number;
  5265. /**
  5266. * Instantiates a bounce easing
  5267. * @see https://easings.net/#easeInBounce
  5268. * @param bounces Defines the number of bounces
  5269. * @param bounciness Defines the amplitude of the bounce
  5270. */
  5271. constructor(
  5272. /** Defines the number of bounces */
  5273. bounces?: number,
  5274. /** Defines the amplitude of the bounce */
  5275. bounciness?: number);
  5276. /** @hidden */
  5277. easeInCore(gradient: number): number;
  5278. }
  5279. /**
  5280. * Easing function with a power of 3 shape (see link below).
  5281. * @see https://easings.net/#easeInCubic
  5282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5283. */
  5284. export class CubicEase extends EasingFunction implements IEasingFunction {
  5285. /** @hidden */
  5286. easeInCore(gradient: number): number;
  5287. }
  5288. /**
  5289. * Easing function with an elastic shape (see link below).
  5290. * @see https://easings.net/#easeInElastic
  5291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5292. */
  5293. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5294. /** Defines the number of oscillations*/
  5295. oscillations: number;
  5296. /** Defines the amplitude of the oscillations*/
  5297. springiness: number;
  5298. /**
  5299. * Instantiates an elastic easing function
  5300. * @see https://easings.net/#easeInElastic
  5301. * @param oscillations Defines the number of oscillations
  5302. * @param springiness Defines the amplitude of the oscillations
  5303. */
  5304. constructor(
  5305. /** Defines the number of oscillations*/
  5306. oscillations?: number,
  5307. /** Defines the amplitude of the oscillations*/
  5308. springiness?: number);
  5309. /** @hidden */
  5310. easeInCore(gradient: number): number;
  5311. }
  5312. /**
  5313. * Easing function with an exponential shape (see link below).
  5314. * @see https://easings.net/#easeInExpo
  5315. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5316. */
  5317. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5318. /** Defines the exponent of the function */
  5319. exponent: number;
  5320. /**
  5321. * Instantiates an exponential easing function
  5322. * @see https://easings.net/#easeInExpo
  5323. * @param exponent Defines the exponent of the function
  5324. */
  5325. constructor(
  5326. /** Defines the exponent of the function */
  5327. exponent?: number);
  5328. /** @hidden */
  5329. easeInCore(gradient: number): number;
  5330. }
  5331. /**
  5332. * Easing function with a power shape (see link below).
  5333. * @see https://easings.net/#easeInQuad
  5334. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5335. */
  5336. export class PowerEase extends EasingFunction implements IEasingFunction {
  5337. /** Defines the power of the function */
  5338. power: number;
  5339. /**
  5340. * Instantiates an power base easing function
  5341. * @see https://easings.net/#easeInQuad
  5342. * @param power Defines the power of the function
  5343. */
  5344. constructor(
  5345. /** Defines the power of the function */
  5346. power?: number);
  5347. /** @hidden */
  5348. easeInCore(gradient: number): number;
  5349. }
  5350. /**
  5351. * Easing function with a power of 2 shape (see link below).
  5352. * @see https://easings.net/#easeInQuad
  5353. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5354. */
  5355. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5356. /** @hidden */
  5357. easeInCore(gradient: number): number;
  5358. }
  5359. /**
  5360. * Easing function with a power of 4 shape (see link below).
  5361. * @see https://easings.net/#easeInQuart
  5362. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5363. */
  5364. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with a power of 5 shape (see link below).
  5370. * @see https://easings.net/#easeInQuint
  5371. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5374. /** @hidden */
  5375. easeInCore(gradient: number): number;
  5376. }
  5377. /**
  5378. * Easing function with a sin shape (see link below).
  5379. * @see https://easings.net/#easeInSine
  5380. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5381. */
  5382. export class SineEase extends EasingFunction implements IEasingFunction {
  5383. /** @hidden */
  5384. easeInCore(gradient: number): number;
  5385. }
  5386. /**
  5387. * Easing function with a bezier shape (see link below).
  5388. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5389. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5390. */
  5391. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5392. /** Defines the x component of the start tangent in the bezier curve */
  5393. x1: number;
  5394. /** Defines the y component of the start tangent in the bezier curve */
  5395. y1: number;
  5396. /** Defines the x component of the end tangent in the bezier curve */
  5397. x2: number;
  5398. /** Defines the y component of the end tangent in the bezier curve */
  5399. y2: number;
  5400. /**
  5401. * Instantiates a bezier function
  5402. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5403. * @param x1 Defines the x component of the start tangent in the bezier curve
  5404. * @param y1 Defines the y component of the start tangent in the bezier curve
  5405. * @param x2 Defines the x component of the end tangent in the bezier curve
  5406. * @param y2 Defines the y component of the end tangent in the bezier curve
  5407. */
  5408. constructor(
  5409. /** Defines the x component of the start tangent in the bezier curve */
  5410. x1?: number,
  5411. /** Defines the y component of the start tangent in the bezier curve */
  5412. y1?: number,
  5413. /** Defines the x component of the end tangent in the bezier curve */
  5414. x2?: number,
  5415. /** Defines the y component of the end tangent in the bezier curve */
  5416. y2?: number);
  5417. /** @hidden */
  5418. easeInCore(gradient: number): number;
  5419. }
  5420. }
  5421. declare module BABYLON {
  5422. /**
  5423. * Class used to hold a RBG color
  5424. */
  5425. export class Color3 {
  5426. /**
  5427. * Defines the red component (between 0 and 1, default is 0)
  5428. */
  5429. r: number;
  5430. /**
  5431. * Defines the green component (between 0 and 1, default is 0)
  5432. */
  5433. g: number;
  5434. /**
  5435. * Defines the blue component (between 0 and 1, default is 0)
  5436. */
  5437. b: number;
  5438. /**
  5439. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5440. * @param r defines the red component (between 0 and 1, default is 0)
  5441. * @param g defines the green component (between 0 and 1, default is 0)
  5442. * @param b defines the blue component (between 0 and 1, default is 0)
  5443. */
  5444. constructor(
  5445. /**
  5446. * Defines the red component (between 0 and 1, default is 0)
  5447. */
  5448. r?: number,
  5449. /**
  5450. * Defines the green component (between 0 and 1, default is 0)
  5451. */
  5452. g?: number,
  5453. /**
  5454. * Defines the blue component (between 0 and 1, default is 0)
  5455. */
  5456. b?: number);
  5457. /**
  5458. * Creates a string with the Color3 current values
  5459. * @returns the string representation of the Color3 object
  5460. */
  5461. toString(): string;
  5462. /**
  5463. * Returns the string "Color3"
  5464. * @returns "Color3"
  5465. */
  5466. getClassName(): string;
  5467. /**
  5468. * Compute the Color3 hash code
  5469. * @returns an unique number that can be used to hash Color3 objects
  5470. */
  5471. getHashCode(): number;
  5472. /**
  5473. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5474. * @param array defines the array where to store the r,g,b components
  5475. * @param index defines an optional index in the target array to define where to start storing values
  5476. * @returns the current Color3 object
  5477. */
  5478. toArray(array: FloatArray, index?: number): Color3;
  5479. /**
  5480. * Returns a new Color4 object from the current Color3 and the given alpha
  5481. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5482. * @returns a new Color4 object
  5483. */
  5484. toColor4(alpha?: number): Color4;
  5485. /**
  5486. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5487. * @returns the new array
  5488. */
  5489. asArray(): number[];
  5490. /**
  5491. * Returns the luminance value
  5492. * @returns a float value
  5493. */
  5494. toLuminance(): number;
  5495. /**
  5496. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5497. * @param otherColor defines the second operand
  5498. * @returns the new Color3 object
  5499. */
  5500. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5501. /**
  5502. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5503. * @param otherColor defines the second operand
  5504. * @param result defines the Color3 object where to store the result
  5505. * @returns the current Color3
  5506. */
  5507. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5508. /**
  5509. * Determines equality between Color3 objects
  5510. * @param otherColor defines the second operand
  5511. * @returns true if the rgb values are equal to the given ones
  5512. */
  5513. equals(otherColor: DeepImmutable<Color3>): boolean;
  5514. /**
  5515. * Determines equality between the current Color3 object and a set of r,b,g values
  5516. * @param r defines the red component to check
  5517. * @param g defines the green component to check
  5518. * @param b defines the blue component to check
  5519. * @returns true if the rgb values are equal to the given ones
  5520. */
  5521. equalsFloats(r: number, g: number, b: number): boolean;
  5522. /**
  5523. * Multiplies in place each rgb value by scale
  5524. * @param scale defines the scaling factor
  5525. * @returns the updated Color3
  5526. */
  5527. scale(scale: number): Color3;
  5528. /**
  5529. * Multiplies the rgb values by scale and stores the result into "result"
  5530. * @param scale defines the scaling factor
  5531. * @param result defines the Color3 object where to store the result
  5532. * @returns the unmodified current Color3
  5533. */
  5534. scaleToRef(scale: number, result: Color3): Color3;
  5535. /**
  5536. * Scale the current Color3 values by a factor and add the result to a given Color3
  5537. * @param scale defines the scale factor
  5538. * @param result defines color to store the result into
  5539. * @returns the unmodified current Color3
  5540. */
  5541. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5542. /**
  5543. * Clamps the rgb values by the min and max values and stores the result into "result"
  5544. * @param min defines minimum clamping value (default is 0)
  5545. * @param max defines maximum clamping value (default is 1)
  5546. * @param result defines color to store the result into
  5547. * @returns the original Color3
  5548. */
  5549. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5550. /**
  5551. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5552. * @param otherColor defines the second operand
  5553. * @returns the new Color3
  5554. */
  5555. add(otherColor: DeepImmutable<Color3>): Color3;
  5556. /**
  5557. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5558. * @param otherColor defines the second operand
  5559. * @param result defines Color3 object to store the result into
  5560. * @returns the unmodified current Color3
  5561. */
  5562. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5563. /**
  5564. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5565. * @param otherColor defines the second operand
  5566. * @returns the new Color3
  5567. */
  5568. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5569. /**
  5570. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5571. * @param otherColor defines the second operand
  5572. * @param result defines Color3 object to store the result into
  5573. * @returns the unmodified current Color3
  5574. */
  5575. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5576. /**
  5577. * Copy the current object
  5578. * @returns a new Color3 copied the current one
  5579. */
  5580. clone(): Color3;
  5581. /**
  5582. * Copies the rgb values from the source in the current Color3
  5583. * @param source defines the source Color3 object
  5584. * @returns the updated Color3 object
  5585. */
  5586. copyFrom(source: DeepImmutable<Color3>): Color3;
  5587. /**
  5588. * Updates the Color3 rgb values from the given floats
  5589. * @param r defines the red component to read from
  5590. * @param g defines the green component to read from
  5591. * @param b defines the blue component to read from
  5592. * @returns the current Color3 object
  5593. */
  5594. copyFromFloats(r: number, g: number, b: number): Color3;
  5595. /**
  5596. * Updates the Color3 rgb values from the given floats
  5597. * @param r defines the red component to read from
  5598. * @param g defines the green component to read from
  5599. * @param b defines the blue component to read from
  5600. * @returns the current Color3 object
  5601. */
  5602. set(r: number, g: number, b: number): Color3;
  5603. /**
  5604. * Compute the Color3 hexadecimal code as a string
  5605. * @returns a string containing the hexadecimal representation of the Color3 object
  5606. */
  5607. toHexString(): string;
  5608. /**
  5609. * Computes a new Color3 converted from the current one to linear space
  5610. * @returns a new Color3 object
  5611. */
  5612. toLinearSpace(): Color3;
  5613. /**
  5614. * Converts current color in rgb space to HSV values
  5615. * @returns a new color3 representing the HSV values
  5616. */
  5617. toHSV(): Color3;
  5618. /**
  5619. * Converts current color in rgb space to HSV values
  5620. * @param result defines the Color3 where to store the HSV values
  5621. */
  5622. toHSVToRef(result: Color3): void;
  5623. /**
  5624. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5625. * @param convertedColor defines the Color3 object where to store the linear space version
  5626. * @returns the unmodified Color3
  5627. */
  5628. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5629. /**
  5630. * Computes a new Color3 converted from the current one to gamma space
  5631. * @returns a new Color3 object
  5632. */
  5633. toGammaSpace(): Color3;
  5634. /**
  5635. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5636. * @param convertedColor defines the Color3 object where to store the gamma space version
  5637. * @returns the unmodified Color3
  5638. */
  5639. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5640. private static _BlackReadOnly;
  5641. /**
  5642. * Convert Hue, saturation and value to a Color3 (RGB)
  5643. * @param hue defines the hue
  5644. * @param saturation defines the saturation
  5645. * @param value defines the value
  5646. * @param result defines the Color3 where to store the RGB values
  5647. */
  5648. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5649. /**
  5650. * Creates a new Color3 from the string containing valid hexadecimal values
  5651. * @param hex defines a string containing valid hexadecimal values
  5652. * @returns a new Color3 object
  5653. */
  5654. static FromHexString(hex: string): Color3;
  5655. /**
  5656. * Creates a new Color3 from the starting index of the given array
  5657. * @param array defines the source array
  5658. * @param offset defines an offset in the source array
  5659. * @returns a new Color3 object
  5660. */
  5661. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5662. /**
  5663. * Creates a new Color3 from integer values (< 256)
  5664. * @param r defines the red component to read from (value between 0 and 255)
  5665. * @param g defines the green component to read from (value between 0 and 255)
  5666. * @param b defines the blue component to read from (value between 0 and 255)
  5667. * @returns a new Color3 object
  5668. */
  5669. static FromInts(r: number, g: number, b: number): Color3;
  5670. /**
  5671. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5672. * @param start defines the start Color3 value
  5673. * @param end defines the end Color3 value
  5674. * @param amount defines the gradient value between start and end
  5675. * @returns a new Color3 object
  5676. */
  5677. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5678. /**
  5679. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5680. * @param left defines the start value
  5681. * @param right defines the end value
  5682. * @param amount defines the gradient factor
  5683. * @param result defines the Color3 object where to store the result
  5684. */
  5685. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5686. /**
  5687. * Returns a Color3 value containing a red color
  5688. * @returns a new Color3 object
  5689. */
  5690. static Red(): Color3;
  5691. /**
  5692. * Returns a Color3 value containing a green color
  5693. * @returns a new Color3 object
  5694. */
  5695. static Green(): Color3;
  5696. /**
  5697. * Returns a Color3 value containing a blue color
  5698. * @returns a new Color3 object
  5699. */
  5700. static Blue(): Color3;
  5701. /**
  5702. * Returns a Color3 value containing a black color
  5703. * @returns a new Color3 object
  5704. */
  5705. static Black(): Color3;
  5706. /**
  5707. * Gets a Color3 value containing a black color that must not be updated
  5708. */
  5709. static get BlackReadOnly(): DeepImmutable<Color3>;
  5710. /**
  5711. * Returns a Color3 value containing a white color
  5712. * @returns a new Color3 object
  5713. */
  5714. static White(): Color3;
  5715. /**
  5716. * Returns a Color3 value containing a purple color
  5717. * @returns a new Color3 object
  5718. */
  5719. static Purple(): Color3;
  5720. /**
  5721. * Returns a Color3 value containing a magenta color
  5722. * @returns a new Color3 object
  5723. */
  5724. static Magenta(): Color3;
  5725. /**
  5726. * Returns a Color3 value containing a yellow color
  5727. * @returns a new Color3 object
  5728. */
  5729. static Yellow(): Color3;
  5730. /**
  5731. * Returns a Color3 value containing a gray color
  5732. * @returns a new Color3 object
  5733. */
  5734. static Gray(): Color3;
  5735. /**
  5736. * Returns a Color3 value containing a teal color
  5737. * @returns a new Color3 object
  5738. */
  5739. static Teal(): Color3;
  5740. /**
  5741. * Returns a Color3 value containing a random color
  5742. * @returns a new Color3 object
  5743. */
  5744. static Random(): Color3;
  5745. }
  5746. /**
  5747. * Class used to hold a RBGA color
  5748. */
  5749. export class Color4 {
  5750. /**
  5751. * Defines the red component (between 0 and 1, default is 0)
  5752. */
  5753. r: number;
  5754. /**
  5755. * Defines the green component (between 0 and 1, default is 0)
  5756. */
  5757. g: number;
  5758. /**
  5759. * Defines the blue component (between 0 and 1, default is 0)
  5760. */
  5761. b: number;
  5762. /**
  5763. * Defines the alpha component (between 0 and 1, default is 1)
  5764. */
  5765. a: number;
  5766. /**
  5767. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5768. * @param r defines the red component (between 0 and 1, default is 0)
  5769. * @param g defines the green component (between 0 and 1, default is 0)
  5770. * @param b defines the blue component (between 0 and 1, default is 0)
  5771. * @param a defines the alpha component (between 0 and 1, default is 1)
  5772. */
  5773. constructor(
  5774. /**
  5775. * Defines the red component (between 0 and 1, default is 0)
  5776. */
  5777. r?: number,
  5778. /**
  5779. * Defines the green component (between 0 and 1, default is 0)
  5780. */
  5781. g?: number,
  5782. /**
  5783. * Defines the blue component (between 0 and 1, default is 0)
  5784. */
  5785. b?: number,
  5786. /**
  5787. * Defines the alpha component (between 0 and 1, default is 1)
  5788. */
  5789. a?: number);
  5790. /**
  5791. * Adds in place the given Color4 values to the current Color4 object
  5792. * @param right defines the second operand
  5793. * @returns the current updated Color4 object
  5794. */
  5795. addInPlace(right: DeepImmutable<Color4>): Color4;
  5796. /**
  5797. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5798. * @returns the new array
  5799. */
  5800. asArray(): number[];
  5801. /**
  5802. * Stores from the starting index in the given array the Color4 successive values
  5803. * @param array defines the array where to store the r,g,b components
  5804. * @param index defines an optional index in the target array to define where to start storing values
  5805. * @returns the current Color4 object
  5806. */
  5807. toArray(array: number[], index?: number): Color4;
  5808. /**
  5809. * Determines equality between Color4 objects
  5810. * @param otherColor defines the second operand
  5811. * @returns true if the rgba values are equal to the given ones
  5812. */
  5813. equals(otherColor: DeepImmutable<Color4>): boolean;
  5814. /**
  5815. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5816. * @param right defines the second operand
  5817. * @returns a new Color4 object
  5818. */
  5819. add(right: DeepImmutable<Color4>): Color4;
  5820. /**
  5821. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5822. * @param right defines the second operand
  5823. * @returns a new Color4 object
  5824. */
  5825. subtract(right: DeepImmutable<Color4>): Color4;
  5826. /**
  5827. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5828. * @param right defines the second operand
  5829. * @param result defines the Color4 object where to store the result
  5830. * @returns the current Color4 object
  5831. */
  5832. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5833. /**
  5834. * Creates a new Color4 with the current Color4 values multiplied by scale
  5835. * @param scale defines the scaling factor to apply
  5836. * @returns a new Color4 object
  5837. */
  5838. scale(scale: number): Color4;
  5839. /**
  5840. * Multiplies the current Color4 values by scale and stores the result in "result"
  5841. * @param scale defines the scaling factor to apply
  5842. * @param result defines the Color4 object where to store the result
  5843. * @returns the current unmodified Color4
  5844. */
  5845. scaleToRef(scale: number, result: Color4): Color4;
  5846. /**
  5847. * Scale the current Color4 values by a factor and add the result to a given Color4
  5848. * @param scale defines the scale factor
  5849. * @param result defines the Color4 object where to store the result
  5850. * @returns the unmodified current Color4
  5851. */
  5852. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5853. /**
  5854. * Clamps the rgb values by the min and max values and stores the result into "result"
  5855. * @param min defines minimum clamping value (default is 0)
  5856. * @param max defines maximum clamping value (default is 1)
  5857. * @param result defines color to store the result into.
  5858. * @returns the cuurent Color4
  5859. */
  5860. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5861. /**
  5862. * Multipy an Color4 value by another and return a new Color4 object
  5863. * @param color defines the Color4 value to multiply by
  5864. * @returns a new Color4 object
  5865. */
  5866. multiply(color: Color4): Color4;
  5867. /**
  5868. * Multipy a Color4 value by another and push the result in a reference value
  5869. * @param color defines the Color4 value to multiply by
  5870. * @param result defines the Color4 to fill the result in
  5871. * @returns the result Color4
  5872. */
  5873. multiplyToRef(color: Color4, result: Color4): Color4;
  5874. /**
  5875. * Creates a string with the Color4 current values
  5876. * @returns the string representation of the Color4 object
  5877. */
  5878. toString(): string;
  5879. /**
  5880. * Returns the string "Color4"
  5881. * @returns "Color4"
  5882. */
  5883. getClassName(): string;
  5884. /**
  5885. * Compute the Color4 hash code
  5886. * @returns an unique number that can be used to hash Color4 objects
  5887. */
  5888. getHashCode(): number;
  5889. /**
  5890. * Creates a new Color4 copied from the current one
  5891. * @returns a new Color4 object
  5892. */
  5893. clone(): Color4;
  5894. /**
  5895. * Copies the given Color4 values into the current one
  5896. * @param source defines the source Color4 object
  5897. * @returns the current updated Color4 object
  5898. */
  5899. copyFrom(source: Color4): Color4;
  5900. /**
  5901. * Copies the given float values into the current one
  5902. * @param r defines the red component to read from
  5903. * @param g defines the green component to read from
  5904. * @param b defines the blue component to read from
  5905. * @param a defines the alpha component to read from
  5906. * @returns the current updated Color4 object
  5907. */
  5908. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5909. /**
  5910. * Copies the given float values into the current one
  5911. * @param r defines the red component to read from
  5912. * @param g defines the green component to read from
  5913. * @param b defines the blue component to read from
  5914. * @param a defines the alpha component to read from
  5915. * @returns the current updated Color4 object
  5916. */
  5917. set(r: number, g: number, b: number, a: number): Color4;
  5918. /**
  5919. * Compute the Color4 hexadecimal code as a string
  5920. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5921. * @returns a string containing the hexadecimal representation of the Color4 object
  5922. */
  5923. toHexString(returnAsColor3?: boolean): string;
  5924. /**
  5925. * Computes a new Color4 converted from the current one to linear space
  5926. * @returns a new Color4 object
  5927. */
  5928. toLinearSpace(): Color4;
  5929. /**
  5930. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5931. * @param convertedColor defines the Color4 object where to store the linear space version
  5932. * @returns the unmodified Color4
  5933. */
  5934. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5935. /**
  5936. * Computes a new Color4 converted from the current one to gamma space
  5937. * @returns a new Color4 object
  5938. */
  5939. toGammaSpace(): Color4;
  5940. /**
  5941. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5942. * @param convertedColor defines the Color4 object where to store the gamma space version
  5943. * @returns the unmodified Color4
  5944. */
  5945. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5946. /**
  5947. * Creates a new Color4 from the string containing valid hexadecimal values
  5948. * @param hex defines a string containing valid hexadecimal values
  5949. * @returns a new Color4 object
  5950. */
  5951. static FromHexString(hex: string): Color4;
  5952. /**
  5953. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5954. * @param left defines the start value
  5955. * @param right defines the end value
  5956. * @param amount defines the gradient factor
  5957. * @returns a new Color4 object
  5958. */
  5959. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5960. /**
  5961. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5962. * @param left defines the start value
  5963. * @param right defines the end value
  5964. * @param amount defines the gradient factor
  5965. * @param result defines the Color4 object where to store data
  5966. */
  5967. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5968. /**
  5969. * Creates a new Color4 from a Color3 and an alpha value
  5970. * @param color3 defines the source Color3 to read from
  5971. * @param alpha defines the alpha component (1.0 by default)
  5972. * @returns a new Color4 object
  5973. */
  5974. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5975. /**
  5976. * Creates a new Color4 from the starting index element of the given array
  5977. * @param array defines the source array to read from
  5978. * @param offset defines the offset in the source array
  5979. * @returns a new Color4 object
  5980. */
  5981. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5982. /**
  5983. * Creates a new Color3 from integer values (< 256)
  5984. * @param r defines the red component to read from (value between 0 and 255)
  5985. * @param g defines the green component to read from (value between 0 and 255)
  5986. * @param b defines the blue component to read from (value between 0 and 255)
  5987. * @param a defines the alpha component to read from (value between 0 and 255)
  5988. * @returns a new Color3 object
  5989. */
  5990. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5991. /**
  5992. * Check the content of a given array and convert it to an array containing RGBA data
  5993. * If the original array was already containing count * 4 values then it is returned directly
  5994. * @param colors defines the array to check
  5995. * @param count defines the number of RGBA data to expect
  5996. * @returns an array containing count * 4 values (RGBA)
  5997. */
  5998. static CheckColors4(colors: number[], count: number): number[];
  5999. }
  6000. /**
  6001. * @hidden
  6002. */
  6003. export class TmpColors {
  6004. static Color3: Color3[];
  6005. static Color4: Color4[];
  6006. }
  6007. }
  6008. declare module BABYLON {
  6009. /**
  6010. * Defines an interface which represents an animation key frame
  6011. */
  6012. export interface IAnimationKey {
  6013. /**
  6014. * Frame of the key frame
  6015. */
  6016. frame: number;
  6017. /**
  6018. * Value at the specifies key frame
  6019. */
  6020. value: any;
  6021. /**
  6022. * The input tangent for the cubic hermite spline
  6023. */
  6024. inTangent?: any;
  6025. /**
  6026. * The output tangent for the cubic hermite spline
  6027. */
  6028. outTangent?: any;
  6029. /**
  6030. * The animation interpolation type
  6031. */
  6032. interpolation?: AnimationKeyInterpolation;
  6033. }
  6034. /**
  6035. * Enum for the animation key frame interpolation type
  6036. */
  6037. export enum AnimationKeyInterpolation {
  6038. /**
  6039. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6040. */
  6041. STEP = 1
  6042. }
  6043. }
  6044. declare module BABYLON {
  6045. /**
  6046. * Represents the range of an animation
  6047. */
  6048. export class AnimationRange {
  6049. /**The name of the animation range**/
  6050. name: string;
  6051. /**The starting frame of the animation */
  6052. from: number;
  6053. /**The ending frame of the animation*/
  6054. to: number;
  6055. /**
  6056. * Initializes the range of an animation
  6057. * @param name The name of the animation range
  6058. * @param from The starting frame of the animation
  6059. * @param to The ending frame of the animation
  6060. */
  6061. constructor(
  6062. /**The name of the animation range**/
  6063. name: string,
  6064. /**The starting frame of the animation */
  6065. from: number,
  6066. /**The ending frame of the animation*/
  6067. to: number);
  6068. /**
  6069. * Makes a copy of the animation range
  6070. * @returns A copy of the animation range
  6071. */
  6072. clone(): AnimationRange;
  6073. }
  6074. }
  6075. declare module BABYLON {
  6076. /**
  6077. * Composed of a frame, and an action function
  6078. */
  6079. export class AnimationEvent {
  6080. /** The frame for which the event is triggered **/
  6081. frame: number;
  6082. /** The event to perform when triggered **/
  6083. action: (currentFrame: number) => void;
  6084. /** Specifies if the event should be triggered only once**/
  6085. onlyOnce?: boolean | undefined;
  6086. /**
  6087. * Specifies if the animation event is done
  6088. */
  6089. isDone: boolean;
  6090. /**
  6091. * Initializes the animation event
  6092. * @param frame The frame for which the event is triggered
  6093. * @param action The event to perform when triggered
  6094. * @param onlyOnce Specifies if the event should be triggered only once
  6095. */
  6096. constructor(
  6097. /** The frame for which the event is triggered **/
  6098. frame: number,
  6099. /** The event to perform when triggered **/
  6100. action: (currentFrame: number) => void,
  6101. /** Specifies if the event should be triggered only once**/
  6102. onlyOnce?: boolean | undefined);
  6103. /** @hidden */
  6104. _clone(): AnimationEvent;
  6105. }
  6106. }
  6107. declare module BABYLON {
  6108. /**
  6109. * Interface used to define a behavior
  6110. */
  6111. export interface Behavior<T> {
  6112. /** gets or sets behavior's name */
  6113. name: string;
  6114. /**
  6115. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6116. */
  6117. init(): void;
  6118. /**
  6119. * Called when the behavior is attached to a target
  6120. * @param target defines the target where the behavior is attached to
  6121. */
  6122. attach(target: T): void;
  6123. /**
  6124. * Called when the behavior is detached from its target
  6125. */
  6126. detach(): void;
  6127. }
  6128. /**
  6129. * Interface implemented by classes supporting behaviors
  6130. */
  6131. export interface IBehaviorAware<T> {
  6132. /**
  6133. * Attach a behavior
  6134. * @param behavior defines the behavior to attach
  6135. * @returns the current host
  6136. */
  6137. addBehavior(behavior: Behavior<T>): T;
  6138. /**
  6139. * Remove a behavior from the current object
  6140. * @param behavior defines the behavior to detach
  6141. * @returns the current host
  6142. */
  6143. removeBehavior(behavior: Behavior<T>): T;
  6144. /**
  6145. * Gets a behavior using its name to search
  6146. * @param name defines the name to search
  6147. * @returns the behavior or null if not found
  6148. */
  6149. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6150. }
  6151. }
  6152. declare module BABYLON {
  6153. /**
  6154. * Defines an array and its length.
  6155. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6156. */
  6157. export interface ISmartArrayLike<T> {
  6158. /**
  6159. * The data of the array.
  6160. */
  6161. data: Array<T>;
  6162. /**
  6163. * The active length of the array.
  6164. */
  6165. length: number;
  6166. }
  6167. /**
  6168. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6169. */
  6170. export class SmartArray<T> implements ISmartArrayLike<T> {
  6171. /**
  6172. * The full set of data from the array.
  6173. */
  6174. data: Array<T>;
  6175. /**
  6176. * The active length of the array.
  6177. */
  6178. length: number;
  6179. protected _id: number;
  6180. /**
  6181. * Instantiates a Smart Array.
  6182. * @param capacity defines the default capacity of the array.
  6183. */
  6184. constructor(capacity: number);
  6185. /**
  6186. * Pushes a value at the end of the active data.
  6187. * @param value defines the object to push in the array.
  6188. */
  6189. push(value: T): void;
  6190. /**
  6191. * Iterates over the active data and apply the lambda to them.
  6192. * @param func defines the action to apply on each value.
  6193. */
  6194. forEach(func: (content: T) => void): void;
  6195. /**
  6196. * Sorts the full sets of data.
  6197. * @param compareFn defines the comparison function to apply.
  6198. */
  6199. sort(compareFn: (a: T, b: T) => number): void;
  6200. /**
  6201. * Resets the active data to an empty array.
  6202. */
  6203. reset(): void;
  6204. /**
  6205. * Releases all the data from the array as well as the array.
  6206. */
  6207. dispose(): void;
  6208. /**
  6209. * Concats the active data with a given array.
  6210. * @param array defines the data to concatenate with.
  6211. */
  6212. concat(array: any): void;
  6213. /**
  6214. * Returns the position of a value in the active data.
  6215. * @param value defines the value to find the index for
  6216. * @returns the index if found in the active data otherwise -1
  6217. */
  6218. indexOf(value: T): number;
  6219. /**
  6220. * Returns whether an element is part of the active data.
  6221. * @param value defines the value to look for
  6222. * @returns true if found in the active data otherwise false
  6223. */
  6224. contains(value: T): boolean;
  6225. private static _GlobalId;
  6226. }
  6227. /**
  6228. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6229. * The data in this array can only be present once
  6230. */
  6231. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6232. private _duplicateId;
  6233. /**
  6234. * Pushes a value at the end of the active data.
  6235. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6236. * @param value defines the object to push in the array.
  6237. */
  6238. push(value: T): void;
  6239. /**
  6240. * Pushes a value at the end of the active data.
  6241. * If the data is already present, it won t be added again
  6242. * @param value defines the object to push in the array.
  6243. * @returns true if added false if it was already present
  6244. */
  6245. pushNoDuplicate(value: T): boolean;
  6246. /**
  6247. * Resets the active data to an empty array.
  6248. */
  6249. reset(): void;
  6250. /**
  6251. * Concats the active data with a given array.
  6252. * This ensures no dupplicate will be present in the result.
  6253. * @param array defines the data to concatenate with.
  6254. */
  6255. concatWithNoDuplicate(array: any): void;
  6256. }
  6257. }
  6258. declare module BABYLON {
  6259. /**
  6260. * @ignore
  6261. * This is a list of all the different input types that are available in the application.
  6262. * Fo instance: ArcRotateCameraGamepadInput...
  6263. */
  6264. export var CameraInputTypes: {};
  6265. /**
  6266. * This is the contract to implement in order to create a new input class.
  6267. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6268. */
  6269. export interface ICameraInput<TCamera extends Camera> {
  6270. /**
  6271. * Defines the camera the input is attached to.
  6272. */
  6273. camera: Nullable<TCamera>;
  6274. /**
  6275. * Gets the class name of the current intput.
  6276. * @returns the class name
  6277. */
  6278. getClassName(): string;
  6279. /**
  6280. * Get the friendly name associated with the input class.
  6281. * @returns the input friendly name
  6282. */
  6283. getSimpleName(): string;
  6284. /**
  6285. * Attach the input controls to a specific dom element to get the input from.
  6286. * @param element Defines the element the controls should be listened from
  6287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6288. */
  6289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6290. /**
  6291. * Detach the current controls from the specified dom element.
  6292. * @param element Defines the element to stop listening the inputs from
  6293. */
  6294. detachControl(element: Nullable<HTMLElement>): void;
  6295. /**
  6296. * Update the current camera state depending on the inputs that have been used this frame.
  6297. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6298. */
  6299. checkInputs?: () => void;
  6300. }
  6301. /**
  6302. * Represents a map of input types to input instance or input index to input instance.
  6303. */
  6304. export interface CameraInputsMap<TCamera extends Camera> {
  6305. /**
  6306. * Accessor to the input by input type.
  6307. */
  6308. [name: string]: ICameraInput<TCamera>;
  6309. /**
  6310. * Accessor to the input by input index.
  6311. */
  6312. [idx: number]: ICameraInput<TCamera>;
  6313. }
  6314. /**
  6315. * This represents the input manager used within a camera.
  6316. * It helps dealing with all the different kind of input attached to a camera.
  6317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6318. */
  6319. export class CameraInputsManager<TCamera extends Camera> {
  6320. /**
  6321. * Defines the list of inputs attahed to the camera.
  6322. */
  6323. attached: CameraInputsMap<TCamera>;
  6324. /**
  6325. * Defines the dom element the camera is collecting inputs from.
  6326. * This is null if the controls have not been attached.
  6327. */
  6328. attachedElement: Nullable<HTMLElement>;
  6329. /**
  6330. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6331. */
  6332. noPreventDefault: boolean;
  6333. /**
  6334. * Defined the camera the input manager belongs to.
  6335. */
  6336. camera: TCamera;
  6337. /**
  6338. * Update the current camera state depending on the inputs that have been used this frame.
  6339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6340. */
  6341. checkInputs: () => void;
  6342. /**
  6343. * Instantiate a new Camera Input Manager.
  6344. * @param camera Defines the camera the input manager blongs to
  6345. */
  6346. constructor(camera: TCamera);
  6347. /**
  6348. * Add an input method to a camera
  6349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6350. * @param input camera input method
  6351. */
  6352. add(input: ICameraInput<TCamera>): void;
  6353. /**
  6354. * Remove a specific input method from a camera
  6355. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6356. * @param inputToRemove camera input method
  6357. */
  6358. remove(inputToRemove: ICameraInput<TCamera>): void;
  6359. /**
  6360. * Remove a specific input type from a camera
  6361. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6362. * @param inputType the type of the input to remove
  6363. */
  6364. removeByType(inputType: string): void;
  6365. private _addCheckInputs;
  6366. /**
  6367. * Attach the input controls to the currently attached dom element to listen the events from.
  6368. * @param input Defines the input to attach
  6369. */
  6370. attachInput(input: ICameraInput<TCamera>): void;
  6371. /**
  6372. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6373. * @param element Defines the dom element to collect the events from
  6374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6375. */
  6376. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6377. /**
  6378. * Detach the current manager inputs controls from a specific dom element.
  6379. * @param element Defines the dom element to collect the events from
  6380. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6381. */
  6382. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6383. /**
  6384. * Rebuild the dynamic inputCheck function from the current list of
  6385. * defined inputs in the manager.
  6386. */
  6387. rebuildInputCheck(): void;
  6388. /**
  6389. * Remove all attached input methods from a camera
  6390. */
  6391. clear(): void;
  6392. /**
  6393. * Serialize the current input manager attached to a camera.
  6394. * This ensures than once parsed,
  6395. * the input associated to the camera will be identical to the current ones
  6396. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6397. */
  6398. serialize(serializedCamera: any): void;
  6399. /**
  6400. * Parses an input manager serialized JSON to restore the previous list of inputs
  6401. * and states associated to a camera.
  6402. * @param parsedCamera Defines the JSON to parse
  6403. */
  6404. parse(parsedCamera: any): void;
  6405. }
  6406. }
  6407. declare module BABYLON {
  6408. /**
  6409. * Class used to store data that will be store in GPU memory
  6410. */
  6411. export class Buffer {
  6412. private _engine;
  6413. private _buffer;
  6414. /** @hidden */
  6415. _data: Nullable<DataArray>;
  6416. private _updatable;
  6417. private _instanced;
  6418. private _divisor;
  6419. /**
  6420. * Gets the byte stride.
  6421. */
  6422. readonly byteStride: number;
  6423. /**
  6424. * Constructor
  6425. * @param engine the engine
  6426. * @param data the data to use for this buffer
  6427. * @param updatable whether the data is updatable
  6428. * @param stride the stride (optional)
  6429. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6430. * @param instanced whether the buffer is instanced (optional)
  6431. * @param useBytes set to true if the stride in in bytes (optional)
  6432. * @param divisor sets an optional divisor for instances (1 by default)
  6433. */
  6434. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6435. /**
  6436. * Create a new VertexBuffer based on the current buffer
  6437. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6438. * @param offset defines offset in the buffer (0 by default)
  6439. * @param size defines the size in floats of attributes (position is 3 for instance)
  6440. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6441. * @param instanced defines if the vertex buffer contains indexed data
  6442. * @param useBytes defines if the offset and stride are in bytes *
  6443. * @param divisor sets an optional divisor for instances (1 by default)
  6444. * @returns the new vertex buffer
  6445. */
  6446. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6447. /**
  6448. * Gets a boolean indicating if the Buffer is updatable?
  6449. * @returns true if the buffer is updatable
  6450. */
  6451. isUpdatable(): boolean;
  6452. /**
  6453. * Gets current buffer's data
  6454. * @returns a DataArray or null
  6455. */
  6456. getData(): Nullable<DataArray>;
  6457. /**
  6458. * Gets underlying native buffer
  6459. * @returns underlying native buffer
  6460. */
  6461. getBuffer(): Nullable<DataBuffer>;
  6462. /**
  6463. * Gets the stride in float32 units (i.e. byte stride / 4).
  6464. * May not be an integer if the byte stride is not divisible by 4.
  6465. * @returns the stride in float32 units
  6466. * @deprecated Please use byteStride instead.
  6467. */
  6468. getStrideSize(): number;
  6469. /**
  6470. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6471. * @param data defines the data to store
  6472. */
  6473. create(data?: Nullable<DataArray>): void;
  6474. /** @hidden */
  6475. _rebuild(): void;
  6476. /**
  6477. * Update current buffer data
  6478. * @param data defines the data to store
  6479. */
  6480. update(data: DataArray): void;
  6481. /**
  6482. * Updates the data directly.
  6483. * @param data the new data
  6484. * @param offset the new offset
  6485. * @param vertexCount the vertex count (optional)
  6486. * @param useBytes set to true if the offset is in bytes
  6487. */
  6488. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6489. /**
  6490. * Release all resources
  6491. */
  6492. dispose(): void;
  6493. }
  6494. /**
  6495. * Specialized buffer used to store vertex data
  6496. */
  6497. export class VertexBuffer {
  6498. /** @hidden */
  6499. _buffer: Buffer;
  6500. private _kind;
  6501. private _size;
  6502. private _ownsBuffer;
  6503. private _instanced;
  6504. private _instanceDivisor;
  6505. /**
  6506. * The byte type.
  6507. */
  6508. static readonly BYTE: number;
  6509. /**
  6510. * The unsigned byte type.
  6511. */
  6512. static readonly UNSIGNED_BYTE: number;
  6513. /**
  6514. * The short type.
  6515. */
  6516. static readonly SHORT: number;
  6517. /**
  6518. * The unsigned short type.
  6519. */
  6520. static readonly UNSIGNED_SHORT: number;
  6521. /**
  6522. * The integer type.
  6523. */
  6524. static readonly INT: number;
  6525. /**
  6526. * The unsigned integer type.
  6527. */
  6528. static readonly UNSIGNED_INT: number;
  6529. /**
  6530. * The float type.
  6531. */
  6532. static readonly FLOAT: number;
  6533. /**
  6534. * Gets or sets the instance divisor when in instanced mode
  6535. */
  6536. get instanceDivisor(): number;
  6537. set instanceDivisor(value: number);
  6538. /**
  6539. * Gets the byte stride.
  6540. */
  6541. readonly byteStride: number;
  6542. /**
  6543. * Gets the byte offset.
  6544. */
  6545. readonly byteOffset: number;
  6546. /**
  6547. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6548. */
  6549. readonly normalized: boolean;
  6550. /**
  6551. * Gets the data type of each component in the array.
  6552. */
  6553. readonly type: number;
  6554. /**
  6555. * Constructor
  6556. * @param engine the engine
  6557. * @param data the data to use for this vertex buffer
  6558. * @param kind the vertex buffer kind
  6559. * @param updatable whether the data is updatable
  6560. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6561. * @param stride the stride (optional)
  6562. * @param instanced whether the buffer is instanced (optional)
  6563. * @param offset the offset of the data (optional)
  6564. * @param size the number of components (optional)
  6565. * @param type the type of the component (optional)
  6566. * @param normalized whether the data contains normalized data (optional)
  6567. * @param useBytes set to true if stride and offset are in bytes (optional)
  6568. * @param divisor defines the instance divisor to use (1 by default)
  6569. */
  6570. 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);
  6571. /** @hidden */
  6572. _rebuild(): void;
  6573. /**
  6574. * Returns the kind of the VertexBuffer (string)
  6575. * @returns a string
  6576. */
  6577. getKind(): string;
  6578. /**
  6579. * Gets a boolean indicating if the VertexBuffer is updatable?
  6580. * @returns true if the buffer is updatable
  6581. */
  6582. isUpdatable(): boolean;
  6583. /**
  6584. * Gets current buffer's data
  6585. * @returns a DataArray or null
  6586. */
  6587. getData(): Nullable<DataArray>;
  6588. /**
  6589. * Gets underlying native buffer
  6590. * @returns underlying native buffer
  6591. */
  6592. getBuffer(): Nullable<DataBuffer>;
  6593. /**
  6594. * Gets the stride in float32 units (i.e. byte stride / 4).
  6595. * May not be an integer if the byte stride is not divisible by 4.
  6596. * @returns the stride in float32 units
  6597. * @deprecated Please use byteStride instead.
  6598. */
  6599. getStrideSize(): number;
  6600. /**
  6601. * Returns the offset as a multiple of the type byte length.
  6602. * @returns the offset in bytes
  6603. * @deprecated Please use byteOffset instead.
  6604. */
  6605. getOffset(): number;
  6606. /**
  6607. * Returns the number of components per vertex attribute (integer)
  6608. * @returns the size in float
  6609. */
  6610. getSize(): number;
  6611. /**
  6612. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6613. * @returns true if this buffer is instanced
  6614. */
  6615. getIsInstanced(): boolean;
  6616. /**
  6617. * Returns the instancing divisor, zero for non-instanced (integer).
  6618. * @returns a number
  6619. */
  6620. getInstanceDivisor(): number;
  6621. /**
  6622. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6623. * @param data defines the data to store
  6624. */
  6625. create(data?: DataArray): void;
  6626. /**
  6627. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6628. * This function will create a new buffer if the current one is not updatable
  6629. * @param data defines the data to store
  6630. */
  6631. update(data: DataArray): void;
  6632. /**
  6633. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6634. * Returns the directly updated WebGLBuffer.
  6635. * @param data the new data
  6636. * @param offset the new offset
  6637. * @param useBytes set to true if the offset is in bytes
  6638. */
  6639. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6640. /**
  6641. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6642. */
  6643. dispose(): void;
  6644. /**
  6645. * Enumerates each value of this vertex buffer as numbers.
  6646. * @param count the number of values to enumerate
  6647. * @param callback the callback function called for each value
  6648. */
  6649. forEach(count: number, callback: (value: number, index: number) => void): void;
  6650. /**
  6651. * Positions
  6652. */
  6653. static readonly PositionKind: string;
  6654. /**
  6655. * Normals
  6656. */
  6657. static readonly NormalKind: string;
  6658. /**
  6659. * Tangents
  6660. */
  6661. static readonly TangentKind: string;
  6662. /**
  6663. * Texture coordinates
  6664. */
  6665. static readonly UVKind: string;
  6666. /**
  6667. * Texture coordinates 2
  6668. */
  6669. static readonly UV2Kind: string;
  6670. /**
  6671. * Texture coordinates 3
  6672. */
  6673. static readonly UV3Kind: string;
  6674. /**
  6675. * Texture coordinates 4
  6676. */
  6677. static readonly UV4Kind: string;
  6678. /**
  6679. * Texture coordinates 5
  6680. */
  6681. static readonly UV5Kind: string;
  6682. /**
  6683. * Texture coordinates 6
  6684. */
  6685. static readonly UV6Kind: string;
  6686. /**
  6687. * Colors
  6688. */
  6689. static readonly ColorKind: string;
  6690. /**
  6691. * Matrix indices (for bones)
  6692. */
  6693. static readonly MatricesIndicesKind: string;
  6694. /**
  6695. * Matrix weights (for bones)
  6696. */
  6697. static readonly MatricesWeightsKind: string;
  6698. /**
  6699. * Additional matrix indices (for bones)
  6700. */
  6701. static readonly MatricesIndicesExtraKind: string;
  6702. /**
  6703. * Additional matrix weights (for bones)
  6704. */
  6705. static readonly MatricesWeightsExtraKind: string;
  6706. /**
  6707. * Deduces the stride given a kind.
  6708. * @param kind The kind string to deduce
  6709. * @returns The deduced stride
  6710. */
  6711. static DeduceStride(kind: string): number;
  6712. /**
  6713. * Gets the byte length of the given type.
  6714. * @param type the type
  6715. * @returns the number of bytes
  6716. */
  6717. static GetTypeByteLength(type: number): number;
  6718. /**
  6719. * Enumerates each value of the given parameters as numbers.
  6720. * @param data the data to enumerate
  6721. * @param byteOffset the byte offset of the data
  6722. * @param byteStride the byte stride of the data
  6723. * @param componentCount the number of components per element
  6724. * @param componentType the type of the component
  6725. * @param count the number of values to enumerate
  6726. * @param normalized whether the data is normalized
  6727. * @param callback the callback function called for each value
  6728. */
  6729. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6730. private static _GetFloatValue;
  6731. }
  6732. }
  6733. declare module BABYLON {
  6734. /**
  6735. * @hidden
  6736. */
  6737. export class IntersectionInfo {
  6738. bu: Nullable<number>;
  6739. bv: Nullable<number>;
  6740. distance: number;
  6741. faceId: number;
  6742. subMeshId: number;
  6743. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6744. }
  6745. }
  6746. declare module BABYLON {
  6747. /**
  6748. * Class used to store bounding sphere information
  6749. */
  6750. export class BoundingSphere {
  6751. /**
  6752. * Gets the center of the bounding sphere in local space
  6753. */
  6754. readonly center: Vector3;
  6755. /**
  6756. * Radius of the bounding sphere in local space
  6757. */
  6758. radius: number;
  6759. /**
  6760. * Gets the center of the bounding sphere in world space
  6761. */
  6762. readonly centerWorld: Vector3;
  6763. /**
  6764. * Radius of the bounding sphere in world space
  6765. */
  6766. radiusWorld: number;
  6767. /**
  6768. * Gets the minimum vector in local space
  6769. */
  6770. readonly minimum: Vector3;
  6771. /**
  6772. * Gets the maximum vector in local space
  6773. */
  6774. readonly maximum: Vector3;
  6775. private _worldMatrix;
  6776. private static readonly TmpVector3;
  6777. /**
  6778. * Creates a new bounding sphere
  6779. * @param min defines the minimum vector (in local space)
  6780. * @param max defines the maximum vector (in local space)
  6781. * @param worldMatrix defines the new world matrix
  6782. */
  6783. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6784. /**
  6785. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6786. * @param min defines the new minimum vector (in local space)
  6787. * @param max defines the new maximum vector (in local space)
  6788. * @param worldMatrix defines the new world matrix
  6789. */
  6790. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6791. /**
  6792. * Scale the current bounding sphere by applying a scale factor
  6793. * @param factor defines the scale factor to apply
  6794. * @returns the current bounding box
  6795. */
  6796. scale(factor: number): BoundingSphere;
  6797. /**
  6798. * Gets the world matrix of the bounding box
  6799. * @returns a matrix
  6800. */
  6801. getWorldMatrix(): DeepImmutable<Matrix>;
  6802. /** @hidden */
  6803. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6804. /**
  6805. * Tests if the bounding sphere is intersecting the frustum planes
  6806. * @param frustumPlanes defines the frustum planes to test
  6807. * @returns true if there is an intersection
  6808. */
  6809. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6810. /**
  6811. * Tests if the bounding sphere center is in between the frustum planes.
  6812. * Used for optimistic fast inclusion.
  6813. * @param frustumPlanes defines the frustum planes to test
  6814. * @returns true if the sphere center is in between the frustum planes
  6815. */
  6816. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6817. /**
  6818. * Tests if a point is inside the bounding sphere
  6819. * @param point defines the point to test
  6820. * @returns true if the point is inside the bounding sphere
  6821. */
  6822. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6823. /**
  6824. * Checks if two sphere intersct
  6825. * @param sphere0 sphere 0
  6826. * @param sphere1 sphere 1
  6827. * @returns true if the speres intersect
  6828. */
  6829. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6830. }
  6831. }
  6832. declare module BABYLON {
  6833. /**
  6834. * Class used to store bounding box information
  6835. */
  6836. export class BoundingBox implements ICullable {
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in local space
  6839. */
  6840. readonly vectors: Vector3[];
  6841. /**
  6842. * Gets the center of the bounding box in local space
  6843. */
  6844. readonly center: Vector3;
  6845. /**
  6846. * Gets the center of the bounding box in world space
  6847. */
  6848. readonly centerWorld: Vector3;
  6849. /**
  6850. * Gets the extend size in local space
  6851. */
  6852. readonly extendSize: Vector3;
  6853. /**
  6854. * Gets the extend size in world space
  6855. */
  6856. readonly extendSizeWorld: Vector3;
  6857. /**
  6858. * Gets the OBB (object bounding box) directions
  6859. */
  6860. readonly directions: Vector3[];
  6861. /**
  6862. * Gets the 8 vectors representing the bounding box in world space
  6863. */
  6864. readonly vectorsWorld: Vector3[];
  6865. /**
  6866. * Gets the minimum vector in world space
  6867. */
  6868. readonly minimumWorld: Vector3;
  6869. /**
  6870. * Gets the maximum vector in world space
  6871. */
  6872. readonly maximumWorld: Vector3;
  6873. /**
  6874. * Gets the minimum vector in local space
  6875. */
  6876. readonly minimum: Vector3;
  6877. /**
  6878. * Gets the maximum vector in local space
  6879. */
  6880. readonly maximum: Vector3;
  6881. private _worldMatrix;
  6882. private static readonly TmpVector3;
  6883. /**
  6884. * @hidden
  6885. */
  6886. _tag: number;
  6887. /**
  6888. * Creates a new bounding box
  6889. * @param min defines the minimum vector (in local space)
  6890. * @param max defines the maximum vector (in local space)
  6891. * @param worldMatrix defines the new world matrix
  6892. */
  6893. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6894. /**
  6895. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6896. * @param min defines the new minimum vector (in local space)
  6897. * @param max defines the new maximum vector (in local space)
  6898. * @param worldMatrix defines the new world matrix
  6899. */
  6900. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6901. /**
  6902. * Scale the current bounding box by applying a scale factor
  6903. * @param factor defines the scale factor to apply
  6904. * @returns the current bounding box
  6905. */
  6906. scale(factor: number): BoundingBox;
  6907. /**
  6908. * Gets the world matrix of the bounding box
  6909. * @returns a matrix
  6910. */
  6911. getWorldMatrix(): DeepImmutable<Matrix>;
  6912. /** @hidden */
  6913. _update(world: DeepImmutable<Matrix>): void;
  6914. /**
  6915. * Tests if the bounding box is intersecting the frustum planes
  6916. * @param frustumPlanes defines the frustum planes to test
  6917. * @returns true if there is an intersection
  6918. */
  6919. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6920. /**
  6921. * Tests if the bounding box is entirely inside the frustum planes
  6922. * @param frustumPlanes defines the frustum planes to test
  6923. * @returns true if there is an inclusion
  6924. */
  6925. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6926. /**
  6927. * Tests if a point is inside the bounding box
  6928. * @param point defines the point to test
  6929. * @returns true if the point is inside the bounding box
  6930. */
  6931. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6932. /**
  6933. * Tests if the bounding box intersects with a bounding sphere
  6934. * @param sphere defines the sphere to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6938. /**
  6939. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6940. * @param min defines the min vector to use
  6941. * @param max defines the max vector to use
  6942. * @returns true if there is an intersection
  6943. */
  6944. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6945. /**
  6946. * Tests if two bounding boxes are intersections
  6947. * @param box0 defines the first box to test
  6948. * @param box1 defines the second box to test
  6949. * @returns true if there is an intersection
  6950. */
  6951. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6952. /**
  6953. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6954. * @param minPoint defines the minimum vector of the bounding box
  6955. * @param maxPoint defines the maximum vector of the bounding box
  6956. * @param sphereCenter defines the sphere center
  6957. * @param sphereRadius defines the sphere radius
  6958. * @returns true if there is an intersection
  6959. */
  6960. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6961. /**
  6962. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6963. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6964. * @param frustumPlanes defines the frustum planes to test
  6965. * @return true if there is an inclusion
  6966. */
  6967. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6968. /**
  6969. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6970. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6971. * @param frustumPlanes defines the frustum planes to test
  6972. * @return true if there is an intersection
  6973. */
  6974. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6975. }
  6976. }
  6977. declare module BABYLON {
  6978. /** @hidden */
  6979. export class Collider {
  6980. /** Define if a collision was found */
  6981. collisionFound: boolean;
  6982. /**
  6983. * Define last intersection point in local space
  6984. */
  6985. intersectionPoint: Vector3;
  6986. /**
  6987. * Define last collided mesh
  6988. */
  6989. collidedMesh: Nullable<AbstractMesh>;
  6990. private _collisionPoint;
  6991. private _planeIntersectionPoint;
  6992. private _tempVector;
  6993. private _tempVector2;
  6994. private _tempVector3;
  6995. private _tempVector4;
  6996. private _edge;
  6997. private _baseToVertex;
  6998. private _destinationPoint;
  6999. private _slidePlaneNormal;
  7000. private _displacementVector;
  7001. /** @hidden */
  7002. _radius: Vector3;
  7003. /** @hidden */
  7004. _retry: number;
  7005. private _velocity;
  7006. private _basePoint;
  7007. private _epsilon;
  7008. /** @hidden */
  7009. _velocityWorldLength: number;
  7010. /** @hidden */
  7011. _basePointWorld: Vector3;
  7012. private _velocityWorld;
  7013. private _normalizedVelocity;
  7014. /** @hidden */
  7015. _initialVelocity: Vector3;
  7016. /** @hidden */
  7017. _initialPosition: Vector3;
  7018. private _nearestDistance;
  7019. private _collisionMask;
  7020. get collisionMask(): number;
  7021. set collisionMask(mask: number);
  7022. /**
  7023. * Gets the plane normal used to compute the sliding response (in local space)
  7024. */
  7025. get slidePlaneNormal(): Vector3;
  7026. /** @hidden */
  7027. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7028. /** @hidden */
  7029. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7030. /** @hidden */
  7031. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7032. /** @hidden */
  7033. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7034. /** @hidden */
  7035. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7036. /** @hidden */
  7037. _getResponse(pos: Vector3, vel: Vector3): void;
  7038. }
  7039. }
  7040. declare module BABYLON {
  7041. /**
  7042. * Interface for cullable objects
  7043. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7044. */
  7045. export interface ICullable {
  7046. /**
  7047. * Checks if the object or part of the object is in the frustum
  7048. * @param frustumPlanes Camera near/planes
  7049. * @returns true if the object is in frustum otherwise false
  7050. */
  7051. isInFrustum(frustumPlanes: Plane[]): boolean;
  7052. /**
  7053. * Checks if a cullable object (mesh...) is in the camera frustum
  7054. * Unlike isInFrustum this cheks the full bounding box
  7055. * @param frustumPlanes Camera near/planes
  7056. * @returns true if the object is in frustum otherwise false
  7057. */
  7058. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7059. }
  7060. /**
  7061. * Info for a bounding data of a mesh
  7062. */
  7063. export class BoundingInfo implements ICullable {
  7064. /**
  7065. * Bounding box for the mesh
  7066. */
  7067. readonly boundingBox: BoundingBox;
  7068. /**
  7069. * Bounding sphere for the mesh
  7070. */
  7071. readonly boundingSphere: BoundingSphere;
  7072. private _isLocked;
  7073. private static readonly TmpVector3;
  7074. /**
  7075. * Constructs bounding info
  7076. * @param minimum min vector of the bounding box/sphere
  7077. * @param maximum max vector of the bounding box/sphere
  7078. * @param worldMatrix defines the new world matrix
  7079. */
  7080. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7081. /**
  7082. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7083. * @param min defines the new minimum vector (in local space)
  7084. * @param max defines the new maximum vector (in local space)
  7085. * @param worldMatrix defines the new world matrix
  7086. */
  7087. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7088. /**
  7089. * min vector of the bounding box/sphere
  7090. */
  7091. get minimum(): Vector3;
  7092. /**
  7093. * max vector of the bounding box/sphere
  7094. */
  7095. get maximum(): Vector3;
  7096. /**
  7097. * If the info is locked and won't be updated to avoid perf overhead
  7098. */
  7099. get isLocked(): boolean;
  7100. set isLocked(value: boolean);
  7101. /**
  7102. * Updates the bounding sphere and box
  7103. * @param world world matrix to be used to update
  7104. */
  7105. update(world: DeepImmutable<Matrix>): void;
  7106. /**
  7107. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7108. * @param center New center of the bounding info
  7109. * @param extend New extend of the bounding info
  7110. * @returns the current bounding info
  7111. */
  7112. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7113. /**
  7114. * Scale the current bounding info by applying a scale factor
  7115. * @param factor defines the scale factor to apply
  7116. * @returns the current bounding info
  7117. */
  7118. scale(factor: number): BoundingInfo;
  7119. /**
  7120. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7121. * @param frustumPlanes defines the frustum to test
  7122. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7123. * @returns true if the bounding info is in the frustum planes
  7124. */
  7125. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7126. /**
  7127. * Gets the world distance between the min and max points of the bounding box
  7128. */
  7129. get diagonalLength(): number;
  7130. /**
  7131. * Checks if a cullable object (mesh...) is in the camera frustum
  7132. * Unlike isInFrustum this cheks the full bounding box
  7133. * @param frustumPlanes Camera near/planes
  7134. * @returns true if the object is in frustum otherwise false
  7135. */
  7136. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7137. /** @hidden */
  7138. _checkCollision(collider: Collider): boolean;
  7139. /**
  7140. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7141. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7142. * @param point the point to check intersection with
  7143. * @returns if the point intersects
  7144. */
  7145. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7146. /**
  7147. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7148. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7149. * @param boundingInfo the bounding info to check intersection with
  7150. * @param precise if the intersection should be done using OBB
  7151. * @returns if the bounding info intersects
  7152. */
  7153. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7154. }
  7155. }
  7156. declare module BABYLON {
  7157. /**
  7158. * Extracts minimum and maximum values from a list of indexed positions
  7159. * @param positions defines the positions to use
  7160. * @param indices defines the indices to the positions
  7161. * @param indexStart defines the start index
  7162. * @param indexCount defines the end index
  7163. * @param bias defines bias value to add to the result
  7164. * @return minimum and maximum values
  7165. */
  7166. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7167. minimum: Vector3;
  7168. maximum: Vector3;
  7169. };
  7170. /**
  7171. * Extracts minimum and maximum values from a list of positions
  7172. * @param positions defines the positions to use
  7173. * @param start defines the start index in the positions array
  7174. * @param count defines the number of positions to handle
  7175. * @param bias defines bias value to add to the result
  7176. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7177. * @return minimum and maximum values
  7178. */
  7179. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7180. minimum: Vector3;
  7181. maximum: Vector3;
  7182. };
  7183. }
  7184. declare module BABYLON {
  7185. /** @hidden */
  7186. export class WebGLDataBuffer extends DataBuffer {
  7187. private _buffer;
  7188. constructor(resource: WebGLBuffer);
  7189. get underlyingResource(): any;
  7190. }
  7191. }
  7192. declare module BABYLON {
  7193. /** @hidden */
  7194. export class WebGLPipelineContext implements IPipelineContext {
  7195. engine: ThinEngine;
  7196. program: Nullable<WebGLProgram>;
  7197. context?: WebGLRenderingContext;
  7198. vertexShader?: WebGLShader;
  7199. fragmentShader?: WebGLShader;
  7200. isParallelCompiled: boolean;
  7201. onCompiled?: () => void;
  7202. transformFeedback?: WebGLTransformFeedback | null;
  7203. vertexCompilationError: Nullable<string>;
  7204. fragmentCompilationError: Nullable<string>;
  7205. programLinkError: Nullable<string>;
  7206. programValidationError: Nullable<string>;
  7207. get isAsync(): boolean;
  7208. get isReady(): boolean;
  7209. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7210. _getVertexShaderCode(): string | null;
  7211. _getFragmentShaderCode(): string | null;
  7212. }
  7213. }
  7214. declare module BABYLON {
  7215. interface ThinEngine {
  7216. /**
  7217. * Create an uniform buffer
  7218. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7219. * @param elements defines the content of the uniform buffer
  7220. * @returns the webGL uniform buffer
  7221. */
  7222. createUniformBuffer(elements: FloatArray): DataBuffer;
  7223. /**
  7224. * Create a dynamic uniform buffer
  7225. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7226. * @param elements defines the content of the uniform buffer
  7227. * @returns the webGL uniform buffer
  7228. */
  7229. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7230. /**
  7231. * Update an existing uniform buffer
  7232. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7233. * @param uniformBuffer defines the target uniform buffer
  7234. * @param elements defines the content to update
  7235. * @param offset defines the offset in the uniform buffer where update should start
  7236. * @param count defines the size of the data to update
  7237. */
  7238. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7239. /**
  7240. * Bind an uniform buffer to the current webGL context
  7241. * @param buffer defines the buffer to bind
  7242. */
  7243. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7244. /**
  7245. * Bind a buffer to the current webGL context at a given location
  7246. * @param buffer defines the buffer to bind
  7247. * @param location defines the index where to bind the buffer
  7248. */
  7249. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7250. /**
  7251. * Bind a specific block at a given index in a specific shader program
  7252. * @param pipelineContext defines the pipeline context to use
  7253. * @param blockName defines the block name
  7254. * @param index defines the index where to bind the block
  7255. */
  7256. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7257. }
  7258. }
  7259. declare module BABYLON {
  7260. /**
  7261. * Uniform buffer objects.
  7262. *
  7263. * Handles blocks of uniform on the GPU.
  7264. *
  7265. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7266. *
  7267. * For more information, please refer to :
  7268. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7269. */
  7270. export class UniformBuffer {
  7271. private _engine;
  7272. private _buffer;
  7273. private _data;
  7274. private _bufferData;
  7275. private _dynamic?;
  7276. private _uniformLocations;
  7277. private _uniformSizes;
  7278. private _uniformLocationPointer;
  7279. private _needSync;
  7280. private _noUBO;
  7281. private _currentEffect;
  7282. /** @hidden */
  7283. _alreadyBound: boolean;
  7284. private static _MAX_UNIFORM_SIZE;
  7285. private static _tempBuffer;
  7286. /**
  7287. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7288. * This is dynamic to allow compat with webgl 1 and 2.
  7289. * You will need to pass the name of the uniform as well as the value.
  7290. */
  7291. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7292. /**
  7293. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7294. * This is dynamic to allow compat with webgl 1 and 2.
  7295. * You will need to pass the name of the uniform as well as the value.
  7296. */
  7297. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7298. /**
  7299. * Lambda to Update a single float in a uniform buffer.
  7300. * This is dynamic to allow compat with webgl 1 and 2.
  7301. * You will need to pass the name of the uniform as well as the value.
  7302. */
  7303. updateFloat: (name: string, x: number) => void;
  7304. /**
  7305. * Lambda to Update a vec2 of float in a uniform buffer.
  7306. * This is dynamic to allow compat with webgl 1 and 2.
  7307. * You will need to pass the name of the uniform as well as the value.
  7308. */
  7309. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7310. /**
  7311. * Lambda to Update a vec3 of float in a uniform buffer.
  7312. * This is dynamic to allow compat with webgl 1 and 2.
  7313. * You will need to pass the name of the uniform as well as the value.
  7314. */
  7315. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7316. /**
  7317. * Lambda to Update a vec4 of float in a uniform buffer.
  7318. * This is dynamic to allow compat with webgl 1 and 2.
  7319. * You will need to pass the name of the uniform as well as the value.
  7320. */
  7321. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7322. /**
  7323. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7324. * This is dynamic to allow compat with webgl 1 and 2.
  7325. * You will need to pass the name of the uniform as well as the value.
  7326. */
  7327. updateMatrix: (name: string, mat: Matrix) => void;
  7328. /**
  7329. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7330. * This is dynamic to allow compat with webgl 1 and 2.
  7331. * You will need to pass the name of the uniform as well as the value.
  7332. */
  7333. updateVector3: (name: string, vector: Vector3) => void;
  7334. /**
  7335. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7336. * This is dynamic to allow compat with webgl 1 and 2.
  7337. * You will need to pass the name of the uniform as well as the value.
  7338. */
  7339. updateVector4: (name: string, vector: Vector4) => void;
  7340. /**
  7341. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7342. * This is dynamic to allow compat with webgl 1 and 2.
  7343. * You will need to pass the name of the uniform as well as the value.
  7344. */
  7345. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7346. /**
  7347. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7348. * This is dynamic to allow compat with webgl 1 and 2.
  7349. * You will need to pass the name of the uniform as well as the value.
  7350. */
  7351. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7352. /**
  7353. * Instantiates a new Uniform buffer objects.
  7354. *
  7355. * Handles blocks of uniform on the GPU.
  7356. *
  7357. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7358. *
  7359. * For more information, please refer to :
  7360. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7361. * @param engine Define the engine the buffer is associated with
  7362. * @param data Define the data contained in the buffer
  7363. * @param dynamic Define if the buffer is updatable
  7364. */
  7365. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7366. /**
  7367. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7368. * or just falling back on setUniformXXX calls.
  7369. */
  7370. get useUbo(): boolean;
  7371. /**
  7372. * Indicates if the WebGL underlying uniform buffer is in sync
  7373. * with the javascript cache data.
  7374. */
  7375. get isSync(): boolean;
  7376. /**
  7377. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7378. * Also, a dynamic UniformBuffer will disable cache verification and always
  7379. * update the underlying WebGL uniform buffer to the GPU.
  7380. * @returns if Dynamic, otherwise false
  7381. */
  7382. isDynamic(): boolean;
  7383. /**
  7384. * The data cache on JS side.
  7385. * @returns the underlying data as a float array
  7386. */
  7387. getData(): Float32Array;
  7388. /**
  7389. * The underlying WebGL Uniform buffer.
  7390. * @returns the webgl buffer
  7391. */
  7392. getBuffer(): Nullable<DataBuffer>;
  7393. /**
  7394. * std140 layout specifies how to align data within an UBO structure.
  7395. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7396. * for specs.
  7397. */
  7398. private _fillAlignment;
  7399. /**
  7400. * Adds an uniform in the buffer.
  7401. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7402. * for the layout to be correct !
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param size Data size, or data directly.
  7405. */
  7406. addUniform(name: string, size: number | number[]): void;
  7407. /**
  7408. * Adds a Matrix 4x4 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param mat A 4x4 matrix.
  7411. */
  7412. addMatrix(name: string, mat: Matrix): void;
  7413. /**
  7414. * Adds a vec2 to the uniform buffer.
  7415. * @param name Name of the uniform, as used in the uniform block in the shader.
  7416. * @param x Define the x component value of the vec2
  7417. * @param y Define the y component value of the vec2
  7418. */
  7419. addFloat2(name: string, x: number, y: number): void;
  7420. /**
  7421. * Adds a vec3 to the uniform buffer.
  7422. * @param name Name of the uniform, as used in the uniform block in the shader.
  7423. * @param x Define the x component value of the vec3
  7424. * @param y Define the y component value of the vec3
  7425. * @param z Define the z component value of the vec3
  7426. */
  7427. addFloat3(name: string, x: number, y: number, z: number): void;
  7428. /**
  7429. * Adds a vec3 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param color Define the vec3 from a Color
  7432. */
  7433. addColor3(name: string, color: Color3): void;
  7434. /**
  7435. * Adds a vec4 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. * @param color Define the rgb components from a Color
  7438. * @param alpha Define the a component of the vec4
  7439. */
  7440. addColor4(name: string, color: Color3, alpha: number): void;
  7441. /**
  7442. * Adds a vec3 to the uniform buffer.
  7443. * @param name Name of the uniform, as used in the uniform block in the shader.
  7444. * @param vector Define the vec3 components from a Vector
  7445. */
  7446. addVector3(name: string, vector: Vector3): void;
  7447. /**
  7448. * Adds a Matrix 3x3 to the uniform buffer.
  7449. * @param name Name of the uniform, as used in the uniform block in the shader.
  7450. */
  7451. addMatrix3x3(name: string): void;
  7452. /**
  7453. * Adds a Matrix 2x2 to the uniform buffer.
  7454. * @param name Name of the uniform, as used in the uniform block in the shader.
  7455. */
  7456. addMatrix2x2(name: string): void;
  7457. /**
  7458. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7459. */
  7460. create(): void;
  7461. /** @hidden */
  7462. _rebuild(): void;
  7463. /**
  7464. * Updates the WebGL Uniform Buffer on the GPU.
  7465. * If the `dynamic` flag is set to true, no cache comparison is done.
  7466. * Otherwise, the buffer will be updated only if the cache differs.
  7467. */
  7468. update(): void;
  7469. /**
  7470. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7471. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7472. * @param data Define the flattened data
  7473. * @param size Define the size of the data.
  7474. */
  7475. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7476. private _valueCache;
  7477. private _cacheMatrix;
  7478. private _updateMatrix3x3ForUniform;
  7479. private _updateMatrix3x3ForEffect;
  7480. private _updateMatrix2x2ForEffect;
  7481. private _updateMatrix2x2ForUniform;
  7482. private _updateFloatForEffect;
  7483. private _updateFloatForUniform;
  7484. private _updateFloat2ForEffect;
  7485. private _updateFloat2ForUniform;
  7486. private _updateFloat3ForEffect;
  7487. private _updateFloat3ForUniform;
  7488. private _updateFloat4ForEffect;
  7489. private _updateFloat4ForUniform;
  7490. private _updateMatrixForEffect;
  7491. private _updateMatrixForUniform;
  7492. private _updateVector3ForEffect;
  7493. private _updateVector3ForUniform;
  7494. private _updateVector4ForEffect;
  7495. private _updateVector4ForUniform;
  7496. private _updateColor3ForEffect;
  7497. private _updateColor3ForUniform;
  7498. private _updateColor4ForEffect;
  7499. private _updateColor4ForUniform;
  7500. /**
  7501. * Sets a sampler uniform on the effect.
  7502. * @param name Define the name of the sampler.
  7503. * @param texture Define the texture to set in the sampler
  7504. */
  7505. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7506. /**
  7507. * Directly updates the value of the uniform in the cache AND on the GPU.
  7508. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7509. * @param data Define the flattened data
  7510. */
  7511. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7512. /**
  7513. * Binds this uniform buffer to an effect.
  7514. * @param effect Define the effect to bind the buffer to
  7515. * @param name Name of the uniform block in the shader.
  7516. */
  7517. bindToEffect(effect: Effect, name: string): void;
  7518. /**
  7519. * Disposes the uniform buffer.
  7520. */
  7521. dispose(): void;
  7522. }
  7523. }
  7524. declare module BABYLON {
  7525. /**
  7526. * Enum that determines the text-wrapping mode to use.
  7527. */
  7528. export enum InspectableType {
  7529. /**
  7530. * Checkbox for booleans
  7531. */
  7532. Checkbox = 0,
  7533. /**
  7534. * Sliders for numbers
  7535. */
  7536. Slider = 1,
  7537. /**
  7538. * Vector3
  7539. */
  7540. Vector3 = 2,
  7541. /**
  7542. * Quaternions
  7543. */
  7544. Quaternion = 3,
  7545. /**
  7546. * Color3
  7547. */
  7548. Color3 = 4,
  7549. /**
  7550. * String
  7551. */
  7552. String = 5
  7553. }
  7554. /**
  7555. * Interface used to define custom inspectable properties.
  7556. * This interface is used by the inspector to display custom property grids
  7557. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7558. */
  7559. export interface IInspectable {
  7560. /**
  7561. * Gets the label to display
  7562. */
  7563. label: string;
  7564. /**
  7565. * Gets the name of the property to edit
  7566. */
  7567. propertyName: string;
  7568. /**
  7569. * Gets the type of the editor to use
  7570. */
  7571. type: InspectableType;
  7572. /**
  7573. * Gets the minimum value of the property when using in "slider" mode
  7574. */
  7575. min?: number;
  7576. /**
  7577. * Gets the maximum value of the property when using in "slider" mode
  7578. */
  7579. max?: number;
  7580. /**
  7581. * Gets the setp to use when using in "slider" mode
  7582. */
  7583. step?: number;
  7584. }
  7585. }
  7586. declare module BABYLON {
  7587. /**
  7588. * Class used to provide helper for timing
  7589. */
  7590. export class TimingTools {
  7591. /**
  7592. * Polyfill for setImmediate
  7593. * @param action defines the action to execute after the current execution block
  7594. */
  7595. static SetImmediate(action: () => void): void;
  7596. }
  7597. }
  7598. declare module BABYLON {
  7599. /**
  7600. * Class used to enable instatition of objects by class name
  7601. */
  7602. export class InstantiationTools {
  7603. /**
  7604. * Use this object to register external classes like custom textures or material
  7605. * to allow the laoders to instantiate them
  7606. */
  7607. static RegisteredExternalClasses: {
  7608. [key: string]: Object;
  7609. };
  7610. /**
  7611. * Tries to instantiate a new object from a given class name
  7612. * @param className defines the class name to instantiate
  7613. * @returns the new object or null if the system was not able to do the instantiation
  7614. */
  7615. static Instantiate(className: string): any;
  7616. }
  7617. }
  7618. declare module BABYLON {
  7619. /**
  7620. * Define options used to create a depth texture
  7621. */
  7622. export class DepthTextureCreationOptions {
  7623. /** Specifies whether or not a stencil should be allocated in the texture */
  7624. generateStencil?: boolean;
  7625. /** Specifies whether or not bilinear filtering is enable on the texture */
  7626. bilinearFiltering?: boolean;
  7627. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7628. comparisonFunction?: number;
  7629. /** Specifies if the created texture is a cube texture */
  7630. isCube?: boolean;
  7631. }
  7632. }
  7633. declare module BABYLON {
  7634. interface ThinEngine {
  7635. /**
  7636. * Creates a depth stencil cube texture.
  7637. * This is only available in WebGL 2.
  7638. * @param size The size of face edge in the cube texture.
  7639. * @param options The options defining the cube texture.
  7640. * @returns The cube texture
  7641. */
  7642. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7643. /**
  7644. * Creates a cube texture
  7645. * @param rootUrl defines the url where the files to load is located
  7646. * @param scene defines the current scene
  7647. * @param files defines the list of files to load (1 per face)
  7648. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7649. * @param onLoad defines an optional callback raised when the texture is loaded
  7650. * @param onError defines an optional callback raised if there is an issue to load the texture
  7651. * @param format defines the format of the data
  7652. * @param forcedExtension defines the extension to use to pick the right loader
  7653. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7654. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7655. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7656. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7657. * @returns the cube texture as an InternalTexture
  7658. */
  7659. 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;
  7660. /**
  7661. * Creates a cube texture
  7662. * @param rootUrl defines the url where the files to load is located
  7663. * @param scene defines the current scene
  7664. * @param files defines the list of files to load (1 per face)
  7665. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7666. * @param onLoad defines an optional callback raised when the texture is loaded
  7667. * @param onError defines an optional callback raised if there is an issue to load the texture
  7668. * @param format defines the format of the data
  7669. * @param forcedExtension defines the extension to use to pick the right loader
  7670. * @returns the cube texture as an InternalTexture
  7671. */
  7672. 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;
  7673. /**
  7674. * Creates a cube texture
  7675. * @param rootUrl defines the url where the files to load is located
  7676. * @param scene defines the current scene
  7677. * @param files defines the list of files to load (1 per face)
  7678. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7679. * @param onLoad defines an optional callback raised when the texture is loaded
  7680. * @param onError defines an optional callback raised if there is an issue to load the texture
  7681. * @param format defines the format of the data
  7682. * @param forcedExtension defines the extension to use to pick the right loader
  7683. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7684. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7685. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7686. * @returns the cube texture as an InternalTexture
  7687. */
  7688. 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;
  7689. /** @hidden */
  7690. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7691. /** @hidden */
  7692. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7693. /** @hidden */
  7694. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7695. /** @hidden */
  7696. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7697. /**
  7698. * @hidden
  7699. */
  7700. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7701. }
  7702. }
  7703. declare module BABYLON {
  7704. /**
  7705. * Class for creating a cube texture
  7706. */
  7707. export class CubeTexture extends BaseTexture {
  7708. private _delayedOnLoad;
  7709. /**
  7710. * Observable triggered once the texture has been loaded.
  7711. */
  7712. onLoadObservable: Observable<CubeTexture>;
  7713. /**
  7714. * The url of the texture
  7715. */
  7716. url: string;
  7717. /**
  7718. * Gets or sets the center of the bounding box associated with the cube texture.
  7719. * It must define where the camera used to render the texture was set
  7720. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7721. */
  7722. boundingBoxPosition: Vector3;
  7723. private _boundingBoxSize;
  7724. /**
  7725. * Gets or sets the size of the bounding box associated with the cube texture
  7726. * When defined, the cubemap will switch to local mode
  7727. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7728. * @example https://www.babylonjs-playground.com/#RNASML
  7729. */
  7730. set boundingBoxSize(value: Vector3);
  7731. /**
  7732. * Returns the bounding box size
  7733. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7734. */
  7735. get boundingBoxSize(): Vector3;
  7736. protected _rotationY: number;
  7737. /**
  7738. * Sets texture matrix rotation angle around Y axis in radians.
  7739. */
  7740. set rotationY(value: number);
  7741. /**
  7742. * Gets texture matrix rotation angle around Y axis radians.
  7743. */
  7744. get rotationY(): number;
  7745. /**
  7746. * Are mip maps generated for this texture or not.
  7747. */
  7748. get noMipmap(): boolean;
  7749. private _noMipmap;
  7750. private _files;
  7751. protected _forcedExtension: Nullable<string>;
  7752. private _extensions;
  7753. private _textureMatrix;
  7754. private _format;
  7755. private _createPolynomials;
  7756. /**
  7757. * Creates a cube texture from an array of image urls
  7758. * @param files defines an array of image urls
  7759. * @param scene defines the hosting scene
  7760. * @param noMipmap specifies if mip maps are not used
  7761. * @returns a cube texture
  7762. */
  7763. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7764. /**
  7765. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7766. * @param url defines the url of the prefiltered texture
  7767. * @param scene defines the scene the texture is attached to
  7768. * @param forcedExtension defines the extension of the file if different from the url
  7769. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7770. * @return the prefiltered texture
  7771. */
  7772. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7773. /**
  7774. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7775. * as prefiltered data.
  7776. * @param rootUrl defines the url of the texture or the root name of the six images
  7777. * @param null defines the scene or engine the texture is attached to
  7778. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7779. * @param noMipmap defines if mipmaps should be created or not
  7780. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7781. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7782. * @param onError defines a callback triggered in case of error during load
  7783. * @param format defines the internal format to use for the texture once loaded
  7784. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7785. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7786. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7787. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7788. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7789. * @return the cube texture
  7790. */
  7791. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, 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);
  7792. /**
  7793. * Get the current class name of the texture useful for serialization or dynamic coding.
  7794. * @returns "CubeTexture"
  7795. */
  7796. getClassName(): string;
  7797. /**
  7798. * Update the url (and optional buffer) of this texture if url was null during construction.
  7799. * @param url the url of the texture
  7800. * @param forcedExtension defines the extension to use
  7801. * @param onLoad callback called when the texture is loaded (defaults to null)
  7802. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7803. */
  7804. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7805. /**
  7806. * Delays loading of the cube texture
  7807. * @param forcedExtension defines the extension to use
  7808. */
  7809. delayLoad(forcedExtension?: string): void;
  7810. /**
  7811. * Returns the reflection texture matrix
  7812. * @returns the reflection texture matrix
  7813. */
  7814. getReflectionTextureMatrix(): Matrix;
  7815. /**
  7816. * Sets the reflection texture matrix
  7817. * @param value Reflection texture matrix
  7818. */
  7819. setReflectionTextureMatrix(value: Matrix): void;
  7820. /**
  7821. * Parses text to create a cube texture
  7822. * @param parsedTexture define the serialized text to read from
  7823. * @param scene defines the hosting scene
  7824. * @param rootUrl defines the root url of the cube texture
  7825. * @returns a cube texture
  7826. */
  7827. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7828. /**
  7829. * Makes a clone, or deep copy, of the cube texture
  7830. * @returns a new cube texture
  7831. */
  7832. clone(): CubeTexture;
  7833. }
  7834. }
  7835. declare module BABYLON {
  7836. /**
  7837. * Manages the defines for the Material
  7838. */
  7839. export class MaterialDefines {
  7840. /** @hidden */
  7841. protected _keys: string[];
  7842. private _isDirty;
  7843. /** @hidden */
  7844. _renderId: number;
  7845. /** @hidden */
  7846. _areLightsDirty: boolean;
  7847. /** @hidden */
  7848. _areLightsDisposed: boolean;
  7849. /** @hidden */
  7850. _areAttributesDirty: boolean;
  7851. /** @hidden */
  7852. _areTexturesDirty: boolean;
  7853. /** @hidden */
  7854. _areFresnelDirty: boolean;
  7855. /** @hidden */
  7856. _areMiscDirty: boolean;
  7857. /** @hidden */
  7858. _areImageProcessingDirty: boolean;
  7859. /** @hidden */
  7860. _normals: boolean;
  7861. /** @hidden */
  7862. _uvs: boolean;
  7863. /** @hidden */
  7864. _needNormals: boolean;
  7865. /** @hidden */
  7866. _needUVs: boolean;
  7867. [id: string]: any;
  7868. /**
  7869. * Specifies if the material needs to be re-calculated
  7870. */
  7871. get isDirty(): boolean;
  7872. /**
  7873. * Marks the material to indicate that it has been re-calculated
  7874. */
  7875. markAsProcessed(): void;
  7876. /**
  7877. * Marks the material to indicate that it needs to be re-calculated
  7878. */
  7879. markAsUnprocessed(): void;
  7880. /**
  7881. * Marks the material to indicate all of its defines need to be re-calculated
  7882. */
  7883. markAllAsDirty(): void;
  7884. /**
  7885. * Marks the material to indicate that image processing needs to be re-calculated
  7886. */
  7887. markAsImageProcessingDirty(): void;
  7888. /**
  7889. * Marks the material to indicate the lights need to be re-calculated
  7890. * @param disposed Defines whether the light is dirty due to dispose or not
  7891. */
  7892. markAsLightDirty(disposed?: boolean): void;
  7893. /**
  7894. * Marks the attribute state as changed
  7895. */
  7896. markAsAttributesDirty(): void;
  7897. /**
  7898. * Marks the texture state as changed
  7899. */
  7900. markAsTexturesDirty(): void;
  7901. /**
  7902. * Marks the fresnel state as changed
  7903. */
  7904. markAsFresnelDirty(): void;
  7905. /**
  7906. * Marks the misc state as changed
  7907. */
  7908. markAsMiscDirty(): void;
  7909. /**
  7910. * Rebuilds the material defines
  7911. */
  7912. rebuild(): void;
  7913. /**
  7914. * Specifies if two material defines are equal
  7915. * @param other - A material define instance to compare to
  7916. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7917. */
  7918. isEqual(other: MaterialDefines): boolean;
  7919. /**
  7920. * Clones this instance's defines to another instance
  7921. * @param other - material defines to clone values to
  7922. */
  7923. cloneTo(other: MaterialDefines): void;
  7924. /**
  7925. * Resets the material define values
  7926. */
  7927. reset(): void;
  7928. /**
  7929. * Converts the material define values to a string
  7930. * @returns - String of material define information
  7931. */
  7932. toString(): string;
  7933. }
  7934. }
  7935. declare module BABYLON {
  7936. /**
  7937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7939. * 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;
  7940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7941. */
  7942. export class ColorCurves {
  7943. private _dirty;
  7944. private _tempColor;
  7945. private _globalCurve;
  7946. private _highlightsCurve;
  7947. private _midtonesCurve;
  7948. private _shadowsCurve;
  7949. private _positiveCurve;
  7950. private _negativeCurve;
  7951. private _globalHue;
  7952. private _globalDensity;
  7953. private _globalSaturation;
  7954. private _globalExposure;
  7955. /**
  7956. * Gets the global Hue value.
  7957. * 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).
  7958. */
  7959. get globalHue(): number;
  7960. /**
  7961. * Sets the global Hue value.
  7962. * 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).
  7963. */
  7964. set globalHue(value: number);
  7965. /**
  7966. * Gets the global Density value.
  7967. * 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.
  7968. * Values less than zero provide a filter of opposite hue.
  7969. */
  7970. get globalDensity(): number;
  7971. /**
  7972. * Sets the global Density value.
  7973. * 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.
  7974. * Values less than zero provide a filter of opposite hue.
  7975. */
  7976. set globalDensity(value: number);
  7977. /**
  7978. * Gets the global Saturation value.
  7979. * 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.
  7980. */
  7981. get globalSaturation(): number;
  7982. /**
  7983. * Sets the global Saturation value.
  7984. * 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.
  7985. */
  7986. set globalSaturation(value: number);
  7987. /**
  7988. * Gets the global Exposure value.
  7989. * 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.
  7990. */
  7991. get globalExposure(): number;
  7992. /**
  7993. * Sets the global Exposure value.
  7994. * 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.
  7995. */
  7996. set globalExposure(value: number);
  7997. private _highlightsHue;
  7998. private _highlightsDensity;
  7999. private _highlightsSaturation;
  8000. private _highlightsExposure;
  8001. /**
  8002. * Gets the highlights Hue value.
  8003. * 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).
  8004. */
  8005. get highlightsHue(): number;
  8006. /**
  8007. * Sets the highlights Hue value.
  8008. * 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).
  8009. */
  8010. set highlightsHue(value: number);
  8011. /**
  8012. * Gets the highlights Density value.
  8013. * 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.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. get highlightsDensity(): number;
  8017. /**
  8018. * Sets the highlights Density value.
  8019. * 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.
  8020. * Values less than zero provide a filter of opposite hue.
  8021. */
  8022. set highlightsDensity(value: number);
  8023. /**
  8024. * Gets the highlights Saturation value.
  8025. * 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.
  8026. */
  8027. get highlightsSaturation(): number;
  8028. /**
  8029. * Sets the highlights Saturation value.
  8030. * 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.
  8031. */
  8032. set highlightsSaturation(value: number);
  8033. /**
  8034. * Gets the highlights Exposure value.
  8035. * 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.
  8036. */
  8037. get highlightsExposure(): number;
  8038. /**
  8039. * Sets the highlights Exposure value.
  8040. * 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.
  8041. */
  8042. set highlightsExposure(value: number);
  8043. private _midtonesHue;
  8044. private _midtonesDensity;
  8045. private _midtonesSaturation;
  8046. private _midtonesExposure;
  8047. /**
  8048. * Gets the midtones Hue value.
  8049. * 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).
  8050. */
  8051. get midtonesHue(): number;
  8052. /**
  8053. * Sets the midtones Hue value.
  8054. * 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).
  8055. */
  8056. set midtonesHue(value: number);
  8057. /**
  8058. * Gets the midtones Density value.
  8059. * 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.
  8060. * Values less than zero provide a filter of opposite hue.
  8061. */
  8062. get midtonesDensity(): number;
  8063. /**
  8064. * Sets the midtones Density value.
  8065. * 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.
  8066. * Values less than zero provide a filter of opposite hue.
  8067. */
  8068. set midtonesDensity(value: number);
  8069. /**
  8070. * Gets the midtones Saturation value.
  8071. * 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.
  8072. */
  8073. get midtonesSaturation(): number;
  8074. /**
  8075. * Sets the midtones Saturation value.
  8076. * 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.
  8077. */
  8078. set midtonesSaturation(value: number);
  8079. /**
  8080. * Gets the midtones Exposure value.
  8081. * 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.
  8082. */
  8083. get midtonesExposure(): number;
  8084. /**
  8085. * Sets the midtones Exposure value.
  8086. * 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.
  8087. */
  8088. set midtonesExposure(value: number);
  8089. private _shadowsHue;
  8090. private _shadowsDensity;
  8091. private _shadowsSaturation;
  8092. private _shadowsExposure;
  8093. /**
  8094. * Gets the shadows Hue value.
  8095. * 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).
  8096. */
  8097. get shadowsHue(): number;
  8098. /**
  8099. * Sets the shadows Hue value.
  8100. * 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).
  8101. */
  8102. set shadowsHue(value: number);
  8103. /**
  8104. * Gets the shadows Density value.
  8105. * 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.
  8106. * Values less than zero provide a filter of opposite hue.
  8107. */
  8108. get shadowsDensity(): number;
  8109. /**
  8110. * Sets the shadows Density value.
  8111. * 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.
  8112. * Values less than zero provide a filter of opposite hue.
  8113. */
  8114. set shadowsDensity(value: number);
  8115. /**
  8116. * Gets the shadows Saturation value.
  8117. * 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.
  8118. */
  8119. get shadowsSaturation(): number;
  8120. /**
  8121. * Sets the shadows Saturation value.
  8122. * 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.
  8123. */
  8124. set shadowsSaturation(value: number);
  8125. /**
  8126. * Gets the shadows Exposure value.
  8127. * 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.
  8128. */
  8129. get shadowsExposure(): number;
  8130. /**
  8131. * Sets the shadows Exposure value.
  8132. * 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.
  8133. */
  8134. set shadowsExposure(value: number);
  8135. /**
  8136. * Returns the class name
  8137. * @returns The class name
  8138. */
  8139. getClassName(): string;
  8140. /**
  8141. * Binds the color curves to the shader.
  8142. * @param colorCurves The color curve to bind
  8143. * @param effect The effect to bind to
  8144. * @param positiveUniform The positive uniform shader parameter
  8145. * @param neutralUniform The neutral uniform shader parameter
  8146. * @param negativeUniform The negative uniform shader parameter
  8147. */
  8148. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8149. /**
  8150. * Prepare the list of uniforms associated with the ColorCurves effects.
  8151. * @param uniformsList The list of uniforms used in the effect
  8152. */
  8153. static PrepareUniforms(uniformsList: string[]): void;
  8154. /**
  8155. * Returns color grading data based on a hue, density, saturation and exposure value.
  8156. * @param filterHue The hue of the color filter.
  8157. * @param filterDensity The density of the color filter.
  8158. * @param saturation The saturation.
  8159. * @param exposure The exposure.
  8160. * @param result The result data container.
  8161. */
  8162. private getColorGradingDataToRef;
  8163. /**
  8164. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8165. * @param value The input slider value in range [-100,100].
  8166. * @returns Adjusted value.
  8167. */
  8168. private static applyColorGradingSliderNonlinear;
  8169. /**
  8170. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8171. * @param hue The hue (H) input.
  8172. * @param saturation The saturation (S) input.
  8173. * @param brightness The brightness (B) input.
  8174. * @result An RGBA color represented as Vector4.
  8175. */
  8176. private static fromHSBToRef;
  8177. /**
  8178. * Returns a value clamped between min and max
  8179. * @param value The value to clamp
  8180. * @param min The minimum of value
  8181. * @param max The maximum of value
  8182. * @returns The clamped value.
  8183. */
  8184. private static clamp;
  8185. /**
  8186. * Clones the current color curve instance.
  8187. * @return The cloned curves
  8188. */
  8189. clone(): ColorCurves;
  8190. /**
  8191. * Serializes the current color curve instance to a json representation.
  8192. * @return a JSON representation
  8193. */
  8194. serialize(): any;
  8195. /**
  8196. * Parses the color curve from a json representation.
  8197. * @param source the JSON source to parse
  8198. * @return The parsed curves
  8199. */
  8200. static Parse(source: any): ColorCurves;
  8201. }
  8202. }
  8203. declare module BABYLON {
  8204. /**
  8205. * Interface to follow in your material defines to integrate easily the
  8206. * Image proccessing functions.
  8207. * @hidden
  8208. */
  8209. export interface IImageProcessingConfigurationDefines {
  8210. IMAGEPROCESSING: boolean;
  8211. VIGNETTE: boolean;
  8212. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8213. VIGNETTEBLENDMODEOPAQUE: boolean;
  8214. TONEMAPPING: boolean;
  8215. TONEMAPPING_ACES: boolean;
  8216. CONTRAST: boolean;
  8217. EXPOSURE: boolean;
  8218. COLORCURVES: boolean;
  8219. COLORGRADING: boolean;
  8220. COLORGRADING3D: boolean;
  8221. SAMPLER3DGREENDEPTH: boolean;
  8222. SAMPLER3DBGRMAP: boolean;
  8223. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8224. }
  8225. /**
  8226. * @hidden
  8227. */
  8228. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8229. IMAGEPROCESSING: boolean;
  8230. VIGNETTE: boolean;
  8231. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8232. VIGNETTEBLENDMODEOPAQUE: boolean;
  8233. TONEMAPPING: boolean;
  8234. TONEMAPPING_ACES: boolean;
  8235. CONTRAST: boolean;
  8236. COLORCURVES: boolean;
  8237. COLORGRADING: boolean;
  8238. COLORGRADING3D: boolean;
  8239. SAMPLER3DGREENDEPTH: boolean;
  8240. SAMPLER3DBGRMAP: boolean;
  8241. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8242. EXPOSURE: boolean;
  8243. constructor();
  8244. }
  8245. /**
  8246. * This groups together the common properties used for image processing either in direct forward pass
  8247. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8248. * or not.
  8249. */
  8250. export class ImageProcessingConfiguration {
  8251. /**
  8252. * Default tone mapping applied in BabylonJS.
  8253. */
  8254. static readonly TONEMAPPING_STANDARD: number;
  8255. /**
  8256. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8257. * to other engines rendering to increase portability.
  8258. */
  8259. static readonly TONEMAPPING_ACES: number;
  8260. /**
  8261. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8262. */
  8263. colorCurves: Nullable<ColorCurves>;
  8264. private _colorCurvesEnabled;
  8265. /**
  8266. * Gets wether the color curves effect is enabled.
  8267. */
  8268. get colorCurvesEnabled(): boolean;
  8269. /**
  8270. * Sets wether the color curves effect is enabled.
  8271. */
  8272. set colorCurvesEnabled(value: boolean);
  8273. private _colorGradingTexture;
  8274. /**
  8275. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8276. */
  8277. get colorGradingTexture(): Nullable<BaseTexture>;
  8278. /**
  8279. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8280. */
  8281. set colorGradingTexture(value: Nullable<BaseTexture>);
  8282. private _colorGradingEnabled;
  8283. /**
  8284. * Gets wether the color grading effect is enabled.
  8285. */
  8286. get colorGradingEnabled(): boolean;
  8287. /**
  8288. * Sets wether the color grading effect is enabled.
  8289. */
  8290. set colorGradingEnabled(value: boolean);
  8291. private _colorGradingWithGreenDepth;
  8292. /**
  8293. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8294. */
  8295. get colorGradingWithGreenDepth(): boolean;
  8296. /**
  8297. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8298. */
  8299. set colorGradingWithGreenDepth(value: boolean);
  8300. private _colorGradingBGR;
  8301. /**
  8302. * Gets wether the color grading texture contains BGR values.
  8303. */
  8304. get colorGradingBGR(): boolean;
  8305. /**
  8306. * Sets wether the color grading texture contains BGR values.
  8307. */
  8308. set colorGradingBGR(value: boolean);
  8309. /** @hidden */
  8310. _exposure: number;
  8311. /**
  8312. * Gets the Exposure used in the effect.
  8313. */
  8314. get exposure(): number;
  8315. /**
  8316. * Sets the Exposure used in the effect.
  8317. */
  8318. set exposure(value: number);
  8319. private _toneMappingEnabled;
  8320. /**
  8321. * Gets wether the tone mapping effect is enabled.
  8322. */
  8323. get toneMappingEnabled(): boolean;
  8324. /**
  8325. * Sets wether the tone mapping effect is enabled.
  8326. */
  8327. set toneMappingEnabled(value: boolean);
  8328. private _toneMappingType;
  8329. /**
  8330. * Gets the type of tone mapping effect.
  8331. */
  8332. get toneMappingType(): number;
  8333. /**
  8334. * Sets the type of tone mapping effect used in BabylonJS.
  8335. */
  8336. set toneMappingType(value: number);
  8337. protected _contrast: number;
  8338. /**
  8339. * Gets the contrast used in the effect.
  8340. */
  8341. get contrast(): number;
  8342. /**
  8343. * Sets the contrast used in the effect.
  8344. */
  8345. set contrast(value: number);
  8346. /**
  8347. * Vignette stretch size.
  8348. */
  8349. vignetteStretch: number;
  8350. /**
  8351. * Vignette centre X Offset.
  8352. */
  8353. vignetteCentreX: number;
  8354. /**
  8355. * Vignette centre Y Offset.
  8356. */
  8357. vignetteCentreY: number;
  8358. /**
  8359. * Vignette weight or intensity of the vignette effect.
  8360. */
  8361. vignetteWeight: number;
  8362. /**
  8363. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8364. * if vignetteEnabled is set to true.
  8365. */
  8366. vignetteColor: Color4;
  8367. /**
  8368. * Camera field of view used by the Vignette effect.
  8369. */
  8370. vignetteCameraFov: number;
  8371. private _vignetteBlendMode;
  8372. /**
  8373. * Gets the vignette blend mode allowing different kind of effect.
  8374. */
  8375. get vignetteBlendMode(): number;
  8376. /**
  8377. * Sets the vignette blend mode allowing different kind of effect.
  8378. */
  8379. set vignetteBlendMode(value: number);
  8380. private _vignetteEnabled;
  8381. /**
  8382. * Gets wether the vignette effect is enabled.
  8383. */
  8384. get vignetteEnabled(): boolean;
  8385. /**
  8386. * Sets wether the vignette effect is enabled.
  8387. */
  8388. set vignetteEnabled(value: boolean);
  8389. private _applyByPostProcess;
  8390. /**
  8391. * Gets wether the image processing is applied through a post process or not.
  8392. */
  8393. get applyByPostProcess(): boolean;
  8394. /**
  8395. * Sets wether the image processing is applied through a post process or not.
  8396. */
  8397. set applyByPostProcess(value: boolean);
  8398. private _isEnabled;
  8399. /**
  8400. * Gets wether the image processing is enabled or not.
  8401. */
  8402. get isEnabled(): boolean;
  8403. /**
  8404. * Sets wether the image processing is enabled or not.
  8405. */
  8406. set isEnabled(value: boolean);
  8407. /**
  8408. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8409. */
  8410. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8411. /**
  8412. * Method called each time the image processing information changes requires to recompile the effect.
  8413. */
  8414. protected _updateParameters(): void;
  8415. /**
  8416. * Gets the current class name.
  8417. * @return "ImageProcessingConfiguration"
  8418. */
  8419. getClassName(): string;
  8420. /**
  8421. * Prepare the list of uniforms associated with the Image Processing effects.
  8422. * @param uniforms The list of uniforms used in the effect
  8423. * @param defines the list of defines currently in use
  8424. */
  8425. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8426. /**
  8427. * Prepare the list of samplers associated with the Image Processing effects.
  8428. * @param samplersList The list of uniforms used in the effect
  8429. * @param defines the list of defines currently in use
  8430. */
  8431. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8432. /**
  8433. * Prepare the list of defines associated to the shader.
  8434. * @param defines the list of defines to complete
  8435. * @param forPostProcess Define if we are currently in post process mode or not
  8436. */
  8437. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8438. /**
  8439. * Returns true if all the image processing information are ready.
  8440. * @returns True if ready, otherwise, false
  8441. */
  8442. isReady(): boolean;
  8443. /**
  8444. * Binds the image processing to the shader.
  8445. * @param effect The effect to bind to
  8446. * @param overrideAspectRatio Override the aspect ratio of the effect
  8447. */
  8448. bind(effect: Effect, overrideAspectRatio?: number): void;
  8449. /**
  8450. * Clones the current image processing instance.
  8451. * @return The cloned image processing
  8452. */
  8453. clone(): ImageProcessingConfiguration;
  8454. /**
  8455. * Serializes the current image processing instance to a json representation.
  8456. * @return a JSON representation
  8457. */
  8458. serialize(): any;
  8459. /**
  8460. * Parses the image processing from a json representation.
  8461. * @param source the JSON source to parse
  8462. * @return The parsed image processing
  8463. */
  8464. static Parse(source: any): ImageProcessingConfiguration;
  8465. private static _VIGNETTEMODE_MULTIPLY;
  8466. private static _VIGNETTEMODE_OPAQUE;
  8467. /**
  8468. * Used to apply the vignette as a mix with the pixel color.
  8469. */
  8470. static get VIGNETTEMODE_MULTIPLY(): number;
  8471. /**
  8472. * Used to apply the vignette as a replacement of the pixel color.
  8473. */
  8474. static get VIGNETTEMODE_OPAQUE(): number;
  8475. }
  8476. }
  8477. declare module BABYLON {
  8478. /** @hidden */
  8479. export var postprocessVertexShader: {
  8480. name: string;
  8481. shader: string;
  8482. };
  8483. }
  8484. declare module BABYLON {
  8485. interface ThinEngine {
  8486. /**
  8487. * Creates a new render target texture
  8488. * @param size defines the size of the texture
  8489. * @param options defines the options used to create the texture
  8490. * @returns a new render target texture stored in an InternalTexture
  8491. */
  8492. createRenderTargetTexture(size: number | {
  8493. width: number;
  8494. height: number;
  8495. layers?: number;
  8496. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8497. /**
  8498. * Creates a depth stencil texture.
  8499. * This is only available in WebGL 2 or with the depth texture extension available.
  8500. * @param size The size of face edge in the texture.
  8501. * @param options The options defining the texture.
  8502. * @returns The texture
  8503. */
  8504. createDepthStencilTexture(size: number | {
  8505. width: number;
  8506. height: number;
  8507. layers?: number;
  8508. }, options: DepthTextureCreationOptions): InternalTexture;
  8509. /** @hidden */
  8510. _createDepthStencilTexture(size: number | {
  8511. width: number;
  8512. height: number;
  8513. layers?: number;
  8514. }, options: DepthTextureCreationOptions): InternalTexture;
  8515. }
  8516. }
  8517. declare module BABYLON {
  8518. /**
  8519. * Defines the kind of connection point for node based material
  8520. */
  8521. export enum NodeMaterialBlockConnectionPointTypes {
  8522. /** Float */
  8523. Float = 1,
  8524. /** Int */
  8525. Int = 2,
  8526. /** Vector2 */
  8527. Vector2 = 4,
  8528. /** Vector3 */
  8529. Vector3 = 8,
  8530. /** Vector4 */
  8531. Vector4 = 16,
  8532. /** Color3 */
  8533. Color3 = 32,
  8534. /** Color4 */
  8535. Color4 = 64,
  8536. /** Matrix */
  8537. Matrix = 128,
  8538. /** Custom object */
  8539. Object = 256,
  8540. /** Detect type based on connection */
  8541. AutoDetect = 1024,
  8542. /** Output type that will be defined by input type */
  8543. BasedOnInput = 2048
  8544. }
  8545. }
  8546. declare module BABYLON {
  8547. /**
  8548. * Enum used to define the target of a block
  8549. */
  8550. export enum NodeMaterialBlockTargets {
  8551. /** Vertex shader */
  8552. Vertex = 1,
  8553. /** Fragment shader */
  8554. Fragment = 2,
  8555. /** Neutral */
  8556. Neutral = 4,
  8557. /** Vertex and Fragment */
  8558. VertexAndFragment = 3
  8559. }
  8560. }
  8561. declare module BABYLON {
  8562. /**
  8563. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8564. */
  8565. export enum NodeMaterialBlockConnectionPointMode {
  8566. /** Value is an uniform */
  8567. Uniform = 0,
  8568. /** Value is a mesh attribute */
  8569. Attribute = 1,
  8570. /** Value is a varying between vertex and fragment shaders */
  8571. Varying = 2,
  8572. /** Mode is undefined */
  8573. Undefined = 3
  8574. }
  8575. }
  8576. declare module BABYLON {
  8577. /**
  8578. * Enum used to define system values e.g. values automatically provided by the system
  8579. */
  8580. export enum NodeMaterialSystemValues {
  8581. /** World */
  8582. World = 1,
  8583. /** View */
  8584. View = 2,
  8585. /** Projection */
  8586. Projection = 3,
  8587. /** ViewProjection */
  8588. ViewProjection = 4,
  8589. /** WorldView */
  8590. WorldView = 5,
  8591. /** WorldViewProjection */
  8592. WorldViewProjection = 6,
  8593. /** CameraPosition */
  8594. CameraPosition = 7,
  8595. /** Fog Color */
  8596. FogColor = 8,
  8597. /** Delta time */
  8598. DeltaTime = 9
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /** Defines supported spaces */
  8603. export enum Space {
  8604. /** Local (object) space */
  8605. LOCAL = 0,
  8606. /** World space */
  8607. WORLD = 1,
  8608. /** Bone space */
  8609. BONE = 2
  8610. }
  8611. /** Defines the 3 main axes */
  8612. export class Axis {
  8613. /** X axis */
  8614. static X: Vector3;
  8615. /** Y axis */
  8616. static Y: Vector3;
  8617. /** Z axis */
  8618. static Z: Vector3;
  8619. }
  8620. }
  8621. declare module BABYLON {
  8622. /**
  8623. * Represents a camera frustum
  8624. */
  8625. export class Frustum {
  8626. /**
  8627. * Gets the planes representing the frustum
  8628. * @param transform matrix to be applied to the returned planes
  8629. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8630. */
  8631. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8632. /**
  8633. * Gets the near frustum plane transformed by the transform matrix
  8634. * @param transform transformation matrix to be applied to the resulting frustum plane
  8635. * @param frustumPlane the resuling frustum plane
  8636. */
  8637. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8638. /**
  8639. * Gets the far frustum plane transformed by the transform matrix
  8640. * @param transform transformation matrix to be applied to the resulting frustum plane
  8641. * @param frustumPlane the resuling frustum plane
  8642. */
  8643. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8644. /**
  8645. * Gets the left frustum plane transformed by the transform matrix
  8646. * @param transform transformation matrix to be applied to the resulting frustum plane
  8647. * @param frustumPlane the resuling frustum plane
  8648. */
  8649. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8650. /**
  8651. * Gets the right frustum plane transformed by the transform matrix
  8652. * @param transform transformation matrix to be applied to the resulting frustum plane
  8653. * @param frustumPlane the resuling frustum plane
  8654. */
  8655. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8656. /**
  8657. * Gets the top frustum plane transformed by the transform matrix
  8658. * @param transform transformation matrix to be applied to the resulting frustum plane
  8659. * @param frustumPlane the resuling frustum plane
  8660. */
  8661. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8662. /**
  8663. * Gets the bottom frustum plane transformed by the transform matrix
  8664. * @param transform transformation matrix to be applied to the resulting frustum plane
  8665. * @param frustumPlane the resuling frustum plane
  8666. */
  8667. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8668. /**
  8669. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8670. * @param transform transformation matrix to be applied to the resulting frustum planes
  8671. * @param frustumPlanes the resuling frustum planes
  8672. */
  8673. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8674. }
  8675. }
  8676. declare module BABYLON {
  8677. /**
  8678. * Interface for the size containing width and height
  8679. */
  8680. export interface ISize {
  8681. /**
  8682. * Width
  8683. */
  8684. width: number;
  8685. /**
  8686. * Heighht
  8687. */
  8688. height: number;
  8689. }
  8690. /**
  8691. * Size containing widht and height
  8692. */
  8693. export class Size implements ISize {
  8694. /**
  8695. * Width
  8696. */
  8697. width: number;
  8698. /**
  8699. * Height
  8700. */
  8701. height: number;
  8702. /**
  8703. * Creates a Size object from the given width and height (floats).
  8704. * @param width width of the new size
  8705. * @param height height of the new size
  8706. */
  8707. constructor(width: number, height: number);
  8708. /**
  8709. * Returns a string with the Size width and height
  8710. * @returns a string with the Size width and height
  8711. */
  8712. toString(): string;
  8713. /**
  8714. * "Size"
  8715. * @returns the string "Size"
  8716. */
  8717. getClassName(): string;
  8718. /**
  8719. * Returns the Size hash code.
  8720. * @returns a hash code for a unique width and height
  8721. */
  8722. getHashCode(): number;
  8723. /**
  8724. * Updates the current size from the given one.
  8725. * @param src the given size
  8726. */
  8727. copyFrom(src: Size): void;
  8728. /**
  8729. * Updates in place the current Size from the given floats.
  8730. * @param width width of the new size
  8731. * @param height height of the new size
  8732. * @returns the updated Size.
  8733. */
  8734. copyFromFloats(width: number, height: number): Size;
  8735. /**
  8736. * Updates in place the current Size from the given floats.
  8737. * @param width width to set
  8738. * @param height height to set
  8739. * @returns the updated Size.
  8740. */
  8741. set(width: number, height: number): Size;
  8742. /**
  8743. * Multiplies the width and height by numbers
  8744. * @param w factor to multiple the width by
  8745. * @param h factor to multiple the height by
  8746. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8747. */
  8748. multiplyByFloats(w: number, h: number): Size;
  8749. /**
  8750. * Clones the size
  8751. * @returns a new Size copied from the given one.
  8752. */
  8753. clone(): Size;
  8754. /**
  8755. * True if the current Size and the given one width and height are strictly equal.
  8756. * @param other the other size to compare against
  8757. * @returns True if the current Size and the given one width and height are strictly equal.
  8758. */
  8759. equals(other: Size): boolean;
  8760. /**
  8761. * The surface of the Size : width * height (float).
  8762. */
  8763. get surface(): number;
  8764. /**
  8765. * Create a new size of zero
  8766. * @returns a new Size set to (0.0, 0.0)
  8767. */
  8768. static Zero(): Size;
  8769. /**
  8770. * Sums the width and height of two sizes
  8771. * @param otherSize size to add to this size
  8772. * @returns a new Size set as the addition result of the current Size and the given one.
  8773. */
  8774. add(otherSize: Size): Size;
  8775. /**
  8776. * Subtracts the width and height of two
  8777. * @param otherSize size to subtract to this size
  8778. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8779. */
  8780. subtract(otherSize: Size): Size;
  8781. /**
  8782. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8783. * @param start starting size to lerp between
  8784. * @param end end size to lerp between
  8785. * @param amount amount to lerp between the start and end values
  8786. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8787. */
  8788. static Lerp(start: Size, end: Size, amount: number): Size;
  8789. }
  8790. }
  8791. declare module BABYLON {
  8792. /**
  8793. * Contains position and normal vectors for a vertex
  8794. */
  8795. export class PositionNormalVertex {
  8796. /** the position of the vertex (defaut: 0,0,0) */
  8797. position: Vector3;
  8798. /** the normal of the vertex (defaut: 0,1,0) */
  8799. normal: Vector3;
  8800. /**
  8801. * Creates a PositionNormalVertex
  8802. * @param position the position of the vertex (defaut: 0,0,0)
  8803. * @param normal the normal of the vertex (defaut: 0,1,0)
  8804. */
  8805. constructor(
  8806. /** the position of the vertex (defaut: 0,0,0) */
  8807. position?: Vector3,
  8808. /** the normal of the vertex (defaut: 0,1,0) */
  8809. normal?: Vector3);
  8810. /**
  8811. * Clones the PositionNormalVertex
  8812. * @returns the cloned PositionNormalVertex
  8813. */
  8814. clone(): PositionNormalVertex;
  8815. }
  8816. /**
  8817. * Contains position, normal and uv vectors for a vertex
  8818. */
  8819. export class PositionNormalTextureVertex {
  8820. /** the position of the vertex (defaut: 0,0,0) */
  8821. position: Vector3;
  8822. /** the normal of the vertex (defaut: 0,1,0) */
  8823. normal: Vector3;
  8824. /** the uv of the vertex (default: 0,0) */
  8825. uv: Vector2;
  8826. /**
  8827. * Creates a PositionNormalTextureVertex
  8828. * @param position the position of the vertex (defaut: 0,0,0)
  8829. * @param normal the normal of the vertex (defaut: 0,1,0)
  8830. * @param uv the uv of the vertex (default: 0,0)
  8831. */
  8832. constructor(
  8833. /** the position of the vertex (defaut: 0,0,0) */
  8834. position?: Vector3,
  8835. /** the normal of the vertex (defaut: 0,1,0) */
  8836. normal?: Vector3,
  8837. /** the uv of the vertex (default: 0,0) */
  8838. uv?: Vector2);
  8839. /**
  8840. * Clones the PositionNormalTextureVertex
  8841. * @returns the cloned PositionNormalTextureVertex
  8842. */
  8843. clone(): PositionNormalTextureVertex;
  8844. }
  8845. }
  8846. declare module BABYLON {
  8847. /**
  8848. * Enum defining the type of animations supported by InputBlock
  8849. */
  8850. export enum AnimatedInputBlockTypes {
  8851. /** No animation */
  8852. None = 0,
  8853. /** Time based animation. Will only work for floats */
  8854. Time = 1
  8855. }
  8856. }
  8857. declare module BABYLON {
  8858. /**
  8859. * Interface describing all the common properties and methods a shadow light needs to implement.
  8860. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8861. * as well as binding the different shadow properties to the effects.
  8862. */
  8863. export interface IShadowLight extends Light {
  8864. /**
  8865. * The light id in the scene (used in scene.findLighById for instance)
  8866. */
  8867. id: string;
  8868. /**
  8869. * The position the shdow will be casted from.
  8870. */
  8871. position: Vector3;
  8872. /**
  8873. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8874. */
  8875. direction: Vector3;
  8876. /**
  8877. * The transformed position. Position of the light in world space taking parenting in account.
  8878. */
  8879. transformedPosition: Vector3;
  8880. /**
  8881. * The transformed direction. Direction of the light in world space taking parenting in account.
  8882. */
  8883. transformedDirection: Vector3;
  8884. /**
  8885. * The friendly name of the light in the scene.
  8886. */
  8887. name: string;
  8888. /**
  8889. * Defines the shadow projection clipping minimum z value.
  8890. */
  8891. shadowMinZ: number;
  8892. /**
  8893. * Defines the shadow projection clipping maximum z value.
  8894. */
  8895. shadowMaxZ: number;
  8896. /**
  8897. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8898. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8899. */
  8900. computeTransformedInformation(): boolean;
  8901. /**
  8902. * Gets the scene the light belongs to.
  8903. * @returns The scene
  8904. */
  8905. getScene(): Scene;
  8906. /**
  8907. * Callback defining a custom Projection Matrix Builder.
  8908. * This can be used to override the default projection matrix computation.
  8909. */
  8910. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8911. /**
  8912. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8913. * @param matrix The materix to updated with the projection information
  8914. * @param viewMatrix The transform matrix of the light
  8915. * @param renderList The list of mesh to render in the map
  8916. * @returns The current light
  8917. */
  8918. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8919. /**
  8920. * Gets the current depth scale used in ESM.
  8921. * @returns The scale
  8922. */
  8923. getDepthScale(): number;
  8924. /**
  8925. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8926. * @returns true if a cube texture needs to be use
  8927. */
  8928. needCube(): boolean;
  8929. /**
  8930. * Detects if the projection matrix requires to be recomputed this frame.
  8931. * @returns true if it requires to be recomputed otherwise, false.
  8932. */
  8933. needProjectionMatrixCompute(): boolean;
  8934. /**
  8935. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8936. */
  8937. forceProjectionMatrixCompute(): void;
  8938. /**
  8939. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8940. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8941. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8942. */
  8943. getShadowDirection(faceIndex?: number): Vector3;
  8944. /**
  8945. * Gets the minZ used for shadow according to both the scene and the light.
  8946. * @param activeCamera The camera we are returning the min for
  8947. * @returns the depth min z
  8948. */
  8949. getDepthMinZ(activeCamera: Camera): number;
  8950. /**
  8951. * Gets the maxZ used for shadow according to both the scene and the light.
  8952. * @param activeCamera The camera we are returning the max for
  8953. * @returns the depth max z
  8954. */
  8955. getDepthMaxZ(activeCamera: Camera): number;
  8956. }
  8957. /**
  8958. * Base implementation IShadowLight
  8959. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8960. */
  8961. export abstract class ShadowLight extends Light implements IShadowLight {
  8962. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8963. protected _position: Vector3;
  8964. protected _setPosition(value: Vector3): void;
  8965. /**
  8966. * Sets the position the shadow will be casted from. Also use as the light position for both
  8967. * point and spot lights.
  8968. */
  8969. get position(): Vector3;
  8970. /**
  8971. * Sets the position the shadow will be casted from. Also use as the light position for both
  8972. * point and spot lights.
  8973. */
  8974. set position(value: Vector3);
  8975. protected _direction: Vector3;
  8976. protected _setDirection(value: Vector3): void;
  8977. /**
  8978. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8979. * Also use as the light direction on spot and directional lights.
  8980. */
  8981. get direction(): Vector3;
  8982. /**
  8983. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8984. * Also use as the light direction on spot and directional lights.
  8985. */
  8986. set direction(value: Vector3);
  8987. protected _shadowMinZ: number;
  8988. /**
  8989. * Gets the shadow projection clipping minimum z value.
  8990. */
  8991. get shadowMinZ(): number;
  8992. /**
  8993. * Sets the shadow projection clipping minimum z value.
  8994. */
  8995. set shadowMinZ(value: number);
  8996. protected _shadowMaxZ: number;
  8997. /**
  8998. * Sets the shadow projection clipping maximum z value.
  8999. */
  9000. get shadowMaxZ(): number;
  9001. /**
  9002. * Gets the shadow projection clipping maximum z value.
  9003. */
  9004. set shadowMaxZ(value: number);
  9005. /**
  9006. * Callback defining a custom Projection Matrix Builder.
  9007. * This can be used to override the default projection matrix computation.
  9008. */
  9009. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9010. /**
  9011. * The transformed position. Position of the light in world space taking parenting in account.
  9012. */
  9013. transformedPosition: Vector3;
  9014. /**
  9015. * The transformed direction. Direction of the light in world space taking parenting in account.
  9016. */
  9017. transformedDirection: Vector3;
  9018. private _needProjectionMatrixCompute;
  9019. /**
  9020. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9021. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9022. */
  9023. computeTransformedInformation(): boolean;
  9024. /**
  9025. * Return the depth scale used for the shadow map.
  9026. * @returns the depth scale.
  9027. */
  9028. getDepthScale(): number;
  9029. /**
  9030. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9031. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9032. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9033. */
  9034. getShadowDirection(faceIndex?: number): Vector3;
  9035. /**
  9036. * Returns the ShadowLight absolute position in the World.
  9037. * @returns the position vector in world space
  9038. */
  9039. getAbsolutePosition(): Vector3;
  9040. /**
  9041. * Sets the ShadowLight direction toward the passed target.
  9042. * @param target The point to target in local space
  9043. * @returns the updated ShadowLight direction
  9044. */
  9045. setDirectionToTarget(target: Vector3): Vector3;
  9046. /**
  9047. * Returns the light rotation in euler definition.
  9048. * @returns the x y z rotation in local space.
  9049. */
  9050. getRotation(): Vector3;
  9051. /**
  9052. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9053. * @returns true if a cube texture needs to be use
  9054. */
  9055. needCube(): boolean;
  9056. /**
  9057. * Detects if the projection matrix requires to be recomputed this frame.
  9058. * @returns true if it requires to be recomputed otherwise, false.
  9059. */
  9060. needProjectionMatrixCompute(): boolean;
  9061. /**
  9062. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9063. */
  9064. forceProjectionMatrixCompute(): void;
  9065. /** @hidden */
  9066. _initCache(): void;
  9067. /** @hidden */
  9068. _isSynchronized(): boolean;
  9069. /**
  9070. * Computes the world matrix of the node
  9071. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9072. * @returns the world matrix
  9073. */
  9074. computeWorldMatrix(force?: boolean): Matrix;
  9075. /**
  9076. * Gets the minZ used for shadow according to both the scene and the light.
  9077. * @param activeCamera The camera we are returning the min for
  9078. * @returns the depth min z
  9079. */
  9080. getDepthMinZ(activeCamera: Camera): number;
  9081. /**
  9082. * Gets the maxZ used for shadow according to both the scene and the light.
  9083. * @param activeCamera The camera we are returning the max for
  9084. * @returns the depth max z
  9085. */
  9086. getDepthMaxZ(activeCamera: Camera): number;
  9087. /**
  9088. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9089. * @param matrix The materix to updated with the projection information
  9090. * @param viewMatrix The transform matrix of the light
  9091. * @param renderList The list of mesh to render in the map
  9092. * @returns The current light
  9093. */
  9094. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9095. }
  9096. }
  9097. declare module BABYLON {
  9098. /** @hidden */
  9099. export var packingFunctions: {
  9100. name: string;
  9101. shader: string;
  9102. };
  9103. }
  9104. declare module BABYLON {
  9105. /** @hidden */
  9106. export var bayerDitherFunctions: {
  9107. name: string;
  9108. shader: string;
  9109. };
  9110. }
  9111. declare module BABYLON {
  9112. /** @hidden */
  9113. export var shadowMapFragmentDeclaration: {
  9114. name: string;
  9115. shader: string;
  9116. };
  9117. }
  9118. declare module BABYLON {
  9119. /** @hidden */
  9120. export var clipPlaneFragmentDeclaration: {
  9121. name: string;
  9122. shader: string;
  9123. };
  9124. }
  9125. declare module BABYLON {
  9126. /** @hidden */
  9127. export var clipPlaneFragment: {
  9128. name: string;
  9129. shader: string;
  9130. };
  9131. }
  9132. declare module BABYLON {
  9133. /** @hidden */
  9134. export var shadowMapFragment: {
  9135. name: string;
  9136. shader: string;
  9137. };
  9138. }
  9139. declare module BABYLON {
  9140. /** @hidden */
  9141. export var shadowMapPixelShader: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module BABYLON {
  9147. /** @hidden */
  9148. export var bonesDeclaration: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module BABYLON {
  9154. /** @hidden */
  9155. export var morphTargetsVertexGlobalDeclaration: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module BABYLON {
  9161. /** @hidden */
  9162. export var morphTargetsVertexDeclaration: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module BABYLON {
  9168. /** @hidden */
  9169. export var instancesDeclaration: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module BABYLON {
  9175. /** @hidden */
  9176. export var helperFunctions: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var shadowMapVertexDeclaration: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var clipPlaneVertexDeclaration: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var morphTargetsVertex: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var instancesVertex: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var bonesVertex: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var shadowMapVertexNormalBias: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var shadowMapVertexMetric: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var clipPlaneVertex: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var shadowMapVertexShader: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var depthBoxBlurPixelShader: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var shadowMapFragmentSoftTransparentShadow: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /**
  9260. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9261. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9262. */
  9263. export class EffectFallbacks implements IEffectFallbacks {
  9264. private _defines;
  9265. private _currentRank;
  9266. private _maxRank;
  9267. private _mesh;
  9268. /**
  9269. * Removes the fallback from the bound mesh.
  9270. */
  9271. unBindMesh(): void;
  9272. /**
  9273. * Adds a fallback on the specified property.
  9274. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9275. * @param define The name of the define in the shader
  9276. */
  9277. addFallback(rank: number, define: string): void;
  9278. /**
  9279. * Sets the mesh to use CPU skinning when needing to fallback.
  9280. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9281. * @param mesh The mesh to use the fallbacks.
  9282. */
  9283. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9284. /**
  9285. * Checks to see if more fallbacks are still availible.
  9286. */
  9287. get hasMoreFallbacks(): boolean;
  9288. /**
  9289. * Removes the defines that should be removed when falling back.
  9290. * @param currentDefines defines the current define statements for the shader.
  9291. * @param effect defines the current effect we try to compile
  9292. * @returns The resulting defines with defines of the current rank removed.
  9293. */
  9294. reduce(currentDefines: string, effect: Effect): string;
  9295. }
  9296. }
  9297. declare module BABYLON {
  9298. /**
  9299. * Interface used to define Action
  9300. */
  9301. export interface IAction {
  9302. /**
  9303. * Trigger for the action
  9304. */
  9305. trigger: number;
  9306. /** Options of the trigger */
  9307. triggerOptions: any;
  9308. /**
  9309. * Gets the trigger parameters
  9310. * @returns the trigger parameters
  9311. */
  9312. getTriggerParameter(): any;
  9313. /**
  9314. * Internal only - executes current action event
  9315. * @hidden
  9316. */
  9317. _executeCurrent(evt?: ActionEvent): void;
  9318. /**
  9319. * Serialize placeholder for child classes
  9320. * @param parent of child
  9321. * @returns the serialized object
  9322. */
  9323. serialize(parent: any): any;
  9324. /**
  9325. * Internal only
  9326. * @hidden
  9327. */
  9328. _prepare(): void;
  9329. /**
  9330. * Internal only - manager for action
  9331. * @hidden
  9332. */
  9333. _actionManager: AbstractActionManager;
  9334. /**
  9335. * Adds action to chain of actions, may be a DoNothingAction
  9336. * @param action defines the next action to execute
  9337. * @returns The action passed in
  9338. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9339. */
  9340. then(action: IAction): IAction;
  9341. }
  9342. /**
  9343. * The action to be carried out following a trigger
  9344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9345. */
  9346. export class Action implements IAction {
  9347. /** the trigger, with or without parameters, for the action */
  9348. triggerOptions: any;
  9349. /**
  9350. * Trigger for the action
  9351. */
  9352. trigger: number;
  9353. /**
  9354. * Internal only - manager for action
  9355. * @hidden
  9356. */
  9357. _actionManager: ActionManager;
  9358. private _nextActiveAction;
  9359. private _child;
  9360. private _condition?;
  9361. private _triggerParameter;
  9362. /**
  9363. * An event triggered prior to action being executed.
  9364. */
  9365. onBeforeExecuteObservable: Observable<Action>;
  9366. /**
  9367. * Creates a new Action
  9368. * @param triggerOptions the trigger, with or without parameters, for the action
  9369. * @param condition an optional determinant of action
  9370. */
  9371. constructor(
  9372. /** the trigger, with or without parameters, for the action */
  9373. triggerOptions: any, condition?: Condition);
  9374. /**
  9375. * Internal only
  9376. * @hidden
  9377. */
  9378. _prepare(): void;
  9379. /**
  9380. * Gets the trigger parameters
  9381. * @returns the trigger parameters
  9382. */
  9383. getTriggerParameter(): any;
  9384. /**
  9385. * Internal only - executes current action event
  9386. * @hidden
  9387. */
  9388. _executeCurrent(evt?: ActionEvent): void;
  9389. /**
  9390. * Execute placeholder for child classes
  9391. * @param evt optional action event
  9392. */
  9393. execute(evt?: ActionEvent): void;
  9394. /**
  9395. * Skips to next active action
  9396. */
  9397. skipToNextActiveAction(): void;
  9398. /**
  9399. * Adds action to chain of actions, may be a DoNothingAction
  9400. * @param action defines the next action to execute
  9401. * @returns The action passed in
  9402. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9403. */
  9404. then(action: Action): Action;
  9405. /**
  9406. * Internal only
  9407. * @hidden
  9408. */
  9409. _getProperty(propertyPath: string): string;
  9410. /**
  9411. * Internal only
  9412. * @hidden
  9413. */
  9414. _getEffectiveTarget(target: any, propertyPath: string): any;
  9415. /**
  9416. * Serialize placeholder for child classes
  9417. * @param parent of child
  9418. * @returns the serialized object
  9419. */
  9420. serialize(parent: any): any;
  9421. /**
  9422. * Internal only called by serialize
  9423. * @hidden
  9424. */
  9425. protected _serialize(serializedAction: any, parent?: any): any;
  9426. /**
  9427. * Internal only
  9428. * @hidden
  9429. */
  9430. static _SerializeValueAsString: (value: any) => string;
  9431. /**
  9432. * Internal only
  9433. * @hidden
  9434. */
  9435. static _GetTargetProperty: (target: Node | Scene) => {
  9436. name: string;
  9437. targetType: string;
  9438. value: string;
  9439. };
  9440. }
  9441. }
  9442. declare module BABYLON {
  9443. /**
  9444. * A Condition applied to an Action
  9445. */
  9446. export class Condition {
  9447. /**
  9448. * Internal only - manager for action
  9449. * @hidden
  9450. */
  9451. _actionManager: ActionManager;
  9452. /**
  9453. * Internal only
  9454. * @hidden
  9455. */
  9456. _evaluationId: number;
  9457. /**
  9458. * Internal only
  9459. * @hidden
  9460. */
  9461. _currentResult: boolean;
  9462. /**
  9463. * Creates a new Condition
  9464. * @param actionManager the manager of the action the condition is applied to
  9465. */
  9466. constructor(actionManager: ActionManager);
  9467. /**
  9468. * Check if the current condition is valid
  9469. * @returns a boolean
  9470. */
  9471. isValid(): boolean;
  9472. /**
  9473. * Internal only
  9474. * @hidden
  9475. */
  9476. _getProperty(propertyPath: string): string;
  9477. /**
  9478. * Internal only
  9479. * @hidden
  9480. */
  9481. _getEffectiveTarget(target: any, propertyPath: string): any;
  9482. /**
  9483. * Serialize placeholder for child classes
  9484. * @returns the serialized object
  9485. */
  9486. serialize(): any;
  9487. /**
  9488. * Internal only
  9489. * @hidden
  9490. */
  9491. protected _serialize(serializedCondition: any): any;
  9492. }
  9493. /**
  9494. * Defines specific conditional operators as extensions of Condition
  9495. */
  9496. export class ValueCondition extends Condition {
  9497. /** path to specify the property of the target the conditional operator uses */
  9498. propertyPath: string;
  9499. /** the value compared by the conditional operator against the current value of the property */
  9500. value: any;
  9501. /** the conditional operator, default ValueCondition.IsEqual */
  9502. operator: number;
  9503. /**
  9504. * Internal only
  9505. * @hidden
  9506. */
  9507. private static _IsEqual;
  9508. /**
  9509. * Internal only
  9510. * @hidden
  9511. */
  9512. private static _IsDifferent;
  9513. /**
  9514. * Internal only
  9515. * @hidden
  9516. */
  9517. private static _IsGreater;
  9518. /**
  9519. * Internal only
  9520. * @hidden
  9521. */
  9522. private static _IsLesser;
  9523. /**
  9524. * returns the number for IsEqual
  9525. */
  9526. static get IsEqual(): number;
  9527. /**
  9528. * Returns the number for IsDifferent
  9529. */
  9530. static get IsDifferent(): number;
  9531. /**
  9532. * Returns the number for IsGreater
  9533. */
  9534. static get IsGreater(): number;
  9535. /**
  9536. * Returns the number for IsLesser
  9537. */
  9538. static get IsLesser(): number;
  9539. /**
  9540. * Internal only The action manager for the condition
  9541. * @hidden
  9542. */
  9543. _actionManager: ActionManager;
  9544. /**
  9545. * Internal only
  9546. * @hidden
  9547. */
  9548. private _target;
  9549. /**
  9550. * Internal only
  9551. * @hidden
  9552. */
  9553. private _effectiveTarget;
  9554. /**
  9555. * Internal only
  9556. * @hidden
  9557. */
  9558. private _property;
  9559. /**
  9560. * Creates a new ValueCondition
  9561. * @param actionManager manager for the action the condition applies to
  9562. * @param target for the action
  9563. * @param propertyPath path to specify the property of the target the conditional operator uses
  9564. * @param value the value compared by the conditional operator against the current value of the property
  9565. * @param operator the conditional operator, default ValueCondition.IsEqual
  9566. */
  9567. constructor(actionManager: ActionManager, target: any,
  9568. /** path to specify the property of the target the conditional operator uses */
  9569. propertyPath: string,
  9570. /** the value compared by the conditional operator against the current value of the property */
  9571. value: any,
  9572. /** the conditional operator, default ValueCondition.IsEqual */
  9573. operator?: number);
  9574. /**
  9575. * Compares the given value with the property value for the specified conditional operator
  9576. * @returns the result of the comparison
  9577. */
  9578. isValid(): boolean;
  9579. /**
  9580. * Serialize the ValueCondition into a JSON compatible object
  9581. * @returns serialization object
  9582. */
  9583. serialize(): any;
  9584. /**
  9585. * Gets the name of the conditional operator for the ValueCondition
  9586. * @param operator the conditional operator
  9587. * @returns the name
  9588. */
  9589. static GetOperatorName(operator: number): string;
  9590. }
  9591. /**
  9592. * Defines a predicate condition as an extension of Condition
  9593. */
  9594. export class PredicateCondition extends Condition {
  9595. /** defines the predicate function used to validate the condition */
  9596. predicate: () => boolean;
  9597. /**
  9598. * Internal only - manager for action
  9599. * @hidden
  9600. */
  9601. _actionManager: ActionManager;
  9602. /**
  9603. * Creates a new PredicateCondition
  9604. * @param actionManager manager for the action the condition applies to
  9605. * @param predicate defines the predicate function used to validate the condition
  9606. */
  9607. constructor(actionManager: ActionManager,
  9608. /** defines the predicate function used to validate the condition */
  9609. predicate: () => boolean);
  9610. /**
  9611. * @returns the validity of the predicate condition
  9612. */
  9613. isValid(): boolean;
  9614. }
  9615. /**
  9616. * Defines a state condition as an extension of Condition
  9617. */
  9618. export class StateCondition extends Condition {
  9619. /** Value to compare with target state */
  9620. value: string;
  9621. /**
  9622. * Internal only - manager for action
  9623. * @hidden
  9624. */
  9625. _actionManager: ActionManager;
  9626. /**
  9627. * Internal only
  9628. * @hidden
  9629. */
  9630. private _target;
  9631. /**
  9632. * Creates a new StateCondition
  9633. * @param actionManager manager for the action the condition applies to
  9634. * @param target of the condition
  9635. * @param value to compare with target state
  9636. */
  9637. constructor(actionManager: ActionManager, target: any,
  9638. /** Value to compare with target state */
  9639. value: string);
  9640. /**
  9641. * Gets a boolean indicating if the current condition is met
  9642. * @returns the validity of the state
  9643. */
  9644. isValid(): boolean;
  9645. /**
  9646. * Serialize the StateCondition into a JSON compatible object
  9647. * @returns serialization object
  9648. */
  9649. serialize(): any;
  9650. }
  9651. }
  9652. declare module BABYLON {
  9653. /**
  9654. * This defines an action responsible to toggle a boolean once triggered.
  9655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9656. */
  9657. export class SwitchBooleanAction extends Action {
  9658. /**
  9659. * The path to the boolean property in the target object
  9660. */
  9661. propertyPath: string;
  9662. private _target;
  9663. private _effectiveTarget;
  9664. private _property;
  9665. /**
  9666. * Instantiate the action
  9667. * @param triggerOptions defines the trigger options
  9668. * @param target defines the object containing the boolean
  9669. * @param propertyPath defines the path to the boolean property in the target object
  9670. * @param condition defines the trigger related conditions
  9671. */
  9672. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9673. /** @hidden */
  9674. _prepare(): void;
  9675. /**
  9676. * Execute the action toggle the boolean value.
  9677. */
  9678. execute(): void;
  9679. /**
  9680. * Serializes the actions and its related information.
  9681. * @param parent defines the object to serialize in
  9682. * @returns the serialized object
  9683. */
  9684. serialize(parent: any): any;
  9685. }
  9686. /**
  9687. * This defines an action responsible to set a the state field of the target
  9688. * to a desired value once triggered.
  9689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9690. */
  9691. export class SetStateAction extends Action {
  9692. /**
  9693. * The value to store in the state field.
  9694. */
  9695. value: string;
  9696. private _target;
  9697. /**
  9698. * Instantiate the action
  9699. * @param triggerOptions defines the trigger options
  9700. * @param target defines the object containing the state property
  9701. * @param value defines the value to store in the state field
  9702. * @param condition defines the trigger related conditions
  9703. */
  9704. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9705. /**
  9706. * Execute the action and store the value on the target state property.
  9707. */
  9708. execute(): void;
  9709. /**
  9710. * Serializes the actions and its related information.
  9711. * @param parent defines the object to serialize in
  9712. * @returns the serialized object
  9713. */
  9714. serialize(parent: any): any;
  9715. }
  9716. /**
  9717. * This defines an action responsible to set a property of the target
  9718. * to a desired value once triggered.
  9719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9720. */
  9721. export class SetValueAction extends Action {
  9722. /**
  9723. * The path of the property to set in the target.
  9724. */
  9725. propertyPath: string;
  9726. /**
  9727. * The value to set in the property
  9728. */
  9729. value: any;
  9730. private _target;
  9731. private _effectiveTarget;
  9732. private _property;
  9733. /**
  9734. * Instantiate the action
  9735. * @param triggerOptions defines the trigger options
  9736. * @param target defines the object containing the property
  9737. * @param propertyPath defines the path of the property to set in the target
  9738. * @param value defines the value to set in the property
  9739. * @param condition defines the trigger related conditions
  9740. */
  9741. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9742. /** @hidden */
  9743. _prepare(): void;
  9744. /**
  9745. * Execute the action and set the targetted property to the desired value.
  9746. */
  9747. execute(): void;
  9748. /**
  9749. * Serializes the actions and its related information.
  9750. * @param parent defines the object to serialize in
  9751. * @returns the serialized object
  9752. */
  9753. serialize(parent: any): any;
  9754. }
  9755. /**
  9756. * This defines an action responsible to increment the target value
  9757. * to a desired value once triggered.
  9758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9759. */
  9760. export class IncrementValueAction extends Action {
  9761. /**
  9762. * The path of the property to increment in the target.
  9763. */
  9764. propertyPath: string;
  9765. /**
  9766. * The value we should increment the property by.
  9767. */
  9768. value: any;
  9769. private _target;
  9770. private _effectiveTarget;
  9771. private _property;
  9772. /**
  9773. * Instantiate the action
  9774. * @param triggerOptions defines the trigger options
  9775. * @param target defines the object containing the property
  9776. * @param propertyPath defines the path of the property to increment in the target
  9777. * @param value defines the value value we should increment the property by
  9778. * @param condition defines the trigger related conditions
  9779. */
  9780. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9781. /** @hidden */
  9782. _prepare(): void;
  9783. /**
  9784. * Execute the action and increment the target of the value amount.
  9785. */
  9786. execute(): void;
  9787. /**
  9788. * Serializes the actions and its related information.
  9789. * @param parent defines the object to serialize in
  9790. * @returns the serialized object
  9791. */
  9792. serialize(parent: any): any;
  9793. }
  9794. /**
  9795. * This defines an action responsible to start an animation once triggered.
  9796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9797. */
  9798. export class PlayAnimationAction extends Action {
  9799. /**
  9800. * Where the animation should start (animation frame)
  9801. */
  9802. from: number;
  9803. /**
  9804. * Where the animation should stop (animation frame)
  9805. */
  9806. to: number;
  9807. /**
  9808. * Define if the animation should loop or stop after the first play.
  9809. */
  9810. loop?: boolean;
  9811. private _target;
  9812. /**
  9813. * Instantiate the action
  9814. * @param triggerOptions defines the trigger options
  9815. * @param target defines the target animation or animation name
  9816. * @param from defines from where the animation should start (animation frame)
  9817. * @param end defines where the animation should stop (animation frame)
  9818. * @param loop defines if the animation should loop or stop after the first play
  9819. * @param condition defines the trigger related conditions
  9820. */
  9821. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9822. /** @hidden */
  9823. _prepare(): void;
  9824. /**
  9825. * Execute the action and play the animation.
  9826. */
  9827. execute(): void;
  9828. /**
  9829. * Serializes the actions and its related information.
  9830. * @param parent defines the object to serialize in
  9831. * @returns the serialized object
  9832. */
  9833. serialize(parent: any): any;
  9834. }
  9835. /**
  9836. * This defines an action responsible to stop an animation once triggered.
  9837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9838. */
  9839. export class StopAnimationAction extends Action {
  9840. private _target;
  9841. /**
  9842. * Instantiate the action
  9843. * @param triggerOptions defines the trigger options
  9844. * @param target defines the target animation or animation name
  9845. * @param condition defines the trigger related conditions
  9846. */
  9847. constructor(triggerOptions: any, target: any, condition?: Condition);
  9848. /** @hidden */
  9849. _prepare(): void;
  9850. /**
  9851. * Execute the action and stop the animation.
  9852. */
  9853. execute(): void;
  9854. /**
  9855. * Serializes the actions and its related information.
  9856. * @param parent defines the object to serialize in
  9857. * @returns the serialized object
  9858. */
  9859. serialize(parent: any): any;
  9860. }
  9861. /**
  9862. * This defines an action responsible that does nothing once triggered.
  9863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9864. */
  9865. export class DoNothingAction extends Action {
  9866. /**
  9867. * Instantiate the action
  9868. * @param triggerOptions defines the trigger options
  9869. * @param condition defines the trigger related conditions
  9870. */
  9871. constructor(triggerOptions?: any, condition?: Condition);
  9872. /**
  9873. * Execute the action and do nothing.
  9874. */
  9875. execute(): void;
  9876. /**
  9877. * Serializes the actions and its related information.
  9878. * @param parent defines the object to serialize in
  9879. * @returns the serialized object
  9880. */
  9881. serialize(parent: any): any;
  9882. }
  9883. /**
  9884. * This defines an action responsible to trigger several actions once triggered.
  9885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9886. */
  9887. export class CombineAction extends Action {
  9888. /**
  9889. * The list of aggregated animations to run.
  9890. */
  9891. children: Action[];
  9892. /**
  9893. * Instantiate the action
  9894. * @param triggerOptions defines the trigger options
  9895. * @param children defines the list of aggregated animations to run
  9896. * @param condition defines the trigger related conditions
  9897. */
  9898. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9899. /** @hidden */
  9900. _prepare(): void;
  9901. /**
  9902. * Execute the action and executes all the aggregated actions.
  9903. */
  9904. execute(evt: ActionEvent): void;
  9905. /**
  9906. * Serializes the actions and its related information.
  9907. * @param parent defines the object to serialize in
  9908. * @returns the serialized object
  9909. */
  9910. serialize(parent: any): any;
  9911. }
  9912. /**
  9913. * This defines an action responsible to run code (external event) once triggered.
  9914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9915. */
  9916. export class ExecuteCodeAction extends Action {
  9917. /**
  9918. * The callback function to run.
  9919. */
  9920. func: (evt: ActionEvent) => void;
  9921. /**
  9922. * Instantiate the action
  9923. * @param triggerOptions defines the trigger options
  9924. * @param func defines the callback function to run
  9925. * @param condition defines the trigger related conditions
  9926. */
  9927. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  9928. /**
  9929. * Execute the action and run the attached code.
  9930. */
  9931. execute(evt: ActionEvent): void;
  9932. }
  9933. /**
  9934. * This defines an action responsible to set the parent property of the target once triggered.
  9935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9936. */
  9937. export class SetParentAction extends Action {
  9938. private _parent;
  9939. private _target;
  9940. /**
  9941. * Instantiate the action
  9942. * @param triggerOptions defines the trigger options
  9943. * @param target defines the target containing the parent property
  9944. * @param parent defines from where the animation should start (animation frame)
  9945. * @param condition defines the trigger related conditions
  9946. */
  9947. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  9948. /** @hidden */
  9949. _prepare(): void;
  9950. /**
  9951. * Execute the action and set the parent property.
  9952. */
  9953. execute(): void;
  9954. /**
  9955. * Serializes the actions and its related information.
  9956. * @param parent defines the object to serialize in
  9957. * @returns the serialized object
  9958. */
  9959. serialize(parent: any): any;
  9960. }
  9961. }
  9962. declare module BABYLON {
  9963. /**
  9964. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  9965. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  9966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9967. */
  9968. export class ActionManager extends AbstractActionManager {
  9969. /**
  9970. * Nothing
  9971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9972. */
  9973. static readonly NothingTrigger: number;
  9974. /**
  9975. * On pick
  9976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9977. */
  9978. static readonly OnPickTrigger: number;
  9979. /**
  9980. * On left pick
  9981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9982. */
  9983. static readonly OnLeftPickTrigger: number;
  9984. /**
  9985. * On right pick
  9986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9987. */
  9988. static readonly OnRightPickTrigger: number;
  9989. /**
  9990. * On center pick
  9991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9992. */
  9993. static readonly OnCenterPickTrigger: number;
  9994. /**
  9995. * On pick down
  9996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9997. */
  9998. static readonly OnPickDownTrigger: number;
  9999. /**
  10000. * On double pick
  10001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10002. */
  10003. static readonly OnDoublePickTrigger: number;
  10004. /**
  10005. * On pick up
  10006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10007. */
  10008. static readonly OnPickUpTrigger: number;
  10009. /**
  10010. * On pick out.
  10011. * This trigger will only be raised if you also declared a OnPickDown
  10012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10013. */
  10014. static readonly OnPickOutTrigger: number;
  10015. /**
  10016. * On long press
  10017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10018. */
  10019. static readonly OnLongPressTrigger: number;
  10020. /**
  10021. * On pointer over
  10022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10023. */
  10024. static readonly OnPointerOverTrigger: number;
  10025. /**
  10026. * On pointer out
  10027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10028. */
  10029. static readonly OnPointerOutTrigger: number;
  10030. /**
  10031. * On every frame
  10032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10033. */
  10034. static readonly OnEveryFrameTrigger: number;
  10035. /**
  10036. * On intersection enter
  10037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10038. */
  10039. static readonly OnIntersectionEnterTrigger: number;
  10040. /**
  10041. * On intersection exit
  10042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10043. */
  10044. static readonly OnIntersectionExitTrigger: number;
  10045. /**
  10046. * On key down
  10047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10048. */
  10049. static readonly OnKeyDownTrigger: number;
  10050. /**
  10051. * On key up
  10052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10053. */
  10054. static readonly OnKeyUpTrigger: number;
  10055. private _scene;
  10056. /**
  10057. * Creates a new action manager
  10058. * @param scene defines the hosting scene
  10059. */
  10060. constructor(scene: Scene);
  10061. /**
  10062. * Releases all associated resources
  10063. */
  10064. dispose(): void;
  10065. /**
  10066. * Gets hosting scene
  10067. * @returns the hosting scene
  10068. */
  10069. getScene(): Scene;
  10070. /**
  10071. * Does this action manager handles actions of any of the given triggers
  10072. * @param triggers defines the triggers to be tested
  10073. * @return a boolean indicating whether one (or more) of the triggers is handled
  10074. */
  10075. hasSpecificTriggers(triggers: number[]): boolean;
  10076. /**
  10077. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10078. * speed.
  10079. * @param triggerA defines the trigger to be tested
  10080. * @param triggerB defines the trigger to be tested
  10081. * @return a boolean indicating whether one (or more) of the triggers is handled
  10082. */
  10083. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10084. /**
  10085. * Does this action manager handles actions of a given trigger
  10086. * @param trigger defines the trigger to be tested
  10087. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10088. * @return whether the trigger is handled
  10089. */
  10090. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10091. /**
  10092. * Does this action manager has pointer triggers
  10093. */
  10094. get hasPointerTriggers(): boolean;
  10095. /**
  10096. * Does this action manager has pick triggers
  10097. */
  10098. get hasPickTriggers(): boolean;
  10099. /**
  10100. * Registers an action to this action manager
  10101. * @param action defines the action to be registered
  10102. * @return the action amended (prepared) after registration
  10103. */
  10104. registerAction(action: IAction): Nullable<IAction>;
  10105. /**
  10106. * Unregisters an action to this action manager
  10107. * @param action defines the action to be unregistered
  10108. * @return a boolean indicating whether the action has been unregistered
  10109. */
  10110. unregisterAction(action: IAction): Boolean;
  10111. /**
  10112. * Process a specific trigger
  10113. * @param trigger defines the trigger to process
  10114. * @param evt defines the event details to be processed
  10115. */
  10116. processTrigger(trigger: number, evt?: IActionEvent): void;
  10117. /** @hidden */
  10118. _getEffectiveTarget(target: any, propertyPath: string): any;
  10119. /** @hidden */
  10120. _getProperty(propertyPath: string): string;
  10121. /**
  10122. * Serialize this manager to a JSON object
  10123. * @param name defines the property name to store this manager
  10124. * @returns a JSON representation of this manager
  10125. */
  10126. serialize(name: string): any;
  10127. /**
  10128. * Creates a new ActionManager from a JSON data
  10129. * @param parsedActions defines the JSON data to read from
  10130. * @param object defines the hosting mesh
  10131. * @param scene defines the hosting scene
  10132. */
  10133. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10134. /**
  10135. * Get a trigger name by index
  10136. * @param trigger defines the trigger index
  10137. * @returns a trigger name
  10138. */
  10139. static GetTriggerName(trigger: number): string;
  10140. }
  10141. }
  10142. declare module BABYLON {
  10143. /**
  10144. * Class used to represent a sprite
  10145. * @see http://doc.babylonjs.com/babylon101/sprites
  10146. */
  10147. export class Sprite implements IAnimatable {
  10148. /** defines the name */
  10149. name: string;
  10150. /** Gets or sets the current world position */
  10151. position: Vector3;
  10152. /** Gets or sets the main color */
  10153. color: Color4;
  10154. /** Gets or sets the width */
  10155. width: number;
  10156. /** Gets or sets the height */
  10157. height: number;
  10158. /** Gets or sets rotation angle */
  10159. angle: number;
  10160. /** Gets or sets the cell index in the sprite sheet */
  10161. cellIndex: number;
  10162. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10163. cellRef: string;
  10164. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10165. invertU: boolean;
  10166. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10167. invertV: boolean;
  10168. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10169. disposeWhenFinishedAnimating: boolean;
  10170. /** Gets the list of attached animations */
  10171. animations: Nullable<Array<Animation>>;
  10172. /** Gets or sets a boolean indicating if the sprite can be picked */
  10173. isPickable: boolean;
  10174. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10175. useAlphaForPicking: boolean;
  10176. /** @hidden */
  10177. _xOffset: number;
  10178. /** @hidden */
  10179. _yOffset: number;
  10180. /** @hidden */
  10181. _xSize: number;
  10182. /** @hidden */
  10183. _ySize: number;
  10184. /**
  10185. * Gets or sets the associated action manager
  10186. */
  10187. actionManager: Nullable<ActionManager>;
  10188. /**
  10189. * An event triggered when the control has been disposed
  10190. */
  10191. onDisposeObservable: Observable<Sprite>;
  10192. private _animationStarted;
  10193. private _loopAnimation;
  10194. private _fromIndex;
  10195. private _toIndex;
  10196. private _delay;
  10197. private _direction;
  10198. private _manager;
  10199. private _time;
  10200. private _onAnimationEnd;
  10201. /**
  10202. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10203. */
  10204. isVisible: boolean;
  10205. /**
  10206. * Gets or sets the sprite size
  10207. */
  10208. get size(): number;
  10209. set size(value: number);
  10210. /**
  10211. * Returns a boolean indicating if the animation is started
  10212. */
  10213. get animationStarted(): boolean;
  10214. /**
  10215. * Gets or sets the unique id of the sprite
  10216. */
  10217. uniqueId: number;
  10218. /**
  10219. * Gets the manager of this sprite
  10220. */
  10221. get manager(): ISpriteManager;
  10222. /**
  10223. * Creates a new Sprite
  10224. * @param name defines the name
  10225. * @param manager defines the manager
  10226. */
  10227. constructor(
  10228. /** defines the name */
  10229. name: string, manager: ISpriteManager);
  10230. /**
  10231. * Returns the string "Sprite"
  10232. * @returns "Sprite"
  10233. */
  10234. getClassName(): string;
  10235. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10236. get fromIndex(): number;
  10237. set fromIndex(value: number);
  10238. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10239. get toIndex(): number;
  10240. set toIndex(value: number);
  10241. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10242. get loopAnimation(): boolean;
  10243. set loopAnimation(value: boolean);
  10244. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10245. get delay(): number;
  10246. set delay(value: number);
  10247. /**
  10248. * Starts an animation
  10249. * @param from defines the initial key
  10250. * @param to defines the end key
  10251. * @param loop defines if the animation must loop
  10252. * @param delay defines the start delay (in ms)
  10253. * @param onAnimationEnd defines a callback to call when animation ends
  10254. */
  10255. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10256. /** Stops current animation (if any) */
  10257. stopAnimation(): void;
  10258. /** @hidden */
  10259. _animate(deltaTime: number): void;
  10260. /** Release associated resources */
  10261. dispose(): void;
  10262. /**
  10263. * Serializes the sprite to a JSON object
  10264. * @returns the JSON object
  10265. */
  10266. serialize(): any;
  10267. /**
  10268. * Parses a JSON object to create a new sprite
  10269. * @param parsedSprite The JSON object to parse
  10270. * @param manager defines the hosting manager
  10271. * @returns the new sprite
  10272. */
  10273. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10274. }
  10275. }
  10276. declare module BABYLON {
  10277. /**
  10278. * Information about the result of picking within a scene
  10279. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10280. */
  10281. export class PickingInfo {
  10282. /** @hidden */
  10283. _pickingUnavailable: boolean;
  10284. /**
  10285. * If the pick collided with an object
  10286. */
  10287. hit: boolean;
  10288. /**
  10289. * Distance away where the pick collided
  10290. */
  10291. distance: number;
  10292. /**
  10293. * The location of pick collision
  10294. */
  10295. pickedPoint: Nullable<Vector3>;
  10296. /**
  10297. * The mesh corresponding the the pick collision
  10298. */
  10299. pickedMesh: Nullable<AbstractMesh>;
  10300. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10301. bu: number;
  10302. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10303. bv: number;
  10304. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10305. faceId: number;
  10306. /** Id of the the submesh that was picked */
  10307. subMeshId: number;
  10308. /** If a sprite was picked, this will be the sprite the pick collided with */
  10309. pickedSprite: Nullable<Sprite>;
  10310. /**
  10311. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10312. */
  10313. originMesh: Nullable<AbstractMesh>;
  10314. /**
  10315. * The ray that was used to perform the picking.
  10316. */
  10317. ray: Nullable<Ray>;
  10318. /**
  10319. * Gets the normal correspodning to the face the pick collided with
  10320. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10321. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10322. * @returns The normal correspodning to the face the pick collided with
  10323. */
  10324. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10325. /**
  10326. * Gets the texture coordinates of where the pick occured
  10327. * @returns the vector containing the coordnates of the texture
  10328. */
  10329. getTextureCoordinates(): Nullable<Vector2>;
  10330. }
  10331. }
  10332. declare module BABYLON {
  10333. /**
  10334. * Class representing a ray with position and direction
  10335. */
  10336. export class Ray {
  10337. /** origin point */
  10338. origin: Vector3;
  10339. /** direction */
  10340. direction: Vector3;
  10341. /** length of the ray */
  10342. length: number;
  10343. private static readonly TmpVector3;
  10344. private _tmpRay;
  10345. /**
  10346. * Creates a new ray
  10347. * @param origin origin point
  10348. * @param direction direction
  10349. * @param length length of the ray
  10350. */
  10351. constructor(
  10352. /** origin point */
  10353. origin: Vector3,
  10354. /** direction */
  10355. direction: Vector3,
  10356. /** length of the ray */
  10357. length?: number);
  10358. /**
  10359. * Checks if the ray intersects a box
  10360. * This does not account for the ray lenght by design to improve perfs.
  10361. * @param minimum bound of the box
  10362. * @param maximum bound of the box
  10363. * @param intersectionTreshold extra extend to be added to the box in all direction
  10364. * @returns if the box was hit
  10365. */
  10366. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10367. /**
  10368. * Checks if the ray intersects a box
  10369. * This does not account for the ray lenght by design to improve perfs.
  10370. * @param box the bounding box to check
  10371. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10372. * @returns if the box was hit
  10373. */
  10374. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10375. /**
  10376. * If the ray hits a sphere
  10377. * @param sphere the bounding sphere to check
  10378. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10379. * @returns true if it hits the sphere
  10380. */
  10381. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10382. /**
  10383. * If the ray hits a triange
  10384. * @param vertex0 triangle vertex
  10385. * @param vertex1 triangle vertex
  10386. * @param vertex2 triangle vertex
  10387. * @returns intersection information if hit
  10388. */
  10389. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10390. /**
  10391. * Checks if ray intersects a plane
  10392. * @param plane the plane to check
  10393. * @returns the distance away it was hit
  10394. */
  10395. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10396. /**
  10397. * Calculate the intercept of a ray on a given axis
  10398. * @param axis to check 'x' | 'y' | 'z'
  10399. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10400. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10401. */
  10402. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10403. /**
  10404. * Checks if ray intersects a mesh
  10405. * @param mesh the mesh to check
  10406. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10407. * @returns picking info of the intersecton
  10408. */
  10409. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10410. /**
  10411. * Checks if ray intersects a mesh
  10412. * @param meshes the meshes to check
  10413. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10414. * @param results array to store result in
  10415. * @returns Array of picking infos
  10416. */
  10417. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10418. private _comparePickingInfo;
  10419. private static smallnum;
  10420. private static rayl;
  10421. /**
  10422. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10423. * @param sega the first point of the segment to test the intersection against
  10424. * @param segb the second point of the segment to test the intersection against
  10425. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10426. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10427. */
  10428. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10429. /**
  10430. * Update the ray from viewport position
  10431. * @param x position
  10432. * @param y y position
  10433. * @param viewportWidth viewport width
  10434. * @param viewportHeight viewport height
  10435. * @param world world matrix
  10436. * @param view view matrix
  10437. * @param projection projection matrix
  10438. * @returns this ray updated
  10439. */
  10440. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10441. /**
  10442. * Creates a ray with origin and direction of 0,0,0
  10443. * @returns the new ray
  10444. */
  10445. static Zero(): Ray;
  10446. /**
  10447. * Creates a new ray from screen space and viewport
  10448. * @param x position
  10449. * @param y y position
  10450. * @param viewportWidth viewport width
  10451. * @param viewportHeight viewport height
  10452. * @param world world matrix
  10453. * @param view view matrix
  10454. * @param projection projection matrix
  10455. * @returns new ray
  10456. */
  10457. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10458. /**
  10459. * 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
  10460. * transformed to the given world matrix.
  10461. * @param origin The origin point
  10462. * @param end The end point
  10463. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10464. * @returns the new ray
  10465. */
  10466. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10467. /**
  10468. * Transforms a ray by a matrix
  10469. * @param ray ray to transform
  10470. * @param matrix matrix to apply
  10471. * @returns the resulting new ray
  10472. */
  10473. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10474. /**
  10475. * Transforms a ray by a matrix
  10476. * @param ray ray to transform
  10477. * @param matrix matrix to apply
  10478. * @param result ray to store result in
  10479. */
  10480. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10481. /**
  10482. * Unproject a ray from screen space to object space
  10483. * @param sourceX defines the screen space x coordinate to use
  10484. * @param sourceY defines the screen space y coordinate to use
  10485. * @param viewportWidth defines the current width of the viewport
  10486. * @param viewportHeight defines the current height of the viewport
  10487. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10488. * @param view defines the view matrix to use
  10489. * @param projection defines the projection matrix to use
  10490. */
  10491. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10492. }
  10493. /**
  10494. * Type used to define predicate used to select faces when a mesh intersection is detected
  10495. */
  10496. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10497. interface Scene {
  10498. /** @hidden */
  10499. _tempPickingRay: Nullable<Ray>;
  10500. /** @hidden */
  10501. _cachedRayForTransform: Ray;
  10502. /** @hidden */
  10503. _pickWithRayInverseMatrix: Matrix;
  10504. /** @hidden */
  10505. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10506. /** @hidden */
  10507. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10508. }
  10509. }
  10510. declare module BABYLON {
  10511. /**
  10512. * Groups all the scene component constants in one place to ease maintenance.
  10513. * @hidden
  10514. */
  10515. export class SceneComponentConstants {
  10516. static readonly NAME_EFFECTLAYER: string;
  10517. static readonly NAME_LAYER: string;
  10518. static readonly NAME_LENSFLARESYSTEM: string;
  10519. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10520. static readonly NAME_PARTICLESYSTEM: string;
  10521. static readonly NAME_GAMEPAD: string;
  10522. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10523. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10524. static readonly NAME_DEPTHRENDERER: string;
  10525. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10526. static readonly NAME_SPRITE: string;
  10527. static readonly NAME_OUTLINERENDERER: string;
  10528. static readonly NAME_PROCEDURALTEXTURE: string;
  10529. static readonly NAME_SHADOWGENERATOR: string;
  10530. static readonly NAME_OCTREE: string;
  10531. static readonly NAME_PHYSICSENGINE: string;
  10532. static readonly NAME_AUDIO: string;
  10533. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10534. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10535. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10536. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10537. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10538. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10539. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10540. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10541. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10542. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10543. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10544. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10545. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10546. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10547. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10548. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10549. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10550. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10551. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10552. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10553. static readonly STEP_AFTERRENDER_AUDIO: number;
  10554. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10555. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10556. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10557. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10558. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10559. static readonly STEP_POINTERMOVE_SPRITE: number;
  10560. static readonly STEP_POINTERDOWN_SPRITE: number;
  10561. static readonly STEP_POINTERUP_SPRITE: number;
  10562. }
  10563. /**
  10564. * This represents a scene component.
  10565. *
  10566. * This is used to decouple the dependency the scene is having on the different workloads like
  10567. * layers, post processes...
  10568. */
  10569. export interface ISceneComponent {
  10570. /**
  10571. * The name of the component. Each component must have a unique name.
  10572. */
  10573. name: string;
  10574. /**
  10575. * The scene the component belongs to.
  10576. */
  10577. scene: Scene;
  10578. /**
  10579. * Register the component to one instance of a scene.
  10580. */
  10581. register(): void;
  10582. /**
  10583. * Rebuilds the elements related to this component in case of
  10584. * context lost for instance.
  10585. */
  10586. rebuild(): void;
  10587. /**
  10588. * Disposes the component and the associated ressources.
  10589. */
  10590. dispose(): void;
  10591. }
  10592. /**
  10593. * This represents a SERIALIZABLE scene component.
  10594. *
  10595. * This extends Scene Component to add Serialization methods on top.
  10596. */
  10597. export interface ISceneSerializableComponent extends ISceneComponent {
  10598. /**
  10599. * Adds all the elements from the container to the scene
  10600. * @param container the container holding the elements
  10601. */
  10602. addFromContainer(container: AbstractScene): void;
  10603. /**
  10604. * Removes all the elements in the container from the scene
  10605. * @param container contains the elements to remove
  10606. * @param dispose if the removed element should be disposed (default: false)
  10607. */
  10608. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10609. /**
  10610. * Serializes the component data to the specified json object
  10611. * @param serializationObject The object to serialize to
  10612. */
  10613. serialize(serializationObject: any): void;
  10614. }
  10615. /**
  10616. * Strong typing of a Mesh related stage step action
  10617. */
  10618. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10619. /**
  10620. * Strong typing of a Evaluate Sub Mesh related stage step action
  10621. */
  10622. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10623. /**
  10624. * Strong typing of a Active Mesh related stage step action
  10625. */
  10626. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10627. /**
  10628. * Strong typing of a Camera related stage step action
  10629. */
  10630. export type CameraStageAction = (camera: Camera) => void;
  10631. /**
  10632. * Strong typing of a Camera Frame buffer related stage step action
  10633. */
  10634. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10635. /**
  10636. * Strong typing of a Render Target related stage step action
  10637. */
  10638. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10639. /**
  10640. * Strong typing of a RenderingGroup related stage step action
  10641. */
  10642. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10643. /**
  10644. * Strong typing of a Mesh Render related stage step action
  10645. */
  10646. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10647. /**
  10648. * Strong typing of a simple stage step action
  10649. */
  10650. export type SimpleStageAction = () => void;
  10651. /**
  10652. * Strong typing of a render target action.
  10653. */
  10654. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10655. /**
  10656. * Strong typing of a pointer move action.
  10657. */
  10658. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10659. /**
  10660. * Strong typing of a pointer up/down action.
  10661. */
  10662. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10663. /**
  10664. * Representation of a stage in the scene (Basically a list of ordered steps)
  10665. * @hidden
  10666. */
  10667. export class Stage<T extends Function> extends Array<{
  10668. index: number;
  10669. component: ISceneComponent;
  10670. action: T;
  10671. }> {
  10672. /**
  10673. * Hide ctor from the rest of the world.
  10674. * @param items The items to add.
  10675. */
  10676. private constructor();
  10677. /**
  10678. * Creates a new Stage.
  10679. * @returns A new instance of a Stage
  10680. */
  10681. static Create<T extends Function>(): Stage<T>;
  10682. /**
  10683. * Registers a step in an ordered way in the targeted stage.
  10684. * @param index Defines the position to register the step in
  10685. * @param component Defines the component attached to the step
  10686. * @param action Defines the action to launch during the step
  10687. */
  10688. registerStep(index: number, component: ISceneComponent, action: T): void;
  10689. /**
  10690. * Clears all the steps from the stage.
  10691. */
  10692. clear(): void;
  10693. }
  10694. }
  10695. declare module BABYLON {
  10696. interface Scene {
  10697. /** @hidden */
  10698. _pointerOverSprite: Nullable<Sprite>;
  10699. /** @hidden */
  10700. _pickedDownSprite: Nullable<Sprite>;
  10701. /** @hidden */
  10702. _tempSpritePickingRay: Nullable<Ray>;
  10703. /**
  10704. * All of the sprite managers added to this scene
  10705. * @see http://doc.babylonjs.com/babylon101/sprites
  10706. */
  10707. spriteManagers: Array<ISpriteManager>;
  10708. /**
  10709. * An event triggered when sprites rendering is about to start
  10710. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10711. */
  10712. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10713. /**
  10714. * An event triggered when sprites rendering is done
  10715. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10716. */
  10717. onAfterSpritesRenderingObservable: Observable<Scene>;
  10718. /** @hidden */
  10719. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10720. /** Launch a ray to try to pick a sprite in the scene
  10721. * @param x position on screen
  10722. * @param y position on screen
  10723. * @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
  10724. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10725. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10726. * @returns a PickingInfo
  10727. */
  10728. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10729. /** Use the given ray to pick a sprite in the scene
  10730. * @param ray The ray (in world space) to use to pick meshes
  10731. * @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
  10732. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10733. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10734. * @returns a PickingInfo
  10735. */
  10736. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10737. /** @hidden */
  10738. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10739. /** Launch a ray to try to pick sprites in the scene
  10740. * @param x position on screen
  10741. * @param y position on screen
  10742. * @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
  10743. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10744. * @returns a PickingInfo array
  10745. */
  10746. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10747. /** Use the given ray to pick sprites in the scene
  10748. * @param ray The ray (in world space) to use to pick meshes
  10749. * @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
  10750. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10751. * @returns a PickingInfo array
  10752. */
  10753. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10754. /**
  10755. * Force the sprite under the pointer
  10756. * @param sprite defines the sprite to use
  10757. */
  10758. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10759. /**
  10760. * Gets the sprite under the pointer
  10761. * @returns a Sprite or null if no sprite is under the pointer
  10762. */
  10763. getPointerOverSprite(): Nullable<Sprite>;
  10764. }
  10765. /**
  10766. * Defines the sprite scene component responsible to manage sprites
  10767. * in a given scene.
  10768. */
  10769. export class SpriteSceneComponent implements ISceneComponent {
  10770. /**
  10771. * The component name helpfull to identify the component in the list of scene components.
  10772. */
  10773. readonly name: string;
  10774. /**
  10775. * The scene the component belongs to.
  10776. */
  10777. scene: Scene;
  10778. /** @hidden */
  10779. private _spritePredicate;
  10780. /**
  10781. * Creates a new instance of the component for the given scene
  10782. * @param scene Defines the scene to register the component in
  10783. */
  10784. constructor(scene: Scene);
  10785. /**
  10786. * Registers the component in a given scene
  10787. */
  10788. register(): void;
  10789. /**
  10790. * Rebuilds the elements related to this component in case of
  10791. * context lost for instance.
  10792. */
  10793. rebuild(): void;
  10794. /**
  10795. * Disposes the component and the associated ressources.
  10796. */
  10797. dispose(): void;
  10798. private _pickSpriteButKeepRay;
  10799. private _pointerMove;
  10800. private _pointerDown;
  10801. private _pointerUp;
  10802. }
  10803. }
  10804. declare module BABYLON {
  10805. /** @hidden */
  10806. export var fogFragmentDeclaration: {
  10807. name: string;
  10808. shader: string;
  10809. };
  10810. }
  10811. declare module BABYLON {
  10812. /** @hidden */
  10813. export var fogFragment: {
  10814. name: string;
  10815. shader: string;
  10816. };
  10817. }
  10818. declare module BABYLON {
  10819. /** @hidden */
  10820. export var spritesPixelShader: {
  10821. name: string;
  10822. shader: string;
  10823. };
  10824. }
  10825. declare module BABYLON {
  10826. /** @hidden */
  10827. export var fogVertexDeclaration: {
  10828. name: string;
  10829. shader: string;
  10830. };
  10831. }
  10832. declare module BABYLON {
  10833. /** @hidden */
  10834. export var spritesVertexShader: {
  10835. name: string;
  10836. shader: string;
  10837. };
  10838. }
  10839. declare module BABYLON {
  10840. /**
  10841. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10842. */
  10843. export interface ISpriteManager extends IDisposable {
  10844. /**
  10845. * Gets manager's name
  10846. */
  10847. name: string;
  10848. /**
  10849. * Restricts the camera to viewing objects with the same layerMask.
  10850. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10851. */
  10852. layerMask: number;
  10853. /**
  10854. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10855. */
  10856. isPickable: boolean;
  10857. /**
  10858. * Gets the hosting scene
  10859. */
  10860. scene: Scene;
  10861. /**
  10862. * Specifies the rendering group id for this mesh (0 by default)
  10863. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10864. */
  10865. renderingGroupId: number;
  10866. /**
  10867. * Defines the list of sprites managed by the manager.
  10868. */
  10869. sprites: Array<Sprite>;
  10870. /**
  10871. * Gets or sets the spritesheet texture
  10872. */
  10873. texture: Texture;
  10874. /** Defines the default width of a cell in the spritesheet */
  10875. cellWidth: number;
  10876. /** Defines the default height of a cell in the spritesheet */
  10877. cellHeight: number;
  10878. /**
  10879. * Tests the intersection of a sprite with a specific ray.
  10880. * @param ray The ray we are sending to test the collision
  10881. * @param camera The camera space we are sending rays in
  10882. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10883. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10884. * @returns picking info or null.
  10885. */
  10886. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10887. /**
  10888. * Intersects the sprites with a ray
  10889. * @param ray defines the ray to intersect with
  10890. * @param camera defines the current active camera
  10891. * @param predicate defines a predicate used to select candidate sprites
  10892. * @returns null if no hit or a PickingInfo array
  10893. */
  10894. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10895. /**
  10896. * Renders the list of sprites on screen.
  10897. */
  10898. render(): void;
  10899. }
  10900. /**
  10901. * Class used to manage multiple sprites on the same spritesheet
  10902. * @see http://doc.babylonjs.com/babylon101/sprites
  10903. */
  10904. export class SpriteManager implements ISpriteManager {
  10905. /** defines the manager's name */
  10906. name: string;
  10907. /** Define the Url to load snippets */
  10908. static SnippetUrl: string;
  10909. /** Snippet ID if the manager was created from the snippet server */
  10910. snippetId: string;
  10911. /** Gets the list of sprites */
  10912. sprites: Sprite[];
  10913. /** Gets or sets the rendering group id (0 by default) */
  10914. renderingGroupId: number;
  10915. /** Gets or sets camera layer mask */
  10916. layerMask: number;
  10917. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10918. fogEnabled: boolean;
  10919. /** Gets or sets a boolean indicating if the sprites are pickable */
  10920. isPickable: boolean;
  10921. /** Defines the default width of a cell in the spritesheet */
  10922. cellWidth: number;
  10923. /** Defines the default height of a cell in the spritesheet */
  10924. cellHeight: number;
  10925. /** Associative array from JSON sprite data file */
  10926. private _cellData;
  10927. /** Array of sprite names from JSON sprite data file */
  10928. private _spriteMap;
  10929. /** True when packed cell data from JSON file is ready*/
  10930. private _packedAndReady;
  10931. private _textureContent;
  10932. /**
  10933. * An event triggered when the manager is disposed.
  10934. */
  10935. onDisposeObservable: Observable<SpriteManager>;
  10936. private _onDisposeObserver;
  10937. /**
  10938. * Callback called when the manager is disposed
  10939. */
  10940. set onDispose(callback: () => void);
  10941. private _capacity;
  10942. private _fromPacked;
  10943. private _spriteTexture;
  10944. private _epsilon;
  10945. private _scene;
  10946. private _vertexData;
  10947. private _buffer;
  10948. private _vertexBuffers;
  10949. private _indexBuffer;
  10950. private _effectBase;
  10951. private _effectFog;
  10952. /**
  10953. * Gets or sets the unique id of the sprite
  10954. */
  10955. uniqueId: number;
  10956. /**
  10957. * Gets the array of sprites
  10958. */
  10959. get children(): Sprite[];
  10960. /**
  10961. * Gets the hosting scene
  10962. */
  10963. get scene(): Scene;
  10964. /**
  10965. * Gets the capacity of the manager
  10966. */
  10967. get capacity(): number;
  10968. /**
  10969. * Gets or sets the spritesheet texture
  10970. */
  10971. get texture(): Texture;
  10972. set texture(value: Texture);
  10973. private _blendMode;
  10974. /**
  10975. * Blend mode use to render the particle, it can be any of
  10976. * the static Constants.ALPHA_x properties provided in this class.
  10977. * Default value is Constants.ALPHA_COMBINE
  10978. */
  10979. get blendMode(): number;
  10980. set blendMode(blendMode: number);
  10981. /** Disables writing to the depth buffer when rendering the sprites.
  10982. * It can be handy to disable depth writing when using textures without alpha channel
  10983. * and setting some specific blend modes.
  10984. */
  10985. disableDepthWrite: boolean;
  10986. /**
  10987. * Creates a new sprite manager
  10988. * @param name defines the manager's name
  10989. * @param imgUrl defines the sprite sheet url
  10990. * @param capacity defines the maximum allowed number of sprites
  10991. * @param cellSize defines the size of a sprite cell
  10992. * @param scene defines the hosting scene
  10993. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10994. * @param samplingMode defines the smapling mode to use with spritesheet
  10995. * @param fromPacked set to false; do not alter
  10996. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10997. */
  10998. constructor(
  10999. /** defines the manager's name */
  11000. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11001. /**
  11002. * Returns the string "SpriteManager"
  11003. * @returns "SpriteManager"
  11004. */
  11005. getClassName(): string;
  11006. private _makePacked;
  11007. private _appendSpriteVertex;
  11008. private _checkTextureAlpha;
  11009. /**
  11010. * Intersects the sprites with a ray
  11011. * @param ray defines the ray to intersect with
  11012. * @param camera defines the current active camera
  11013. * @param predicate defines a predicate used to select candidate sprites
  11014. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11015. * @returns null if no hit or a PickingInfo
  11016. */
  11017. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11018. /**
  11019. * Intersects the sprites with a ray
  11020. * @param ray defines the ray to intersect with
  11021. * @param camera defines the current active camera
  11022. * @param predicate defines a predicate used to select candidate sprites
  11023. * @returns null if no hit or a PickingInfo array
  11024. */
  11025. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11026. /**
  11027. * Render all child sprites
  11028. */
  11029. render(): void;
  11030. /**
  11031. * Release associated resources
  11032. */
  11033. dispose(): void;
  11034. /**
  11035. * Serializes the sprite manager to a JSON object
  11036. * @param serializeTexture defines if the texture must be serialized as well
  11037. * @returns the JSON object
  11038. */
  11039. serialize(serializeTexture?: boolean): any;
  11040. /**
  11041. * Parses a JSON object to create a new sprite manager.
  11042. * @param parsedManager The JSON object to parse
  11043. * @param scene The scene to create the sprite managerin
  11044. * @param rootUrl The root url to use to load external dependencies like texture
  11045. * @returns the new sprite manager
  11046. */
  11047. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11048. /**
  11049. * Creates a sprite manager from a snippet saved in a remote file
  11050. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11051. * @param url defines the url to load from
  11052. * @param scene defines the hosting scene
  11053. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11054. * @returns a promise that will resolve to the new sprite manager
  11055. */
  11056. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11057. /**
  11058. * Creates a sprite manager from a snippet saved by the sprite editor
  11059. * @param snippetId defines the snippet to load
  11060. * @param scene defines the hosting scene
  11061. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11062. * @returns a promise that will resolve to the new sprite manager
  11063. */
  11064. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11065. }
  11066. }
  11067. declare module BABYLON {
  11068. /** Interface used by value gradients (color, factor, ...) */
  11069. export interface IValueGradient {
  11070. /**
  11071. * Gets or sets the gradient value (between 0 and 1)
  11072. */
  11073. gradient: number;
  11074. }
  11075. /** Class used to store color4 gradient */
  11076. export class ColorGradient implements IValueGradient {
  11077. /**
  11078. * Gets or sets the gradient value (between 0 and 1)
  11079. */
  11080. gradient: number;
  11081. /**
  11082. * Gets or sets first associated color
  11083. */
  11084. color1: Color4;
  11085. /**
  11086. * Gets or sets second associated color
  11087. */
  11088. color2?: Color4 | undefined;
  11089. /**
  11090. * Creates a new color4 gradient
  11091. * @param gradient gets or sets the gradient value (between 0 and 1)
  11092. * @param color1 gets or sets first associated color
  11093. * @param color2 gets or sets first second color
  11094. */
  11095. constructor(
  11096. /**
  11097. * Gets or sets the gradient value (between 0 and 1)
  11098. */
  11099. gradient: number,
  11100. /**
  11101. * Gets or sets first associated color
  11102. */
  11103. color1: Color4,
  11104. /**
  11105. * Gets or sets second associated color
  11106. */
  11107. color2?: Color4 | undefined);
  11108. /**
  11109. * Will get a color picked randomly between color1 and color2.
  11110. * If color2 is undefined then color1 will be used
  11111. * @param result defines the target Color4 to store the result in
  11112. */
  11113. getColorToRef(result: Color4): void;
  11114. }
  11115. /** Class used to store color 3 gradient */
  11116. export class Color3Gradient implements IValueGradient {
  11117. /**
  11118. * Gets or sets the gradient value (between 0 and 1)
  11119. */
  11120. gradient: number;
  11121. /**
  11122. * Gets or sets the associated color
  11123. */
  11124. color: Color3;
  11125. /**
  11126. * Creates a new color3 gradient
  11127. * @param gradient gets or sets the gradient value (between 0 and 1)
  11128. * @param color gets or sets associated color
  11129. */
  11130. constructor(
  11131. /**
  11132. * Gets or sets the gradient value (between 0 and 1)
  11133. */
  11134. gradient: number,
  11135. /**
  11136. * Gets or sets the associated color
  11137. */
  11138. color: Color3);
  11139. }
  11140. /** Class used to store factor gradient */
  11141. export class FactorGradient implements IValueGradient {
  11142. /**
  11143. * Gets or sets the gradient value (between 0 and 1)
  11144. */
  11145. gradient: number;
  11146. /**
  11147. * Gets or sets first associated factor
  11148. */
  11149. factor1: number;
  11150. /**
  11151. * Gets or sets second associated factor
  11152. */
  11153. factor2?: number | undefined;
  11154. /**
  11155. * Creates a new factor gradient
  11156. * @param gradient gets or sets the gradient value (between 0 and 1)
  11157. * @param factor1 gets or sets first associated factor
  11158. * @param factor2 gets or sets second associated factor
  11159. */
  11160. constructor(
  11161. /**
  11162. * Gets or sets the gradient value (between 0 and 1)
  11163. */
  11164. gradient: number,
  11165. /**
  11166. * Gets or sets first associated factor
  11167. */
  11168. factor1: number,
  11169. /**
  11170. * Gets or sets second associated factor
  11171. */
  11172. factor2?: number | undefined);
  11173. /**
  11174. * Will get a number picked randomly between factor1 and factor2.
  11175. * If factor2 is undefined then factor1 will be used
  11176. * @returns the picked number
  11177. */
  11178. getFactor(): number;
  11179. }
  11180. /**
  11181. * Helper used to simplify some generic gradient tasks
  11182. */
  11183. export class GradientHelper {
  11184. /**
  11185. * Gets the current gradient from an array of IValueGradient
  11186. * @param ratio defines the current ratio to get
  11187. * @param gradients defines the array of IValueGradient
  11188. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11189. */
  11190. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11191. }
  11192. }
  11193. declare module BABYLON {
  11194. interface ThinEngine {
  11195. /**
  11196. * Creates a dynamic texture
  11197. * @param width defines the width of the texture
  11198. * @param height defines the height of the texture
  11199. * @param generateMipMaps defines if the engine should generate the mip levels
  11200. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11201. * @returns the dynamic texture inside an InternalTexture
  11202. */
  11203. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11204. /**
  11205. * Update the content of a dynamic texture
  11206. * @param texture defines the texture to update
  11207. * @param canvas defines the canvas containing the source
  11208. * @param invertY defines if data must be stored with Y axis inverted
  11209. * @param premulAlpha defines if alpha is stored as premultiplied
  11210. * @param format defines the format of the data
  11211. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11212. */
  11213. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11214. }
  11215. }
  11216. declare module BABYLON {
  11217. /**
  11218. * Helper class used to generate a canvas to manipulate images
  11219. */
  11220. export class CanvasGenerator {
  11221. /**
  11222. * Create a new canvas (or offscreen canvas depending on the context)
  11223. * @param width defines the expected width
  11224. * @param height defines the expected height
  11225. * @return a new canvas or offscreen canvas
  11226. */
  11227. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11228. }
  11229. }
  11230. declare module BABYLON {
  11231. /**
  11232. * A class extending Texture allowing drawing on a texture
  11233. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11234. */
  11235. export class DynamicTexture extends Texture {
  11236. private _generateMipMaps;
  11237. private _canvas;
  11238. private _context;
  11239. /**
  11240. * Creates a DynamicTexture
  11241. * @param name defines the name of the texture
  11242. * @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
  11243. * @param scene defines the scene where you want the texture
  11244. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11245. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11246. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11247. */
  11248. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11249. /**
  11250. * Get the current class name of the texture useful for serialization or dynamic coding.
  11251. * @returns "DynamicTexture"
  11252. */
  11253. getClassName(): string;
  11254. /**
  11255. * Gets the current state of canRescale
  11256. */
  11257. get canRescale(): boolean;
  11258. private _recreate;
  11259. /**
  11260. * Scales the texture
  11261. * @param ratio the scale factor to apply to both width and height
  11262. */
  11263. scale(ratio: number): void;
  11264. /**
  11265. * Resizes the texture
  11266. * @param width the new width
  11267. * @param height the new height
  11268. */
  11269. scaleTo(width: number, height: number): void;
  11270. /**
  11271. * Gets the context of the canvas used by the texture
  11272. * @returns the canvas context of the dynamic texture
  11273. */
  11274. getContext(): CanvasRenderingContext2D;
  11275. /**
  11276. * Clears the texture
  11277. */
  11278. clear(): void;
  11279. /**
  11280. * Updates the texture
  11281. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11282. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11283. */
  11284. update(invertY?: boolean, premulAlpha?: boolean): void;
  11285. /**
  11286. * Draws text onto the texture
  11287. * @param text defines the text to be drawn
  11288. * @param x defines the placement of the text from the left
  11289. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11290. * @param font defines the font to be used with font-style, font-size, font-name
  11291. * @param color defines the color used for the text
  11292. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11293. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11294. * @param update defines whether texture is immediately update (default is true)
  11295. */
  11296. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11297. /**
  11298. * Clones the texture
  11299. * @returns the clone of the texture.
  11300. */
  11301. clone(): DynamicTexture;
  11302. /**
  11303. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11304. * @returns a serialized dynamic texture object
  11305. */
  11306. serialize(): any;
  11307. /** @hidden */
  11308. _rebuild(): void;
  11309. }
  11310. }
  11311. declare module BABYLON {
  11312. interface ThinEngine {
  11313. /**
  11314. * Creates a raw texture
  11315. * @param data defines the data to store in the texture
  11316. * @param width defines the width of the texture
  11317. * @param height defines the height of the texture
  11318. * @param format defines the format of the data
  11319. * @param generateMipMaps defines if the engine should generate the mip levels
  11320. * @param invertY defines if data must be stored with Y axis inverted
  11321. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11322. * @param compression defines the compression used (null by default)
  11323. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11324. * @returns the raw texture inside an InternalTexture
  11325. */
  11326. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11327. /**
  11328. * Update a raw texture
  11329. * @param texture defines the texture to update
  11330. * @param data defines the data to store in the texture
  11331. * @param format defines the format of the data
  11332. * @param invertY defines if data must be stored with Y axis inverted
  11333. */
  11334. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11335. /**
  11336. * Update a raw texture
  11337. * @param texture defines the texture to update
  11338. * @param data defines the data to store in the texture
  11339. * @param format defines the format of the data
  11340. * @param invertY defines if data must be stored with Y axis inverted
  11341. * @param compression defines the compression used (null by default)
  11342. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11343. */
  11344. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11345. /**
  11346. * Creates a new raw cube texture
  11347. * @param data defines the array of data to use to create each face
  11348. * @param size defines the size of the textures
  11349. * @param format defines the format of the data
  11350. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11351. * @param generateMipMaps defines if the engine should generate the mip levels
  11352. * @param invertY defines if data must be stored with Y axis inverted
  11353. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11354. * @param compression defines the compression used (null by default)
  11355. * @returns the cube texture as an InternalTexture
  11356. */
  11357. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11358. /**
  11359. * Update a raw cube texture
  11360. * @param texture defines the texture to udpdate
  11361. * @param data defines the data to store
  11362. * @param format defines the data format
  11363. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11364. * @param invertY defines if data must be stored with Y axis inverted
  11365. */
  11366. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11367. /**
  11368. * Update a raw cube texture
  11369. * @param texture defines the texture to udpdate
  11370. * @param data defines the data to store
  11371. * @param format defines the data format
  11372. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11373. * @param invertY defines if data must be stored with Y axis inverted
  11374. * @param compression defines the compression used (null by default)
  11375. */
  11376. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11377. /**
  11378. * Update a raw cube texture
  11379. * @param texture defines the texture to udpdate
  11380. * @param data defines the data to store
  11381. * @param format defines the data format
  11382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11383. * @param invertY defines if data must be stored with Y axis inverted
  11384. * @param compression defines the compression used (null by default)
  11385. * @param level defines which level of the texture to update
  11386. */
  11387. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11388. /**
  11389. * Creates a new raw cube texture from a specified url
  11390. * @param url defines the url where the data is located
  11391. * @param scene defines the current scene
  11392. * @param size defines the size of the textures
  11393. * @param format defines the format of the data
  11394. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11395. * @param noMipmap defines if the engine should avoid generating the mip levels
  11396. * @param callback defines a callback used to extract texture data from loaded data
  11397. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11398. * @param onLoad defines a callback called when texture is loaded
  11399. * @param onError defines a callback called if there is an error
  11400. * @returns the cube texture as an InternalTexture
  11401. */
  11402. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  11403. /**
  11404. * Creates a new raw cube texture from a specified url
  11405. * @param url defines the url where the data is located
  11406. * @param scene defines the current scene
  11407. * @param size defines the size of the textures
  11408. * @param format defines the format of the data
  11409. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11410. * @param noMipmap defines if the engine should avoid generating the mip levels
  11411. * @param callback defines a callback used to extract texture data from loaded data
  11412. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11413. * @param onLoad defines a callback called when texture is loaded
  11414. * @param onError defines a callback called if there is an error
  11415. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11416. * @param invertY defines if data must be stored with Y axis inverted
  11417. * @returns the cube texture as an InternalTexture
  11418. */
  11419. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  11420. /**
  11421. * Creates a new raw 3D texture
  11422. * @param data defines the data used to create the texture
  11423. * @param width defines the width of the texture
  11424. * @param height defines the height of the texture
  11425. * @param depth defines the depth of the texture
  11426. * @param format defines the format of the texture
  11427. * @param generateMipMaps defines if the engine must generate mip levels
  11428. * @param invertY defines if data must be stored with Y axis inverted
  11429. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11430. * @param compression defines the compressed used (can be null)
  11431. * @param textureType defines the compressed used (can be null)
  11432. * @returns a new raw 3D texture (stored in an InternalTexture)
  11433. */
  11434. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11435. /**
  11436. * Update a raw 3D texture
  11437. * @param texture defines the texture to update
  11438. * @param data defines the data to store
  11439. * @param format defines the data format
  11440. * @param invertY defines if data must be stored with Y axis inverted
  11441. */
  11442. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11443. /**
  11444. * Update a raw 3D texture
  11445. * @param texture defines the texture to update
  11446. * @param data defines the data to store
  11447. * @param format defines the data format
  11448. * @param invertY defines if data must be stored with Y axis inverted
  11449. * @param compression defines the used compression (can be null)
  11450. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11451. */
  11452. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11453. /**
  11454. * Creates a new raw 2D array texture
  11455. * @param data defines the data used to create the texture
  11456. * @param width defines the width of the texture
  11457. * @param height defines the height of the texture
  11458. * @param depth defines the number of layers of the texture
  11459. * @param format defines the format of the texture
  11460. * @param generateMipMaps defines if the engine must generate mip levels
  11461. * @param invertY defines if data must be stored with Y axis inverted
  11462. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11463. * @param compression defines the compressed used (can be null)
  11464. * @param textureType defines the compressed used (can be null)
  11465. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11466. */
  11467. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11468. /**
  11469. * Update a raw 2D array texture
  11470. * @param texture defines the texture to update
  11471. * @param data defines the data to store
  11472. * @param format defines the data format
  11473. * @param invertY defines if data must be stored with Y axis inverted
  11474. */
  11475. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11476. /**
  11477. * Update a raw 2D array texture
  11478. * @param texture defines the texture to update
  11479. * @param data defines the data to store
  11480. * @param format defines the data format
  11481. * @param invertY defines if data must be stored with Y axis inverted
  11482. * @param compression defines the used compression (can be null)
  11483. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11484. */
  11485. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11486. }
  11487. }
  11488. declare module BABYLON {
  11489. /**
  11490. * Raw texture can help creating a texture directly from an array of data.
  11491. * This can be super useful if you either get the data from an uncompressed source or
  11492. * if you wish to create your texture pixel by pixel.
  11493. */
  11494. export class RawTexture extends Texture {
  11495. /**
  11496. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11497. */
  11498. format: number;
  11499. /**
  11500. * Instantiates a new RawTexture.
  11501. * Raw texture can help creating a texture directly from an array of data.
  11502. * This can be super useful if you either get the data from an uncompressed source or
  11503. * if you wish to create your texture pixel by pixel.
  11504. * @param data define the array of data to use to create the texture
  11505. * @param width define the width of the texture
  11506. * @param height define the height of the texture
  11507. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11508. * @param scene define the scene the texture belongs to
  11509. * @param generateMipMaps define whether mip maps should be generated or not
  11510. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11511. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11512. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11513. */
  11514. constructor(data: ArrayBufferView, width: number, height: number,
  11515. /**
  11516. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11517. */
  11518. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11519. /**
  11520. * Updates the texture underlying data.
  11521. * @param data Define the new data of the texture
  11522. */
  11523. update(data: ArrayBufferView): void;
  11524. /**
  11525. * Creates a luminance texture from some data.
  11526. * @param data Define the texture data
  11527. * @param width Define the width of the texture
  11528. * @param height Define the height of the texture
  11529. * @param scene Define the scene the texture belongs to
  11530. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11531. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11532. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11533. * @returns the luminance texture
  11534. */
  11535. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11536. /**
  11537. * Creates a luminance alpha texture from some data.
  11538. * @param data Define the texture data
  11539. * @param width Define the width of the texture
  11540. * @param height Define the height of the texture
  11541. * @param scene Define the scene the texture belongs to
  11542. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11543. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11544. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11545. * @returns the luminance alpha texture
  11546. */
  11547. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11548. /**
  11549. * Creates an alpha texture from some data.
  11550. * @param data Define the texture data
  11551. * @param width Define the width of the texture
  11552. * @param height Define the height of the texture
  11553. * @param scene Define the scene the texture belongs to
  11554. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11555. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11556. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11557. * @returns the alpha texture
  11558. */
  11559. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11560. /**
  11561. * Creates a RGB texture from some data.
  11562. * @param data Define the texture data
  11563. * @param width Define the width of the texture
  11564. * @param height Define the height of the texture
  11565. * @param scene Define the scene the texture belongs to
  11566. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11567. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11568. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11569. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11570. * @returns the RGB alpha texture
  11571. */
  11572. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11573. /**
  11574. * Creates a RGBA texture from some data.
  11575. * @param data Define the texture data
  11576. * @param width Define the width of the texture
  11577. * @param height Define the height of the texture
  11578. * @param scene Define the scene the texture belongs to
  11579. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11580. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11581. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11582. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11583. * @returns the RGBA texture
  11584. */
  11585. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11586. /**
  11587. * Creates a R texture from some data.
  11588. * @param data Define the texture data
  11589. * @param width Define the width of the texture
  11590. * @param height Define the height of the texture
  11591. * @param scene Define the scene the texture belongs to
  11592. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11593. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11594. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11595. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11596. * @returns the R texture
  11597. */
  11598. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11599. }
  11600. }
  11601. declare module BABYLON {
  11602. interface AbstractScene {
  11603. /**
  11604. * The list of procedural textures added to the scene
  11605. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11606. */
  11607. proceduralTextures: Array<ProceduralTexture>;
  11608. }
  11609. /**
  11610. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11611. * in a given scene.
  11612. */
  11613. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11614. /**
  11615. * The component name helpfull to identify the component in the list of scene components.
  11616. */
  11617. readonly name: string;
  11618. /**
  11619. * The scene the component belongs to.
  11620. */
  11621. scene: Scene;
  11622. /**
  11623. * Creates a new instance of the component for the given scene
  11624. * @param scene Defines the scene to register the component in
  11625. */
  11626. constructor(scene: Scene);
  11627. /**
  11628. * Registers the component in a given scene
  11629. */
  11630. register(): void;
  11631. /**
  11632. * Rebuilds the elements related to this component in case of
  11633. * context lost for instance.
  11634. */
  11635. rebuild(): void;
  11636. /**
  11637. * Disposes the component and the associated ressources.
  11638. */
  11639. dispose(): void;
  11640. private _beforeClear;
  11641. }
  11642. }
  11643. declare module BABYLON {
  11644. interface ThinEngine {
  11645. /**
  11646. * Creates a new render target cube texture
  11647. * @param size defines the size of the texture
  11648. * @param options defines the options used to create the texture
  11649. * @returns a new render target cube texture stored in an InternalTexture
  11650. */
  11651. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11652. }
  11653. }
  11654. declare module BABYLON {
  11655. /** @hidden */
  11656. export var proceduralVertexShader: {
  11657. name: string;
  11658. shader: string;
  11659. };
  11660. }
  11661. declare module BABYLON {
  11662. /**
  11663. * 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.
  11664. * This is the base class of any Procedural texture and contains most of the shareable code.
  11665. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11666. */
  11667. export class ProceduralTexture extends Texture {
  11668. isCube: boolean;
  11669. /**
  11670. * Define if the texture is enabled or not (disabled texture will not render)
  11671. */
  11672. isEnabled: boolean;
  11673. /**
  11674. * Define if the texture must be cleared before rendering (default is true)
  11675. */
  11676. autoClear: boolean;
  11677. /**
  11678. * Callback called when the texture is generated
  11679. */
  11680. onGenerated: () => void;
  11681. /**
  11682. * Event raised when the texture is generated
  11683. */
  11684. onGeneratedObservable: Observable<ProceduralTexture>;
  11685. /** @hidden */
  11686. _generateMipMaps: boolean;
  11687. /** @hidden **/
  11688. _effect: Effect;
  11689. /** @hidden */
  11690. _textures: {
  11691. [key: string]: Texture;
  11692. };
  11693. /** @hidden */
  11694. protected _fallbackTexture: Nullable<Texture>;
  11695. private _size;
  11696. private _currentRefreshId;
  11697. private _frameId;
  11698. private _refreshRate;
  11699. private _vertexBuffers;
  11700. private _indexBuffer;
  11701. private _uniforms;
  11702. private _samplers;
  11703. private _fragment;
  11704. private _floats;
  11705. private _ints;
  11706. private _floatsArrays;
  11707. private _colors3;
  11708. private _colors4;
  11709. private _vectors2;
  11710. private _vectors3;
  11711. private _matrices;
  11712. private _fallbackTextureUsed;
  11713. private _fullEngine;
  11714. private _cachedDefines;
  11715. private _contentUpdateId;
  11716. private _contentData;
  11717. /**
  11718. * Instantiates a new procedural texture.
  11719. * 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.
  11720. * This is the base class of any Procedural texture and contains most of the shareable code.
  11721. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11722. * @param name Define the name of the texture
  11723. * @param size Define the size of the texture to create
  11724. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11725. * @param scene Define the scene the texture belongs to
  11726. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11727. * @param generateMipMaps Define if the texture should creates mip maps or not
  11728. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11729. */
  11730. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11731. /**
  11732. * The effect that is created when initializing the post process.
  11733. * @returns The created effect corresponding the the postprocess.
  11734. */
  11735. getEffect(): Effect;
  11736. /**
  11737. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11738. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11739. */
  11740. getContent(): Nullable<ArrayBufferView>;
  11741. private _createIndexBuffer;
  11742. /** @hidden */
  11743. _rebuild(): void;
  11744. /**
  11745. * Resets the texture in order to recreate its associated resources.
  11746. * This can be called in case of context loss
  11747. */
  11748. reset(): void;
  11749. protected _getDefines(): string;
  11750. /**
  11751. * Is the texture ready to be used ? (rendered at least once)
  11752. * @returns true if ready, otherwise, false.
  11753. */
  11754. isReady(): boolean;
  11755. /**
  11756. * Resets the refresh counter of the texture and start bak from scratch.
  11757. * Could be useful to regenerate the texture if it is setup to render only once.
  11758. */
  11759. resetRefreshCounter(): void;
  11760. /**
  11761. * Set the fragment shader to use in order to render the texture.
  11762. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11763. */
  11764. setFragment(fragment: any): void;
  11765. /**
  11766. * Define the refresh rate of the texture or the rendering frequency.
  11767. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11768. */
  11769. get refreshRate(): number;
  11770. set refreshRate(value: number);
  11771. /** @hidden */
  11772. _shouldRender(): boolean;
  11773. /**
  11774. * Get the size the texture is rendering at.
  11775. * @returns the size (texture is always squared)
  11776. */
  11777. getRenderSize(): number;
  11778. /**
  11779. * Resize the texture to new value.
  11780. * @param size Define the new size the texture should have
  11781. * @param generateMipMaps Define whether the new texture should create mip maps
  11782. */
  11783. resize(size: number, generateMipMaps: boolean): void;
  11784. private _checkUniform;
  11785. /**
  11786. * Set a texture in the shader program used to render.
  11787. * @param name Define the name of the uniform samplers as defined in the shader
  11788. * @param texture Define the texture to bind to this sampler
  11789. * @return the texture itself allowing "fluent" like uniform updates
  11790. */
  11791. setTexture(name: string, texture: Texture): ProceduralTexture;
  11792. /**
  11793. * Set a float in the shader.
  11794. * @param name Define the name of the uniform as defined in the shader
  11795. * @param value Define the value to give to the uniform
  11796. * @return the texture itself allowing "fluent" like uniform updates
  11797. */
  11798. setFloat(name: string, value: number): ProceduralTexture;
  11799. /**
  11800. * Set a int in the shader.
  11801. * @param name Define the name of the uniform as defined in the shader
  11802. * @param value Define the value to give to the uniform
  11803. * @return the texture itself allowing "fluent" like uniform updates
  11804. */
  11805. setInt(name: string, value: number): ProceduralTexture;
  11806. /**
  11807. * Set an array of floats in the shader.
  11808. * @param name Define the name of the uniform as defined in the shader
  11809. * @param value Define the value to give to the uniform
  11810. * @return the texture itself allowing "fluent" like uniform updates
  11811. */
  11812. setFloats(name: string, value: number[]): ProceduralTexture;
  11813. /**
  11814. * Set a vec3 in the shader from a Color3.
  11815. * @param name Define the name of the uniform as defined in the shader
  11816. * @param value Define the value to give to the uniform
  11817. * @return the texture itself allowing "fluent" like uniform updates
  11818. */
  11819. setColor3(name: string, value: Color3): ProceduralTexture;
  11820. /**
  11821. * Set a vec4 in the shader from a Color4.
  11822. * @param name Define the name of the uniform as defined in the shader
  11823. * @param value Define the value to give to the uniform
  11824. * @return the texture itself allowing "fluent" like uniform updates
  11825. */
  11826. setColor4(name: string, value: Color4): ProceduralTexture;
  11827. /**
  11828. * Set a vec2 in the shader from a Vector2.
  11829. * @param name Define the name of the uniform as defined in the shader
  11830. * @param value Define the value to give to the uniform
  11831. * @return the texture itself allowing "fluent" like uniform updates
  11832. */
  11833. setVector2(name: string, value: Vector2): ProceduralTexture;
  11834. /**
  11835. * Set a vec3 in the shader from a Vector3.
  11836. * @param name Define the name of the uniform as defined in the shader
  11837. * @param value Define the value to give to the uniform
  11838. * @return the texture itself allowing "fluent" like uniform updates
  11839. */
  11840. setVector3(name: string, value: Vector3): ProceduralTexture;
  11841. /**
  11842. * Set a mat4 in the shader from a MAtrix.
  11843. * @param name Define the name of the uniform as defined in the shader
  11844. * @param value Define the value to give to the uniform
  11845. * @return the texture itself allowing "fluent" like uniform updates
  11846. */
  11847. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11848. /**
  11849. * Render the texture to its associated render target.
  11850. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11851. */
  11852. render(useCameraPostProcess?: boolean): void;
  11853. /**
  11854. * Clone the texture.
  11855. * @returns the cloned texture
  11856. */
  11857. clone(): ProceduralTexture;
  11858. /**
  11859. * Dispose the texture and release its asoociated resources.
  11860. */
  11861. dispose(): void;
  11862. }
  11863. }
  11864. declare module BABYLON {
  11865. /**
  11866. * This represents the base class for particle system in Babylon.
  11867. * 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.
  11868. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11869. * @example https://doc.babylonjs.com/babylon101/particles
  11870. */
  11871. export class BaseParticleSystem {
  11872. /**
  11873. * Source color is added to the destination color without alpha affecting the result
  11874. */
  11875. static BLENDMODE_ONEONE: number;
  11876. /**
  11877. * Blend current color and particle color using particle’s alpha
  11878. */
  11879. static BLENDMODE_STANDARD: number;
  11880. /**
  11881. * Add current color and particle color multiplied by particle’s alpha
  11882. */
  11883. static BLENDMODE_ADD: number;
  11884. /**
  11885. * Multiply current color with particle color
  11886. */
  11887. static BLENDMODE_MULTIPLY: number;
  11888. /**
  11889. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11890. */
  11891. static BLENDMODE_MULTIPLYADD: number;
  11892. /**
  11893. * List of animations used by the particle system.
  11894. */
  11895. animations: Animation[];
  11896. /**
  11897. * Gets or sets the unique id of the particle system
  11898. */
  11899. uniqueId: number;
  11900. /**
  11901. * The id of the Particle system.
  11902. */
  11903. id: string;
  11904. /**
  11905. * The friendly name of the Particle system.
  11906. */
  11907. name: string;
  11908. /**
  11909. * Snippet ID if the particle system was created from the snippet server
  11910. */
  11911. snippetId: string;
  11912. /**
  11913. * The rendering group used by the Particle system to chose when to render.
  11914. */
  11915. renderingGroupId: number;
  11916. /**
  11917. * The emitter represents the Mesh or position we are attaching the particle system to.
  11918. */
  11919. emitter: Nullable<AbstractMesh | Vector3>;
  11920. /**
  11921. * The maximum number of particles to emit per frame
  11922. */
  11923. emitRate: number;
  11924. /**
  11925. * If you want to launch only a few particles at once, that can be done, as well.
  11926. */
  11927. manualEmitCount: number;
  11928. /**
  11929. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11930. */
  11931. updateSpeed: number;
  11932. /**
  11933. * The amount of time the particle system is running (depends of the overall update speed).
  11934. */
  11935. targetStopDuration: number;
  11936. /**
  11937. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11938. */
  11939. disposeOnStop: boolean;
  11940. /**
  11941. * Minimum power of emitting particles.
  11942. */
  11943. minEmitPower: number;
  11944. /**
  11945. * Maximum power of emitting particles.
  11946. */
  11947. maxEmitPower: number;
  11948. /**
  11949. * Minimum life time of emitting particles.
  11950. */
  11951. minLifeTime: number;
  11952. /**
  11953. * Maximum life time of emitting particles.
  11954. */
  11955. maxLifeTime: number;
  11956. /**
  11957. * Minimum Size of emitting particles.
  11958. */
  11959. minSize: number;
  11960. /**
  11961. * Maximum Size of emitting particles.
  11962. */
  11963. maxSize: number;
  11964. /**
  11965. * Minimum scale of emitting particles on X axis.
  11966. */
  11967. minScaleX: number;
  11968. /**
  11969. * Maximum scale of emitting particles on X axis.
  11970. */
  11971. maxScaleX: number;
  11972. /**
  11973. * Minimum scale of emitting particles on Y axis.
  11974. */
  11975. minScaleY: number;
  11976. /**
  11977. * Maximum scale of emitting particles on Y axis.
  11978. */
  11979. maxScaleY: number;
  11980. /**
  11981. * Gets or sets the minimal initial rotation in radians.
  11982. */
  11983. minInitialRotation: number;
  11984. /**
  11985. * Gets or sets the maximal initial rotation in radians.
  11986. */
  11987. maxInitialRotation: number;
  11988. /**
  11989. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11990. */
  11991. minAngularSpeed: number;
  11992. /**
  11993. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11994. */
  11995. maxAngularSpeed: number;
  11996. /**
  11997. * The texture used to render each particle. (this can be a spritesheet)
  11998. */
  11999. particleTexture: Nullable<Texture>;
  12000. /**
  12001. * The layer mask we are rendering the particles through.
  12002. */
  12003. layerMask: number;
  12004. /**
  12005. * This can help using your own shader to render the particle system.
  12006. * The according effect will be created
  12007. */
  12008. customShader: any;
  12009. /**
  12010. * By default particle system starts as soon as they are created. This prevents the
  12011. * automatic start to happen and let you decide when to start emitting particles.
  12012. */
  12013. preventAutoStart: boolean;
  12014. private _noiseTexture;
  12015. /**
  12016. * Gets or sets a texture used to add random noise to particle positions
  12017. */
  12018. get noiseTexture(): Nullable<ProceduralTexture>;
  12019. set noiseTexture(value: Nullable<ProceduralTexture>);
  12020. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12021. noiseStrength: Vector3;
  12022. /**
  12023. * Callback triggered when the particle animation is ending.
  12024. */
  12025. onAnimationEnd: Nullable<() => void>;
  12026. /**
  12027. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12028. */
  12029. blendMode: number;
  12030. /**
  12031. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12032. * to override the particles.
  12033. */
  12034. forceDepthWrite: boolean;
  12035. /** 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 */
  12036. preWarmCycles: number;
  12037. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12038. preWarmStepOffset: number;
  12039. /**
  12040. * 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)
  12041. */
  12042. spriteCellChangeSpeed: number;
  12043. /**
  12044. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12045. */
  12046. startSpriteCellID: number;
  12047. /**
  12048. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12049. */
  12050. endSpriteCellID: number;
  12051. /**
  12052. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12053. */
  12054. spriteCellWidth: number;
  12055. /**
  12056. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12057. */
  12058. spriteCellHeight: number;
  12059. /**
  12060. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12061. */
  12062. spriteRandomStartCell: boolean;
  12063. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12064. translationPivot: Vector2;
  12065. /** @hidden */
  12066. protected _isAnimationSheetEnabled: boolean;
  12067. /**
  12068. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12069. */
  12070. beginAnimationOnStart: boolean;
  12071. /**
  12072. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12073. */
  12074. beginAnimationFrom: number;
  12075. /**
  12076. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12077. */
  12078. beginAnimationTo: number;
  12079. /**
  12080. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12081. */
  12082. beginAnimationLoop: boolean;
  12083. /**
  12084. * Gets or sets a world offset applied to all particles
  12085. */
  12086. worldOffset: Vector3;
  12087. /**
  12088. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12089. */
  12090. get isAnimationSheetEnabled(): boolean;
  12091. set isAnimationSheetEnabled(value: boolean);
  12092. /**
  12093. * Get hosting scene
  12094. * @returns the scene
  12095. */
  12096. getScene(): Scene;
  12097. /**
  12098. * You can use gravity if you want to give an orientation to your particles.
  12099. */
  12100. gravity: Vector3;
  12101. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12102. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12103. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12104. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12105. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12106. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12107. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12108. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12109. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12110. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12111. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12112. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12113. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12114. /**
  12115. * Defines the delay in milliseconds before starting the system (0 by default)
  12116. */
  12117. startDelay: number;
  12118. /**
  12119. * Gets the current list of drag gradients.
  12120. * You must use addDragGradient and removeDragGradient to udpate this list
  12121. * @returns the list of drag gradients
  12122. */
  12123. getDragGradients(): Nullable<Array<FactorGradient>>;
  12124. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12125. limitVelocityDamping: number;
  12126. /**
  12127. * Gets the current list of limit velocity gradients.
  12128. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12129. * @returns the list of limit velocity gradients
  12130. */
  12131. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12132. /**
  12133. * Gets the current list of color gradients.
  12134. * You must use addColorGradient and removeColorGradient to udpate this list
  12135. * @returns the list of color gradients
  12136. */
  12137. getColorGradients(): Nullable<Array<ColorGradient>>;
  12138. /**
  12139. * Gets the current list of size gradients.
  12140. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12141. * @returns the list of size gradients
  12142. */
  12143. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12144. /**
  12145. * Gets the current list of color remap gradients.
  12146. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12147. * @returns the list of color remap gradients
  12148. */
  12149. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12150. /**
  12151. * Gets the current list of alpha remap gradients.
  12152. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12153. * @returns the list of alpha remap gradients
  12154. */
  12155. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12156. /**
  12157. * Gets the current list of life time gradients.
  12158. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12159. * @returns the list of life time gradients
  12160. */
  12161. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12162. /**
  12163. * Gets the current list of angular speed gradients.
  12164. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12165. * @returns the list of angular speed gradients
  12166. */
  12167. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12168. /**
  12169. * Gets the current list of velocity gradients.
  12170. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12171. * @returns the list of velocity gradients
  12172. */
  12173. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12174. /**
  12175. * Gets the current list of start size gradients.
  12176. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12177. * @returns the list of start size gradients
  12178. */
  12179. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12180. /**
  12181. * Gets the current list of emit rate gradients.
  12182. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12183. * @returns the list of emit rate gradients
  12184. */
  12185. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12186. /**
  12187. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12188. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12189. */
  12190. get direction1(): Vector3;
  12191. set direction1(value: Vector3);
  12192. /**
  12193. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12194. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12195. */
  12196. get direction2(): Vector3;
  12197. set direction2(value: Vector3);
  12198. /**
  12199. * 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.
  12200. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12201. */
  12202. get minEmitBox(): Vector3;
  12203. set minEmitBox(value: Vector3);
  12204. /**
  12205. * 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.
  12206. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12207. */
  12208. get maxEmitBox(): Vector3;
  12209. set maxEmitBox(value: Vector3);
  12210. /**
  12211. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12212. */
  12213. color1: Color4;
  12214. /**
  12215. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12216. */
  12217. color2: Color4;
  12218. /**
  12219. * Color the particle will have at the end of its lifetime
  12220. */
  12221. colorDead: Color4;
  12222. /**
  12223. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12224. */
  12225. textureMask: Color4;
  12226. /**
  12227. * The particle emitter type defines the emitter used by the particle system.
  12228. * It can be for example box, sphere, or cone...
  12229. */
  12230. particleEmitterType: IParticleEmitterType;
  12231. /** @hidden */
  12232. _isSubEmitter: boolean;
  12233. /**
  12234. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12235. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12236. */
  12237. billboardMode: number;
  12238. protected _isBillboardBased: boolean;
  12239. /**
  12240. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12241. */
  12242. get isBillboardBased(): boolean;
  12243. set isBillboardBased(value: boolean);
  12244. /**
  12245. * The scene the particle system belongs to.
  12246. */
  12247. protected _scene: Scene;
  12248. /**
  12249. * Local cache of defines for image processing.
  12250. */
  12251. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12252. /**
  12253. * Default configuration related to image processing available in the standard Material.
  12254. */
  12255. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12256. /**
  12257. * Gets the image processing configuration used either in this material.
  12258. */
  12259. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12260. /**
  12261. * Sets the Default image processing configuration used either in the this material.
  12262. *
  12263. * If sets to null, the scene one is in use.
  12264. */
  12265. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12266. /**
  12267. * Attaches a new image processing configuration to the Standard Material.
  12268. * @param configuration
  12269. */
  12270. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12271. /** @hidden */
  12272. protected _reset(): void;
  12273. /** @hidden */
  12274. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12275. /**
  12276. * Instantiates a particle system.
  12277. * 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.
  12278. * @param name The name of the particle system
  12279. */
  12280. constructor(name: string);
  12281. /**
  12282. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12283. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12284. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12285. * @returns the emitter
  12286. */
  12287. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12288. /**
  12289. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12290. * @param radius The radius of the hemisphere to emit from
  12291. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12292. * @returns the emitter
  12293. */
  12294. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12295. /**
  12296. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12297. * @param radius The radius of the sphere to emit from
  12298. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12299. * @returns the emitter
  12300. */
  12301. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12302. /**
  12303. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12304. * @param radius The radius of the sphere to emit from
  12305. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12306. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12307. * @returns the emitter
  12308. */
  12309. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12310. /**
  12311. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12312. * @param radius The radius of the emission cylinder
  12313. * @param height The height of the emission cylinder
  12314. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12315. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12316. * @returns the emitter
  12317. */
  12318. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12319. /**
  12320. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12321. * @param radius The radius of the cylinder to emit from
  12322. * @param height The height of the emission cylinder
  12323. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12324. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12325. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12326. * @returns the emitter
  12327. */
  12328. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12329. /**
  12330. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12331. * @param radius The radius of the cone to emit from
  12332. * @param angle The base angle of the cone
  12333. * @returns the emitter
  12334. */
  12335. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12336. /**
  12337. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12338. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12339. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12340. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12341. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12342. * @returns the emitter
  12343. */
  12344. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12345. }
  12346. }
  12347. declare module BABYLON {
  12348. /**
  12349. * Type of sub emitter
  12350. */
  12351. export enum SubEmitterType {
  12352. /**
  12353. * Attached to the particle over it's lifetime
  12354. */
  12355. ATTACHED = 0,
  12356. /**
  12357. * Created when the particle dies
  12358. */
  12359. END = 1
  12360. }
  12361. /**
  12362. * Sub emitter class used to emit particles from an existing particle
  12363. */
  12364. export class SubEmitter {
  12365. /**
  12366. * the particle system to be used by the sub emitter
  12367. */
  12368. particleSystem: ParticleSystem;
  12369. /**
  12370. * Type of the submitter (Default: END)
  12371. */
  12372. type: SubEmitterType;
  12373. /**
  12374. * 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)
  12375. * Note: This only is supported when using an emitter of type Mesh
  12376. */
  12377. inheritDirection: boolean;
  12378. /**
  12379. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12380. */
  12381. inheritedVelocityAmount: number;
  12382. /**
  12383. * Creates a sub emitter
  12384. * @param particleSystem the particle system to be used by the sub emitter
  12385. */
  12386. constructor(
  12387. /**
  12388. * the particle system to be used by the sub emitter
  12389. */
  12390. particleSystem: ParticleSystem);
  12391. /**
  12392. * Clones the sub emitter
  12393. * @returns the cloned sub emitter
  12394. */
  12395. clone(): SubEmitter;
  12396. /**
  12397. * Serialize current object to a JSON object
  12398. * @returns the serialized object
  12399. */
  12400. serialize(): any;
  12401. /** @hidden */
  12402. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12403. /**
  12404. * Creates a new SubEmitter from a serialized JSON version
  12405. * @param serializationObject defines the JSON object to read from
  12406. * @param scene defines the hosting scene
  12407. * @param rootUrl defines the rootUrl for data loading
  12408. * @returns a new SubEmitter
  12409. */
  12410. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12411. /** Release associated resources */
  12412. dispose(): void;
  12413. }
  12414. }
  12415. declare module BABYLON {
  12416. /** @hidden */
  12417. export var imageProcessingDeclaration: {
  12418. name: string;
  12419. shader: string;
  12420. };
  12421. }
  12422. declare module BABYLON {
  12423. /** @hidden */
  12424. export var imageProcessingFunctions: {
  12425. name: string;
  12426. shader: string;
  12427. };
  12428. }
  12429. declare module BABYLON {
  12430. /** @hidden */
  12431. export var particlesPixelShader: {
  12432. name: string;
  12433. shader: string;
  12434. };
  12435. }
  12436. declare module BABYLON {
  12437. /** @hidden */
  12438. export var particlesVertexShader: {
  12439. name: string;
  12440. shader: string;
  12441. };
  12442. }
  12443. declare module BABYLON {
  12444. /**
  12445. * This represents a particle system in Babylon.
  12446. * 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.
  12447. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12448. * @example https://doc.babylonjs.com/babylon101/particles
  12449. */
  12450. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12451. /**
  12452. * Billboard mode will only apply to Y axis
  12453. */
  12454. static readonly BILLBOARDMODE_Y: number;
  12455. /**
  12456. * Billboard mode will apply to all axes
  12457. */
  12458. static readonly BILLBOARDMODE_ALL: number;
  12459. /**
  12460. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12461. */
  12462. static readonly BILLBOARDMODE_STRETCHED: number;
  12463. /**
  12464. * This function can be defined to provide custom update for active particles.
  12465. * This function will be called instead of regular update (age, position, color, etc.).
  12466. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12467. */
  12468. updateFunction: (particles: Particle[]) => void;
  12469. private _emitterWorldMatrix;
  12470. /**
  12471. * This function can be defined to specify initial direction for every new particle.
  12472. * It by default use the emitterType defined function
  12473. */
  12474. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12475. /**
  12476. * This function can be defined to specify initial position for every new particle.
  12477. * It by default use the emitterType defined function
  12478. */
  12479. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12480. /**
  12481. * @hidden
  12482. */
  12483. _inheritedVelocityOffset: Vector3;
  12484. /**
  12485. * An event triggered when the system is disposed
  12486. */
  12487. onDisposeObservable: Observable<IParticleSystem>;
  12488. private _onDisposeObserver;
  12489. /**
  12490. * Sets a callback that will be triggered when the system is disposed
  12491. */
  12492. set onDispose(callback: () => void);
  12493. private _particles;
  12494. private _epsilon;
  12495. private _capacity;
  12496. private _stockParticles;
  12497. private _newPartsExcess;
  12498. private _vertexData;
  12499. private _vertexBuffer;
  12500. private _vertexBuffers;
  12501. private _spriteBuffer;
  12502. private _indexBuffer;
  12503. private _effect;
  12504. private _customEffect;
  12505. private _cachedDefines;
  12506. private _scaledColorStep;
  12507. private _colorDiff;
  12508. private _scaledDirection;
  12509. private _scaledGravity;
  12510. private _currentRenderId;
  12511. private _alive;
  12512. private _useInstancing;
  12513. private _started;
  12514. private _stopped;
  12515. private _actualFrame;
  12516. private _scaledUpdateSpeed;
  12517. private _vertexBufferSize;
  12518. /** @hidden */
  12519. _currentEmitRateGradient: Nullable<FactorGradient>;
  12520. /** @hidden */
  12521. _currentEmitRate1: number;
  12522. /** @hidden */
  12523. _currentEmitRate2: number;
  12524. /** @hidden */
  12525. _currentStartSizeGradient: Nullable<FactorGradient>;
  12526. /** @hidden */
  12527. _currentStartSize1: number;
  12528. /** @hidden */
  12529. _currentStartSize2: number;
  12530. private readonly _rawTextureWidth;
  12531. private _rampGradientsTexture;
  12532. private _useRampGradients;
  12533. /** Gets or sets a boolean indicating that ramp gradients must be used
  12534. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12535. */
  12536. get useRampGradients(): boolean;
  12537. set useRampGradients(value: boolean);
  12538. /**
  12539. * 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.
  12540. * 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: [])
  12541. */
  12542. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12543. private _subEmitters;
  12544. /**
  12545. * @hidden
  12546. * If the particle systems emitter should be disposed when the particle system is disposed
  12547. */
  12548. _disposeEmitterOnDispose: boolean;
  12549. /**
  12550. * The current active Sub-systems, this property is used by the root particle system only.
  12551. */
  12552. activeSubSystems: Array<ParticleSystem>;
  12553. /**
  12554. * Specifies if the particles are updated in emitter local space or world space
  12555. */
  12556. isLocal: boolean;
  12557. private _rootParticleSystem;
  12558. /**
  12559. * Gets the current list of active particles
  12560. */
  12561. get particles(): Particle[];
  12562. /**
  12563. * Gets the number of particles active at the same time.
  12564. * @returns The number of active particles.
  12565. */
  12566. getActiveCount(): number;
  12567. /**
  12568. * Returns the string "ParticleSystem"
  12569. * @returns a string containing the class name
  12570. */
  12571. getClassName(): string;
  12572. /**
  12573. * Gets a boolean indicating that the system is stopping
  12574. * @returns true if the system is currently stopping
  12575. */
  12576. isStopping(): boolean;
  12577. /**
  12578. * Gets the custom effect used to render the particles
  12579. * @param blendMode Blend mode for which the effect should be retrieved
  12580. * @returns The effect
  12581. */
  12582. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12583. /**
  12584. * Sets the custom effect used to render the particles
  12585. * @param effect The effect to set
  12586. * @param blendMode Blend mode for which the effect should be set
  12587. */
  12588. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12589. /** @hidden */
  12590. private _onBeforeDrawParticlesObservable;
  12591. /**
  12592. * Observable that will be called just before the particles are drawn
  12593. */
  12594. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12595. /**
  12596. * Gets the name of the particle vertex shader
  12597. */
  12598. get vertexShaderName(): string;
  12599. /**
  12600. * Instantiates a particle system.
  12601. * 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.
  12602. * @param name The name of the particle system
  12603. * @param capacity The max number of particles alive at the same time
  12604. * @param scene The scene the particle system belongs to
  12605. * @param customEffect a custom effect used to change the way particles are rendered by default
  12606. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12607. * @param epsilon Offset used to render the particles
  12608. */
  12609. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12610. private _addFactorGradient;
  12611. private _removeFactorGradient;
  12612. /**
  12613. * Adds a new life time gradient
  12614. * @param gradient defines the gradient to use (between 0 and 1)
  12615. * @param factor defines the life time factor to affect to the specified gradient
  12616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12617. * @returns the current particle system
  12618. */
  12619. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12620. /**
  12621. * Remove a specific life time gradient
  12622. * @param gradient defines the gradient to remove
  12623. * @returns the current particle system
  12624. */
  12625. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12626. /**
  12627. * Adds a new size gradient
  12628. * @param gradient defines the gradient to use (between 0 and 1)
  12629. * @param factor defines the size factor to affect to the specified gradient
  12630. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12631. * @returns the current particle system
  12632. */
  12633. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12634. /**
  12635. * Remove a specific size gradient
  12636. * @param gradient defines the gradient to remove
  12637. * @returns the current particle system
  12638. */
  12639. removeSizeGradient(gradient: number): IParticleSystem;
  12640. /**
  12641. * Adds a new color remap gradient
  12642. * @param gradient defines the gradient to use (between 0 and 1)
  12643. * @param min defines the color remap minimal range
  12644. * @param max defines the color remap maximal range
  12645. * @returns the current particle system
  12646. */
  12647. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12648. /**
  12649. * Remove a specific color remap gradient
  12650. * @param gradient defines the gradient to remove
  12651. * @returns the current particle system
  12652. */
  12653. removeColorRemapGradient(gradient: number): IParticleSystem;
  12654. /**
  12655. * Adds a new alpha remap gradient
  12656. * @param gradient defines the gradient to use (between 0 and 1)
  12657. * @param min defines the alpha remap minimal range
  12658. * @param max defines the alpha remap maximal range
  12659. * @returns the current particle system
  12660. */
  12661. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12662. /**
  12663. * Remove a specific alpha remap gradient
  12664. * @param gradient defines the gradient to remove
  12665. * @returns the current particle system
  12666. */
  12667. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12668. /**
  12669. * Adds a new angular speed gradient
  12670. * @param gradient defines the gradient to use (between 0 and 1)
  12671. * @param factor defines the angular speed to affect to the specified gradient
  12672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12673. * @returns the current particle system
  12674. */
  12675. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12676. /**
  12677. * Remove a specific angular speed gradient
  12678. * @param gradient defines the gradient to remove
  12679. * @returns the current particle system
  12680. */
  12681. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12682. /**
  12683. * Adds a new velocity gradient
  12684. * @param gradient defines the gradient to use (between 0 and 1)
  12685. * @param factor defines the velocity to affect to the specified gradient
  12686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12687. * @returns the current particle system
  12688. */
  12689. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12690. /**
  12691. * Remove a specific velocity gradient
  12692. * @param gradient defines the gradient to remove
  12693. * @returns the current particle system
  12694. */
  12695. removeVelocityGradient(gradient: number): IParticleSystem;
  12696. /**
  12697. * Adds a new limit velocity gradient
  12698. * @param gradient defines the gradient to use (between 0 and 1)
  12699. * @param factor defines the limit velocity value to affect to the specified gradient
  12700. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12701. * @returns the current particle system
  12702. */
  12703. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12704. /**
  12705. * Remove a specific limit velocity gradient
  12706. * @param gradient defines the gradient to remove
  12707. * @returns the current particle system
  12708. */
  12709. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12710. /**
  12711. * Adds a new drag gradient
  12712. * @param gradient defines the gradient to use (between 0 and 1)
  12713. * @param factor defines the drag value to affect to the specified gradient
  12714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12715. * @returns the current particle system
  12716. */
  12717. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12718. /**
  12719. * Remove a specific drag gradient
  12720. * @param gradient defines the gradient to remove
  12721. * @returns the current particle system
  12722. */
  12723. removeDragGradient(gradient: number): IParticleSystem;
  12724. /**
  12725. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12726. * @param gradient defines the gradient to use (between 0 and 1)
  12727. * @param factor defines the emit rate value to affect to the specified gradient
  12728. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12729. * @returns the current particle system
  12730. */
  12731. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12732. /**
  12733. * Remove a specific emit rate gradient
  12734. * @param gradient defines the gradient to remove
  12735. * @returns the current particle system
  12736. */
  12737. removeEmitRateGradient(gradient: number): IParticleSystem;
  12738. /**
  12739. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12740. * @param gradient defines the gradient to use (between 0 and 1)
  12741. * @param factor defines the start size value to affect to the specified gradient
  12742. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12743. * @returns the current particle system
  12744. */
  12745. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12746. /**
  12747. * Remove a specific start size gradient
  12748. * @param gradient defines the gradient to remove
  12749. * @returns the current particle system
  12750. */
  12751. removeStartSizeGradient(gradient: number): IParticleSystem;
  12752. private _createRampGradientTexture;
  12753. /**
  12754. * Gets the current list of ramp gradients.
  12755. * You must use addRampGradient and removeRampGradient to udpate this list
  12756. * @returns the list of ramp gradients
  12757. */
  12758. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12759. /** Force the system to rebuild all gradients that need to be resync */
  12760. forceRefreshGradients(): void;
  12761. private _syncRampGradientTexture;
  12762. /**
  12763. * Adds a new ramp gradient used to remap particle colors
  12764. * @param gradient defines the gradient to use (between 0 and 1)
  12765. * @param color defines the color to affect to the specified gradient
  12766. * @returns the current particle system
  12767. */
  12768. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12769. /**
  12770. * Remove a specific ramp gradient
  12771. * @param gradient defines the gradient to remove
  12772. * @returns the current particle system
  12773. */
  12774. removeRampGradient(gradient: number): ParticleSystem;
  12775. /**
  12776. * Adds a new color gradient
  12777. * @param gradient defines the gradient to use (between 0 and 1)
  12778. * @param color1 defines the color to affect to the specified gradient
  12779. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12780. * @returns this particle system
  12781. */
  12782. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12783. /**
  12784. * Remove a specific color gradient
  12785. * @param gradient defines the gradient to remove
  12786. * @returns this particle system
  12787. */
  12788. removeColorGradient(gradient: number): IParticleSystem;
  12789. private _fetchR;
  12790. protected _reset(): void;
  12791. private _resetEffect;
  12792. private _createVertexBuffers;
  12793. private _createIndexBuffer;
  12794. /**
  12795. * Gets the maximum number of particles active at the same time.
  12796. * @returns The max number of active particles.
  12797. */
  12798. getCapacity(): number;
  12799. /**
  12800. * Gets whether there are still active particles in the system.
  12801. * @returns True if it is alive, otherwise false.
  12802. */
  12803. isAlive(): boolean;
  12804. /**
  12805. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12806. * @returns True if it has been started, otherwise false.
  12807. */
  12808. isStarted(): boolean;
  12809. private _prepareSubEmitterInternalArray;
  12810. /**
  12811. * Starts the particle system and begins to emit
  12812. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12813. */
  12814. start(delay?: number): void;
  12815. /**
  12816. * Stops the particle system.
  12817. * @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.
  12818. */
  12819. stop(stopSubEmitters?: boolean): void;
  12820. /**
  12821. * Remove all active particles
  12822. */
  12823. reset(): void;
  12824. /**
  12825. * @hidden (for internal use only)
  12826. */
  12827. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12828. /**
  12829. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12830. * Its lifetime will start back at 0.
  12831. */
  12832. recycleParticle: (particle: Particle) => void;
  12833. private _stopSubEmitters;
  12834. private _createParticle;
  12835. private _removeFromRoot;
  12836. private _emitFromParticle;
  12837. private _update;
  12838. /** @hidden */
  12839. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12840. /** @hidden */
  12841. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12842. /**
  12843. * Fill the defines array according to the current settings of the particle system
  12844. * @param defines Array to be updated
  12845. * @param blendMode blend mode to take into account when updating the array
  12846. */
  12847. fillDefines(defines: Array<string>, blendMode: number): void;
  12848. /**
  12849. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12850. * @param uniforms Uniforms array to fill
  12851. * @param attributes Attributes array to fill
  12852. * @param samplers Samplers array to fill
  12853. */
  12854. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12855. /** @hidden */
  12856. private _getEffect;
  12857. /**
  12858. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12859. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12860. */
  12861. animate(preWarmOnly?: boolean): void;
  12862. private _appendParticleVertices;
  12863. /**
  12864. * Rebuilds the particle system.
  12865. */
  12866. rebuild(): void;
  12867. /**
  12868. * Is this system ready to be used/rendered
  12869. * @return true if the system is ready
  12870. */
  12871. isReady(): boolean;
  12872. private _render;
  12873. /**
  12874. * Renders the particle system in its current state.
  12875. * @returns the current number of particles
  12876. */
  12877. render(): number;
  12878. /**
  12879. * Disposes the particle system and free the associated resources
  12880. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12881. */
  12882. dispose(disposeTexture?: boolean): void;
  12883. /**
  12884. * Clones the particle system.
  12885. * @param name The name of the cloned object
  12886. * @param newEmitter The new emitter to use
  12887. * @returns the cloned particle system
  12888. */
  12889. clone(name: string, newEmitter: any): ParticleSystem;
  12890. /**
  12891. * Serializes the particle system to a JSON object
  12892. * @param serializeTexture defines if the texture must be serialized as well
  12893. * @returns the JSON object
  12894. */
  12895. serialize(serializeTexture?: boolean): any;
  12896. /** @hidden */
  12897. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12898. /** @hidden */
  12899. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12900. /**
  12901. * Parses a JSON object to create a particle system.
  12902. * @param parsedParticleSystem The JSON object to parse
  12903. * @param scene The scene to create the particle system in
  12904. * @param rootUrl The root url to use to load external dependencies like texture
  12905. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12906. * @returns the Parsed particle system
  12907. */
  12908. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12909. }
  12910. }
  12911. declare module BABYLON {
  12912. /**
  12913. * A particle represents one of the element emitted by a particle system.
  12914. * This is mainly define by its coordinates, direction, velocity and age.
  12915. */
  12916. export class Particle {
  12917. /**
  12918. * The particle system the particle belongs to.
  12919. */
  12920. particleSystem: ParticleSystem;
  12921. private static _Count;
  12922. /**
  12923. * Unique ID of the particle
  12924. */
  12925. id: number;
  12926. /**
  12927. * The world position of the particle in the scene.
  12928. */
  12929. position: Vector3;
  12930. /**
  12931. * The world direction of the particle in the scene.
  12932. */
  12933. direction: Vector3;
  12934. /**
  12935. * The color of the particle.
  12936. */
  12937. color: Color4;
  12938. /**
  12939. * The color change of the particle per step.
  12940. */
  12941. colorStep: Color4;
  12942. /**
  12943. * Defines how long will the life of the particle be.
  12944. */
  12945. lifeTime: number;
  12946. /**
  12947. * The current age of the particle.
  12948. */
  12949. age: number;
  12950. /**
  12951. * The current size of the particle.
  12952. */
  12953. size: number;
  12954. /**
  12955. * The current scale of the particle.
  12956. */
  12957. scale: Vector2;
  12958. /**
  12959. * The current angle of the particle.
  12960. */
  12961. angle: number;
  12962. /**
  12963. * Defines how fast is the angle changing.
  12964. */
  12965. angularSpeed: number;
  12966. /**
  12967. * Defines the cell index used by the particle to be rendered from a sprite.
  12968. */
  12969. cellIndex: number;
  12970. /**
  12971. * The information required to support color remapping
  12972. */
  12973. remapData: Vector4;
  12974. /** @hidden */
  12975. _randomCellOffset?: number;
  12976. /** @hidden */
  12977. _initialDirection: Nullable<Vector3>;
  12978. /** @hidden */
  12979. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12980. /** @hidden */
  12981. _initialStartSpriteCellID: number;
  12982. /** @hidden */
  12983. _initialEndSpriteCellID: number;
  12984. /** @hidden */
  12985. _currentColorGradient: Nullable<ColorGradient>;
  12986. /** @hidden */
  12987. _currentColor1: Color4;
  12988. /** @hidden */
  12989. _currentColor2: Color4;
  12990. /** @hidden */
  12991. _currentSizeGradient: Nullable<FactorGradient>;
  12992. /** @hidden */
  12993. _currentSize1: number;
  12994. /** @hidden */
  12995. _currentSize2: number;
  12996. /** @hidden */
  12997. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12998. /** @hidden */
  12999. _currentAngularSpeed1: number;
  13000. /** @hidden */
  13001. _currentAngularSpeed2: number;
  13002. /** @hidden */
  13003. _currentVelocityGradient: Nullable<FactorGradient>;
  13004. /** @hidden */
  13005. _currentVelocity1: number;
  13006. /** @hidden */
  13007. _currentVelocity2: number;
  13008. /** @hidden */
  13009. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13010. /** @hidden */
  13011. _currentLimitVelocity1: number;
  13012. /** @hidden */
  13013. _currentLimitVelocity2: number;
  13014. /** @hidden */
  13015. _currentDragGradient: Nullable<FactorGradient>;
  13016. /** @hidden */
  13017. _currentDrag1: number;
  13018. /** @hidden */
  13019. _currentDrag2: number;
  13020. /** @hidden */
  13021. _randomNoiseCoordinates1: Vector3;
  13022. /** @hidden */
  13023. _randomNoiseCoordinates2: Vector3;
  13024. /** @hidden */
  13025. _localPosition?: Vector3;
  13026. /**
  13027. * Creates a new instance Particle
  13028. * @param particleSystem the particle system the particle belongs to
  13029. */
  13030. constructor(
  13031. /**
  13032. * The particle system the particle belongs to.
  13033. */
  13034. particleSystem: ParticleSystem);
  13035. private updateCellInfoFromSystem;
  13036. /**
  13037. * Defines how the sprite cell index is updated for the particle
  13038. */
  13039. updateCellIndex(): void;
  13040. /** @hidden */
  13041. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13042. /** @hidden */
  13043. _inheritParticleInfoToSubEmitters(): void;
  13044. /** @hidden */
  13045. _reset(): void;
  13046. /**
  13047. * Copy the properties of particle to another one.
  13048. * @param other the particle to copy the information to.
  13049. */
  13050. copyTo(other: Particle): void;
  13051. }
  13052. }
  13053. declare module BABYLON {
  13054. /**
  13055. * Particle emitter represents a volume emitting particles.
  13056. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13057. */
  13058. export interface IParticleEmitterType {
  13059. /**
  13060. * Called by the particle System when the direction is computed for the created particle.
  13061. * @param worldMatrix is the world matrix of the particle system
  13062. * @param directionToUpdate is the direction vector to update with the result
  13063. * @param particle is the particle we are computed the direction for
  13064. * @param isLocal defines if the direction should be set in local space
  13065. */
  13066. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13067. /**
  13068. * Called by the particle System when the position is computed for the created particle.
  13069. * @param worldMatrix is the world matrix of the particle system
  13070. * @param positionToUpdate is the position vector to update with the result
  13071. * @param particle is the particle we are computed the position for
  13072. * @param isLocal defines if the position should be set in local space
  13073. */
  13074. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13075. /**
  13076. * Clones the current emitter and returns a copy of it
  13077. * @returns the new emitter
  13078. */
  13079. clone(): IParticleEmitterType;
  13080. /**
  13081. * Called by the GPUParticleSystem to setup the update shader
  13082. * @param effect defines the update shader
  13083. */
  13084. applyToShader(effect: Effect): void;
  13085. /**
  13086. * Returns a string to use to update the GPU particles update shader
  13087. * @returns the effect defines string
  13088. */
  13089. getEffectDefines(): string;
  13090. /**
  13091. * Returns a string representing the class name
  13092. * @returns a string containing the class name
  13093. */
  13094. getClassName(): string;
  13095. /**
  13096. * Serializes the particle system to a JSON object.
  13097. * @returns the JSON object
  13098. */
  13099. serialize(): any;
  13100. /**
  13101. * Parse properties from a JSON object
  13102. * @param serializationObject defines the JSON object
  13103. * @param scene defines the hosting scene
  13104. */
  13105. parse(serializationObject: any, scene: Scene): void;
  13106. }
  13107. }
  13108. declare module BABYLON {
  13109. /**
  13110. * Particle emitter emitting particles from the inside of a box.
  13111. * It emits the particles randomly between 2 given directions.
  13112. */
  13113. export class BoxParticleEmitter implements IParticleEmitterType {
  13114. /**
  13115. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13116. */
  13117. direction1: Vector3;
  13118. /**
  13119. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13120. */
  13121. direction2: Vector3;
  13122. /**
  13123. * 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.
  13124. */
  13125. minEmitBox: Vector3;
  13126. /**
  13127. * 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.
  13128. */
  13129. maxEmitBox: Vector3;
  13130. /**
  13131. * Creates a new instance BoxParticleEmitter
  13132. */
  13133. constructor();
  13134. /**
  13135. * Called by the particle System when the direction is computed for the created particle.
  13136. * @param worldMatrix is the world matrix of the particle system
  13137. * @param directionToUpdate is the direction vector to update with the result
  13138. * @param particle is the particle we are computed the direction for
  13139. * @param isLocal defines if the direction should be set in local space
  13140. */
  13141. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13142. /**
  13143. * Called by the particle System when the position is computed for the created particle.
  13144. * @param worldMatrix is the world matrix of the particle system
  13145. * @param positionToUpdate is the position vector to update with the result
  13146. * @param particle is the particle we are computed the position for
  13147. * @param isLocal defines if the position should be set in local space
  13148. */
  13149. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13150. /**
  13151. * Clones the current emitter and returns a copy of it
  13152. * @returns the new emitter
  13153. */
  13154. clone(): BoxParticleEmitter;
  13155. /**
  13156. * Called by the GPUParticleSystem to setup the update shader
  13157. * @param effect defines the update shader
  13158. */
  13159. applyToShader(effect: Effect): void;
  13160. /**
  13161. * Returns a string to use to update the GPU particles update shader
  13162. * @returns a string containng the defines string
  13163. */
  13164. getEffectDefines(): string;
  13165. /**
  13166. * Returns the string "BoxParticleEmitter"
  13167. * @returns a string containing the class name
  13168. */
  13169. getClassName(): string;
  13170. /**
  13171. * Serializes the particle system to a JSON object.
  13172. * @returns the JSON object
  13173. */
  13174. serialize(): any;
  13175. /**
  13176. * Parse properties from a JSON object
  13177. * @param serializationObject defines the JSON object
  13178. */
  13179. parse(serializationObject: any): void;
  13180. }
  13181. }
  13182. declare module BABYLON {
  13183. /**
  13184. * Particle emitter emitting particles from the inside of a cone.
  13185. * It emits the particles alongside the cone volume from the base to the particle.
  13186. * The emission direction might be randomized.
  13187. */
  13188. export class ConeParticleEmitter implements IParticleEmitterType {
  13189. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13190. directionRandomizer: number;
  13191. private _radius;
  13192. private _angle;
  13193. private _height;
  13194. /**
  13195. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13196. */
  13197. radiusRange: number;
  13198. /**
  13199. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13200. */
  13201. heightRange: number;
  13202. /**
  13203. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13204. */
  13205. emitFromSpawnPointOnly: boolean;
  13206. /**
  13207. * Gets or sets the radius of the emission cone
  13208. */
  13209. get radius(): number;
  13210. set radius(value: number);
  13211. /**
  13212. * Gets or sets the angle of the emission cone
  13213. */
  13214. get angle(): number;
  13215. set angle(value: number);
  13216. private _buildHeight;
  13217. /**
  13218. * Creates a new instance ConeParticleEmitter
  13219. * @param radius the radius of the emission cone (1 by default)
  13220. * @param angle the cone base angle (PI by default)
  13221. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13222. */
  13223. constructor(radius?: number, angle?: number,
  13224. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13225. directionRandomizer?: number);
  13226. /**
  13227. * Called by the particle System when the direction is computed for the created particle.
  13228. * @param worldMatrix is the world matrix of the particle system
  13229. * @param directionToUpdate is the direction vector to update with the result
  13230. * @param particle is the particle we are computed the direction for
  13231. * @param isLocal defines if the direction should be set in local space
  13232. */
  13233. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13234. /**
  13235. * Called by the particle System when the position is computed for the created particle.
  13236. * @param worldMatrix is the world matrix of the particle system
  13237. * @param positionToUpdate is the position vector to update with the result
  13238. * @param particle is the particle we are computed the position for
  13239. * @param isLocal defines if the position should be set in local space
  13240. */
  13241. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13242. /**
  13243. * Clones the current emitter and returns a copy of it
  13244. * @returns the new emitter
  13245. */
  13246. clone(): ConeParticleEmitter;
  13247. /**
  13248. * Called by the GPUParticleSystem to setup the update shader
  13249. * @param effect defines the update shader
  13250. */
  13251. applyToShader(effect: Effect): void;
  13252. /**
  13253. * Returns a string to use to update the GPU particles update shader
  13254. * @returns a string containng the defines string
  13255. */
  13256. getEffectDefines(): string;
  13257. /**
  13258. * Returns the string "ConeParticleEmitter"
  13259. * @returns a string containing the class name
  13260. */
  13261. getClassName(): string;
  13262. /**
  13263. * Serializes the particle system to a JSON object.
  13264. * @returns the JSON object
  13265. */
  13266. serialize(): any;
  13267. /**
  13268. * Parse properties from a JSON object
  13269. * @param serializationObject defines the JSON object
  13270. */
  13271. parse(serializationObject: any): void;
  13272. }
  13273. }
  13274. declare module BABYLON {
  13275. /**
  13276. * Particle emitter emitting particles from the inside of a cylinder.
  13277. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13278. */
  13279. export class CylinderParticleEmitter implements IParticleEmitterType {
  13280. /**
  13281. * The radius of the emission cylinder.
  13282. */
  13283. radius: number;
  13284. /**
  13285. * The height of the emission cylinder.
  13286. */
  13287. height: number;
  13288. /**
  13289. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13290. */
  13291. radiusRange: number;
  13292. /**
  13293. * How much to randomize the particle direction [0-1].
  13294. */
  13295. directionRandomizer: number;
  13296. /**
  13297. * Creates a new instance CylinderParticleEmitter
  13298. * @param radius the radius of the emission cylinder (1 by default)
  13299. * @param height the height of the emission cylinder (1 by default)
  13300. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13301. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13302. */
  13303. constructor(
  13304. /**
  13305. * The radius of the emission cylinder.
  13306. */
  13307. radius?: number,
  13308. /**
  13309. * The height of the emission cylinder.
  13310. */
  13311. height?: number,
  13312. /**
  13313. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13314. */
  13315. radiusRange?: number,
  13316. /**
  13317. * How much to randomize the particle direction [0-1].
  13318. */
  13319. directionRandomizer?: number);
  13320. /**
  13321. * Called by the particle System when the direction is computed for the created particle.
  13322. * @param worldMatrix is the world matrix of the particle system
  13323. * @param directionToUpdate is the direction vector to update with the result
  13324. * @param particle is the particle we are computed the direction for
  13325. * @param isLocal defines if the direction should be set in local space
  13326. */
  13327. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13328. /**
  13329. * Called by the particle System when the position is computed for the created particle.
  13330. * @param worldMatrix is the world matrix of the particle system
  13331. * @param positionToUpdate is the position vector to update with the result
  13332. * @param particle is the particle we are computed the position for
  13333. * @param isLocal defines if the position should be set in local space
  13334. */
  13335. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13336. /**
  13337. * Clones the current emitter and returns a copy of it
  13338. * @returns the new emitter
  13339. */
  13340. clone(): CylinderParticleEmitter;
  13341. /**
  13342. * Called by the GPUParticleSystem to setup the update shader
  13343. * @param effect defines the update shader
  13344. */
  13345. applyToShader(effect: Effect): void;
  13346. /**
  13347. * Returns a string to use to update the GPU particles update shader
  13348. * @returns a string containng the defines string
  13349. */
  13350. getEffectDefines(): string;
  13351. /**
  13352. * Returns the string "CylinderParticleEmitter"
  13353. * @returns a string containing the class name
  13354. */
  13355. getClassName(): string;
  13356. /**
  13357. * Serializes the particle system to a JSON object.
  13358. * @returns the JSON object
  13359. */
  13360. serialize(): any;
  13361. /**
  13362. * Parse properties from a JSON object
  13363. * @param serializationObject defines the JSON object
  13364. */
  13365. parse(serializationObject: any): void;
  13366. }
  13367. /**
  13368. * Particle emitter emitting particles from the inside of a cylinder.
  13369. * It emits the particles randomly between two vectors.
  13370. */
  13371. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13372. /**
  13373. * The min limit of the emission direction.
  13374. */
  13375. direction1: Vector3;
  13376. /**
  13377. * The max limit of the emission direction.
  13378. */
  13379. direction2: Vector3;
  13380. /**
  13381. * Creates a new instance CylinderDirectedParticleEmitter
  13382. * @param radius the radius of the emission cylinder (1 by default)
  13383. * @param height the height of the emission cylinder (1 by default)
  13384. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13385. * @param direction1 the min limit of the emission direction (up vector by default)
  13386. * @param direction2 the max limit of the emission direction (up vector by default)
  13387. */
  13388. constructor(radius?: number, height?: number, radiusRange?: number,
  13389. /**
  13390. * The min limit of the emission direction.
  13391. */
  13392. direction1?: Vector3,
  13393. /**
  13394. * The max limit of the emission direction.
  13395. */
  13396. direction2?: Vector3);
  13397. /**
  13398. * Called by the particle System when the direction is computed for the created particle.
  13399. * @param worldMatrix is the world matrix of the particle system
  13400. * @param directionToUpdate is the direction vector to update with the result
  13401. * @param particle is the particle we are computed the direction for
  13402. */
  13403. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13404. /**
  13405. * Clones the current emitter and returns a copy of it
  13406. * @returns the new emitter
  13407. */
  13408. clone(): CylinderDirectedParticleEmitter;
  13409. /**
  13410. * Called by the GPUParticleSystem to setup the update shader
  13411. * @param effect defines the update shader
  13412. */
  13413. applyToShader(effect: Effect): void;
  13414. /**
  13415. * Returns a string to use to update the GPU particles update shader
  13416. * @returns a string containng the defines string
  13417. */
  13418. getEffectDefines(): string;
  13419. /**
  13420. * Returns the string "CylinderDirectedParticleEmitter"
  13421. * @returns a string containing the class name
  13422. */
  13423. getClassName(): string;
  13424. /**
  13425. * Serializes the particle system to a JSON object.
  13426. * @returns the JSON object
  13427. */
  13428. serialize(): any;
  13429. /**
  13430. * Parse properties from a JSON object
  13431. * @param serializationObject defines the JSON object
  13432. */
  13433. parse(serializationObject: any): void;
  13434. }
  13435. }
  13436. declare module BABYLON {
  13437. /**
  13438. * Particle emitter emitting particles from the inside of a hemisphere.
  13439. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13440. */
  13441. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13442. /**
  13443. * The radius of the emission hemisphere.
  13444. */
  13445. radius: number;
  13446. /**
  13447. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13448. */
  13449. radiusRange: number;
  13450. /**
  13451. * How much to randomize the particle direction [0-1].
  13452. */
  13453. directionRandomizer: number;
  13454. /**
  13455. * Creates a new instance HemisphericParticleEmitter
  13456. * @param radius the radius of the emission hemisphere (1 by default)
  13457. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13458. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13459. */
  13460. constructor(
  13461. /**
  13462. * The radius of the emission hemisphere.
  13463. */
  13464. radius?: number,
  13465. /**
  13466. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13467. */
  13468. radiusRange?: number,
  13469. /**
  13470. * How much to randomize the particle direction [0-1].
  13471. */
  13472. directionRandomizer?: number);
  13473. /**
  13474. * Called by the particle System when the direction is computed for the created particle.
  13475. * @param worldMatrix is the world matrix of the particle system
  13476. * @param directionToUpdate is the direction vector to update with the result
  13477. * @param particle is the particle we are computed the direction for
  13478. * @param isLocal defines if the direction should be set in local space
  13479. */
  13480. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13481. /**
  13482. * Called by the particle System when the position is computed for the created particle.
  13483. * @param worldMatrix is the world matrix of the particle system
  13484. * @param positionToUpdate is the position vector to update with the result
  13485. * @param particle is the particle we are computed the position for
  13486. * @param isLocal defines if the position should be set in local space
  13487. */
  13488. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13489. /**
  13490. * Clones the current emitter and returns a copy of it
  13491. * @returns the new emitter
  13492. */
  13493. clone(): HemisphericParticleEmitter;
  13494. /**
  13495. * Called by the GPUParticleSystem to setup the update shader
  13496. * @param effect defines the update shader
  13497. */
  13498. applyToShader(effect: Effect): void;
  13499. /**
  13500. * Returns a string to use to update the GPU particles update shader
  13501. * @returns a string containng the defines string
  13502. */
  13503. getEffectDefines(): string;
  13504. /**
  13505. * Returns the string "HemisphericParticleEmitter"
  13506. * @returns a string containing the class name
  13507. */
  13508. getClassName(): string;
  13509. /**
  13510. * Serializes the particle system to a JSON object.
  13511. * @returns the JSON object
  13512. */
  13513. serialize(): any;
  13514. /**
  13515. * Parse properties from a JSON object
  13516. * @param serializationObject defines the JSON object
  13517. */
  13518. parse(serializationObject: any): void;
  13519. }
  13520. }
  13521. declare module BABYLON {
  13522. /**
  13523. * Particle emitter emitting particles from a point.
  13524. * It emits the particles randomly between 2 given directions.
  13525. */
  13526. export class PointParticleEmitter implements IParticleEmitterType {
  13527. /**
  13528. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13529. */
  13530. direction1: Vector3;
  13531. /**
  13532. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13533. */
  13534. direction2: Vector3;
  13535. /**
  13536. * Creates a new instance PointParticleEmitter
  13537. */
  13538. constructor();
  13539. /**
  13540. * Called by the particle System when the direction is computed for the created particle.
  13541. * @param worldMatrix is the world matrix of the particle system
  13542. * @param directionToUpdate is the direction vector to update with the result
  13543. * @param particle is the particle we are computed the direction for
  13544. * @param isLocal defines if the direction should be set in local space
  13545. */
  13546. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13547. /**
  13548. * Called by the particle System when the position is computed for the created particle.
  13549. * @param worldMatrix is the world matrix of the particle system
  13550. * @param positionToUpdate is the position vector to update with the result
  13551. * @param particle is the particle we are computed the position for
  13552. * @param isLocal defines if the position should be set in local space
  13553. */
  13554. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13555. /**
  13556. * Clones the current emitter and returns a copy of it
  13557. * @returns the new emitter
  13558. */
  13559. clone(): PointParticleEmitter;
  13560. /**
  13561. * Called by the GPUParticleSystem to setup the update shader
  13562. * @param effect defines the update shader
  13563. */
  13564. applyToShader(effect: Effect): void;
  13565. /**
  13566. * Returns a string to use to update the GPU particles update shader
  13567. * @returns a string containng the defines string
  13568. */
  13569. getEffectDefines(): string;
  13570. /**
  13571. * Returns the string "PointParticleEmitter"
  13572. * @returns a string containing the class name
  13573. */
  13574. getClassName(): string;
  13575. /**
  13576. * Serializes the particle system to a JSON object.
  13577. * @returns the JSON object
  13578. */
  13579. serialize(): any;
  13580. /**
  13581. * Parse properties from a JSON object
  13582. * @param serializationObject defines the JSON object
  13583. */
  13584. parse(serializationObject: any): void;
  13585. }
  13586. }
  13587. declare module BABYLON {
  13588. /**
  13589. * Particle emitter emitting particles from the inside of a sphere.
  13590. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13591. */
  13592. export class SphereParticleEmitter implements IParticleEmitterType {
  13593. /**
  13594. * The radius of the emission sphere.
  13595. */
  13596. radius: number;
  13597. /**
  13598. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13599. */
  13600. radiusRange: number;
  13601. /**
  13602. * How much to randomize the particle direction [0-1].
  13603. */
  13604. directionRandomizer: number;
  13605. /**
  13606. * Creates a new instance SphereParticleEmitter
  13607. * @param radius the radius of the emission sphere (1 by default)
  13608. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13609. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13610. */
  13611. constructor(
  13612. /**
  13613. * The radius of the emission sphere.
  13614. */
  13615. radius?: number,
  13616. /**
  13617. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13618. */
  13619. radiusRange?: number,
  13620. /**
  13621. * How much to randomize the particle direction [0-1].
  13622. */
  13623. directionRandomizer?: number);
  13624. /**
  13625. * Called by the particle System when the direction is computed for the created particle.
  13626. * @param worldMatrix is the world matrix of the particle system
  13627. * @param directionToUpdate is the direction vector to update with the result
  13628. * @param particle is the particle we are computed the direction for
  13629. * @param isLocal defines if the direction should be set in local space
  13630. */
  13631. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13632. /**
  13633. * Called by the particle System when the position is computed for the created particle.
  13634. * @param worldMatrix is the world matrix of the particle system
  13635. * @param positionToUpdate is the position vector to update with the result
  13636. * @param particle is the particle we are computed the position for
  13637. * @param isLocal defines if the position should be set in local space
  13638. */
  13639. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13640. /**
  13641. * Clones the current emitter and returns a copy of it
  13642. * @returns the new emitter
  13643. */
  13644. clone(): SphereParticleEmitter;
  13645. /**
  13646. * Called by the GPUParticleSystem to setup the update shader
  13647. * @param effect defines the update shader
  13648. */
  13649. applyToShader(effect: Effect): void;
  13650. /**
  13651. * Returns a string to use to update the GPU particles update shader
  13652. * @returns a string containng the defines string
  13653. */
  13654. getEffectDefines(): string;
  13655. /**
  13656. * Returns the string "SphereParticleEmitter"
  13657. * @returns a string containing the class name
  13658. */
  13659. getClassName(): string;
  13660. /**
  13661. * Serializes the particle system to a JSON object.
  13662. * @returns the JSON object
  13663. */
  13664. serialize(): any;
  13665. /**
  13666. * Parse properties from a JSON object
  13667. * @param serializationObject defines the JSON object
  13668. */
  13669. parse(serializationObject: any): void;
  13670. }
  13671. /**
  13672. * Particle emitter emitting particles from the inside of a sphere.
  13673. * It emits the particles randomly between two vectors.
  13674. */
  13675. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13676. /**
  13677. * The min limit of the emission direction.
  13678. */
  13679. direction1: Vector3;
  13680. /**
  13681. * The max limit of the emission direction.
  13682. */
  13683. direction2: Vector3;
  13684. /**
  13685. * Creates a new instance SphereDirectedParticleEmitter
  13686. * @param radius the radius of the emission sphere (1 by default)
  13687. * @param direction1 the min limit of the emission direction (up vector by default)
  13688. * @param direction2 the max limit of the emission direction (up vector by default)
  13689. */
  13690. constructor(radius?: number,
  13691. /**
  13692. * The min limit of the emission direction.
  13693. */
  13694. direction1?: Vector3,
  13695. /**
  13696. * The max limit of the emission direction.
  13697. */
  13698. direction2?: Vector3);
  13699. /**
  13700. * Called by the particle System when the direction is computed for the created particle.
  13701. * @param worldMatrix is the world matrix of the particle system
  13702. * @param directionToUpdate is the direction vector to update with the result
  13703. * @param particle is the particle we are computed the direction for
  13704. */
  13705. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13706. /**
  13707. * Clones the current emitter and returns a copy of it
  13708. * @returns the new emitter
  13709. */
  13710. clone(): SphereDirectedParticleEmitter;
  13711. /**
  13712. * Called by the GPUParticleSystem to setup the update shader
  13713. * @param effect defines the update shader
  13714. */
  13715. applyToShader(effect: Effect): void;
  13716. /**
  13717. * Returns a string to use to update the GPU particles update shader
  13718. * @returns a string containng the defines string
  13719. */
  13720. getEffectDefines(): string;
  13721. /**
  13722. * Returns the string "SphereDirectedParticleEmitter"
  13723. * @returns a string containing the class name
  13724. */
  13725. getClassName(): string;
  13726. /**
  13727. * Serializes the particle system to a JSON object.
  13728. * @returns the JSON object
  13729. */
  13730. serialize(): any;
  13731. /**
  13732. * Parse properties from a JSON object
  13733. * @param serializationObject defines the JSON object
  13734. */
  13735. parse(serializationObject: any): void;
  13736. }
  13737. }
  13738. declare module BABYLON {
  13739. /**
  13740. * Particle emitter emitting particles from a custom list of positions.
  13741. */
  13742. export class CustomParticleEmitter implements IParticleEmitterType {
  13743. /**
  13744. * Gets or sets the position generator that will create the inital position of each particle.
  13745. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13746. */
  13747. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13748. /**
  13749. * Gets or sets the destination generator that will create the final destination of each particle.
  13750. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13751. */
  13752. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13753. /**
  13754. * Creates a new instance CustomParticleEmitter
  13755. */
  13756. constructor();
  13757. /**
  13758. * Called by the particle System when the direction is computed for the created particle.
  13759. * @param worldMatrix is the world matrix of the particle system
  13760. * @param directionToUpdate is the direction vector to update with the result
  13761. * @param particle is the particle we are computed the direction for
  13762. * @param isLocal defines if the direction should be set in local space
  13763. */
  13764. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13765. /**
  13766. * Called by the particle System when the position is computed for the created particle.
  13767. * @param worldMatrix is the world matrix of the particle system
  13768. * @param positionToUpdate is the position vector to update with the result
  13769. * @param particle is the particle we are computed the position for
  13770. * @param isLocal defines if the position should be set in local space
  13771. */
  13772. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13773. /**
  13774. * Clones the current emitter and returns a copy of it
  13775. * @returns the new emitter
  13776. */
  13777. clone(): CustomParticleEmitter;
  13778. /**
  13779. * Called by the GPUParticleSystem to setup the update shader
  13780. * @param effect defines the update shader
  13781. */
  13782. applyToShader(effect: Effect): void;
  13783. /**
  13784. * Returns a string to use to update the GPU particles update shader
  13785. * @returns a string containng the defines string
  13786. */
  13787. getEffectDefines(): string;
  13788. /**
  13789. * Returns the string "PointParticleEmitter"
  13790. * @returns a string containing the class name
  13791. */
  13792. getClassName(): string;
  13793. /**
  13794. * Serializes the particle system to a JSON object.
  13795. * @returns the JSON object
  13796. */
  13797. serialize(): any;
  13798. /**
  13799. * Parse properties from a JSON object
  13800. * @param serializationObject defines the JSON object
  13801. */
  13802. parse(serializationObject: any): void;
  13803. }
  13804. }
  13805. declare module BABYLON {
  13806. /**
  13807. * Particle emitter emitting particles from the inside of a box.
  13808. * It emits the particles randomly between 2 given directions.
  13809. */
  13810. export class MeshParticleEmitter implements IParticleEmitterType {
  13811. private _indices;
  13812. private _positions;
  13813. private _normals;
  13814. private _storedNormal;
  13815. private _mesh;
  13816. /**
  13817. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13818. */
  13819. direction1: Vector3;
  13820. /**
  13821. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13822. */
  13823. direction2: Vector3;
  13824. /**
  13825. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13826. */
  13827. useMeshNormalsForDirection: boolean;
  13828. /** Defines the mesh to use as source */
  13829. get mesh(): Nullable<AbstractMesh>;
  13830. set mesh(value: Nullable<AbstractMesh>);
  13831. /**
  13832. * Creates a new instance MeshParticleEmitter
  13833. * @param mesh defines the mesh to use as source
  13834. */
  13835. constructor(mesh?: Nullable<AbstractMesh>);
  13836. /**
  13837. * Called by the particle System when the direction is computed for the created particle.
  13838. * @param worldMatrix is the world matrix of the particle system
  13839. * @param directionToUpdate is the direction vector to update with the result
  13840. * @param particle is the particle we are computed the direction for
  13841. * @param isLocal defines if the direction should be set in local space
  13842. */
  13843. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13844. /**
  13845. * Called by the particle System when the position is computed for the created particle.
  13846. * @param worldMatrix is the world matrix of the particle system
  13847. * @param positionToUpdate is the position vector to update with the result
  13848. * @param particle is the particle we are computed the position for
  13849. * @param isLocal defines if the position should be set in local space
  13850. */
  13851. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13852. /**
  13853. * Clones the current emitter and returns a copy of it
  13854. * @returns the new emitter
  13855. */
  13856. clone(): MeshParticleEmitter;
  13857. /**
  13858. * Called by the GPUParticleSystem to setup the update shader
  13859. * @param effect defines the update shader
  13860. */
  13861. applyToShader(effect: Effect): void;
  13862. /**
  13863. * Returns a string to use to update the GPU particles update shader
  13864. * @returns a string containng the defines string
  13865. */
  13866. getEffectDefines(): string;
  13867. /**
  13868. * Returns the string "BoxParticleEmitter"
  13869. * @returns a string containing the class name
  13870. */
  13871. getClassName(): string;
  13872. /**
  13873. * Serializes the particle system to a JSON object.
  13874. * @returns the JSON object
  13875. */
  13876. serialize(): any;
  13877. /**
  13878. * Parse properties from a JSON object
  13879. * @param serializationObject defines the JSON object
  13880. * @param scene defines the hosting scene
  13881. */
  13882. parse(serializationObject: any, scene: Scene): void;
  13883. }
  13884. }
  13885. declare module BABYLON {
  13886. /**
  13887. * Interface representing a particle system in Babylon.js.
  13888. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13889. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13890. */
  13891. export interface IParticleSystem {
  13892. /**
  13893. * List of animations used by the particle system.
  13894. */
  13895. animations: Animation[];
  13896. /**
  13897. * The id of the Particle system.
  13898. */
  13899. id: string;
  13900. /**
  13901. * The name of the Particle system.
  13902. */
  13903. name: string;
  13904. /**
  13905. * The emitter represents the Mesh or position we are attaching the particle system to.
  13906. */
  13907. emitter: Nullable<AbstractMesh | Vector3>;
  13908. /**
  13909. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13910. */
  13911. isBillboardBased: boolean;
  13912. /**
  13913. * The rendering group used by the Particle system to chose when to render.
  13914. */
  13915. renderingGroupId: number;
  13916. /**
  13917. * The layer mask we are rendering the particles through.
  13918. */
  13919. layerMask: number;
  13920. /**
  13921. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13922. */
  13923. updateSpeed: number;
  13924. /**
  13925. * The amount of time the particle system is running (depends of the overall update speed).
  13926. */
  13927. targetStopDuration: number;
  13928. /**
  13929. * The texture used to render each particle. (this can be a spritesheet)
  13930. */
  13931. particleTexture: Nullable<Texture>;
  13932. /**
  13933. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13934. */
  13935. blendMode: number;
  13936. /**
  13937. * Minimum life time of emitting particles.
  13938. */
  13939. minLifeTime: number;
  13940. /**
  13941. * Maximum life time of emitting particles.
  13942. */
  13943. maxLifeTime: number;
  13944. /**
  13945. * Minimum Size of emitting particles.
  13946. */
  13947. minSize: number;
  13948. /**
  13949. * Maximum Size of emitting particles.
  13950. */
  13951. maxSize: number;
  13952. /**
  13953. * Minimum scale of emitting particles on X axis.
  13954. */
  13955. minScaleX: number;
  13956. /**
  13957. * Maximum scale of emitting particles on X axis.
  13958. */
  13959. maxScaleX: number;
  13960. /**
  13961. * Minimum scale of emitting particles on Y axis.
  13962. */
  13963. minScaleY: number;
  13964. /**
  13965. * Maximum scale of emitting particles on Y axis.
  13966. */
  13967. maxScaleY: number;
  13968. /**
  13969. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13970. */
  13971. color1: Color4;
  13972. /**
  13973. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13974. */
  13975. color2: Color4;
  13976. /**
  13977. * Color the particle will have at the end of its lifetime.
  13978. */
  13979. colorDead: Color4;
  13980. /**
  13981. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13982. */
  13983. emitRate: number;
  13984. /**
  13985. * You can use gravity if you want to give an orientation to your particles.
  13986. */
  13987. gravity: Vector3;
  13988. /**
  13989. * Minimum power of emitting particles.
  13990. */
  13991. minEmitPower: number;
  13992. /**
  13993. * Maximum power of emitting particles.
  13994. */
  13995. maxEmitPower: number;
  13996. /**
  13997. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13998. */
  13999. minAngularSpeed: number;
  14000. /**
  14001. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14002. */
  14003. maxAngularSpeed: number;
  14004. /**
  14005. * Gets or sets the minimal initial rotation in radians.
  14006. */
  14007. minInitialRotation: number;
  14008. /**
  14009. * Gets or sets the maximal initial rotation in radians.
  14010. */
  14011. maxInitialRotation: number;
  14012. /**
  14013. * The particle emitter type defines the emitter used by the particle system.
  14014. * It can be for example box, sphere, or cone...
  14015. */
  14016. particleEmitterType: Nullable<IParticleEmitterType>;
  14017. /**
  14018. * Defines the delay in milliseconds before starting the system (0 by default)
  14019. */
  14020. startDelay: number;
  14021. /**
  14022. * 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
  14023. */
  14024. preWarmCycles: number;
  14025. /**
  14026. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14027. */
  14028. preWarmStepOffset: number;
  14029. /**
  14030. * 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)
  14031. */
  14032. spriteCellChangeSpeed: number;
  14033. /**
  14034. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14035. */
  14036. startSpriteCellID: number;
  14037. /**
  14038. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14039. */
  14040. endSpriteCellID: number;
  14041. /**
  14042. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14043. */
  14044. spriteCellWidth: number;
  14045. /**
  14046. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14047. */
  14048. spriteCellHeight: number;
  14049. /**
  14050. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14051. */
  14052. spriteRandomStartCell: boolean;
  14053. /**
  14054. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14055. */
  14056. isAnimationSheetEnabled: boolean;
  14057. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14058. translationPivot: Vector2;
  14059. /**
  14060. * Gets or sets a texture used to add random noise to particle positions
  14061. */
  14062. noiseTexture: Nullable<BaseTexture>;
  14063. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14064. noiseStrength: Vector3;
  14065. /**
  14066. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14067. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14068. */
  14069. billboardMode: number;
  14070. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14071. limitVelocityDamping: number;
  14072. /**
  14073. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14074. */
  14075. beginAnimationOnStart: boolean;
  14076. /**
  14077. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14078. */
  14079. beginAnimationFrom: number;
  14080. /**
  14081. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14082. */
  14083. beginAnimationTo: number;
  14084. /**
  14085. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14086. */
  14087. beginAnimationLoop: boolean;
  14088. /**
  14089. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14090. */
  14091. disposeOnStop: boolean;
  14092. /**
  14093. * Specifies if the particles are updated in emitter local space or world space
  14094. */
  14095. isLocal: boolean;
  14096. /** Snippet ID if the particle system was created from the snippet server */
  14097. snippetId: string;
  14098. /**
  14099. * Gets the maximum number of particles active at the same time.
  14100. * @returns The max number of active particles.
  14101. */
  14102. getCapacity(): number;
  14103. /**
  14104. * Gets the number of particles active at the same time.
  14105. * @returns The number of active particles.
  14106. */
  14107. getActiveCount(): number;
  14108. /**
  14109. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14110. * @returns True if it has been started, otherwise false.
  14111. */
  14112. isStarted(): boolean;
  14113. /**
  14114. * Animates the particle system for this frame.
  14115. */
  14116. animate(): void;
  14117. /**
  14118. * Renders the particle system in its current state.
  14119. * @returns the current number of particles
  14120. */
  14121. render(): number;
  14122. /**
  14123. * Dispose the particle system and frees its associated resources.
  14124. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14125. */
  14126. dispose(disposeTexture?: boolean): void;
  14127. /**
  14128. * An event triggered when the system is disposed
  14129. */
  14130. onDisposeObservable: Observable<IParticleSystem>;
  14131. /**
  14132. * Clones the particle system.
  14133. * @param name The name of the cloned object
  14134. * @param newEmitter The new emitter to use
  14135. * @returns the cloned particle system
  14136. */
  14137. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14138. /**
  14139. * Serializes the particle system to a JSON object
  14140. * @param serializeTexture defines if the texture must be serialized as well
  14141. * @returns the JSON object
  14142. */
  14143. serialize(serializeTexture: boolean): any;
  14144. /**
  14145. * Rebuild the particle system
  14146. */
  14147. rebuild(): void;
  14148. /** Force the system to rebuild all gradients that need to be resync */
  14149. forceRefreshGradients(): void;
  14150. /**
  14151. * Starts the particle system and begins to emit
  14152. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14153. */
  14154. start(delay?: number): void;
  14155. /**
  14156. * Stops the particle system.
  14157. */
  14158. stop(): void;
  14159. /**
  14160. * Remove all active particles
  14161. */
  14162. reset(): void;
  14163. /**
  14164. * Gets a boolean indicating that the system is stopping
  14165. * @returns true if the system is currently stopping
  14166. */
  14167. isStopping(): boolean;
  14168. /**
  14169. * Is this system ready to be used/rendered
  14170. * @return true if the system is ready
  14171. */
  14172. isReady(): boolean;
  14173. /**
  14174. * Returns the string "ParticleSystem"
  14175. * @returns a string containing the class name
  14176. */
  14177. getClassName(): string;
  14178. /**
  14179. * Gets the custom effect used to render the particles
  14180. * @param blendMode Blend mode for which the effect should be retrieved
  14181. * @returns The effect
  14182. */
  14183. getCustomEffect(blendMode: number): Nullable<Effect>;
  14184. /**
  14185. * Sets the custom effect used to render the particles
  14186. * @param effect The effect to set
  14187. * @param blendMode Blend mode for which the effect should be set
  14188. */
  14189. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14190. /**
  14191. * Fill the defines array according to the current settings of the particle system
  14192. * @param defines Array to be updated
  14193. * @param blendMode blend mode to take into account when updating the array
  14194. */
  14195. fillDefines(defines: Array<string>, blendMode: number): void;
  14196. /**
  14197. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14198. * @param uniforms Uniforms array to fill
  14199. * @param attributes Attributes array to fill
  14200. * @param samplers Samplers array to fill
  14201. */
  14202. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14203. /**
  14204. * Observable that will be called just before the particles are drawn
  14205. */
  14206. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14207. /**
  14208. * Gets the name of the particle vertex shader
  14209. */
  14210. vertexShaderName: string;
  14211. /**
  14212. * Adds a new color gradient
  14213. * @param gradient defines the gradient to use (between 0 and 1)
  14214. * @param color1 defines the color to affect to the specified gradient
  14215. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14216. * @returns the current particle system
  14217. */
  14218. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14219. /**
  14220. * Remove a specific color gradient
  14221. * @param gradient defines the gradient to remove
  14222. * @returns the current particle system
  14223. */
  14224. removeColorGradient(gradient: number): IParticleSystem;
  14225. /**
  14226. * Adds a new size gradient
  14227. * @param gradient defines the gradient to use (between 0 and 1)
  14228. * @param factor defines the size factor to affect to the specified gradient
  14229. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14230. * @returns the current particle system
  14231. */
  14232. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14233. /**
  14234. * Remove a specific size gradient
  14235. * @param gradient defines the gradient to remove
  14236. * @returns the current particle system
  14237. */
  14238. removeSizeGradient(gradient: number): IParticleSystem;
  14239. /**
  14240. * Gets the current list of color gradients.
  14241. * You must use addColorGradient and removeColorGradient to udpate this list
  14242. * @returns the list of color gradients
  14243. */
  14244. getColorGradients(): Nullable<Array<ColorGradient>>;
  14245. /**
  14246. * Gets the current list of size gradients.
  14247. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14248. * @returns the list of size gradients
  14249. */
  14250. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14251. /**
  14252. * Gets the current list of angular speed gradients.
  14253. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14254. * @returns the list of angular speed gradients
  14255. */
  14256. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14257. /**
  14258. * Adds a new angular speed gradient
  14259. * @param gradient defines the gradient to use (between 0 and 1)
  14260. * @param factor defines the angular speed to affect to the specified gradient
  14261. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14262. * @returns the current particle system
  14263. */
  14264. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14265. /**
  14266. * Remove a specific angular speed gradient
  14267. * @param gradient defines the gradient to remove
  14268. * @returns the current particle system
  14269. */
  14270. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14271. /**
  14272. * Gets the current list of velocity gradients.
  14273. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14274. * @returns the list of velocity gradients
  14275. */
  14276. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14277. /**
  14278. * Adds a new velocity gradient
  14279. * @param gradient defines the gradient to use (between 0 and 1)
  14280. * @param factor defines the velocity to affect to the specified gradient
  14281. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14282. * @returns the current particle system
  14283. */
  14284. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14285. /**
  14286. * Remove a specific velocity gradient
  14287. * @param gradient defines the gradient to remove
  14288. * @returns the current particle system
  14289. */
  14290. removeVelocityGradient(gradient: number): IParticleSystem;
  14291. /**
  14292. * Gets the current list of limit velocity gradients.
  14293. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14294. * @returns the list of limit velocity gradients
  14295. */
  14296. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14297. /**
  14298. * Adds a new limit velocity gradient
  14299. * @param gradient defines the gradient to use (between 0 and 1)
  14300. * @param factor defines the limit velocity to affect to the specified gradient
  14301. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14302. * @returns the current particle system
  14303. */
  14304. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14305. /**
  14306. * Remove a specific limit velocity gradient
  14307. * @param gradient defines the gradient to remove
  14308. * @returns the current particle system
  14309. */
  14310. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14311. /**
  14312. * Adds a new drag gradient
  14313. * @param gradient defines the gradient to use (between 0 and 1)
  14314. * @param factor defines the drag to affect to the specified gradient
  14315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14316. * @returns the current particle system
  14317. */
  14318. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14319. /**
  14320. * Remove a specific drag gradient
  14321. * @param gradient defines the gradient to remove
  14322. * @returns the current particle system
  14323. */
  14324. removeDragGradient(gradient: number): IParticleSystem;
  14325. /**
  14326. * Gets the current list of drag gradients.
  14327. * You must use addDragGradient and removeDragGradient to udpate this list
  14328. * @returns the list of drag gradients
  14329. */
  14330. getDragGradients(): Nullable<Array<FactorGradient>>;
  14331. /**
  14332. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14333. * @param gradient defines the gradient to use (between 0 and 1)
  14334. * @param factor defines the emit rate to affect to the specified gradient
  14335. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14336. * @returns the current particle system
  14337. */
  14338. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14339. /**
  14340. * Remove a specific emit rate gradient
  14341. * @param gradient defines the gradient to remove
  14342. * @returns the current particle system
  14343. */
  14344. removeEmitRateGradient(gradient: number): IParticleSystem;
  14345. /**
  14346. * Gets the current list of emit rate gradients.
  14347. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14348. * @returns the list of emit rate gradients
  14349. */
  14350. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14351. /**
  14352. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14353. * @param gradient defines the gradient to use (between 0 and 1)
  14354. * @param factor defines the start size to affect to the specified gradient
  14355. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14356. * @returns the current particle system
  14357. */
  14358. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14359. /**
  14360. * Remove a specific start size gradient
  14361. * @param gradient defines the gradient to remove
  14362. * @returns the current particle system
  14363. */
  14364. removeStartSizeGradient(gradient: number): IParticleSystem;
  14365. /**
  14366. * Gets the current list of start size gradients.
  14367. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14368. * @returns the list of start size gradients
  14369. */
  14370. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14371. /**
  14372. * Adds a new life time gradient
  14373. * @param gradient defines the gradient to use (between 0 and 1)
  14374. * @param factor defines the life time factor to affect to the specified gradient
  14375. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14376. * @returns the current particle system
  14377. */
  14378. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14379. /**
  14380. * Remove a specific life time gradient
  14381. * @param gradient defines the gradient to remove
  14382. * @returns the current particle system
  14383. */
  14384. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14385. /**
  14386. * Gets the current list of life time gradients.
  14387. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14388. * @returns the list of life time gradients
  14389. */
  14390. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14391. /**
  14392. * Gets the current list of color gradients.
  14393. * You must use addColorGradient and removeColorGradient to udpate this list
  14394. * @returns the list of color gradients
  14395. */
  14396. getColorGradients(): Nullable<Array<ColorGradient>>;
  14397. /**
  14398. * Adds a new ramp gradient used to remap particle colors
  14399. * @param gradient defines the gradient to use (between 0 and 1)
  14400. * @param color defines the color to affect to the specified gradient
  14401. * @returns the current particle system
  14402. */
  14403. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14404. /**
  14405. * Gets the current list of ramp gradients.
  14406. * You must use addRampGradient and removeRampGradient to udpate this list
  14407. * @returns the list of ramp gradients
  14408. */
  14409. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14410. /** Gets or sets a boolean indicating that ramp gradients must be used
  14411. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14412. */
  14413. useRampGradients: boolean;
  14414. /**
  14415. * Adds a new color remap gradient
  14416. * @param gradient defines the gradient to use (between 0 and 1)
  14417. * @param min defines the color remap minimal range
  14418. * @param max defines the color remap maximal range
  14419. * @returns the current particle system
  14420. */
  14421. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14422. /**
  14423. * Gets the current list of color remap gradients.
  14424. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14425. * @returns the list of color remap gradients
  14426. */
  14427. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14428. /**
  14429. * Adds a new alpha remap gradient
  14430. * @param gradient defines the gradient to use (between 0 and 1)
  14431. * @param min defines the alpha remap minimal range
  14432. * @param max defines the alpha remap maximal range
  14433. * @returns the current particle system
  14434. */
  14435. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14436. /**
  14437. * Gets the current list of alpha remap gradients.
  14438. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14439. * @returns the list of alpha remap gradients
  14440. */
  14441. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14442. /**
  14443. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14444. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14445. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14446. * @returns the emitter
  14447. */
  14448. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14449. /**
  14450. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14451. * @param radius The radius of the hemisphere to emit from
  14452. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14453. * @returns the emitter
  14454. */
  14455. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14456. /**
  14457. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14458. * @param radius The radius of the sphere to emit from
  14459. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14460. * @returns the emitter
  14461. */
  14462. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14463. /**
  14464. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14465. * @param radius The radius of the sphere to emit from
  14466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14468. * @returns the emitter
  14469. */
  14470. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14471. /**
  14472. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14473. * @param radius The radius of the emission cylinder
  14474. * @param height The height of the emission cylinder
  14475. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14476. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14477. * @returns the emitter
  14478. */
  14479. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14480. /**
  14481. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14482. * @param radius The radius of the cylinder to emit from
  14483. * @param height The height of the emission cylinder
  14484. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14485. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14486. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14487. * @returns the emitter
  14488. */
  14489. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14490. /**
  14491. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14492. * @param radius The radius of the cone to emit from
  14493. * @param angle The base angle of the cone
  14494. * @returns the emitter
  14495. */
  14496. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14497. /**
  14498. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14499. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14500. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14501. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14502. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14503. * @returns the emitter
  14504. */
  14505. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14506. /**
  14507. * Get hosting scene
  14508. * @returns the scene
  14509. */
  14510. getScene(): Scene;
  14511. }
  14512. }
  14513. declare module BABYLON {
  14514. /**
  14515. * 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.
  14516. * @see https://doc.babylonjs.com/how_to/transformnode
  14517. */
  14518. export class TransformNode extends Node {
  14519. /**
  14520. * Object will not rotate to face the camera
  14521. */
  14522. static BILLBOARDMODE_NONE: number;
  14523. /**
  14524. * Object will rotate to face the camera but only on the x axis
  14525. */
  14526. static BILLBOARDMODE_X: number;
  14527. /**
  14528. * Object will rotate to face the camera but only on the y axis
  14529. */
  14530. static BILLBOARDMODE_Y: number;
  14531. /**
  14532. * Object will rotate to face the camera but only on the z axis
  14533. */
  14534. static BILLBOARDMODE_Z: number;
  14535. /**
  14536. * Object will rotate to face the camera
  14537. */
  14538. static BILLBOARDMODE_ALL: number;
  14539. /**
  14540. * Object will rotate to face the camera's position instead of orientation
  14541. */
  14542. static BILLBOARDMODE_USE_POSITION: number;
  14543. private _forward;
  14544. private _forwardInverted;
  14545. private _up;
  14546. private _right;
  14547. private _rightInverted;
  14548. private _position;
  14549. private _rotation;
  14550. private _rotationQuaternion;
  14551. protected _scaling: Vector3;
  14552. protected _isDirty: boolean;
  14553. private _transformToBoneReferal;
  14554. private _isAbsoluteSynced;
  14555. private _billboardMode;
  14556. /**
  14557. * Gets or sets the billboard mode. Default is 0.
  14558. *
  14559. * | Value | Type | Description |
  14560. * | --- | --- | --- |
  14561. * | 0 | BILLBOARDMODE_NONE | |
  14562. * | 1 | BILLBOARDMODE_X | |
  14563. * | 2 | BILLBOARDMODE_Y | |
  14564. * | 4 | BILLBOARDMODE_Z | |
  14565. * | 7 | BILLBOARDMODE_ALL | |
  14566. *
  14567. */
  14568. get billboardMode(): number;
  14569. set billboardMode(value: number);
  14570. private _preserveParentRotationForBillboard;
  14571. /**
  14572. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14573. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14574. */
  14575. get preserveParentRotationForBillboard(): boolean;
  14576. set preserveParentRotationForBillboard(value: boolean);
  14577. /**
  14578. * 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
  14579. */
  14580. scalingDeterminant: number;
  14581. private _infiniteDistance;
  14582. /**
  14583. * Gets or sets the distance of the object to max, often used by skybox
  14584. */
  14585. get infiniteDistance(): boolean;
  14586. set infiniteDistance(value: boolean);
  14587. /**
  14588. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14589. * By default the system will update normals to compensate
  14590. */
  14591. ignoreNonUniformScaling: boolean;
  14592. /**
  14593. * 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
  14594. */
  14595. reIntegrateRotationIntoRotationQuaternion: boolean;
  14596. /** @hidden */
  14597. _poseMatrix: Nullable<Matrix>;
  14598. /** @hidden */
  14599. _localMatrix: Matrix;
  14600. private _usePivotMatrix;
  14601. private _absolutePosition;
  14602. private _absoluteScaling;
  14603. private _absoluteRotationQuaternion;
  14604. private _pivotMatrix;
  14605. private _pivotMatrixInverse;
  14606. protected _postMultiplyPivotMatrix: boolean;
  14607. protected _isWorldMatrixFrozen: boolean;
  14608. /** @hidden */
  14609. _indexInSceneTransformNodesArray: number;
  14610. /**
  14611. * An event triggered after the world matrix is updated
  14612. */
  14613. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14614. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14615. /**
  14616. * Gets a string identifying the name of the class
  14617. * @returns "TransformNode" string
  14618. */
  14619. getClassName(): string;
  14620. /**
  14621. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14622. */
  14623. get position(): Vector3;
  14624. set position(newPosition: Vector3);
  14625. /**
  14626. * 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)).
  14627. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14628. */
  14629. get rotation(): Vector3;
  14630. set rotation(newRotation: Vector3);
  14631. /**
  14632. * 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)).
  14633. */
  14634. get scaling(): Vector3;
  14635. set scaling(newScaling: Vector3);
  14636. /**
  14637. * 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).
  14638. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14639. */
  14640. get rotationQuaternion(): Nullable<Quaternion>;
  14641. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14642. /**
  14643. * The forward direction of that transform in world space.
  14644. */
  14645. get forward(): Vector3;
  14646. /**
  14647. * The up direction of that transform in world space.
  14648. */
  14649. get up(): Vector3;
  14650. /**
  14651. * The right direction of that transform in world space.
  14652. */
  14653. get right(): Vector3;
  14654. /**
  14655. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14656. * @param matrix the matrix to copy the pose from
  14657. * @returns this TransformNode.
  14658. */
  14659. updatePoseMatrix(matrix: Matrix): TransformNode;
  14660. /**
  14661. * Returns the mesh Pose matrix.
  14662. * @returns the pose matrix
  14663. */
  14664. getPoseMatrix(): Matrix;
  14665. /** @hidden */
  14666. _isSynchronized(): boolean;
  14667. /** @hidden */
  14668. _initCache(): void;
  14669. /**
  14670. * Flag the transform node as dirty (Forcing it to update everything)
  14671. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14672. * @returns this transform node
  14673. */
  14674. markAsDirty(property: string): TransformNode;
  14675. /**
  14676. * Returns the current mesh absolute position.
  14677. * Returns a Vector3.
  14678. */
  14679. get absolutePosition(): Vector3;
  14680. /**
  14681. * Returns the current mesh absolute scaling.
  14682. * Returns a Vector3.
  14683. */
  14684. get absoluteScaling(): Vector3;
  14685. /**
  14686. * Returns the current mesh absolute rotation.
  14687. * Returns a Quaternion.
  14688. */
  14689. get absoluteRotationQuaternion(): Quaternion;
  14690. /**
  14691. * Sets a new matrix to apply before all other transformation
  14692. * @param matrix defines the transform matrix
  14693. * @returns the current TransformNode
  14694. */
  14695. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14696. /**
  14697. * Sets a new pivot matrix to the current node
  14698. * @param matrix defines the new pivot matrix to use
  14699. * @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
  14700. * @returns the current TransformNode
  14701. */
  14702. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14703. /**
  14704. * Returns the mesh pivot matrix.
  14705. * Default : Identity.
  14706. * @returns the matrix
  14707. */
  14708. getPivotMatrix(): Matrix;
  14709. /**
  14710. * Instantiate (when possible) or clone that node with its hierarchy
  14711. * @param newParent defines the new parent to use for the instance (or clone)
  14712. * @param options defines options to configure how copy is done
  14713. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14714. * @returns an instance (or a clone) of the current node with its hiearchy
  14715. */
  14716. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14717. doNotInstantiate: boolean;
  14718. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14719. /**
  14720. * Prevents the World matrix to be computed any longer
  14721. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14722. * @returns the TransformNode.
  14723. */
  14724. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14725. /**
  14726. * Allows back the World matrix computation.
  14727. * @returns the TransformNode.
  14728. */
  14729. unfreezeWorldMatrix(): this;
  14730. /**
  14731. * True if the World matrix has been frozen.
  14732. */
  14733. get isWorldMatrixFrozen(): boolean;
  14734. /**
  14735. * Retuns the mesh absolute position in the World.
  14736. * @returns a Vector3.
  14737. */
  14738. getAbsolutePosition(): Vector3;
  14739. /**
  14740. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14741. * @param absolutePosition the absolute position to set
  14742. * @returns the TransformNode.
  14743. */
  14744. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14745. /**
  14746. * Sets the mesh position in its local space.
  14747. * @param vector3 the position to set in localspace
  14748. * @returns the TransformNode.
  14749. */
  14750. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14751. /**
  14752. * Returns the mesh position in the local space from the current World matrix values.
  14753. * @returns a new Vector3.
  14754. */
  14755. getPositionExpressedInLocalSpace(): Vector3;
  14756. /**
  14757. * Translates the mesh along the passed Vector3 in its local space.
  14758. * @param vector3 the distance to translate in localspace
  14759. * @returns the TransformNode.
  14760. */
  14761. locallyTranslate(vector3: Vector3): TransformNode;
  14762. private static _lookAtVectorCache;
  14763. /**
  14764. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14765. * @param targetPoint the position (must be in same space as current mesh) to look at
  14766. * @param yawCor optional yaw (y-axis) correction in radians
  14767. * @param pitchCor optional pitch (x-axis) correction in radians
  14768. * @param rollCor optional roll (z-axis) correction in radians
  14769. * @param space the choosen space of the target
  14770. * @returns the TransformNode.
  14771. */
  14772. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14773. /**
  14774. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14775. * This Vector3 is expressed in the World space.
  14776. * @param localAxis axis to rotate
  14777. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14778. */
  14779. getDirection(localAxis: Vector3): Vector3;
  14780. /**
  14781. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14782. * localAxis is expressed in the mesh local space.
  14783. * result is computed in the Wordl space from the mesh World matrix.
  14784. * @param localAxis axis to rotate
  14785. * @param result the resulting transformnode
  14786. * @returns this TransformNode.
  14787. */
  14788. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14789. /**
  14790. * Sets this transform node rotation to the given local axis.
  14791. * @param localAxis the axis in local space
  14792. * @param yawCor optional yaw (y-axis) correction in radians
  14793. * @param pitchCor optional pitch (x-axis) correction in radians
  14794. * @param rollCor optional roll (z-axis) correction in radians
  14795. * @returns this TransformNode
  14796. */
  14797. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14798. /**
  14799. * Sets a new pivot point to the current node
  14800. * @param point defines the new pivot point to use
  14801. * @param space defines if the point is in world or local space (local by default)
  14802. * @returns the current TransformNode
  14803. */
  14804. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14805. /**
  14806. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14807. * @returns the pivot point
  14808. */
  14809. getPivotPoint(): Vector3;
  14810. /**
  14811. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14812. * @param result the vector3 to store the result
  14813. * @returns this TransformNode.
  14814. */
  14815. getPivotPointToRef(result: Vector3): TransformNode;
  14816. /**
  14817. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14818. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14819. */
  14820. getAbsolutePivotPoint(): Vector3;
  14821. /**
  14822. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14823. * @param result vector3 to store the result
  14824. * @returns this TransformNode.
  14825. */
  14826. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14827. /**
  14828. * Defines the passed node as the parent of the current node.
  14829. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14830. * @see https://doc.babylonjs.com/how_to/parenting
  14831. * @param node the node ot set as the parent
  14832. * @returns this TransformNode.
  14833. */
  14834. setParent(node: Nullable<Node>): TransformNode;
  14835. private _nonUniformScaling;
  14836. /**
  14837. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14838. */
  14839. get nonUniformScaling(): boolean;
  14840. /** @hidden */
  14841. _updateNonUniformScalingState(value: boolean): boolean;
  14842. /**
  14843. * Attach the current TransformNode to another TransformNode associated with a bone
  14844. * @param bone Bone affecting the TransformNode
  14845. * @param affectedTransformNode TransformNode associated with the bone
  14846. * @returns this object
  14847. */
  14848. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14849. /**
  14850. * Detach the transform node if its associated with a bone
  14851. * @returns this object
  14852. */
  14853. detachFromBone(): TransformNode;
  14854. private static _rotationAxisCache;
  14855. /**
  14856. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14857. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14858. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14859. * The passed axis is also normalized.
  14860. * @param axis the axis to rotate around
  14861. * @param amount the amount to rotate in radians
  14862. * @param space Space to rotate in (Default: local)
  14863. * @returns the TransformNode.
  14864. */
  14865. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14866. /**
  14867. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14868. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14869. * The passed axis is also normalized. .
  14870. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14871. * @param point the point to rotate around
  14872. * @param axis the axis to rotate around
  14873. * @param amount the amount to rotate in radians
  14874. * @returns the TransformNode
  14875. */
  14876. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14877. /**
  14878. * Translates the mesh along the axis vector for the passed distance in the given space.
  14879. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14880. * @param axis the axis to translate in
  14881. * @param distance the distance to translate
  14882. * @param space Space to rotate in (Default: local)
  14883. * @returns the TransformNode.
  14884. */
  14885. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14886. /**
  14887. * Adds a rotation step to the mesh current rotation.
  14888. * x, y, z are Euler angles expressed in radians.
  14889. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14890. * This means this rotation is made in the mesh local space only.
  14891. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14892. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14893. * ```javascript
  14894. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14895. * ```
  14896. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14897. * 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.
  14898. * @param x Rotation to add
  14899. * @param y Rotation to add
  14900. * @param z Rotation to add
  14901. * @returns the TransformNode.
  14902. */
  14903. addRotation(x: number, y: number, z: number): TransformNode;
  14904. /**
  14905. * @hidden
  14906. */
  14907. protected _getEffectiveParent(): Nullable<Node>;
  14908. /**
  14909. * Computes the world matrix of the node
  14910. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14911. * @returns the world matrix
  14912. */
  14913. computeWorldMatrix(force?: boolean): Matrix;
  14914. /**
  14915. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14916. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14917. */
  14918. resetLocalMatrix(independentOfChildren?: boolean): void;
  14919. protected _afterComputeWorldMatrix(): void;
  14920. /**
  14921. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14922. * @param func callback function to add
  14923. *
  14924. * @returns the TransformNode.
  14925. */
  14926. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14927. /**
  14928. * Removes a registered callback function.
  14929. * @param func callback function to remove
  14930. * @returns the TransformNode.
  14931. */
  14932. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14933. /**
  14934. * Gets the position of the current mesh in camera space
  14935. * @param camera defines the camera to use
  14936. * @returns a position
  14937. */
  14938. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14939. /**
  14940. * Returns the distance from the mesh to the active camera
  14941. * @param camera defines the camera to use
  14942. * @returns the distance
  14943. */
  14944. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14945. /**
  14946. * Clone the current transform node
  14947. * @param name Name of the new clone
  14948. * @param newParent New parent for the clone
  14949. * @param doNotCloneChildren Do not clone children hierarchy
  14950. * @returns the new transform node
  14951. */
  14952. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14953. /**
  14954. * Serializes the objects information.
  14955. * @param currentSerializationObject defines the object to serialize in
  14956. * @returns the serialized object
  14957. */
  14958. serialize(currentSerializationObject?: any): any;
  14959. /**
  14960. * Returns a new TransformNode object parsed from the source provided.
  14961. * @param parsedTransformNode is the source.
  14962. * @param scene the scne the object belongs to
  14963. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14964. * @returns a new TransformNode object parsed from the source provided.
  14965. */
  14966. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14967. /**
  14968. * Get all child-transformNodes of this node
  14969. * @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
  14970. * @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
  14971. * @returns an array of TransformNode
  14972. */
  14973. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14974. /**
  14975. * Releases resources associated with this transform node.
  14976. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14977. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14978. */
  14979. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14980. /**
  14981. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14982. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14983. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14984. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14985. * @returns the current mesh
  14986. */
  14987. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14988. private _syncAbsoluteScalingAndRotation;
  14989. }
  14990. }
  14991. declare module BABYLON {
  14992. /**
  14993. * Class used to override all child animations of a given target
  14994. */
  14995. export class AnimationPropertiesOverride {
  14996. /**
  14997. * Gets or sets a value indicating if animation blending must be used
  14998. */
  14999. enableBlending: boolean;
  15000. /**
  15001. * Gets or sets the blending speed to use when enableBlending is true
  15002. */
  15003. blendingSpeed: number;
  15004. /**
  15005. * Gets or sets the default loop mode to use
  15006. */
  15007. loopMode: number;
  15008. }
  15009. }
  15010. declare module BABYLON {
  15011. /**
  15012. * Class used to store bone information
  15013. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15014. */
  15015. export class Bone extends Node {
  15016. /**
  15017. * defines the bone name
  15018. */
  15019. name: string;
  15020. private static _tmpVecs;
  15021. private static _tmpQuat;
  15022. private static _tmpMats;
  15023. /**
  15024. * Gets the list of child bones
  15025. */
  15026. children: Bone[];
  15027. /** Gets the animations associated with this bone */
  15028. animations: Animation[];
  15029. /**
  15030. * Gets or sets bone length
  15031. */
  15032. length: number;
  15033. /**
  15034. * @hidden Internal only
  15035. * Set this value to map this bone to a different index in the transform matrices
  15036. * Set this value to -1 to exclude the bone from the transform matrices
  15037. */
  15038. _index: Nullable<number>;
  15039. private _skeleton;
  15040. private _localMatrix;
  15041. private _restPose;
  15042. private _baseMatrix;
  15043. private _absoluteTransform;
  15044. private _invertedAbsoluteTransform;
  15045. private _parent;
  15046. private _scalingDeterminant;
  15047. private _worldTransform;
  15048. private _localScaling;
  15049. private _localRotation;
  15050. private _localPosition;
  15051. private _needToDecompose;
  15052. private _needToCompose;
  15053. /** @hidden */
  15054. _linkedTransformNode: Nullable<TransformNode>;
  15055. /** @hidden */
  15056. _waitingTransformNodeId: Nullable<string>;
  15057. /** @hidden */
  15058. get _matrix(): Matrix;
  15059. /** @hidden */
  15060. set _matrix(value: Matrix);
  15061. /**
  15062. * Create a new bone
  15063. * @param name defines the bone name
  15064. * @param skeleton defines the parent skeleton
  15065. * @param parentBone defines the parent (can be null if the bone is the root)
  15066. * @param localMatrix defines the local matrix
  15067. * @param restPose defines the rest pose matrix
  15068. * @param baseMatrix defines the base matrix
  15069. * @param index defines index of the bone in the hiearchy
  15070. */
  15071. constructor(
  15072. /**
  15073. * defines the bone name
  15074. */
  15075. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15076. /**
  15077. * Gets the current object class name.
  15078. * @return the class name
  15079. */
  15080. getClassName(): string;
  15081. /**
  15082. * Gets the parent skeleton
  15083. * @returns a skeleton
  15084. */
  15085. getSkeleton(): Skeleton;
  15086. /**
  15087. * Gets parent bone
  15088. * @returns a bone or null if the bone is the root of the bone hierarchy
  15089. */
  15090. getParent(): Nullable<Bone>;
  15091. /**
  15092. * Returns an array containing the root bones
  15093. * @returns an array containing the root bones
  15094. */
  15095. getChildren(): Array<Bone>;
  15096. /**
  15097. * Gets the node index in matrix array generated for rendering
  15098. * @returns the node index
  15099. */
  15100. getIndex(): number;
  15101. /**
  15102. * Sets the parent bone
  15103. * @param parent defines the parent (can be null if the bone is the root)
  15104. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15105. */
  15106. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15107. /**
  15108. * Gets the local matrix
  15109. * @returns a matrix
  15110. */
  15111. getLocalMatrix(): Matrix;
  15112. /**
  15113. * Gets the base matrix (initial matrix which remains unchanged)
  15114. * @returns a matrix
  15115. */
  15116. getBaseMatrix(): Matrix;
  15117. /**
  15118. * Gets the rest pose matrix
  15119. * @returns a matrix
  15120. */
  15121. getRestPose(): Matrix;
  15122. /**
  15123. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15124. */
  15125. getWorldMatrix(): Matrix;
  15126. /**
  15127. * Sets the local matrix to rest pose matrix
  15128. */
  15129. returnToRest(): void;
  15130. /**
  15131. * Gets the inverse of the absolute transform matrix.
  15132. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15133. * @returns a matrix
  15134. */
  15135. getInvertedAbsoluteTransform(): Matrix;
  15136. /**
  15137. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15138. * @returns a matrix
  15139. */
  15140. getAbsoluteTransform(): Matrix;
  15141. /**
  15142. * Links with the given transform node.
  15143. * The local matrix of this bone is copied from the transform node every frame.
  15144. * @param transformNode defines the transform node to link to
  15145. */
  15146. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15147. /**
  15148. * Gets the node used to drive the bone's transformation
  15149. * @returns a transform node or null
  15150. */
  15151. getTransformNode(): Nullable<TransformNode>;
  15152. /** Gets or sets current position (in local space) */
  15153. get position(): Vector3;
  15154. set position(newPosition: Vector3);
  15155. /** Gets or sets current rotation (in local space) */
  15156. get rotation(): Vector3;
  15157. set rotation(newRotation: Vector3);
  15158. /** Gets or sets current rotation quaternion (in local space) */
  15159. get rotationQuaternion(): Quaternion;
  15160. set rotationQuaternion(newRotation: Quaternion);
  15161. /** Gets or sets current scaling (in local space) */
  15162. get scaling(): Vector3;
  15163. set scaling(newScaling: Vector3);
  15164. /**
  15165. * Gets the animation properties override
  15166. */
  15167. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15168. private _decompose;
  15169. private _compose;
  15170. /**
  15171. * Update the base and local matrices
  15172. * @param matrix defines the new base or local matrix
  15173. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15174. * @param updateLocalMatrix defines if the local matrix should be updated
  15175. */
  15176. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15177. /** @hidden */
  15178. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15179. /**
  15180. * Flag the bone as dirty (Forcing it to update everything)
  15181. */
  15182. markAsDirty(): void;
  15183. /** @hidden */
  15184. _markAsDirtyAndCompose(): void;
  15185. private _markAsDirtyAndDecompose;
  15186. /**
  15187. * Translate the bone in local or world space
  15188. * @param vec The amount to translate the bone
  15189. * @param space The space that the translation is in
  15190. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15191. */
  15192. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15193. /**
  15194. * Set the postion of the bone in local or world space
  15195. * @param position The position to set the bone
  15196. * @param space The space that the position is in
  15197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15198. */
  15199. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15200. /**
  15201. * Set the absolute position of the bone (world space)
  15202. * @param position The position to set the bone
  15203. * @param mesh The mesh that this bone is attached to
  15204. */
  15205. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15206. /**
  15207. * Scale the bone on the x, y and z axes (in local space)
  15208. * @param x The amount to scale the bone on the x axis
  15209. * @param y The amount to scale the bone on the y axis
  15210. * @param z The amount to scale the bone on the z axis
  15211. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15212. */
  15213. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15214. /**
  15215. * Set the bone scaling in local space
  15216. * @param scale defines the scaling vector
  15217. */
  15218. setScale(scale: Vector3): void;
  15219. /**
  15220. * Gets the current scaling in local space
  15221. * @returns the current scaling vector
  15222. */
  15223. getScale(): Vector3;
  15224. /**
  15225. * Gets the current scaling in local space and stores it in a target vector
  15226. * @param result defines the target vector
  15227. */
  15228. getScaleToRef(result: Vector3): void;
  15229. /**
  15230. * Set the yaw, pitch, and roll of the bone in local or world space
  15231. * @param yaw The rotation of the bone on the y axis
  15232. * @param pitch The rotation of the bone on the x axis
  15233. * @param roll The rotation of the bone on the z axis
  15234. * @param space The space that the axes of rotation are in
  15235. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15236. */
  15237. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15238. /**
  15239. * Add a rotation to the bone on an axis in local or world space
  15240. * @param axis The axis to rotate the bone on
  15241. * @param amount The amount to rotate the bone
  15242. * @param space The space that the axis is in
  15243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15244. */
  15245. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15246. /**
  15247. * Set the rotation of the bone to a particular axis angle in local or world space
  15248. * @param axis The axis to rotate the bone on
  15249. * @param angle The angle that the bone should be rotated to
  15250. * @param space The space that the axis is in
  15251. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15252. */
  15253. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15254. /**
  15255. * Set the euler rotation of the bone in local of world space
  15256. * @param rotation The euler rotation that the bone should be set to
  15257. * @param space The space that the rotation is in
  15258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15259. */
  15260. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15261. /**
  15262. * Set the quaternion rotation of the bone in local of world space
  15263. * @param quat The quaternion rotation that the bone should be set to
  15264. * @param space The space that the rotation is in
  15265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15266. */
  15267. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15268. /**
  15269. * Set the rotation matrix of the bone in local of world space
  15270. * @param rotMat The rotation matrix that the bone should be set to
  15271. * @param space The space that the rotation is in
  15272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15273. */
  15274. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15275. private _rotateWithMatrix;
  15276. private _getNegativeRotationToRef;
  15277. /**
  15278. * Get the position of the bone in local or world space
  15279. * @param space The space that the returned position is in
  15280. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15281. * @returns The position of the bone
  15282. */
  15283. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15284. /**
  15285. * Copy the position of the bone to a vector3 in local or world space
  15286. * @param space The space that the returned position is in
  15287. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15288. * @param result The vector3 to copy the position to
  15289. */
  15290. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15291. /**
  15292. * Get the absolute position of the bone (world space)
  15293. * @param mesh The mesh that this bone is attached to
  15294. * @returns The absolute position of the bone
  15295. */
  15296. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15297. /**
  15298. * Copy the absolute position of the bone (world space) to the result param
  15299. * @param mesh The mesh that this bone is attached to
  15300. * @param result The vector3 to copy the absolute position to
  15301. */
  15302. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15303. /**
  15304. * Compute the absolute transforms of this bone and its children
  15305. */
  15306. computeAbsoluteTransforms(): void;
  15307. /**
  15308. * Get the world direction from an axis that is in the local space of the bone
  15309. * @param localAxis The local direction that is used to compute the world direction
  15310. * @param mesh The mesh that this bone is attached to
  15311. * @returns The world direction
  15312. */
  15313. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15314. /**
  15315. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15316. * @param localAxis The local direction that is used to compute the world direction
  15317. * @param mesh The mesh that this bone is attached to
  15318. * @param result The vector3 that the world direction will be copied to
  15319. */
  15320. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15321. /**
  15322. * Get the euler rotation of the bone in local or world space
  15323. * @param space The space that the rotation should be in
  15324. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15325. * @returns The euler rotation
  15326. */
  15327. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15328. /**
  15329. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15330. * @param space The space that the rotation should be in
  15331. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15332. * @param result The vector3 that the rotation should be copied to
  15333. */
  15334. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15335. /**
  15336. * Get the quaternion rotation of the bone in either local or world space
  15337. * @param space The space that the rotation should be in
  15338. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15339. * @returns The quaternion rotation
  15340. */
  15341. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15342. /**
  15343. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15344. * @param space The space that the rotation should be in
  15345. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15346. * @param result The quaternion that the rotation should be copied to
  15347. */
  15348. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15349. /**
  15350. * Get the rotation matrix of the bone in local or world space
  15351. * @param space The space that the rotation should be in
  15352. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15353. * @returns The rotation matrix
  15354. */
  15355. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15356. /**
  15357. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15358. * @param space The space that the rotation should be in
  15359. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15360. * @param result The quaternion that the rotation should be copied to
  15361. */
  15362. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15363. /**
  15364. * Get the world position of a point that is in the local space of the bone
  15365. * @param position The local position
  15366. * @param mesh The mesh that this bone is attached to
  15367. * @returns The world position
  15368. */
  15369. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15370. /**
  15371. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15372. * @param position The local position
  15373. * @param mesh The mesh that this bone is attached to
  15374. * @param result The vector3 that the world position should be copied to
  15375. */
  15376. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15377. /**
  15378. * Get the local position of a point that is in world space
  15379. * @param position The world position
  15380. * @param mesh The mesh that this bone is attached to
  15381. * @returns The local position
  15382. */
  15383. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15384. /**
  15385. * Get the local position of a point that is in world space and copy it to the result param
  15386. * @param position The world position
  15387. * @param mesh The mesh that this bone is attached to
  15388. * @param result The vector3 that the local position should be copied to
  15389. */
  15390. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15391. }
  15392. }
  15393. declare module BABYLON {
  15394. /**
  15395. * Defines a runtime animation
  15396. */
  15397. export class RuntimeAnimation {
  15398. private _events;
  15399. /**
  15400. * The current frame of the runtime animation
  15401. */
  15402. private _currentFrame;
  15403. /**
  15404. * The animation used by the runtime animation
  15405. */
  15406. private _animation;
  15407. /**
  15408. * The target of the runtime animation
  15409. */
  15410. private _target;
  15411. /**
  15412. * The initiating animatable
  15413. */
  15414. private _host;
  15415. /**
  15416. * The original value of the runtime animation
  15417. */
  15418. private _originalValue;
  15419. /**
  15420. * The original blend value of the runtime animation
  15421. */
  15422. private _originalBlendValue;
  15423. /**
  15424. * The offsets cache of the runtime animation
  15425. */
  15426. private _offsetsCache;
  15427. /**
  15428. * The high limits cache of the runtime animation
  15429. */
  15430. private _highLimitsCache;
  15431. /**
  15432. * Specifies if the runtime animation has been stopped
  15433. */
  15434. private _stopped;
  15435. /**
  15436. * The blending factor of the runtime animation
  15437. */
  15438. private _blendingFactor;
  15439. /**
  15440. * The BabylonJS scene
  15441. */
  15442. private _scene;
  15443. /**
  15444. * The current value of the runtime animation
  15445. */
  15446. private _currentValue;
  15447. /** @hidden */
  15448. _animationState: _IAnimationState;
  15449. /**
  15450. * The active target of the runtime animation
  15451. */
  15452. private _activeTargets;
  15453. private _currentActiveTarget;
  15454. private _directTarget;
  15455. /**
  15456. * The target path of the runtime animation
  15457. */
  15458. private _targetPath;
  15459. /**
  15460. * The weight of the runtime animation
  15461. */
  15462. private _weight;
  15463. /**
  15464. * The ratio offset of the runtime animation
  15465. */
  15466. private _ratioOffset;
  15467. /**
  15468. * The previous delay of the runtime animation
  15469. */
  15470. private _previousDelay;
  15471. /**
  15472. * The previous ratio of the runtime animation
  15473. */
  15474. private _previousRatio;
  15475. private _enableBlending;
  15476. private _keys;
  15477. private _minFrame;
  15478. private _maxFrame;
  15479. private _minValue;
  15480. private _maxValue;
  15481. private _targetIsArray;
  15482. /**
  15483. * Gets the current frame of the runtime animation
  15484. */
  15485. get currentFrame(): number;
  15486. /**
  15487. * Gets the weight of the runtime animation
  15488. */
  15489. get weight(): number;
  15490. /**
  15491. * Gets the current value of the runtime animation
  15492. */
  15493. get currentValue(): any;
  15494. /**
  15495. * Gets the target path of the runtime animation
  15496. */
  15497. get targetPath(): string;
  15498. /**
  15499. * Gets the actual target of the runtime animation
  15500. */
  15501. get target(): any;
  15502. /**
  15503. * Gets the additive state of the runtime animation
  15504. */
  15505. get isAdditive(): boolean;
  15506. /** @hidden */
  15507. _onLoop: () => void;
  15508. /**
  15509. * Create a new RuntimeAnimation object
  15510. * @param target defines the target of the animation
  15511. * @param animation defines the source animation object
  15512. * @param scene defines the hosting scene
  15513. * @param host defines the initiating Animatable
  15514. */
  15515. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15516. private _preparePath;
  15517. /**
  15518. * Gets the animation from the runtime animation
  15519. */
  15520. get animation(): Animation;
  15521. /**
  15522. * Resets the runtime animation to the beginning
  15523. * @param restoreOriginal defines whether to restore the target property to the original value
  15524. */
  15525. reset(restoreOriginal?: boolean): void;
  15526. /**
  15527. * Specifies if the runtime animation is stopped
  15528. * @returns Boolean specifying if the runtime animation is stopped
  15529. */
  15530. isStopped(): boolean;
  15531. /**
  15532. * Disposes of the runtime animation
  15533. */
  15534. dispose(): void;
  15535. /**
  15536. * Apply the interpolated value to the target
  15537. * @param currentValue defines the value computed by the animation
  15538. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15539. */
  15540. setValue(currentValue: any, weight: number): void;
  15541. private _getOriginalValues;
  15542. private _setValue;
  15543. /**
  15544. * Gets the loop pmode of the runtime animation
  15545. * @returns Loop Mode
  15546. */
  15547. private _getCorrectLoopMode;
  15548. /**
  15549. * Move the current animation to a given frame
  15550. * @param frame defines the frame to move to
  15551. */
  15552. goToFrame(frame: number): void;
  15553. /**
  15554. * @hidden Internal use only
  15555. */
  15556. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15557. /**
  15558. * Execute the current animation
  15559. * @param delay defines the delay to add to the current frame
  15560. * @param from defines the lower bound of the animation range
  15561. * @param to defines the upper bound of the animation range
  15562. * @param loop defines if the current animation must loop
  15563. * @param speedRatio defines the current speed ratio
  15564. * @param weight defines the weight of the animation (default is -1 so no weight)
  15565. * @param onLoop optional callback called when animation loops
  15566. * @returns a boolean indicating if the animation is running
  15567. */
  15568. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15569. }
  15570. }
  15571. declare module BABYLON {
  15572. /**
  15573. * Class used to store an actual running animation
  15574. */
  15575. export class Animatable {
  15576. /** defines the target object */
  15577. target: any;
  15578. /** defines the starting frame number (default is 0) */
  15579. fromFrame: number;
  15580. /** defines the ending frame number (default is 100) */
  15581. toFrame: number;
  15582. /** defines if the animation must loop (default is false) */
  15583. loopAnimation: boolean;
  15584. /** defines a callback to call when animation ends if it is not looping */
  15585. onAnimationEnd?: (() => void) | null | undefined;
  15586. /** defines a callback to call when animation loops */
  15587. onAnimationLoop?: (() => void) | null | undefined;
  15588. /** defines whether the animation should be evaluated additively */
  15589. isAdditive: boolean;
  15590. private _localDelayOffset;
  15591. private _pausedDelay;
  15592. private _runtimeAnimations;
  15593. private _paused;
  15594. private _scene;
  15595. private _speedRatio;
  15596. private _weight;
  15597. private _syncRoot;
  15598. /**
  15599. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15600. * This will only apply for non looping animation (default is true)
  15601. */
  15602. disposeOnEnd: boolean;
  15603. /**
  15604. * Gets a boolean indicating if the animation has started
  15605. */
  15606. animationStarted: boolean;
  15607. /**
  15608. * Observer raised when the animation ends
  15609. */
  15610. onAnimationEndObservable: Observable<Animatable>;
  15611. /**
  15612. * Observer raised when the animation loops
  15613. */
  15614. onAnimationLoopObservable: Observable<Animatable>;
  15615. /**
  15616. * Gets the root Animatable used to synchronize and normalize animations
  15617. */
  15618. get syncRoot(): Nullable<Animatable>;
  15619. /**
  15620. * Gets the current frame of the first RuntimeAnimation
  15621. * Used to synchronize Animatables
  15622. */
  15623. get masterFrame(): number;
  15624. /**
  15625. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15626. */
  15627. get weight(): number;
  15628. set weight(value: number);
  15629. /**
  15630. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15631. */
  15632. get speedRatio(): number;
  15633. set speedRatio(value: number);
  15634. /**
  15635. * Creates a new Animatable
  15636. * @param scene defines the hosting scene
  15637. * @param target defines the target object
  15638. * @param fromFrame defines the starting frame number (default is 0)
  15639. * @param toFrame defines the ending frame number (default is 100)
  15640. * @param loopAnimation defines if the animation must loop (default is false)
  15641. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15642. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15643. * @param animations defines a group of animation to add to the new Animatable
  15644. * @param onAnimationLoop defines a callback to call when animation loops
  15645. * @param isAdditive defines whether the animation should be evaluated additively
  15646. */
  15647. constructor(scene: Scene,
  15648. /** defines the target object */
  15649. target: any,
  15650. /** defines the starting frame number (default is 0) */
  15651. fromFrame?: number,
  15652. /** defines the ending frame number (default is 100) */
  15653. toFrame?: number,
  15654. /** defines if the animation must loop (default is false) */
  15655. loopAnimation?: boolean, speedRatio?: number,
  15656. /** defines a callback to call when animation ends if it is not looping */
  15657. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15658. /** defines a callback to call when animation loops */
  15659. onAnimationLoop?: (() => void) | null | undefined,
  15660. /** defines whether the animation should be evaluated additively */
  15661. isAdditive?: boolean);
  15662. /**
  15663. * Synchronize and normalize current Animatable with a source Animatable
  15664. * This is useful when using animation weights and when animations are not of the same length
  15665. * @param root defines the root Animatable to synchronize with
  15666. * @returns the current Animatable
  15667. */
  15668. syncWith(root: Animatable): Animatable;
  15669. /**
  15670. * Gets the list of runtime animations
  15671. * @returns an array of RuntimeAnimation
  15672. */
  15673. getAnimations(): RuntimeAnimation[];
  15674. /**
  15675. * Adds more animations to the current animatable
  15676. * @param target defines the target of the animations
  15677. * @param animations defines the new animations to add
  15678. */
  15679. appendAnimations(target: any, animations: Animation[]): void;
  15680. /**
  15681. * Gets the source animation for a specific property
  15682. * @param property defines the propertyu to look for
  15683. * @returns null or the source animation for the given property
  15684. */
  15685. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15686. /**
  15687. * Gets the runtime animation for a specific property
  15688. * @param property defines the propertyu to look for
  15689. * @returns null or the runtime animation for the given property
  15690. */
  15691. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15692. /**
  15693. * Resets the animatable to its original state
  15694. */
  15695. reset(): void;
  15696. /**
  15697. * Allows the animatable to blend with current running animations
  15698. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15699. * @param blendingSpeed defines the blending speed to use
  15700. */
  15701. enableBlending(blendingSpeed: number): void;
  15702. /**
  15703. * Disable animation blending
  15704. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15705. */
  15706. disableBlending(): void;
  15707. /**
  15708. * Jump directly to a given frame
  15709. * @param frame defines the frame to jump to
  15710. */
  15711. goToFrame(frame: number): void;
  15712. /**
  15713. * Pause the animation
  15714. */
  15715. pause(): void;
  15716. /**
  15717. * Restart the animation
  15718. */
  15719. restart(): void;
  15720. private _raiseOnAnimationEnd;
  15721. /**
  15722. * Stop and delete the current animation
  15723. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15724. * @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)
  15725. */
  15726. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15727. /**
  15728. * Wait asynchronously for the animation to end
  15729. * @returns a promise which will be fullfilled when the animation ends
  15730. */
  15731. waitAsync(): Promise<Animatable>;
  15732. /** @hidden */
  15733. _animate(delay: number): boolean;
  15734. }
  15735. interface Scene {
  15736. /** @hidden */
  15737. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15738. /** @hidden */
  15739. _processLateAnimationBindingsForMatrices(holder: {
  15740. totalWeight: number;
  15741. totalAdditiveWeight: number;
  15742. animations: RuntimeAnimation[];
  15743. additiveAnimations: RuntimeAnimation[];
  15744. originalValue: Matrix;
  15745. }): any;
  15746. /** @hidden */
  15747. _processLateAnimationBindingsForQuaternions(holder: {
  15748. totalWeight: number;
  15749. totalAdditiveWeight: number;
  15750. animations: RuntimeAnimation[];
  15751. additiveAnimations: RuntimeAnimation[];
  15752. originalValue: Quaternion;
  15753. }, refQuaternion: Quaternion): Quaternion;
  15754. /** @hidden */
  15755. _processLateAnimationBindings(): void;
  15756. /**
  15757. * Will start the animation sequence of a given target
  15758. * @param target defines the target
  15759. * @param from defines from which frame should animation start
  15760. * @param to defines until which frame should animation run.
  15761. * @param weight defines the weight to apply to the animation (1.0 by default)
  15762. * @param loop defines if the animation loops
  15763. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15764. * @param onAnimationEnd defines the function to be executed when the animation ends
  15765. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15766. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15767. * @param onAnimationLoop defines the callback to call when an animation loops
  15768. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15769. * @returns the animatable object created for this animation
  15770. */
  15771. 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;
  15772. /**
  15773. * Will start the animation sequence of a given target
  15774. * @param target defines the target
  15775. * @param from defines from which frame should animation start
  15776. * @param to defines until which frame should animation run.
  15777. * @param loop defines if the animation loops
  15778. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15779. * @param onAnimationEnd defines the function to be executed when the animation ends
  15780. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15781. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15782. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15783. * @param onAnimationLoop defines the callback to call when an animation loops
  15784. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15785. * @returns the animatable object created for this animation
  15786. */
  15787. 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;
  15788. /**
  15789. * Will start the animation sequence of a given target and its hierarchy
  15790. * @param target defines the target
  15791. * @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.
  15792. * @param from defines from which frame should animation start
  15793. * @param to defines until which frame should animation run.
  15794. * @param loop defines if the animation loops
  15795. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15796. * @param onAnimationEnd defines the function to be executed when the animation ends
  15797. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15798. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15799. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15800. * @param onAnimationLoop defines the callback to call when an animation loops
  15801. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15802. * @returns the list of created animatables
  15803. */
  15804. 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[];
  15805. /**
  15806. * Begin a new animation on a given node
  15807. * @param target defines the target where the animation will take place
  15808. * @param animations defines the list of animations to start
  15809. * @param from defines the initial value
  15810. * @param to defines the final value
  15811. * @param loop defines if you want animation to loop (off by default)
  15812. * @param speedRatio defines the speed ratio to apply to all animations
  15813. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15814. * @param onAnimationLoop defines the callback to call when an animation loops
  15815. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15816. * @returns the list of created animatables
  15817. */
  15818. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15819. /**
  15820. * Begin a new animation on a given node and its hierarchy
  15821. * @param target defines the root node where the animation will take place
  15822. * @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.
  15823. * @param animations defines the list of animations to start
  15824. * @param from defines the initial value
  15825. * @param to defines the final value
  15826. * @param loop defines if you want animation to loop (off by default)
  15827. * @param speedRatio defines the speed ratio to apply to all animations
  15828. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15829. * @param onAnimationLoop defines the callback to call when an animation loops
  15830. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15831. * @returns the list of animatables created for all nodes
  15832. */
  15833. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15834. /**
  15835. * Gets the animatable associated with a specific target
  15836. * @param target defines the target of the animatable
  15837. * @returns the required animatable if found
  15838. */
  15839. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15840. /**
  15841. * Gets all animatables associated with a given target
  15842. * @param target defines the target to look animatables for
  15843. * @returns an array of Animatables
  15844. */
  15845. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15846. /**
  15847. * Stops and removes all animations that have been applied to the scene
  15848. */
  15849. stopAllAnimations(): void;
  15850. /**
  15851. * Gets the current delta time used by animation engine
  15852. */
  15853. deltaTime: number;
  15854. }
  15855. interface Bone {
  15856. /**
  15857. * Copy an animation range from another bone
  15858. * @param source defines the source bone
  15859. * @param rangeName defines the range name to copy
  15860. * @param frameOffset defines the frame offset
  15861. * @param rescaleAsRequired defines if rescaling must be applied if required
  15862. * @param skelDimensionsRatio defines the scaling ratio
  15863. * @returns true if operation was successful
  15864. */
  15865. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15866. }
  15867. }
  15868. declare module BABYLON {
  15869. /**
  15870. * Class used to handle skinning animations
  15871. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15872. */
  15873. export class Skeleton implements IAnimatable {
  15874. /** defines the skeleton name */
  15875. name: string;
  15876. /** defines the skeleton Id */
  15877. id: string;
  15878. /**
  15879. * Defines the list of child bones
  15880. */
  15881. bones: Bone[];
  15882. /**
  15883. * Defines an estimate of the dimension of the skeleton at rest
  15884. */
  15885. dimensionsAtRest: Vector3;
  15886. /**
  15887. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15888. */
  15889. needInitialSkinMatrix: boolean;
  15890. /**
  15891. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15892. */
  15893. overrideMesh: Nullable<AbstractMesh>;
  15894. /**
  15895. * Gets the list of animations attached to this skeleton
  15896. */
  15897. animations: Array<Animation>;
  15898. private _scene;
  15899. private _isDirty;
  15900. private _transformMatrices;
  15901. private _transformMatrixTexture;
  15902. private _meshesWithPoseMatrix;
  15903. private _animatables;
  15904. private _identity;
  15905. private _synchronizedWithMesh;
  15906. private _ranges;
  15907. private _lastAbsoluteTransformsUpdateId;
  15908. private _canUseTextureForBones;
  15909. private _uniqueId;
  15910. /** @hidden */
  15911. _numBonesWithLinkedTransformNode: number;
  15912. /** @hidden */
  15913. _hasWaitingData: Nullable<boolean>;
  15914. /**
  15915. * Specifies if the skeleton should be serialized
  15916. */
  15917. doNotSerialize: boolean;
  15918. private _useTextureToStoreBoneMatrices;
  15919. /**
  15920. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15921. * Please note that this option is not available if the hardware does not support it
  15922. */
  15923. get useTextureToStoreBoneMatrices(): boolean;
  15924. set useTextureToStoreBoneMatrices(value: boolean);
  15925. private _animationPropertiesOverride;
  15926. /**
  15927. * Gets or sets the animation properties override
  15928. */
  15929. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15930. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15931. /**
  15932. * List of inspectable custom properties (used by the Inspector)
  15933. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15934. */
  15935. inspectableCustomProperties: IInspectable[];
  15936. /**
  15937. * An observable triggered before computing the skeleton's matrices
  15938. */
  15939. onBeforeComputeObservable: Observable<Skeleton>;
  15940. /**
  15941. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15942. */
  15943. get isUsingTextureForMatrices(): boolean;
  15944. /**
  15945. * Gets the unique ID of this skeleton
  15946. */
  15947. get uniqueId(): number;
  15948. /**
  15949. * Creates a new skeleton
  15950. * @param name defines the skeleton name
  15951. * @param id defines the skeleton Id
  15952. * @param scene defines the hosting scene
  15953. */
  15954. constructor(
  15955. /** defines the skeleton name */
  15956. name: string,
  15957. /** defines the skeleton Id */
  15958. id: string, scene: Scene);
  15959. /**
  15960. * Gets the current object class name.
  15961. * @return the class name
  15962. */
  15963. getClassName(): string;
  15964. /**
  15965. * Returns an array containing the root bones
  15966. * @returns an array containing the root bones
  15967. */
  15968. getChildren(): Array<Bone>;
  15969. /**
  15970. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15971. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15972. * @returns a Float32Array containing matrices data
  15973. */
  15974. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15975. /**
  15976. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15977. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15978. * @returns a raw texture containing the data
  15979. */
  15980. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15981. /**
  15982. * Gets the current hosting scene
  15983. * @returns a scene object
  15984. */
  15985. getScene(): Scene;
  15986. /**
  15987. * Gets a string representing the current skeleton data
  15988. * @param fullDetails defines a boolean indicating if we want a verbose version
  15989. * @returns a string representing the current skeleton data
  15990. */
  15991. toString(fullDetails?: boolean): string;
  15992. /**
  15993. * Get bone's index searching by name
  15994. * @param name defines bone's name to search for
  15995. * @return the indice of the bone. Returns -1 if not found
  15996. */
  15997. getBoneIndexByName(name: string): number;
  15998. /**
  15999. * Creater a new animation range
  16000. * @param name defines the name of the range
  16001. * @param from defines the start key
  16002. * @param to defines the end key
  16003. */
  16004. createAnimationRange(name: string, from: number, to: number): void;
  16005. /**
  16006. * Delete a specific animation range
  16007. * @param name defines the name of the range
  16008. * @param deleteFrames defines if frames must be removed as well
  16009. */
  16010. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16011. /**
  16012. * Gets a specific animation range
  16013. * @param name defines the name of the range to look for
  16014. * @returns the requested animation range or null if not found
  16015. */
  16016. getAnimationRange(name: string): Nullable<AnimationRange>;
  16017. /**
  16018. * Gets the list of all animation ranges defined on this skeleton
  16019. * @returns an array
  16020. */
  16021. getAnimationRanges(): Nullable<AnimationRange>[];
  16022. /**
  16023. * Copy animation range from a source skeleton.
  16024. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16025. * @param source defines the source skeleton
  16026. * @param name defines the name of the range to copy
  16027. * @param rescaleAsRequired defines if rescaling must be applied if required
  16028. * @returns true if operation was successful
  16029. */
  16030. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16031. /**
  16032. * Forces the skeleton to go to rest pose
  16033. */
  16034. returnToRest(): void;
  16035. private _getHighestAnimationFrame;
  16036. /**
  16037. * Begin a specific animation range
  16038. * @param name defines the name of the range to start
  16039. * @param loop defines if looping must be turned on (false by default)
  16040. * @param speedRatio defines the speed ratio to apply (1 by default)
  16041. * @param onAnimationEnd defines a callback which will be called when animation will end
  16042. * @returns a new animatable
  16043. */
  16044. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16045. /**
  16046. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16047. * @param skeleton defines the Skeleton containing the animation range to convert
  16048. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16049. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16050. * @returns the original skeleton
  16051. */
  16052. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16053. /** @hidden */
  16054. _markAsDirty(): void;
  16055. /** @hidden */
  16056. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16057. /** @hidden */
  16058. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16059. private _computeTransformMatrices;
  16060. /**
  16061. * Build all resources required to render a skeleton
  16062. */
  16063. prepare(): void;
  16064. /**
  16065. * Gets the list of animatables currently running for this skeleton
  16066. * @returns an array of animatables
  16067. */
  16068. getAnimatables(): IAnimatable[];
  16069. /**
  16070. * Clone the current skeleton
  16071. * @param name defines the name of the new skeleton
  16072. * @param id defines the id of the new skeleton
  16073. * @returns the new skeleton
  16074. */
  16075. clone(name: string, id?: string): Skeleton;
  16076. /**
  16077. * Enable animation blending for this skeleton
  16078. * @param blendingSpeed defines the blending speed to apply
  16079. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16080. */
  16081. enableBlending(blendingSpeed?: number): void;
  16082. /**
  16083. * Releases all resources associated with the current skeleton
  16084. */
  16085. dispose(): void;
  16086. /**
  16087. * Serialize the skeleton in a JSON object
  16088. * @returns a JSON object
  16089. */
  16090. serialize(): any;
  16091. /**
  16092. * Creates a new skeleton from serialized data
  16093. * @param parsedSkeleton defines the serialized data
  16094. * @param scene defines the hosting scene
  16095. * @returns a new skeleton
  16096. */
  16097. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16098. /**
  16099. * Compute all node absolute transforms
  16100. * @param forceUpdate defines if computation must be done even if cache is up to date
  16101. */
  16102. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16103. /**
  16104. * Gets the root pose matrix
  16105. * @returns a matrix
  16106. */
  16107. getPoseMatrix(): Nullable<Matrix>;
  16108. /**
  16109. * Sorts bones per internal index
  16110. */
  16111. sortBones(): void;
  16112. private _sortBones;
  16113. }
  16114. }
  16115. declare module BABYLON {
  16116. /**
  16117. * Creates an instance based on a source mesh.
  16118. */
  16119. export class InstancedMesh extends AbstractMesh {
  16120. private _sourceMesh;
  16121. private _currentLOD;
  16122. /** @hidden */
  16123. _indexInSourceMeshInstanceArray: number;
  16124. constructor(name: string, source: Mesh);
  16125. /**
  16126. * Returns the string "InstancedMesh".
  16127. */
  16128. getClassName(): string;
  16129. /** Gets the list of lights affecting that mesh */
  16130. get lightSources(): Light[];
  16131. _resyncLightSources(): void;
  16132. _resyncLightSource(light: Light): void;
  16133. _removeLightSource(light: Light, dispose: boolean): void;
  16134. /**
  16135. * If the source mesh receives shadows
  16136. */
  16137. get receiveShadows(): boolean;
  16138. /**
  16139. * The material of the source mesh
  16140. */
  16141. get material(): Nullable<Material>;
  16142. /**
  16143. * Visibility of the source mesh
  16144. */
  16145. get visibility(): number;
  16146. /**
  16147. * Skeleton of the source mesh
  16148. */
  16149. get skeleton(): Nullable<Skeleton>;
  16150. /**
  16151. * Rendering ground id of the source mesh
  16152. */
  16153. get renderingGroupId(): number;
  16154. set renderingGroupId(value: number);
  16155. /**
  16156. * Returns the total number of vertices (integer).
  16157. */
  16158. getTotalVertices(): number;
  16159. /**
  16160. * Returns a positive integer : the total number of indices in this mesh geometry.
  16161. * @returns the numner of indices or zero if the mesh has no geometry.
  16162. */
  16163. getTotalIndices(): number;
  16164. /**
  16165. * The source mesh of the instance
  16166. */
  16167. get sourceMesh(): Mesh;
  16168. /**
  16169. * Creates a new InstancedMesh object from the mesh model.
  16170. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16171. * @param name defines the name of the new instance
  16172. * @returns a new InstancedMesh
  16173. */
  16174. createInstance(name: string): InstancedMesh;
  16175. /**
  16176. * Is this node ready to be used/rendered
  16177. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16178. * @return {boolean} is it ready
  16179. */
  16180. isReady(completeCheck?: boolean): boolean;
  16181. /**
  16182. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16183. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16184. * @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.
  16185. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16186. */
  16187. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16188. /**
  16189. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16190. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16191. * The `data` are either a numeric array either a Float32Array.
  16192. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16193. * 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).
  16194. * Note that a new underlying VertexBuffer object is created each call.
  16195. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16196. *
  16197. * Possible `kind` values :
  16198. * - VertexBuffer.PositionKind
  16199. * - VertexBuffer.UVKind
  16200. * - VertexBuffer.UV2Kind
  16201. * - VertexBuffer.UV3Kind
  16202. * - VertexBuffer.UV4Kind
  16203. * - VertexBuffer.UV5Kind
  16204. * - VertexBuffer.UV6Kind
  16205. * - VertexBuffer.ColorKind
  16206. * - VertexBuffer.MatricesIndicesKind
  16207. * - VertexBuffer.MatricesIndicesExtraKind
  16208. * - VertexBuffer.MatricesWeightsKind
  16209. * - VertexBuffer.MatricesWeightsExtraKind
  16210. *
  16211. * Returns the Mesh.
  16212. */
  16213. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16214. /**
  16215. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16216. * If the mesh has no geometry, it is simply returned as it is.
  16217. * The `data` are either a numeric array either a Float32Array.
  16218. * No new underlying VertexBuffer object is created.
  16219. * 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.
  16220. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16221. *
  16222. * Possible `kind` values :
  16223. * - VertexBuffer.PositionKind
  16224. * - VertexBuffer.UVKind
  16225. * - VertexBuffer.UV2Kind
  16226. * - VertexBuffer.UV3Kind
  16227. * - VertexBuffer.UV4Kind
  16228. * - VertexBuffer.UV5Kind
  16229. * - VertexBuffer.UV6Kind
  16230. * - VertexBuffer.ColorKind
  16231. * - VertexBuffer.MatricesIndicesKind
  16232. * - VertexBuffer.MatricesIndicesExtraKind
  16233. * - VertexBuffer.MatricesWeightsKind
  16234. * - VertexBuffer.MatricesWeightsExtraKind
  16235. *
  16236. * Returns the Mesh.
  16237. */
  16238. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16239. /**
  16240. * Sets the mesh indices.
  16241. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16242. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16243. * This method creates a new index buffer each call.
  16244. * Returns the Mesh.
  16245. */
  16246. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16247. /**
  16248. * Boolean : True if the mesh owns the requested kind of data.
  16249. */
  16250. isVerticesDataPresent(kind: string): boolean;
  16251. /**
  16252. * Returns an array of indices (IndicesArray).
  16253. */
  16254. getIndices(): Nullable<IndicesArray>;
  16255. get _positions(): Nullable<Vector3[]>;
  16256. /**
  16257. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16258. * This means the mesh underlying bounding box and sphere are recomputed.
  16259. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16260. * @returns the current mesh
  16261. */
  16262. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16263. /** @hidden */
  16264. _preActivate(): InstancedMesh;
  16265. /** @hidden */
  16266. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16267. /** @hidden */
  16268. _postActivate(): void;
  16269. getWorldMatrix(): Matrix;
  16270. get isAnInstance(): boolean;
  16271. /**
  16272. * Returns the current associated LOD AbstractMesh.
  16273. */
  16274. getLOD(camera: Camera): AbstractMesh;
  16275. /** @hidden */
  16276. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16277. /** @hidden */
  16278. _syncSubMeshes(): InstancedMesh;
  16279. /** @hidden */
  16280. _generatePointsArray(): boolean;
  16281. /**
  16282. * Creates a new InstancedMesh from the current mesh.
  16283. * - name (string) : the cloned mesh name
  16284. * - newParent (optional Node) : the optional Node to parent the clone to.
  16285. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16286. *
  16287. * Returns the clone.
  16288. */
  16289. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16290. /**
  16291. * Disposes the InstancedMesh.
  16292. * Returns nothing.
  16293. */
  16294. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16295. }
  16296. interface Mesh {
  16297. /**
  16298. * Register a custom buffer that will be instanced
  16299. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16300. * @param kind defines the buffer kind
  16301. * @param stride defines the stride in floats
  16302. */
  16303. registerInstancedBuffer(kind: string, stride: number): void;
  16304. /** @hidden */
  16305. _userInstancedBuffersStorage: {
  16306. data: {
  16307. [key: string]: Float32Array;
  16308. };
  16309. sizes: {
  16310. [key: string]: number;
  16311. };
  16312. vertexBuffers: {
  16313. [key: string]: Nullable<VertexBuffer>;
  16314. };
  16315. strides: {
  16316. [key: string]: number;
  16317. };
  16318. };
  16319. }
  16320. interface AbstractMesh {
  16321. /**
  16322. * Object used to store instanced buffers defined by user
  16323. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16324. */
  16325. instancedBuffers: {
  16326. [key: string]: any;
  16327. };
  16328. }
  16329. }
  16330. declare module BABYLON {
  16331. /**
  16332. * Defines the options associated with the creation of a shader material.
  16333. */
  16334. export interface IShaderMaterialOptions {
  16335. /**
  16336. * Does the material work in alpha blend mode
  16337. */
  16338. needAlphaBlending: boolean;
  16339. /**
  16340. * Does the material work in alpha test mode
  16341. */
  16342. needAlphaTesting: boolean;
  16343. /**
  16344. * The list of attribute names used in the shader
  16345. */
  16346. attributes: string[];
  16347. /**
  16348. * The list of unifrom names used in the shader
  16349. */
  16350. uniforms: string[];
  16351. /**
  16352. * The list of UBO names used in the shader
  16353. */
  16354. uniformBuffers: string[];
  16355. /**
  16356. * The list of sampler names used in the shader
  16357. */
  16358. samplers: string[];
  16359. /**
  16360. * The list of defines used in the shader
  16361. */
  16362. defines: string[];
  16363. }
  16364. /**
  16365. * 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.
  16366. *
  16367. * This returned material effects how the mesh will look based on the code in the shaders.
  16368. *
  16369. * @see http://doc.babylonjs.com/how_to/shader_material
  16370. */
  16371. export class ShaderMaterial extends Material {
  16372. private _shaderPath;
  16373. private _options;
  16374. private _textures;
  16375. private _textureArrays;
  16376. private _floats;
  16377. private _ints;
  16378. private _floatsArrays;
  16379. private _colors3;
  16380. private _colors3Arrays;
  16381. private _colors4;
  16382. private _colors4Arrays;
  16383. private _vectors2;
  16384. private _vectors3;
  16385. private _vectors4;
  16386. private _matrices;
  16387. private _matrixArrays;
  16388. private _matrices3x3;
  16389. private _matrices2x2;
  16390. private _vectors2Arrays;
  16391. private _vectors3Arrays;
  16392. private _vectors4Arrays;
  16393. private _cachedWorldViewMatrix;
  16394. private _cachedWorldViewProjectionMatrix;
  16395. private _renderId;
  16396. private _multiview;
  16397. private _cachedDefines;
  16398. /**
  16399. * Instantiate a new shader material.
  16400. * 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.
  16401. * This returned material effects how the mesh will look based on the code in the shaders.
  16402. * @see http://doc.babylonjs.com/how_to/shader_material
  16403. * @param name Define the name of the material in the scene
  16404. * @param scene Define the scene the material belongs to
  16405. * @param shaderPath Defines the route to the shader code in one of three ways:
  16406. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16407. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16408. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16409. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16410. * @param options Define the options used to create the shader
  16411. */
  16412. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16413. /**
  16414. * Gets the shader path used to define the shader code
  16415. * It can be modified to trigger a new compilation
  16416. */
  16417. get shaderPath(): any;
  16418. /**
  16419. * Sets the shader path used to define the shader code
  16420. * It can be modified to trigger a new compilation
  16421. */
  16422. set shaderPath(shaderPath: any);
  16423. /**
  16424. * Gets the options used to compile the shader.
  16425. * They can be modified to trigger a new compilation
  16426. */
  16427. get options(): IShaderMaterialOptions;
  16428. /**
  16429. * Gets the current class name of the material e.g. "ShaderMaterial"
  16430. * Mainly use in serialization.
  16431. * @returns the class name
  16432. */
  16433. getClassName(): string;
  16434. /**
  16435. * Specifies if the material will require alpha blending
  16436. * @returns a boolean specifying if alpha blending is needed
  16437. */
  16438. needAlphaBlending(): boolean;
  16439. /**
  16440. * Specifies if this material should be rendered in alpha test mode
  16441. * @returns a boolean specifying if an alpha test is needed.
  16442. */
  16443. needAlphaTesting(): boolean;
  16444. private _checkUniform;
  16445. /**
  16446. * Set a texture in the shader.
  16447. * @param name Define the name of the uniform samplers as defined in the shader
  16448. * @param texture Define the texture to bind to this sampler
  16449. * @return the material itself allowing "fluent" like uniform updates
  16450. */
  16451. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16452. /**
  16453. * Set a texture array in the shader.
  16454. * @param name Define the name of the uniform sampler array as defined in the shader
  16455. * @param textures Define the list of textures to bind to this sampler
  16456. * @return the material itself allowing "fluent" like uniform updates
  16457. */
  16458. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16459. /**
  16460. * Set a float in the shader.
  16461. * @param name Define the name of the uniform as defined in the shader
  16462. * @param value Define the value to give to the uniform
  16463. * @return the material itself allowing "fluent" like uniform updates
  16464. */
  16465. setFloat(name: string, value: number): ShaderMaterial;
  16466. /**
  16467. * Set a int in the shader.
  16468. * @param name Define the name of the uniform as defined in the shader
  16469. * @param value Define the value to give to the uniform
  16470. * @return the material itself allowing "fluent" like uniform updates
  16471. */
  16472. setInt(name: string, value: number): ShaderMaterial;
  16473. /**
  16474. * Set an array of floats in the shader.
  16475. * @param name Define the name of the uniform as defined in the shader
  16476. * @param value Define the value to give to the uniform
  16477. * @return the material itself allowing "fluent" like uniform updates
  16478. */
  16479. setFloats(name: string, value: number[]): ShaderMaterial;
  16480. /**
  16481. * Set a vec3 in the shader from a Color3.
  16482. * @param name Define the name of the uniform as defined in the shader
  16483. * @param value Define the value to give to the uniform
  16484. * @return the material itself allowing "fluent" like uniform updates
  16485. */
  16486. setColor3(name: string, value: Color3): ShaderMaterial;
  16487. /**
  16488. * Set a vec3 array in the shader from a Color3 array.
  16489. * @param name Define the name of the uniform as defined in the shader
  16490. * @param value Define the value to give to the uniform
  16491. * @return the material itself allowing "fluent" like uniform updates
  16492. */
  16493. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16494. /**
  16495. * Set a vec4 in the shader from a Color4.
  16496. * @param name Define the name of the uniform as defined in the shader
  16497. * @param value Define the value to give to the uniform
  16498. * @return the material itself allowing "fluent" like uniform updates
  16499. */
  16500. setColor4(name: string, value: Color4): ShaderMaterial;
  16501. /**
  16502. * Set a vec4 array in the shader from a Color4 array.
  16503. * @param name Define the name of the uniform as defined in the shader
  16504. * @param value Define the value to give to the uniform
  16505. * @return the material itself allowing "fluent" like uniform updates
  16506. */
  16507. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16508. /**
  16509. * Set a vec2 in the shader from a Vector2.
  16510. * @param name Define the name of the uniform as defined in the shader
  16511. * @param value Define the value to give to the uniform
  16512. * @return the material itself allowing "fluent" like uniform updates
  16513. */
  16514. setVector2(name: string, value: Vector2): ShaderMaterial;
  16515. /**
  16516. * Set a vec3 in the shader from a Vector3.
  16517. * @param name Define the name of the uniform as defined in the shader
  16518. * @param value Define the value to give to the uniform
  16519. * @return the material itself allowing "fluent" like uniform updates
  16520. */
  16521. setVector3(name: string, value: Vector3): ShaderMaterial;
  16522. /**
  16523. * Set a vec4 in the shader from a Vector4.
  16524. * @param name Define the name of the uniform as defined in the shader
  16525. * @param value Define the value to give to the uniform
  16526. * @return the material itself allowing "fluent" like uniform updates
  16527. */
  16528. setVector4(name: string, value: Vector4): ShaderMaterial;
  16529. /**
  16530. * Set a mat4 in the shader from a Matrix.
  16531. * @param name Define the name of the uniform as defined in the shader
  16532. * @param value Define the value to give to the uniform
  16533. * @return the material itself allowing "fluent" like uniform updates
  16534. */
  16535. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16536. /**
  16537. * Set a float32Array in the shader from a matrix array.
  16538. * @param name Define the name of the uniform as defined in the shader
  16539. * @param value Define the value to give to the uniform
  16540. * @return the material itself allowing "fluent" like uniform updates
  16541. */
  16542. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16543. /**
  16544. * Set a mat3 in the shader from a Float32Array.
  16545. * @param name Define the name of the uniform as defined in the shader
  16546. * @param value Define the value to give to the uniform
  16547. * @return the material itself allowing "fluent" like uniform updates
  16548. */
  16549. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16550. /**
  16551. * Set a mat2 in the shader from a Float32Array.
  16552. * @param name Define the name of the uniform as defined in the shader
  16553. * @param value Define the value to give to the uniform
  16554. * @return the material itself allowing "fluent" like uniform updates
  16555. */
  16556. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16557. /**
  16558. * Set a vec2 array in the shader from a number array.
  16559. * @param name Define the name of the uniform as defined in the shader
  16560. * @param value Define the value to give to the uniform
  16561. * @return the material itself allowing "fluent" like uniform updates
  16562. */
  16563. setArray2(name: string, value: number[]): ShaderMaterial;
  16564. /**
  16565. * Set a vec3 array in the shader from a number array.
  16566. * @param name Define the name of the uniform as defined in the shader
  16567. * @param value Define the value to give to the uniform
  16568. * @return the material itself allowing "fluent" like uniform updates
  16569. */
  16570. setArray3(name: string, value: number[]): ShaderMaterial;
  16571. /**
  16572. * Set a vec4 array in the shader from a number array.
  16573. * @param name Define the name of the uniform as defined in the shader
  16574. * @param value Define the value to give to the uniform
  16575. * @return the material itself allowing "fluent" like uniform updates
  16576. */
  16577. setArray4(name: string, value: number[]): ShaderMaterial;
  16578. private _checkCache;
  16579. /**
  16580. * Specifies that the submesh is ready to be used
  16581. * @param mesh defines the mesh to check
  16582. * @param subMesh defines which submesh to check
  16583. * @param useInstances specifies that instances should be used
  16584. * @returns a boolean indicating that the submesh is ready or not
  16585. */
  16586. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16587. /**
  16588. * Checks if the material is ready to render the requested mesh
  16589. * @param mesh Define the mesh to render
  16590. * @param useInstances Define whether or not the material is used with instances
  16591. * @returns true if ready, otherwise false
  16592. */
  16593. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16594. /**
  16595. * Binds the world matrix to the material
  16596. * @param world defines the world transformation matrix
  16597. * @param effectOverride - If provided, use this effect instead of internal effect
  16598. */
  16599. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16600. /**
  16601. * Binds the submesh to this material by preparing the effect and shader to draw
  16602. * @param world defines the world transformation matrix
  16603. * @param mesh defines the mesh containing the submesh
  16604. * @param subMesh defines the submesh to bind the material to
  16605. */
  16606. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16607. /**
  16608. * Binds the material to the mesh
  16609. * @param world defines the world transformation matrix
  16610. * @param mesh defines the mesh to bind the material to
  16611. * @param effectOverride - If provided, use this effect instead of internal effect
  16612. */
  16613. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16614. protected _afterBind(mesh?: Mesh): void;
  16615. /**
  16616. * Gets the active textures from the material
  16617. * @returns an array of textures
  16618. */
  16619. getActiveTextures(): BaseTexture[];
  16620. /**
  16621. * Specifies if the material uses a texture
  16622. * @param texture defines the texture to check against the material
  16623. * @returns a boolean specifying if the material uses the texture
  16624. */
  16625. hasTexture(texture: BaseTexture): boolean;
  16626. /**
  16627. * Makes a duplicate of the material, and gives it a new name
  16628. * @param name defines the new name for the duplicated material
  16629. * @returns the cloned material
  16630. */
  16631. clone(name: string): ShaderMaterial;
  16632. /**
  16633. * Disposes the material
  16634. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16635. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16636. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16637. */
  16638. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16639. /**
  16640. * Serializes this material in a JSON representation
  16641. * @returns the serialized material object
  16642. */
  16643. serialize(): any;
  16644. /**
  16645. * Creates a shader material from parsed shader material data
  16646. * @param source defines the JSON represnetation of the material
  16647. * @param scene defines the hosting scene
  16648. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16649. * @returns a new material
  16650. */
  16651. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16652. }
  16653. }
  16654. declare module BABYLON {
  16655. /** @hidden */
  16656. export var colorPixelShader: {
  16657. name: string;
  16658. shader: string;
  16659. };
  16660. }
  16661. declare module BABYLON {
  16662. /** @hidden */
  16663. export var colorVertexShader: {
  16664. name: string;
  16665. shader: string;
  16666. };
  16667. }
  16668. declare module BABYLON {
  16669. /**
  16670. * Line mesh
  16671. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16672. */
  16673. export class LinesMesh extends Mesh {
  16674. /**
  16675. * If vertex color should be applied to the mesh
  16676. */
  16677. readonly useVertexColor?: boolean | undefined;
  16678. /**
  16679. * If vertex alpha should be applied to the mesh
  16680. */
  16681. readonly useVertexAlpha?: boolean | undefined;
  16682. /**
  16683. * Color of the line (Default: White)
  16684. */
  16685. color: Color3;
  16686. /**
  16687. * Alpha of the line (Default: 1)
  16688. */
  16689. alpha: number;
  16690. /**
  16691. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16692. * This margin is expressed in world space coordinates, so its value may vary.
  16693. * Default value is 0.1
  16694. */
  16695. intersectionThreshold: number;
  16696. private _colorShader;
  16697. private color4;
  16698. /**
  16699. * Creates a new LinesMesh
  16700. * @param name defines the name
  16701. * @param scene defines the hosting scene
  16702. * @param parent defines the parent mesh if any
  16703. * @param source defines the optional source LinesMesh used to clone data from
  16704. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16705. * When false, achieved by calling a clone(), also passing False.
  16706. * This will make creation of children, recursive.
  16707. * @param useVertexColor defines if this LinesMesh supports vertex color
  16708. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16709. */
  16710. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16711. /**
  16712. * If vertex color should be applied to the mesh
  16713. */
  16714. useVertexColor?: boolean | undefined,
  16715. /**
  16716. * If vertex alpha should be applied to the mesh
  16717. */
  16718. useVertexAlpha?: boolean | undefined);
  16719. private _addClipPlaneDefine;
  16720. private _removeClipPlaneDefine;
  16721. isReady(): boolean;
  16722. /**
  16723. * Returns the string "LineMesh"
  16724. */
  16725. getClassName(): string;
  16726. /**
  16727. * @hidden
  16728. */
  16729. get material(): Material;
  16730. /**
  16731. * @hidden
  16732. */
  16733. set material(value: Material);
  16734. /**
  16735. * @hidden
  16736. */
  16737. get checkCollisions(): boolean;
  16738. /** @hidden */
  16739. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16740. /** @hidden */
  16741. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16742. /**
  16743. * Disposes of the line mesh
  16744. * @param doNotRecurse If children should be disposed
  16745. */
  16746. dispose(doNotRecurse?: boolean): void;
  16747. /**
  16748. * Returns a new LineMesh object cloned from the current one.
  16749. */
  16750. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16751. /**
  16752. * Creates a new InstancedLinesMesh object from the mesh model.
  16753. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16754. * @param name defines the name of the new instance
  16755. * @returns a new InstancedLinesMesh
  16756. */
  16757. createInstance(name: string): InstancedLinesMesh;
  16758. }
  16759. /**
  16760. * Creates an instance based on a source LinesMesh
  16761. */
  16762. export class InstancedLinesMesh extends InstancedMesh {
  16763. /**
  16764. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16765. * This margin is expressed in world space coordinates, so its value may vary.
  16766. * Initilized with the intersectionThreshold value of the source LinesMesh
  16767. */
  16768. intersectionThreshold: number;
  16769. constructor(name: string, source: LinesMesh);
  16770. /**
  16771. * Returns the string "InstancedLinesMesh".
  16772. */
  16773. getClassName(): string;
  16774. }
  16775. }
  16776. declare module BABYLON {
  16777. /** @hidden */
  16778. export var linePixelShader: {
  16779. name: string;
  16780. shader: string;
  16781. };
  16782. }
  16783. declare module BABYLON {
  16784. /** @hidden */
  16785. export var lineVertexShader: {
  16786. name: string;
  16787. shader: string;
  16788. };
  16789. }
  16790. declare module BABYLON {
  16791. interface AbstractMesh {
  16792. /**
  16793. * Gets the edgesRenderer associated with the mesh
  16794. */
  16795. edgesRenderer: Nullable<EdgesRenderer>;
  16796. }
  16797. interface LinesMesh {
  16798. /**
  16799. * Enables the edge rendering mode on the mesh.
  16800. * This mode makes the mesh edges visible
  16801. * @param epsilon defines the maximal distance between two angles to detect a face
  16802. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16803. * @returns the currentAbstractMesh
  16804. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16805. */
  16806. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16807. }
  16808. interface InstancedLinesMesh {
  16809. /**
  16810. * Enables the edge rendering mode on the mesh.
  16811. * This mode makes the mesh edges visible
  16812. * @param epsilon defines the maximal distance between two angles to detect a face
  16813. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16814. * @returns the current InstancedLinesMesh
  16815. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16816. */
  16817. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16818. }
  16819. /**
  16820. * Defines the minimum contract an Edges renderer should follow.
  16821. */
  16822. export interface IEdgesRenderer extends IDisposable {
  16823. /**
  16824. * Gets or sets a boolean indicating if the edgesRenderer is active
  16825. */
  16826. isEnabled: boolean;
  16827. /**
  16828. * Renders the edges of the attached mesh,
  16829. */
  16830. render(): void;
  16831. /**
  16832. * Checks wether or not the edges renderer is ready to render.
  16833. * @return true if ready, otherwise false.
  16834. */
  16835. isReady(): boolean;
  16836. }
  16837. /**
  16838. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16839. */
  16840. export class EdgesRenderer implements IEdgesRenderer {
  16841. /**
  16842. * Define the size of the edges with an orthographic camera
  16843. */
  16844. edgesWidthScalerForOrthographic: number;
  16845. /**
  16846. * Define the size of the edges with a perspective camera
  16847. */
  16848. edgesWidthScalerForPerspective: number;
  16849. protected _source: AbstractMesh;
  16850. protected _linesPositions: number[];
  16851. protected _linesNormals: number[];
  16852. protected _linesIndices: number[];
  16853. protected _epsilon: number;
  16854. protected _indicesCount: number;
  16855. protected _lineShader: ShaderMaterial;
  16856. protected _ib: DataBuffer;
  16857. protected _buffers: {
  16858. [key: string]: Nullable<VertexBuffer>;
  16859. };
  16860. protected _checkVerticesInsteadOfIndices: boolean;
  16861. private _meshRebuildObserver;
  16862. private _meshDisposeObserver;
  16863. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16864. isEnabled: boolean;
  16865. /**
  16866. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16867. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16868. * @param source Mesh used to create edges
  16869. * @param epsilon sum of angles in adjacency to check for edge
  16870. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16871. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16872. */
  16873. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16874. protected _prepareRessources(): void;
  16875. /** @hidden */
  16876. _rebuild(): void;
  16877. /**
  16878. * Releases the required resources for the edges renderer
  16879. */
  16880. dispose(): void;
  16881. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16882. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16883. /**
  16884. * Checks if the pair of p0 and p1 is en edge
  16885. * @param faceIndex
  16886. * @param edge
  16887. * @param faceNormals
  16888. * @param p0
  16889. * @param p1
  16890. * @private
  16891. */
  16892. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16893. /**
  16894. * push line into the position, normal and index buffer
  16895. * @protected
  16896. */
  16897. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16898. /**
  16899. * Generates lines edges from adjacencjes
  16900. * @private
  16901. */
  16902. _generateEdgesLines(): void;
  16903. /**
  16904. * Checks wether or not the edges renderer is ready to render.
  16905. * @return true if ready, otherwise false.
  16906. */
  16907. isReady(): boolean;
  16908. /**
  16909. * Renders the edges of the attached mesh,
  16910. */
  16911. render(): void;
  16912. }
  16913. /**
  16914. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16915. */
  16916. export class LineEdgesRenderer extends EdgesRenderer {
  16917. /**
  16918. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16919. * @param source LineMesh used to generate edges
  16920. * @param epsilon not important (specified angle for edge detection)
  16921. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16922. */
  16923. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16924. /**
  16925. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16926. */
  16927. _generateEdgesLines(): void;
  16928. }
  16929. }
  16930. declare module BABYLON {
  16931. /**
  16932. * This represents the object necessary to create a rendering group.
  16933. * This is exclusively used and created by the rendering manager.
  16934. * To modify the behavior, you use the available helpers in your scene or meshes.
  16935. * @hidden
  16936. */
  16937. export class RenderingGroup {
  16938. index: number;
  16939. private static _zeroVector;
  16940. private _scene;
  16941. private _opaqueSubMeshes;
  16942. private _transparentSubMeshes;
  16943. private _alphaTestSubMeshes;
  16944. private _depthOnlySubMeshes;
  16945. private _particleSystems;
  16946. private _spriteManagers;
  16947. private _opaqueSortCompareFn;
  16948. private _alphaTestSortCompareFn;
  16949. private _transparentSortCompareFn;
  16950. private _renderOpaque;
  16951. private _renderAlphaTest;
  16952. private _renderTransparent;
  16953. /** @hidden */
  16954. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  16955. onBeforeTransparentRendering: () => void;
  16956. /**
  16957. * Set the opaque sort comparison function.
  16958. * If null the sub meshes will be render in the order they were created
  16959. */
  16960. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16961. /**
  16962. * Set the alpha test sort comparison function.
  16963. * If null the sub meshes will be render in the order they were created
  16964. */
  16965. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16966. /**
  16967. * Set the transparent sort comparison function.
  16968. * If null the sub meshes will be render in the order they were created
  16969. */
  16970. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16971. /**
  16972. * Creates a new rendering group.
  16973. * @param index The rendering group index
  16974. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16975. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16976. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16977. */
  16978. 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>);
  16979. /**
  16980. * Render all the sub meshes contained in the group.
  16981. * @param customRenderFunction Used to override the default render behaviour of the group.
  16982. * @returns true if rendered some submeshes.
  16983. */
  16984. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16985. /**
  16986. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16987. * @param subMeshes The submeshes to render
  16988. */
  16989. private renderOpaqueSorted;
  16990. /**
  16991. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16992. * @param subMeshes The submeshes to render
  16993. */
  16994. private renderAlphaTestSorted;
  16995. /**
  16996. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16997. * @param subMeshes The submeshes to render
  16998. */
  16999. private renderTransparentSorted;
  17000. /**
  17001. * Renders the submeshes in a specified order.
  17002. * @param subMeshes The submeshes to sort before render
  17003. * @param sortCompareFn The comparison function use to sort
  17004. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17005. * @param transparent Specifies to activate blending if true
  17006. */
  17007. private static renderSorted;
  17008. /**
  17009. * Renders the submeshes in the order they were dispatched (no sort applied).
  17010. * @param subMeshes The submeshes to render
  17011. */
  17012. private static renderUnsorted;
  17013. /**
  17014. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17015. * are rendered back to front if in the same alpha index.
  17016. *
  17017. * @param a The first submesh
  17018. * @param b The second submesh
  17019. * @returns The result of the comparison
  17020. */
  17021. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17022. /**
  17023. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17024. * are rendered back to front.
  17025. *
  17026. * @param a The first submesh
  17027. * @param b The second submesh
  17028. * @returns The result of the comparison
  17029. */
  17030. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17031. /**
  17032. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17033. * are rendered front to back (prevent overdraw).
  17034. *
  17035. * @param a The first submesh
  17036. * @param b The second submesh
  17037. * @returns The result of the comparison
  17038. */
  17039. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17040. /**
  17041. * Resets the different lists of submeshes to prepare a new frame.
  17042. */
  17043. prepare(): void;
  17044. dispose(): void;
  17045. /**
  17046. * Inserts the submesh in its correct queue depending on its material.
  17047. * @param subMesh The submesh to dispatch
  17048. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17049. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17050. */
  17051. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17052. dispatchSprites(spriteManager: ISpriteManager): void;
  17053. dispatchParticles(particleSystem: IParticleSystem): void;
  17054. private _renderParticles;
  17055. private _renderSprites;
  17056. }
  17057. }
  17058. declare module BABYLON {
  17059. /**
  17060. * Interface describing the different options available in the rendering manager
  17061. * regarding Auto Clear between groups.
  17062. */
  17063. export interface IRenderingManagerAutoClearSetup {
  17064. /**
  17065. * Defines whether or not autoclear is enable.
  17066. */
  17067. autoClear: boolean;
  17068. /**
  17069. * Defines whether or not to autoclear the depth buffer.
  17070. */
  17071. depth: boolean;
  17072. /**
  17073. * Defines whether or not to autoclear the stencil buffer.
  17074. */
  17075. stencil: boolean;
  17076. }
  17077. /**
  17078. * This class is used by the onRenderingGroupObservable
  17079. */
  17080. export class RenderingGroupInfo {
  17081. /**
  17082. * The Scene that being rendered
  17083. */
  17084. scene: Scene;
  17085. /**
  17086. * The camera currently used for the rendering pass
  17087. */
  17088. camera: Nullable<Camera>;
  17089. /**
  17090. * The ID of the renderingGroup being processed
  17091. */
  17092. renderingGroupId: number;
  17093. }
  17094. /**
  17095. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17096. * It is enable to manage the different groups as well as the different necessary sort functions.
  17097. * This should not be used directly aside of the few static configurations
  17098. */
  17099. export class RenderingManager {
  17100. /**
  17101. * The max id used for rendering groups (not included)
  17102. */
  17103. static MAX_RENDERINGGROUPS: number;
  17104. /**
  17105. * The min id used for rendering groups (included)
  17106. */
  17107. static MIN_RENDERINGGROUPS: number;
  17108. /**
  17109. * Used to globally prevent autoclearing scenes.
  17110. */
  17111. static AUTOCLEAR: boolean;
  17112. /**
  17113. * @hidden
  17114. */
  17115. _useSceneAutoClearSetup: boolean;
  17116. private _scene;
  17117. private _renderingGroups;
  17118. private _depthStencilBufferAlreadyCleaned;
  17119. private _autoClearDepthStencil;
  17120. private _customOpaqueSortCompareFn;
  17121. private _customAlphaTestSortCompareFn;
  17122. private _customTransparentSortCompareFn;
  17123. private _renderingGroupInfo;
  17124. /**
  17125. * Instantiates a new rendering group for a particular scene
  17126. * @param scene Defines the scene the groups belongs to
  17127. */
  17128. constructor(scene: Scene);
  17129. private _clearDepthStencilBuffer;
  17130. /**
  17131. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17132. * @hidden
  17133. */
  17134. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17135. /**
  17136. * Resets the different information of the group to prepare a new frame
  17137. * @hidden
  17138. */
  17139. reset(): void;
  17140. /**
  17141. * Dispose and release the group and its associated resources.
  17142. * @hidden
  17143. */
  17144. dispose(): void;
  17145. /**
  17146. * Clear the info related to rendering groups preventing retention points during dispose.
  17147. */
  17148. freeRenderingGroups(): void;
  17149. private _prepareRenderingGroup;
  17150. /**
  17151. * Add a sprite manager to the rendering manager in order to render it this frame.
  17152. * @param spriteManager Define the sprite manager to render
  17153. */
  17154. dispatchSprites(spriteManager: ISpriteManager): void;
  17155. /**
  17156. * Add a particle system to the rendering manager in order to render it this frame.
  17157. * @param particleSystem Define the particle system to render
  17158. */
  17159. dispatchParticles(particleSystem: IParticleSystem): void;
  17160. /**
  17161. * Add a submesh to the manager in order to render it this frame
  17162. * @param subMesh The submesh to dispatch
  17163. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17164. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17165. */
  17166. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17167. /**
  17168. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17169. * This allowed control for front to back rendering or reversly depending of the special needs.
  17170. *
  17171. * @param renderingGroupId The rendering group id corresponding to its index
  17172. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17173. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17174. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17175. */
  17176. 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;
  17177. /**
  17178. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17179. *
  17180. * @param renderingGroupId The rendering group id corresponding to its index
  17181. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17182. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17183. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17184. */
  17185. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17186. /**
  17187. * Gets the current auto clear configuration for one rendering group of the rendering
  17188. * manager.
  17189. * @param index the rendering group index to get the information for
  17190. * @returns The auto clear setup for the requested rendering group
  17191. */
  17192. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17193. }
  17194. }
  17195. declare module BABYLON {
  17196. /**
  17197. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17198. */
  17199. export interface ICustomShaderOptions {
  17200. /**
  17201. * Gets or sets the custom shader name to use
  17202. */
  17203. shaderName: string;
  17204. /**
  17205. * The list of attribute names used in the shader
  17206. */
  17207. attributes?: string[];
  17208. /**
  17209. * The list of unifrom names used in the shader
  17210. */
  17211. uniforms?: string[];
  17212. /**
  17213. * The list of sampler names used in the shader
  17214. */
  17215. samplers?: string[];
  17216. /**
  17217. * The list of defines used in the shader
  17218. */
  17219. defines?: string[];
  17220. }
  17221. /**
  17222. * Interface to implement to create a shadow generator compatible with BJS.
  17223. */
  17224. export interface IShadowGenerator {
  17225. /**
  17226. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17227. * @returns The render target texture if present otherwise, null
  17228. */
  17229. getShadowMap(): Nullable<RenderTargetTexture>;
  17230. /**
  17231. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17232. * @param subMesh The submesh we want to render in the shadow map
  17233. * @param useInstances Defines wether will draw in the map using instances
  17234. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17235. * @returns true if ready otherwise, false
  17236. */
  17237. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17238. /**
  17239. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17240. * @param defines Defines of the material we want to update
  17241. * @param lightIndex Index of the light in the enabled light list of the material
  17242. */
  17243. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17244. /**
  17245. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17246. * defined in the generator but impacting the effect).
  17247. * It implies the unifroms available on the materials are the standard BJS ones.
  17248. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17249. * @param effect The effect we are binfing the information for
  17250. */
  17251. bindShadowLight(lightIndex: string, effect: Effect): void;
  17252. /**
  17253. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17254. * (eq to shadow prjection matrix * light transform matrix)
  17255. * @returns The transform matrix used to create the shadow map
  17256. */
  17257. getTransformMatrix(): Matrix;
  17258. /**
  17259. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17260. * Cube and 2D textures for instance.
  17261. */
  17262. recreateShadowMap(): void;
  17263. /**
  17264. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17265. * @param onCompiled Callback triggered at the and of the effects compilation
  17266. * @param options Sets of optional options forcing the compilation with different modes
  17267. */
  17268. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17269. useInstances: boolean;
  17270. }>): void;
  17271. /**
  17272. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17273. * @param options Sets of optional options forcing the compilation with different modes
  17274. * @returns A promise that resolves when the compilation completes
  17275. */
  17276. forceCompilationAsync(options?: Partial<{
  17277. useInstances: boolean;
  17278. }>): Promise<void>;
  17279. /**
  17280. * Serializes the shadow generator setup to a json object.
  17281. * @returns The serialized JSON object
  17282. */
  17283. serialize(): any;
  17284. /**
  17285. * Disposes the Shadow map and related Textures and effects.
  17286. */
  17287. dispose(): void;
  17288. }
  17289. /**
  17290. * Default implementation IShadowGenerator.
  17291. * This is the main object responsible of generating shadows in the framework.
  17292. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17293. */
  17294. export class ShadowGenerator implements IShadowGenerator {
  17295. /**
  17296. * Name of the shadow generator class
  17297. */
  17298. static CLASSNAME: string;
  17299. /**
  17300. * Shadow generator mode None: no filtering applied.
  17301. */
  17302. static readonly FILTER_NONE: number;
  17303. /**
  17304. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17305. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17306. */
  17307. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17308. /**
  17309. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17310. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17311. */
  17312. static readonly FILTER_POISSONSAMPLING: number;
  17313. /**
  17314. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17315. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17316. */
  17317. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17318. /**
  17319. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17320. * edge artifacts on steep falloff.
  17321. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17322. */
  17323. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17324. /**
  17325. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17326. * edge artifacts on steep falloff.
  17327. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17328. */
  17329. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17330. /**
  17331. * Shadow generator mode PCF: Percentage Closer Filtering
  17332. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17333. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17334. */
  17335. static readonly FILTER_PCF: number;
  17336. /**
  17337. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17338. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17339. * Contact Hardening
  17340. */
  17341. static readonly FILTER_PCSS: number;
  17342. /**
  17343. * Reserved for PCF and PCSS
  17344. * Highest Quality.
  17345. *
  17346. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17347. *
  17348. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17349. */
  17350. static readonly QUALITY_HIGH: number;
  17351. /**
  17352. * Reserved for PCF and PCSS
  17353. * Good tradeoff for quality/perf cross devices
  17354. *
  17355. * Execute PCF on a 3*3 kernel.
  17356. *
  17357. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17358. */
  17359. static readonly QUALITY_MEDIUM: number;
  17360. /**
  17361. * Reserved for PCF and PCSS
  17362. * The lowest quality but the fastest.
  17363. *
  17364. * Execute PCF on a 1*1 kernel.
  17365. *
  17366. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17367. */
  17368. static readonly QUALITY_LOW: number;
  17369. /** Gets or sets the custom shader name to use */
  17370. customShaderOptions: ICustomShaderOptions;
  17371. /**
  17372. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17373. */
  17374. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17375. /**
  17376. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17377. */
  17378. onAfterShadowMapRenderObservable: Observable<Effect>;
  17379. /**
  17380. * Observable triggered before a mesh is rendered in the shadow map.
  17381. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17382. */
  17383. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17384. /**
  17385. * Observable triggered after a mesh is rendered in the shadow map.
  17386. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17387. */
  17388. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17389. protected _bias: number;
  17390. /**
  17391. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17392. */
  17393. get bias(): number;
  17394. /**
  17395. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17396. */
  17397. set bias(bias: number);
  17398. protected _normalBias: number;
  17399. /**
  17400. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17401. */
  17402. get normalBias(): number;
  17403. /**
  17404. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17405. */
  17406. set normalBias(normalBias: number);
  17407. protected _blurBoxOffset: number;
  17408. /**
  17409. * Gets the blur box offset: offset applied during the blur pass.
  17410. * Only useful if useKernelBlur = false
  17411. */
  17412. get blurBoxOffset(): number;
  17413. /**
  17414. * Sets the blur box offset: offset applied during the blur pass.
  17415. * Only useful if useKernelBlur = false
  17416. */
  17417. set blurBoxOffset(value: number);
  17418. protected _blurScale: number;
  17419. /**
  17420. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17421. * 2 means half of the size.
  17422. */
  17423. get blurScale(): number;
  17424. /**
  17425. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17426. * 2 means half of the size.
  17427. */
  17428. set blurScale(value: number);
  17429. protected _blurKernel: number;
  17430. /**
  17431. * Gets the blur kernel: kernel size of the blur pass.
  17432. * Only useful if useKernelBlur = true
  17433. */
  17434. get blurKernel(): number;
  17435. /**
  17436. * Sets the blur kernel: kernel size of the blur pass.
  17437. * Only useful if useKernelBlur = true
  17438. */
  17439. set blurKernel(value: number);
  17440. protected _useKernelBlur: boolean;
  17441. /**
  17442. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17443. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17444. */
  17445. get useKernelBlur(): boolean;
  17446. /**
  17447. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17448. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17449. */
  17450. set useKernelBlur(value: boolean);
  17451. protected _depthScale: number;
  17452. /**
  17453. * Gets the depth scale used in ESM mode.
  17454. */
  17455. get depthScale(): number;
  17456. /**
  17457. * Sets the depth scale used in ESM mode.
  17458. * This can override the scale stored on the light.
  17459. */
  17460. set depthScale(value: number);
  17461. protected _validateFilter(filter: number): number;
  17462. protected _filter: number;
  17463. /**
  17464. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17465. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17466. */
  17467. get filter(): number;
  17468. /**
  17469. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17470. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17471. */
  17472. set filter(value: number);
  17473. /**
  17474. * Gets if the current filter is set to Poisson Sampling.
  17475. */
  17476. get usePoissonSampling(): boolean;
  17477. /**
  17478. * Sets the current filter to Poisson Sampling.
  17479. */
  17480. set usePoissonSampling(value: boolean);
  17481. /**
  17482. * Gets if the current filter is set to ESM.
  17483. */
  17484. get useExponentialShadowMap(): boolean;
  17485. /**
  17486. * Sets the current filter is to ESM.
  17487. */
  17488. set useExponentialShadowMap(value: boolean);
  17489. /**
  17490. * Gets if the current filter is set to filtered ESM.
  17491. */
  17492. get useBlurExponentialShadowMap(): boolean;
  17493. /**
  17494. * Gets if the current filter is set to filtered ESM.
  17495. */
  17496. set useBlurExponentialShadowMap(value: boolean);
  17497. /**
  17498. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17499. * exponential to prevent steep falloff artifacts).
  17500. */
  17501. get useCloseExponentialShadowMap(): boolean;
  17502. /**
  17503. * Sets the current filter to "close ESM" (using the inverse of the
  17504. * exponential to prevent steep falloff artifacts).
  17505. */
  17506. set useCloseExponentialShadowMap(value: boolean);
  17507. /**
  17508. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17509. * exponential to prevent steep falloff artifacts).
  17510. */
  17511. get useBlurCloseExponentialShadowMap(): boolean;
  17512. /**
  17513. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17514. * exponential to prevent steep falloff artifacts).
  17515. */
  17516. set useBlurCloseExponentialShadowMap(value: boolean);
  17517. /**
  17518. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17519. */
  17520. get usePercentageCloserFiltering(): boolean;
  17521. /**
  17522. * Sets the current filter to "PCF" (percentage closer filtering).
  17523. */
  17524. set usePercentageCloserFiltering(value: boolean);
  17525. protected _filteringQuality: number;
  17526. /**
  17527. * Gets the PCF or PCSS Quality.
  17528. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17529. */
  17530. get filteringQuality(): number;
  17531. /**
  17532. * Sets the PCF or PCSS Quality.
  17533. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17534. */
  17535. set filteringQuality(filteringQuality: number);
  17536. /**
  17537. * Gets if the current filter is set to "PCSS" (contact hardening).
  17538. */
  17539. get useContactHardeningShadow(): boolean;
  17540. /**
  17541. * Sets the current filter to "PCSS" (contact hardening).
  17542. */
  17543. set useContactHardeningShadow(value: boolean);
  17544. protected _contactHardeningLightSizeUVRatio: number;
  17545. /**
  17546. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17547. * Using a ratio helps keeping shape stability independently of the map size.
  17548. *
  17549. * It does not account for the light projection as it was having too much
  17550. * instability during the light setup or during light position changes.
  17551. *
  17552. * Only valid if useContactHardeningShadow is true.
  17553. */
  17554. get contactHardeningLightSizeUVRatio(): number;
  17555. /**
  17556. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17557. * Using a ratio helps keeping shape stability independently of the map size.
  17558. *
  17559. * It does not account for the light projection as it was having too much
  17560. * instability during the light setup or during light position changes.
  17561. *
  17562. * Only valid if useContactHardeningShadow is true.
  17563. */
  17564. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17565. protected _darkness: number;
  17566. /** Gets or sets the actual darkness of a shadow */
  17567. get darkness(): number;
  17568. set darkness(value: number);
  17569. /**
  17570. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17571. * 0 means strongest and 1 would means no shadow.
  17572. * @returns the darkness.
  17573. */
  17574. getDarkness(): number;
  17575. /**
  17576. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17577. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17578. * @returns the shadow generator allowing fluent coding.
  17579. */
  17580. setDarkness(darkness: number): ShadowGenerator;
  17581. protected _transparencyShadow: boolean;
  17582. /** Gets or sets the ability to have transparent shadow */
  17583. get transparencyShadow(): boolean;
  17584. set transparencyShadow(value: boolean);
  17585. /**
  17586. * Sets the ability to have transparent shadow (boolean).
  17587. * @param transparent True if transparent else False
  17588. * @returns the shadow generator allowing fluent coding
  17589. */
  17590. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17591. /**
  17592. * Enables or disables shadows with varying strength based on the transparency
  17593. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17594. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17595. * mesh.visibility * alphaTexture.a
  17596. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17597. */
  17598. enableSoftTransparentShadow: boolean;
  17599. protected _shadowMap: Nullable<RenderTargetTexture>;
  17600. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17601. /**
  17602. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17603. * @returns The render target texture if present otherwise, null
  17604. */
  17605. getShadowMap(): Nullable<RenderTargetTexture>;
  17606. /**
  17607. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17608. * @returns The render target texture if the shadow map is present otherwise, null
  17609. */
  17610. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17611. /**
  17612. * Gets the class name of that object
  17613. * @returns "ShadowGenerator"
  17614. */
  17615. getClassName(): string;
  17616. /**
  17617. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17618. * @param mesh Mesh to add
  17619. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17620. * @returns the Shadow Generator itself
  17621. */
  17622. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17623. /**
  17624. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17625. * @param mesh Mesh to remove
  17626. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17627. * @returns the Shadow Generator itself
  17628. */
  17629. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17630. /**
  17631. * Controls the extent to which the shadows fade out at the edge of the frustum
  17632. */
  17633. frustumEdgeFalloff: number;
  17634. protected _light: IShadowLight;
  17635. /**
  17636. * Returns the associated light object.
  17637. * @returns the light generating the shadow
  17638. */
  17639. getLight(): IShadowLight;
  17640. /**
  17641. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17642. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17643. * It might on the other hand introduce peter panning.
  17644. */
  17645. forceBackFacesOnly: boolean;
  17646. protected _scene: Scene;
  17647. protected _lightDirection: Vector3;
  17648. protected _effect: Effect;
  17649. protected _viewMatrix: Matrix;
  17650. protected _projectionMatrix: Matrix;
  17651. protected _transformMatrix: Matrix;
  17652. protected _cachedPosition: Vector3;
  17653. protected _cachedDirection: Vector3;
  17654. protected _cachedDefines: string;
  17655. protected _currentRenderID: number;
  17656. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17657. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17658. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17659. protected _blurPostProcesses: PostProcess[];
  17660. protected _mapSize: number;
  17661. protected _currentFaceIndex: number;
  17662. protected _currentFaceIndexCache: number;
  17663. protected _textureType: number;
  17664. protected _defaultTextureMatrix: Matrix;
  17665. protected _storedUniqueId: Nullable<number>;
  17666. /** @hidden */
  17667. static _SceneComponentInitialization: (scene: Scene) => void;
  17668. /**
  17669. * Creates a ShadowGenerator object.
  17670. * A ShadowGenerator is the required tool to use the shadows.
  17671. * Each light casting shadows needs to use its own ShadowGenerator.
  17672. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17673. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17674. * @param light The light object generating the shadows.
  17675. * @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.
  17676. */
  17677. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17678. protected _initializeGenerator(): void;
  17679. protected _createTargetRenderTexture(): void;
  17680. protected _initializeShadowMap(): void;
  17681. protected _initializeBlurRTTAndPostProcesses(): void;
  17682. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17683. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17684. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17685. protected _applyFilterValues(): void;
  17686. /**
  17687. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17688. * @param onCompiled Callback triggered at the and of the effects compilation
  17689. * @param options Sets of optional options forcing the compilation with different modes
  17690. */
  17691. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17692. useInstances: boolean;
  17693. }>): void;
  17694. /**
  17695. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17696. * @param options Sets of optional options forcing the compilation with different modes
  17697. * @returns A promise that resolves when the compilation completes
  17698. */
  17699. forceCompilationAsync(options?: Partial<{
  17700. useInstances: boolean;
  17701. }>): Promise<void>;
  17702. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17703. private _prepareShadowDefines;
  17704. /**
  17705. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17706. * @param subMesh The submesh we want to render in the shadow map
  17707. * @param useInstances Defines wether will draw in the map using instances
  17708. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17709. * @returns true if ready otherwise, false
  17710. */
  17711. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17712. /**
  17713. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17714. * @param defines Defines of the material we want to update
  17715. * @param lightIndex Index of the light in the enabled light list of the material
  17716. */
  17717. prepareDefines(defines: any, lightIndex: number): void;
  17718. /**
  17719. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17720. * defined in the generator but impacting the effect).
  17721. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17722. * @param effect The effect we are binfing the information for
  17723. */
  17724. bindShadowLight(lightIndex: string, effect: Effect): void;
  17725. /**
  17726. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17727. * (eq to shadow prjection matrix * light transform matrix)
  17728. * @returns The transform matrix used to create the shadow map
  17729. */
  17730. getTransformMatrix(): Matrix;
  17731. /**
  17732. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17733. * Cube and 2D textures for instance.
  17734. */
  17735. recreateShadowMap(): void;
  17736. protected _disposeBlurPostProcesses(): void;
  17737. protected _disposeRTTandPostProcesses(): void;
  17738. /**
  17739. * Disposes the ShadowGenerator.
  17740. * Returns nothing.
  17741. */
  17742. dispose(): void;
  17743. /**
  17744. * Serializes the shadow generator setup to a json object.
  17745. * @returns The serialized JSON object
  17746. */
  17747. serialize(): any;
  17748. /**
  17749. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17750. * @param parsedShadowGenerator The JSON object to parse
  17751. * @param scene The scene to create the shadow map for
  17752. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17753. * @returns The parsed shadow generator
  17754. */
  17755. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17756. }
  17757. }
  17758. declare module BABYLON {
  17759. /**
  17760. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17761. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17762. * 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.
  17763. */
  17764. export abstract class Light extends Node {
  17765. /**
  17766. * Falloff Default: light is falling off following the material specification:
  17767. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17768. */
  17769. static readonly FALLOFF_DEFAULT: number;
  17770. /**
  17771. * Falloff Physical: light is falling off following the inverse squared distance law.
  17772. */
  17773. static readonly FALLOFF_PHYSICAL: number;
  17774. /**
  17775. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17776. * to enhance interoperability with other engines.
  17777. */
  17778. static readonly FALLOFF_GLTF: number;
  17779. /**
  17780. * Falloff Standard: light is falling off like in the standard material
  17781. * to enhance interoperability with other materials.
  17782. */
  17783. static readonly FALLOFF_STANDARD: number;
  17784. /**
  17785. * If every light affecting the material is in this lightmapMode,
  17786. * material.lightmapTexture adds or multiplies
  17787. * (depends on material.useLightmapAsShadowmap)
  17788. * after every other light calculations.
  17789. */
  17790. static readonly LIGHTMAP_DEFAULT: number;
  17791. /**
  17792. * material.lightmapTexture as only diffuse lighting from this light
  17793. * adds only specular lighting from this light
  17794. * adds dynamic shadows
  17795. */
  17796. static readonly LIGHTMAP_SPECULAR: number;
  17797. /**
  17798. * material.lightmapTexture as only lighting
  17799. * no light calculation from this light
  17800. * only adds dynamic shadows from this light
  17801. */
  17802. static readonly LIGHTMAP_SHADOWSONLY: number;
  17803. /**
  17804. * Each light type uses the default quantity according to its type:
  17805. * point/spot lights use luminous intensity
  17806. * directional lights use illuminance
  17807. */
  17808. static readonly INTENSITYMODE_AUTOMATIC: number;
  17809. /**
  17810. * lumen (lm)
  17811. */
  17812. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17813. /**
  17814. * candela (lm/sr)
  17815. */
  17816. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17817. /**
  17818. * lux (lm/m^2)
  17819. */
  17820. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17821. /**
  17822. * nit (cd/m^2)
  17823. */
  17824. static readonly INTENSITYMODE_LUMINANCE: number;
  17825. /**
  17826. * Light type const id of the point light.
  17827. */
  17828. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17829. /**
  17830. * Light type const id of the directional light.
  17831. */
  17832. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17833. /**
  17834. * Light type const id of the spot light.
  17835. */
  17836. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17837. /**
  17838. * Light type const id of the hemispheric light.
  17839. */
  17840. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17841. /**
  17842. * Diffuse gives the basic color to an object.
  17843. */
  17844. diffuse: Color3;
  17845. /**
  17846. * Specular produces a highlight color on an object.
  17847. * Note: This is note affecting PBR materials.
  17848. */
  17849. specular: Color3;
  17850. /**
  17851. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17852. * falling off base on range or angle.
  17853. * This can be set to any values in Light.FALLOFF_x.
  17854. *
  17855. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17856. * other types of materials.
  17857. */
  17858. falloffType: number;
  17859. /**
  17860. * Strength of the light.
  17861. * Note: By default it is define in the framework own unit.
  17862. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17863. */
  17864. intensity: number;
  17865. private _range;
  17866. protected _inverseSquaredRange: number;
  17867. /**
  17868. * Defines how far from the source the light is impacting in scene units.
  17869. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17870. */
  17871. get range(): number;
  17872. /**
  17873. * Defines how far from the source the light is impacting in scene units.
  17874. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17875. */
  17876. set range(value: number);
  17877. /**
  17878. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17879. * of light.
  17880. */
  17881. private _photometricScale;
  17882. private _intensityMode;
  17883. /**
  17884. * Gets the photometric scale used to interpret the intensity.
  17885. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17886. */
  17887. get intensityMode(): number;
  17888. /**
  17889. * Sets the photometric scale used to interpret the intensity.
  17890. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17891. */
  17892. set intensityMode(value: number);
  17893. private _radius;
  17894. /**
  17895. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17896. */
  17897. get radius(): number;
  17898. /**
  17899. * sets the light radius used by PBR Materials to simulate soft area lights.
  17900. */
  17901. set radius(value: number);
  17902. private _renderPriority;
  17903. /**
  17904. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17905. * exceeding the number allowed of the materials.
  17906. */
  17907. renderPriority: number;
  17908. private _shadowEnabled;
  17909. /**
  17910. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17911. * the current shadow generator.
  17912. */
  17913. get shadowEnabled(): boolean;
  17914. /**
  17915. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17916. * the current shadow generator.
  17917. */
  17918. set shadowEnabled(value: boolean);
  17919. private _includedOnlyMeshes;
  17920. /**
  17921. * Gets the only meshes impacted by this light.
  17922. */
  17923. get includedOnlyMeshes(): AbstractMesh[];
  17924. /**
  17925. * Sets the only meshes impacted by this light.
  17926. */
  17927. set includedOnlyMeshes(value: AbstractMesh[]);
  17928. private _excludedMeshes;
  17929. /**
  17930. * Gets the meshes not impacted by this light.
  17931. */
  17932. get excludedMeshes(): AbstractMesh[];
  17933. /**
  17934. * Sets the meshes not impacted by this light.
  17935. */
  17936. set excludedMeshes(value: AbstractMesh[]);
  17937. private _excludeWithLayerMask;
  17938. /**
  17939. * Gets the layer id use to find what meshes are not impacted by the light.
  17940. * Inactive if 0
  17941. */
  17942. get excludeWithLayerMask(): number;
  17943. /**
  17944. * Sets the layer id use to find what meshes are not impacted by the light.
  17945. * Inactive if 0
  17946. */
  17947. set excludeWithLayerMask(value: number);
  17948. private _includeOnlyWithLayerMask;
  17949. /**
  17950. * Gets the layer id use to find what meshes are impacted by the light.
  17951. * Inactive if 0
  17952. */
  17953. get includeOnlyWithLayerMask(): number;
  17954. /**
  17955. * Sets the layer id use to find what meshes are impacted by the light.
  17956. * Inactive if 0
  17957. */
  17958. set includeOnlyWithLayerMask(value: number);
  17959. private _lightmapMode;
  17960. /**
  17961. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17962. */
  17963. get lightmapMode(): number;
  17964. /**
  17965. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17966. */
  17967. set lightmapMode(value: number);
  17968. /**
  17969. * Shadow generator associted to the light.
  17970. * @hidden Internal use only.
  17971. */
  17972. _shadowGenerator: Nullable<IShadowGenerator>;
  17973. /**
  17974. * @hidden Internal use only.
  17975. */
  17976. _excludedMeshesIds: string[];
  17977. /**
  17978. * @hidden Internal use only.
  17979. */
  17980. _includedOnlyMeshesIds: string[];
  17981. /**
  17982. * The current light unifom buffer.
  17983. * @hidden Internal use only.
  17984. */
  17985. _uniformBuffer: UniformBuffer;
  17986. /** @hidden */
  17987. _renderId: number;
  17988. /**
  17989. * Creates a Light object in the scene.
  17990. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17991. * @param name The firendly name of the light
  17992. * @param scene The scene the light belongs too
  17993. */
  17994. constructor(name: string, scene: Scene);
  17995. protected abstract _buildUniformLayout(): void;
  17996. /**
  17997. * Sets the passed Effect "effect" with the Light information.
  17998. * @param effect The effect to update
  17999. * @param lightIndex The index of the light in the effect to update
  18000. * @returns The light
  18001. */
  18002. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18003. /**
  18004. * Sets the passed Effect "effect" with the Light textures.
  18005. * @param effect The effect to update
  18006. * @param lightIndex The index of the light in the effect to update
  18007. * @returns The light
  18008. */
  18009. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18010. /**
  18011. * Binds the lights information from the scene to the effect for the given mesh.
  18012. * @param lightIndex Light index
  18013. * @param scene The scene where the light belongs to
  18014. * @param effect The effect we are binding the data to
  18015. * @param useSpecular Defines if specular is supported
  18016. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18017. */
  18018. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18019. /**
  18020. * Sets the passed Effect "effect" with the Light information.
  18021. * @param effect The effect to update
  18022. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18023. * @returns The light
  18024. */
  18025. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18026. /**
  18027. * Returns the string "Light".
  18028. * @returns the class name
  18029. */
  18030. getClassName(): string;
  18031. /** @hidden */
  18032. readonly _isLight: boolean;
  18033. /**
  18034. * Converts the light information to a readable string for debug purpose.
  18035. * @param fullDetails Supports for multiple levels of logging within scene loading
  18036. * @returns the human readable light info
  18037. */
  18038. toString(fullDetails?: boolean): string;
  18039. /** @hidden */
  18040. protected _syncParentEnabledState(): void;
  18041. /**
  18042. * Set the enabled state of this node.
  18043. * @param value - the new enabled state
  18044. */
  18045. setEnabled(value: boolean): void;
  18046. /**
  18047. * Returns the Light associated shadow generator if any.
  18048. * @return the associated shadow generator.
  18049. */
  18050. getShadowGenerator(): Nullable<IShadowGenerator>;
  18051. /**
  18052. * Returns a Vector3, the absolute light position in the World.
  18053. * @returns the world space position of the light
  18054. */
  18055. getAbsolutePosition(): Vector3;
  18056. /**
  18057. * Specifies if the light will affect the passed mesh.
  18058. * @param mesh The mesh to test against the light
  18059. * @return true the mesh is affected otherwise, false.
  18060. */
  18061. canAffectMesh(mesh: AbstractMesh): boolean;
  18062. /**
  18063. * Sort function to order lights for rendering.
  18064. * @param a First Light object to compare to second.
  18065. * @param b Second Light object to compare first.
  18066. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18067. */
  18068. static CompareLightsPriority(a: Light, b: Light): number;
  18069. /**
  18070. * Releases resources associated with this node.
  18071. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18072. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18073. */
  18074. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18075. /**
  18076. * Returns the light type ID (integer).
  18077. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18078. */
  18079. getTypeID(): number;
  18080. /**
  18081. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18082. * @returns the scaled intensity in intensity mode unit
  18083. */
  18084. getScaledIntensity(): number;
  18085. /**
  18086. * Returns a new Light object, named "name", from the current one.
  18087. * @param name The name of the cloned light
  18088. * @param newParent The parent of this light, if it has one
  18089. * @returns the new created light
  18090. */
  18091. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18092. /**
  18093. * Serializes the current light into a Serialization object.
  18094. * @returns the serialized object.
  18095. */
  18096. serialize(): any;
  18097. /**
  18098. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18099. * This new light is named "name" and added to the passed scene.
  18100. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18101. * @param name The friendly name of the light
  18102. * @param scene The scene the new light will belong to
  18103. * @returns the constructor function
  18104. */
  18105. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18106. /**
  18107. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18108. * @param parsedLight The JSON representation of the light
  18109. * @param scene The scene to create the parsed light in
  18110. * @returns the created light after parsing
  18111. */
  18112. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18113. private _hookArrayForExcluded;
  18114. private _hookArrayForIncludedOnly;
  18115. private _resyncMeshes;
  18116. /**
  18117. * Forces the meshes to update their light related information in their rendering used effects
  18118. * @hidden Internal Use Only
  18119. */
  18120. _markMeshesAsLightDirty(): void;
  18121. /**
  18122. * Recomputes the cached photometric scale if needed.
  18123. */
  18124. private _computePhotometricScale;
  18125. /**
  18126. * Returns the Photometric Scale according to the light type and intensity mode.
  18127. */
  18128. private _getPhotometricScale;
  18129. /**
  18130. * Reorder the light in the scene according to their defined priority.
  18131. * @hidden Internal Use Only
  18132. */
  18133. _reorderLightsInScene(): void;
  18134. /**
  18135. * Prepares the list of defines specific to the light type.
  18136. * @param defines the list of defines
  18137. * @param lightIndex defines the index of the light for the effect
  18138. */
  18139. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18140. }
  18141. }
  18142. declare module BABYLON {
  18143. /**
  18144. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18145. * This is the base of the follow, arc rotate cameras and Free camera
  18146. * @see http://doc.babylonjs.com/features/cameras
  18147. */
  18148. export class TargetCamera extends Camera {
  18149. private static _RigCamTransformMatrix;
  18150. private static _TargetTransformMatrix;
  18151. private static _TargetFocalPoint;
  18152. /**
  18153. * Define the current direction the camera is moving to
  18154. */
  18155. cameraDirection: Vector3;
  18156. /**
  18157. * Define the current rotation the camera is rotating to
  18158. */
  18159. cameraRotation: Vector2;
  18160. /**
  18161. * When set, the up vector of the camera will be updated by the rotation of the camera
  18162. */
  18163. updateUpVectorFromRotation: boolean;
  18164. private _tmpQuaternion;
  18165. /**
  18166. * Define the current rotation of the camera
  18167. */
  18168. rotation: Vector3;
  18169. /**
  18170. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18171. */
  18172. rotationQuaternion: Quaternion;
  18173. /**
  18174. * Define the current speed of the camera
  18175. */
  18176. speed: number;
  18177. /**
  18178. * Add constraint to the camera to prevent it to move freely in all directions and
  18179. * around all axis.
  18180. */
  18181. noRotationConstraint: boolean;
  18182. /**
  18183. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18184. * panning
  18185. */
  18186. invertRotation: boolean;
  18187. /**
  18188. * Speed multiplier for inverse camera panning
  18189. */
  18190. inverseRotationSpeed: number;
  18191. /**
  18192. * Define the current target of the camera as an object or a position.
  18193. */
  18194. lockedTarget: any;
  18195. /** @hidden */
  18196. _currentTarget: Vector3;
  18197. /** @hidden */
  18198. _initialFocalDistance: number;
  18199. /** @hidden */
  18200. _viewMatrix: Matrix;
  18201. /** @hidden */
  18202. _camMatrix: Matrix;
  18203. /** @hidden */
  18204. _cameraTransformMatrix: Matrix;
  18205. /** @hidden */
  18206. _cameraRotationMatrix: Matrix;
  18207. /** @hidden */
  18208. _referencePoint: Vector3;
  18209. /** @hidden */
  18210. _transformedReferencePoint: Vector3;
  18211. protected _globalCurrentTarget: Vector3;
  18212. protected _globalCurrentUpVector: Vector3;
  18213. /** @hidden */
  18214. _reset: () => void;
  18215. private _defaultUp;
  18216. /**
  18217. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18218. * This is the base of the follow, arc rotate cameras and Free camera
  18219. * @see http://doc.babylonjs.com/features/cameras
  18220. * @param name Defines the name of the camera in the scene
  18221. * @param position Defines the start position of the camera in the scene
  18222. * @param scene Defines the scene the camera belongs to
  18223. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18224. */
  18225. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18226. /**
  18227. * Gets the position in front of the camera at a given distance.
  18228. * @param distance The distance from the camera we want the position to be
  18229. * @returns the position
  18230. */
  18231. getFrontPosition(distance: number): Vector3;
  18232. /** @hidden */
  18233. _getLockedTargetPosition(): Nullable<Vector3>;
  18234. private _storedPosition;
  18235. private _storedRotation;
  18236. private _storedRotationQuaternion;
  18237. /**
  18238. * Store current camera state of the camera (fov, position, rotation, etc..)
  18239. * @returns the camera
  18240. */
  18241. storeState(): Camera;
  18242. /**
  18243. * Restored camera state. You must call storeState() first
  18244. * @returns whether it was successful or not
  18245. * @hidden
  18246. */
  18247. _restoreStateValues(): boolean;
  18248. /** @hidden */
  18249. _initCache(): void;
  18250. /** @hidden */
  18251. _updateCache(ignoreParentClass?: boolean): void;
  18252. /** @hidden */
  18253. _isSynchronizedViewMatrix(): boolean;
  18254. /** @hidden */
  18255. _computeLocalCameraSpeed(): number;
  18256. /**
  18257. * Defines the target the camera should look at.
  18258. * @param target Defines the new target as a Vector or a mesh
  18259. */
  18260. setTarget(target: Vector3): void;
  18261. /**
  18262. * Return the current target position of the camera. This value is expressed in local space.
  18263. * @returns the target position
  18264. */
  18265. getTarget(): Vector3;
  18266. /** @hidden */
  18267. _decideIfNeedsToMove(): boolean;
  18268. /** @hidden */
  18269. _updatePosition(): void;
  18270. /** @hidden */
  18271. _checkInputs(): void;
  18272. protected _updateCameraRotationMatrix(): void;
  18273. /**
  18274. * 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)
  18275. * @returns the current camera
  18276. */
  18277. private _rotateUpVectorWithCameraRotationMatrix;
  18278. private _cachedRotationZ;
  18279. private _cachedQuaternionRotationZ;
  18280. /** @hidden */
  18281. _getViewMatrix(): Matrix;
  18282. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18283. /**
  18284. * @hidden
  18285. */
  18286. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18287. /**
  18288. * @hidden
  18289. */
  18290. _updateRigCameras(): void;
  18291. private _getRigCamPositionAndTarget;
  18292. /**
  18293. * Gets the current object class name.
  18294. * @return the class name
  18295. */
  18296. getClassName(): string;
  18297. }
  18298. }
  18299. declare module BABYLON {
  18300. /**
  18301. * Gather the list of keyboard event types as constants.
  18302. */
  18303. export class KeyboardEventTypes {
  18304. /**
  18305. * The keydown event is fired when a key becomes active (pressed).
  18306. */
  18307. static readonly KEYDOWN: number;
  18308. /**
  18309. * The keyup event is fired when a key has been released.
  18310. */
  18311. static readonly KEYUP: number;
  18312. }
  18313. /**
  18314. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18315. */
  18316. export class KeyboardInfo {
  18317. /**
  18318. * Defines the type of event (KeyboardEventTypes)
  18319. */
  18320. type: number;
  18321. /**
  18322. * Defines the related dom event
  18323. */
  18324. event: KeyboardEvent;
  18325. /**
  18326. * Instantiates a new keyboard info.
  18327. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18328. * @param type Defines the type of event (KeyboardEventTypes)
  18329. * @param event Defines the related dom event
  18330. */
  18331. constructor(
  18332. /**
  18333. * Defines the type of event (KeyboardEventTypes)
  18334. */
  18335. type: number,
  18336. /**
  18337. * Defines the related dom event
  18338. */
  18339. event: KeyboardEvent);
  18340. }
  18341. /**
  18342. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18343. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18344. */
  18345. export class KeyboardInfoPre extends KeyboardInfo {
  18346. /**
  18347. * Defines the type of event (KeyboardEventTypes)
  18348. */
  18349. type: number;
  18350. /**
  18351. * Defines the related dom event
  18352. */
  18353. event: KeyboardEvent;
  18354. /**
  18355. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18356. */
  18357. skipOnPointerObservable: boolean;
  18358. /**
  18359. * Instantiates a new keyboard pre info.
  18360. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18361. * @param type Defines the type of event (KeyboardEventTypes)
  18362. * @param event Defines the related dom event
  18363. */
  18364. constructor(
  18365. /**
  18366. * Defines the type of event (KeyboardEventTypes)
  18367. */
  18368. type: number,
  18369. /**
  18370. * Defines the related dom event
  18371. */
  18372. event: KeyboardEvent);
  18373. }
  18374. }
  18375. declare module BABYLON {
  18376. /**
  18377. * Manage the keyboard inputs to control the movement of a free camera.
  18378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18379. */
  18380. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18381. /**
  18382. * Defines the camera the input is attached to.
  18383. */
  18384. camera: FreeCamera;
  18385. /**
  18386. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18387. */
  18388. keysUp: number[];
  18389. /**
  18390. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18391. */
  18392. keysUpward: number[];
  18393. /**
  18394. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18395. */
  18396. keysDown: number[];
  18397. /**
  18398. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18399. */
  18400. keysDownward: number[];
  18401. /**
  18402. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18403. */
  18404. keysLeft: number[];
  18405. /**
  18406. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18407. */
  18408. keysRight: number[];
  18409. private _keys;
  18410. private _onCanvasBlurObserver;
  18411. private _onKeyboardObserver;
  18412. private _engine;
  18413. private _scene;
  18414. /**
  18415. * Attach the input controls to a specific dom element to get the input from.
  18416. * @param element Defines the element the controls should be listened from
  18417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18418. */
  18419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18420. /**
  18421. * Detach the current controls from the specified dom element.
  18422. * @param element Defines the element to stop listening the inputs from
  18423. */
  18424. detachControl(element: Nullable<HTMLElement>): void;
  18425. /**
  18426. * Update the current camera state depending on the inputs that have been used this frame.
  18427. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18428. */
  18429. checkInputs(): void;
  18430. /**
  18431. * Gets the class name of the current intput.
  18432. * @returns the class name
  18433. */
  18434. getClassName(): string;
  18435. /** @hidden */
  18436. _onLostFocus(): void;
  18437. /**
  18438. * Get the friendly name associated with the input class.
  18439. * @returns the input friendly name
  18440. */
  18441. getSimpleName(): string;
  18442. }
  18443. }
  18444. declare module BABYLON {
  18445. /**
  18446. * Gather the list of pointer event types as constants.
  18447. */
  18448. export class PointerEventTypes {
  18449. /**
  18450. * 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.
  18451. */
  18452. static readonly POINTERDOWN: number;
  18453. /**
  18454. * The pointerup event is fired when a pointer is no longer active.
  18455. */
  18456. static readonly POINTERUP: number;
  18457. /**
  18458. * The pointermove event is fired when a pointer changes coordinates.
  18459. */
  18460. static readonly POINTERMOVE: number;
  18461. /**
  18462. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18463. */
  18464. static readonly POINTERWHEEL: number;
  18465. /**
  18466. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18467. */
  18468. static readonly POINTERPICK: number;
  18469. /**
  18470. * The pointertap event is fired when a the object has been touched and released without drag.
  18471. */
  18472. static readonly POINTERTAP: number;
  18473. /**
  18474. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18475. */
  18476. static readonly POINTERDOUBLETAP: number;
  18477. }
  18478. /**
  18479. * Base class of pointer info types.
  18480. */
  18481. export class PointerInfoBase {
  18482. /**
  18483. * Defines the type of event (PointerEventTypes)
  18484. */
  18485. type: number;
  18486. /**
  18487. * Defines the related dom event
  18488. */
  18489. event: PointerEvent | MouseWheelEvent;
  18490. /**
  18491. * Instantiates the base class of pointers info.
  18492. * @param type Defines the type of event (PointerEventTypes)
  18493. * @param event Defines the related dom event
  18494. */
  18495. constructor(
  18496. /**
  18497. * Defines the type of event (PointerEventTypes)
  18498. */
  18499. type: number,
  18500. /**
  18501. * Defines the related dom event
  18502. */
  18503. event: PointerEvent | MouseWheelEvent);
  18504. }
  18505. /**
  18506. * This class is used to store pointer related info for the onPrePointerObservable event.
  18507. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18508. */
  18509. export class PointerInfoPre extends PointerInfoBase {
  18510. /**
  18511. * Ray from a pointer if availible (eg. 6dof controller)
  18512. */
  18513. ray: Nullable<Ray>;
  18514. /**
  18515. * Defines the local position of the pointer on the canvas.
  18516. */
  18517. localPosition: Vector2;
  18518. /**
  18519. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18520. */
  18521. skipOnPointerObservable: boolean;
  18522. /**
  18523. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18524. * @param type Defines the type of event (PointerEventTypes)
  18525. * @param event Defines the related dom event
  18526. * @param localX Defines the local x coordinates of the pointer when the event occured
  18527. * @param localY Defines the local y coordinates of the pointer when the event occured
  18528. */
  18529. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18530. }
  18531. /**
  18532. * This type contains all the data related to a pointer event in Babylon.js.
  18533. * 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.
  18534. */
  18535. export class PointerInfo extends PointerInfoBase {
  18536. /**
  18537. * Defines the picking info associated to the info (if any)\
  18538. */
  18539. pickInfo: Nullable<PickingInfo>;
  18540. /**
  18541. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18542. * @param type Defines the type of event (PointerEventTypes)
  18543. * @param event Defines the related dom event
  18544. * @param pickInfo Defines the picking info associated to the info (if any)\
  18545. */
  18546. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18547. /**
  18548. * Defines the picking info associated to the info (if any)\
  18549. */
  18550. pickInfo: Nullable<PickingInfo>);
  18551. }
  18552. /**
  18553. * Data relating to a touch event on the screen.
  18554. */
  18555. export interface PointerTouch {
  18556. /**
  18557. * X coordinate of touch.
  18558. */
  18559. x: number;
  18560. /**
  18561. * Y coordinate of touch.
  18562. */
  18563. y: number;
  18564. /**
  18565. * Id of touch. Unique for each finger.
  18566. */
  18567. pointerId: number;
  18568. /**
  18569. * Event type passed from DOM.
  18570. */
  18571. type: any;
  18572. }
  18573. }
  18574. declare module BABYLON {
  18575. /**
  18576. * Manage the mouse inputs to control the movement of a free camera.
  18577. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18578. */
  18579. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18580. /**
  18581. * Define if touch is enabled in the mouse input
  18582. */
  18583. touchEnabled: boolean;
  18584. /**
  18585. * Defines the camera the input is attached to.
  18586. */
  18587. camera: FreeCamera;
  18588. /**
  18589. * Defines the buttons associated with the input to handle camera move.
  18590. */
  18591. buttons: number[];
  18592. /**
  18593. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18594. */
  18595. angularSensibility: number;
  18596. private _pointerInput;
  18597. private _onMouseMove;
  18598. private _observer;
  18599. private previousPosition;
  18600. /**
  18601. * Observable for when a pointer move event occurs containing the move offset
  18602. */
  18603. onPointerMovedObservable: Observable<{
  18604. offsetX: number;
  18605. offsetY: number;
  18606. }>;
  18607. /**
  18608. * @hidden
  18609. * If the camera should be rotated automatically based on pointer movement
  18610. */
  18611. _allowCameraRotation: boolean;
  18612. /**
  18613. * Manage the mouse inputs to control the movement of a free camera.
  18614. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18615. * @param touchEnabled Defines if touch is enabled or not
  18616. */
  18617. constructor(
  18618. /**
  18619. * Define if touch is enabled in the mouse input
  18620. */
  18621. touchEnabled?: boolean);
  18622. /**
  18623. * Attach the input controls to a specific dom element to get the input from.
  18624. * @param element Defines the element the controls should be listened from
  18625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18626. */
  18627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18628. /**
  18629. * Called on JS contextmenu event.
  18630. * Override this method to provide functionality.
  18631. */
  18632. protected onContextMenu(evt: PointerEvent): void;
  18633. /**
  18634. * Detach the current controls from the specified dom element.
  18635. * @param element Defines the element to stop listening the inputs from
  18636. */
  18637. detachControl(element: Nullable<HTMLElement>): void;
  18638. /**
  18639. * Gets the class name of the current intput.
  18640. * @returns the class name
  18641. */
  18642. getClassName(): string;
  18643. /**
  18644. * Get the friendly name associated with the input class.
  18645. * @returns the input friendly name
  18646. */
  18647. getSimpleName(): string;
  18648. }
  18649. }
  18650. declare module BABYLON {
  18651. /**
  18652. * Manage the touch inputs to control the movement of a free camera.
  18653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18654. */
  18655. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18656. /**
  18657. * Defines the camera the input is attached to.
  18658. */
  18659. camera: FreeCamera;
  18660. /**
  18661. * Defines the touch sensibility for rotation.
  18662. * The higher the faster.
  18663. */
  18664. touchAngularSensibility: number;
  18665. /**
  18666. * Defines the touch sensibility for move.
  18667. * The higher the faster.
  18668. */
  18669. touchMoveSensibility: number;
  18670. private _offsetX;
  18671. private _offsetY;
  18672. private _pointerPressed;
  18673. private _pointerInput;
  18674. private _observer;
  18675. private _onLostFocus;
  18676. /**
  18677. * Attach the input controls to a specific dom element to get the input from.
  18678. * @param element Defines the element the controls should be listened from
  18679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18680. */
  18681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18682. /**
  18683. * Detach the current controls from the specified dom element.
  18684. * @param element Defines the element to stop listening the inputs from
  18685. */
  18686. detachControl(element: Nullable<HTMLElement>): void;
  18687. /**
  18688. * Update the current camera state depending on the inputs that have been used this frame.
  18689. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18690. */
  18691. checkInputs(): void;
  18692. /**
  18693. * Gets the class name of the current intput.
  18694. * @returns the class name
  18695. */
  18696. getClassName(): string;
  18697. /**
  18698. * Get the friendly name associated with the input class.
  18699. * @returns the input friendly name
  18700. */
  18701. getSimpleName(): string;
  18702. }
  18703. }
  18704. declare module BABYLON {
  18705. /**
  18706. * Default Inputs manager for the FreeCamera.
  18707. * It groups all the default supported inputs for ease of use.
  18708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18709. */
  18710. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18711. /**
  18712. * @hidden
  18713. */
  18714. _mouseInput: Nullable<FreeCameraMouseInput>;
  18715. /**
  18716. * Instantiates a new FreeCameraInputsManager.
  18717. * @param camera Defines the camera the inputs belong to
  18718. */
  18719. constructor(camera: FreeCamera);
  18720. /**
  18721. * Add keyboard input support to the input manager.
  18722. * @returns the current input manager
  18723. */
  18724. addKeyboard(): FreeCameraInputsManager;
  18725. /**
  18726. * Add mouse input support to the input manager.
  18727. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18728. * @returns the current input manager
  18729. */
  18730. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18731. /**
  18732. * Removes the mouse input support from the manager
  18733. * @returns the current input manager
  18734. */
  18735. removeMouse(): FreeCameraInputsManager;
  18736. /**
  18737. * Add touch input support to the input manager.
  18738. * @returns the current input manager
  18739. */
  18740. addTouch(): FreeCameraInputsManager;
  18741. /**
  18742. * Remove all attached input methods from a camera
  18743. */
  18744. clear(): void;
  18745. }
  18746. }
  18747. declare module BABYLON {
  18748. /**
  18749. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18750. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18751. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18752. */
  18753. export class FreeCamera extends TargetCamera {
  18754. /**
  18755. * Define the collision ellipsoid of the camera.
  18756. * This is helpful to simulate a camera body like the player body around the camera
  18757. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18758. */
  18759. ellipsoid: Vector3;
  18760. /**
  18761. * Define an offset for the position of the ellipsoid around the camera.
  18762. * This can be helpful to determine the center of the body near the gravity center of the body
  18763. * instead of its head.
  18764. */
  18765. ellipsoidOffset: Vector3;
  18766. /**
  18767. * Enable or disable collisions of the camera with the rest of the scene objects.
  18768. */
  18769. checkCollisions: boolean;
  18770. /**
  18771. * Enable or disable gravity on the camera.
  18772. */
  18773. applyGravity: boolean;
  18774. /**
  18775. * Define the input manager associated to the camera.
  18776. */
  18777. inputs: FreeCameraInputsManager;
  18778. /**
  18779. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18780. * Higher values reduce sensitivity.
  18781. */
  18782. get angularSensibility(): number;
  18783. /**
  18784. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18785. * Higher values reduce sensitivity.
  18786. */
  18787. set angularSensibility(value: number);
  18788. /**
  18789. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18790. */
  18791. get keysUp(): number[];
  18792. set keysUp(value: number[]);
  18793. /**
  18794. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18795. */
  18796. get keysUpward(): number[];
  18797. set keysUpward(value: number[]);
  18798. /**
  18799. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18800. */
  18801. get keysDown(): number[];
  18802. set keysDown(value: number[]);
  18803. /**
  18804. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18805. */
  18806. get keysDownward(): number[];
  18807. set keysDownward(value: number[]);
  18808. /**
  18809. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18810. */
  18811. get keysLeft(): number[];
  18812. set keysLeft(value: number[]);
  18813. /**
  18814. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18815. */
  18816. get keysRight(): number[];
  18817. set keysRight(value: number[]);
  18818. /**
  18819. * Event raised when the camera collide with a mesh in the scene.
  18820. */
  18821. onCollide: (collidedMesh: AbstractMesh) => void;
  18822. private _collider;
  18823. private _needMoveForGravity;
  18824. private _oldPosition;
  18825. private _diffPosition;
  18826. private _newPosition;
  18827. /** @hidden */
  18828. _localDirection: Vector3;
  18829. /** @hidden */
  18830. _transformedDirection: Vector3;
  18831. /**
  18832. * Instantiates a Free Camera.
  18833. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18834. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18835. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18836. * @param name Define the name of the camera in the scene
  18837. * @param position Define the start position of the camera in the scene
  18838. * @param scene Define the scene the camera belongs to
  18839. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18840. */
  18841. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18842. /**
  18843. * Attached controls to the current camera.
  18844. * @param element Defines the element the controls should be listened from
  18845. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18846. */
  18847. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18848. /**
  18849. * Detach the current controls from the camera.
  18850. * The camera will stop reacting to inputs.
  18851. * @param element Defines the element to stop listening the inputs from
  18852. */
  18853. detachControl(element: HTMLElement): void;
  18854. private _collisionMask;
  18855. /**
  18856. * Define a collision mask to limit the list of object the camera can collide with
  18857. */
  18858. get collisionMask(): number;
  18859. set collisionMask(mask: number);
  18860. /** @hidden */
  18861. _collideWithWorld(displacement: Vector3): void;
  18862. private _onCollisionPositionChange;
  18863. /** @hidden */
  18864. _checkInputs(): void;
  18865. /** @hidden */
  18866. _decideIfNeedsToMove(): boolean;
  18867. /** @hidden */
  18868. _updatePosition(): void;
  18869. /**
  18870. * Destroy the camera and release the current resources hold by it.
  18871. */
  18872. dispose(): void;
  18873. /**
  18874. * Gets the current object class name.
  18875. * @return the class name
  18876. */
  18877. getClassName(): string;
  18878. }
  18879. }
  18880. declare module BABYLON {
  18881. /**
  18882. * Represents a gamepad control stick position
  18883. */
  18884. export class StickValues {
  18885. /**
  18886. * The x component of the control stick
  18887. */
  18888. x: number;
  18889. /**
  18890. * The y component of the control stick
  18891. */
  18892. y: number;
  18893. /**
  18894. * Initializes the gamepad x and y control stick values
  18895. * @param x The x component of the gamepad control stick value
  18896. * @param y The y component of the gamepad control stick value
  18897. */
  18898. constructor(
  18899. /**
  18900. * The x component of the control stick
  18901. */
  18902. x: number,
  18903. /**
  18904. * The y component of the control stick
  18905. */
  18906. y: number);
  18907. }
  18908. /**
  18909. * An interface which manages callbacks for gamepad button changes
  18910. */
  18911. export interface GamepadButtonChanges {
  18912. /**
  18913. * Called when a gamepad has been changed
  18914. */
  18915. changed: boolean;
  18916. /**
  18917. * Called when a gamepad press event has been triggered
  18918. */
  18919. pressChanged: boolean;
  18920. /**
  18921. * Called when a touch event has been triggered
  18922. */
  18923. touchChanged: boolean;
  18924. /**
  18925. * Called when a value has changed
  18926. */
  18927. valueChanged: boolean;
  18928. }
  18929. /**
  18930. * Represents a gamepad
  18931. */
  18932. export class Gamepad {
  18933. /**
  18934. * The id of the gamepad
  18935. */
  18936. id: string;
  18937. /**
  18938. * The index of the gamepad
  18939. */
  18940. index: number;
  18941. /**
  18942. * The browser gamepad
  18943. */
  18944. browserGamepad: any;
  18945. /**
  18946. * Specifies what type of gamepad this represents
  18947. */
  18948. type: number;
  18949. private _leftStick;
  18950. private _rightStick;
  18951. /** @hidden */
  18952. _isConnected: boolean;
  18953. private _leftStickAxisX;
  18954. private _leftStickAxisY;
  18955. private _rightStickAxisX;
  18956. private _rightStickAxisY;
  18957. /**
  18958. * Triggered when the left control stick has been changed
  18959. */
  18960. private _onleftstickchanged;
  18961. /**
  18962. * Triggered when the right control stick has been changed
  18963. */
  18964. private _onrightstickchanged;
  18965. /**
  18966. * Represents a gamepad controller
  18967. */
  18968. static GAMEPAD: number;
  18969. /**
  18970. * Represents a generic controller
  18971. */
  18972. static GENERIC: number;
  18973. /**
  18974. * Represents an XBox controller
  18975. */
  18976. static XBOX: number;
  18977. /**
  18978. * Represents a pose-enabled controller
  18979. */
  18980. static POSE_ENABLED: number;
  18981. /**
  18982. * Represents an Dual Shock controller
  18983. */
  18984. static DUALSHOCK: number;
  18985. /**
  18986. * Specifies whether the left control stick should be Y-inverted
  18987. */
  18988. protected _invertLeftStickY: boolean;
  18989. /**
  18990. * Specifies if the gamepad has been connected
  18991. */
  18992. get isConnected(): boolean;
  18993. /**
  18994. * Initializes the gamepad
  18995. * @param id The id of the gamepad
  18996. * @param index The index of the gamepad
  18997. * @param browserGamepad The browser gamepad
  18998. * @param leftStickX The x component of the left joystick
  18999. * @param leftStickY The y component of the left joystick
  19000. * @param rightStickX The x component of the right joystick
  19001. * @param rightStickY The y component of the right joystick
  19002. */
  19003. constructor(
  19004. /**
  19005. * The id of the gamepad
  19006. */
  19007. id: string,
  19008. /**
  19009. * The index of the gamepad
  19010. */
  19011. index: number,
  19012. /**
  19013. * The browser gamepad
  19014. */
  19015. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19016. /**
  19017. * Callback triggered when the left joystick has changed
  19018. * @param callback
  19019. */
  19020. onleftstickchanged(callback: (values: StickValues) => void): void;
  19021. /**
  19022. * Callback triggered when the right joystick has changed
  19023. * @param callback
  19024. */
  19025. onrightstickchanged(callback: (values: StickValues) => void): void;
  19026. /**
  19027. * Gets the left joystick
  19028. */
  19029. get leftStick(): StickValues;
  19030. /**
  19031. * Sets the left joystick values
  19032. */
  19033. set leftStick(newValues: StickValues);
  19034. /**
  19035. * Gets the right joystick
  19036. */
  19037. get rightStick(): StickValues;
  19038. /**
  19039. * Sets the right joystick value
  19040. */
  19041. set rightStick(newValues: StickValues);
  19042. /**
  19043. * Updates the gamepad joystick positions
  19044. */
  19045. update(): void;
  19046. /**
  19047. * Disposes the gamepad
  19048. */
  19049. dispose(): void;
  19050. }
  19051. /**
  19052. * Represents a generic gamepad
  19053. */
  19054. export class GenericPad extends Gamepad {
  19055. private _buttons;
  19056. private _onbuttondown;
  19057. private _onbuttonup;
  19058. /**
  19059. * Observable triggered when a button has been pressed
  19060. */
  19061. onButtonDownObservable: Observable<number>;
  19062. /**
  19063. * Observable triggered when a button has been released
  19064. */
  19065. onButtonUpObservable: Observable<number>;
  19066. /**
  19067. * Callback triggered when a button has been pressed
  19068. * @param callback Called when a button has been pressed
  19069. */
  19070. onbuttondown(callback: (buttonPressed: number) => void): void;
  19071. /**
  19072. * Callback triggered when a button has been released
  19073. * @param callback Called when a button has been released
  19074. */
  19075. onbuttonup(callback: (buttonReleased: number) => void): void;
  19076. /**
  19077. * Initializes the generic gamepad
  19078. * @param id The id of the generic gamepad
  19079. * @param index The index of the generic gamepad
  19080. * @param browserGamepad The browser gamepad
  19081. */
  19082. constructor(id: string, index: number, browserGamepad: any);
  19083. private _setButtonValue;
  19084. /**
  19085. * Updates the generic gamepad
  19086. */
  19087. update(): void;
  19088. /**
  19089. * Disposes the generic gamepad
  19090. */
  19091. dispose(): void;
  19092. }
  19093. }
  19094. declare module BABYLON {
  19095. /**
  19096. * Defines the types of pose enabled controllers that are supported
  19097. */
  19098. export enum PoseEnabledControllerType {
  19099. /**
  19100. * HTC Vive
  19101. */
  19102. VIVE = 0,
  19103. /**
  19104. * Oculus Rift
  19105. */
  19106. OCULUS = 1,
  19107. /**
  19108. * Windows mixed reality
  19109. */
  19110. WINDOWS = 2,
  19111. /**
  19112. * Samsung gear VR
  19113. */
  19114. GEAR_VR = 3,
  19115. /**
  19116. * Google Daydream
  19117. */
  19118. DAYDREAM = 4,
  19119. /**
  19120. * Generic
  19121. */
  19122. GENERIC = 5
  19123. }
  19124. /**
  19125. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19126. */
  19127. export interface MutableGamepadButton {
  19128. /**
  19129. * Value of the button/trigger
  19130. */
  19131. value: number;
  19132. /**
  19133. * If the button/trigger is currently touched
  19134. */
  19135. touched: boolean;
  19136. /**
  19137. * If the button/trigger is currently pressed
  19138. */
  19139. pressed: boolean;
  19140. }
  19141. /**
  19142. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19143. * @hidden
  19144. */
  19145. export interface ExtendedGamepadButton extends GamepadButton {
  19146. /**
  19147. * If the button/trigger is currently pressed
  19148. */
  19149. readonly pressed: boolean;
  19150. /**
  19151. * If the button/trigger is currently touched
  19152. */
  19153. readonly touched: boolean;
  19154. /**
  19155. * Value of the button/trigger
  19156. */
  19157. readonly value: number;
  19158. }
  19159. /** @hidden */
  19160. export interface _GamePadFactory {
  19161. /**
  19162. * Returns whether or not the current gamepad can be created for this type of controller.
  19163. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19164. * @returns true if it can be created, otherwise false
  19165. */
  19166. canCreate(gamepadInfo: any): boolean;
  19167. /**
  19168. * Creates a new instance of the Gamepad.
  19169. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19170. * @returns the new gamepad instance
  19171. */
  19172. create(gamepadInfo: any): Gamepad;
  19173. }
  19174. /**
  19175. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19176. */
  19177. export class PoseEnabledControllerHelper {
  19178. /** @hidden */
  19179. static _ControllerFactories: _GamePadFactory[];
  19180. /** @hidden */
  19181. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19182. /**
  19183. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19184. * @param vrGamepad the gamepad to initialized
  19185. * @returns a vr controller of the type the gamepad identified as
  19186. */
  19187. static InitiateController(vrGamepad: any): Gamepad;
  19188. }
  19189. /**
  19190. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19191. */
  19192. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19193. /**
  19194. * If the controller is used in a webXR session
  19195. */
  19196. isXR: boolean;
  19197. private _deviceRoomPosition;
  19198. private _deviceRoomRotationQuaternion;
  19199. /**
  19200. * The device position in babylon space
  19201. */
  19202. devicePosition: Vector3;
  19203. /**
  19204. * The device rotation in babylon space
  19205. */
  19206. deviceRotationQuaternion: Quaternion;
  19207. /**
  19208. * The scale factor of the device in babylon space
  19209. */
  19210. deviceScaleFactor: number;
  19211. /**
  19212. * (Likely devicePosition should be used instead) The device position in its room space
  19213. */
  19214. position: Vector3;
  19215. /**
  19216. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19217. */
  19218. rotationQuaternion: Quaternion;
  19219. /**
  19220. * The type of controller (Eg. Windows mixed reality)
  19221. */
  19222. controllerType: PoseEnabledControllerType;
  19223. protected _calculatedPosition: Vector3;
  19224. private _calculatedRotation;
  19225. /**
  19226. * The raw pose from the device
  19227. */
  19228. rawPose: DevicePose;
  19229. private _trackPosition;
  19230. private _maxRotationDistFromHeadset;
  19231. private _draggedRoomRotation;
  19232. /**
  19233. * @hidden
  19234. */
  19235. _disableTrackPosition(fixedPosition: Vector3): void;
  19236. /**
  19237. * Internal, the mesh attached to the controller
  19238. * @hidden
  19239. */
  19240. _mesh: Nullable<AbstractMesh>;
  19241. private _poseControlledCamera;
  19242. private _leftHandSystemQuaternion;
  19243. /**
  19244. * Internal, matrix used to convert room space to babylon space
  19245. * @hidden
  19246. */
  19247. _deviceToWorld: Matrix;
  19248. /**
  19249. * Node to be used when casting a ray from the controller
  19250. * @hidden
  19251. */
  19252. _pointingPoseNode: Nullable<TransformNode>;
  19253. /**
  19254. * Name of the child mesh that can be used to cast a ray from the controller
  19255. */
  19256. static readonly POINTING_POSE: string;
  19257. /**
  19258. * Creates a new PoseEnabledController from a gamepad
  19259. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19260. */
  19261. constructor(browserGamepad: any);
  19262. private _workingMatrix;
  19263. /**
  19264. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19265. */
  19266. update(): void;
  19267. /**
  19268. * Updates only the pose device and mesh without doing any button event checking
  19269. */
  19270. protected _updatePoseAndMesh(): void;
  19271. /**
  19272. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19273. * @param poseData raw pose fromthe device
  19274. */
  19275. updateFromDevice(poseData: DevicePose): void;
  19276. /**
  19277. * @hidden
  19278. */
  19279. _meshAttachedObservable: Observable<AbstractMesh>;
  19280. /**
  19281. * Attaches a mesh to the controller
  19282. * @param mesh the mesh to be attached
  19283. */
  19284. attachToMesh(mesh: AbstractMesh): void;
  19285. /**
  19286. * Attaches the controllers mesh to a camera
  19287. * @param camera the camera the mesh should be attached to
  19288. */
  19289. attachToPoseControlledCamera(camera: TargetCamera): void;
  19290. /**
  19291. * Disposes of the controller
  19292. */
  19293. dispose(): void;
  19294. /**
  19295. * The mesh that is attached to the controller
  19296. */
  19297. get mesh(): Nullable<AbstractMesh>;
  19298. /**
  19299. * Gets the ray of the controller in the direction the controller is pointing
  19300. * @param length the length the resulting ray should be
  19301. * @returns a ray in the direction the controller is pointing
  19302. */
  19303. getForwardRay(length?: number): Ray;
  19304. }
  19305. }
  19306. declare module BABYLON {
  19307. /**
  19308. * Defines the WebVRController object that represents controllers tracked in 3D space
  19309. */
  19310. export abstract class WebVRController extends PoseEnabledController {
  19311. /**
  19312. * Internal, the default controller model for the controller
  19313. */
  19314. protected _defaultModel: Nullable<AbstractMesh>;
  19315. /**
  19316. * Fired when the trigger state has changed
  19317. */
  19318. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19319. /**
  19320. * Fired when the main button state has changed
  19321. */
  19322. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19323. /**
  19324. * Fired when the secondary button state has changed
  19325. */
  19326. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19327. /**
  19328. * Fired when the pad state has changed
  19329. */
  19330. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19331. /**
  19332. * Fired when controllers stick values have changed
  19333. */
  19334. onPadValuesChangedObservable: Observable<StickValues>;
  19335. /**
  19336. * Array of button availible on the controller
  19337. */
  19338. protected _buttons: Array<MutableGamepadButton>;
  19339. private _onButtonStateChange;
  19340. /**
  19341. * Fired when a controller button's state has changed
  19342. * @param callback the callback containing the button that was modified
  19343. */
  19344. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19345. /**
  19346. * X and Y axis corresponding to the controllers joystick
  19347. */
  19348. pad: StickValues;
  19349. /**
  19350. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19351. */
  19352. hand: string;
  19353. /**
  19354. * The default controller model for the controller
  19355. */
  19356. get defaultModel(): Nullable<AbstractMesh>;
  19357. /**
  19358. * Creates a new WebVRController from a gamepad
  19359. * @param vrGamepad the gamepad that the WebVRController should be created from
  19360. */
  19361. constructor(vrGamepad: any);
  19362. /**
  19363. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19364. */
  19365. update(): void;
  19366. /**
  19367. * Function to be called when a button is modified
  19368. */
  19369. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19370. /**
  19371. * Loads a mesh and attaches it to the controller
  19372. * @param scene the scene the mesh should be added to
  19373. * @param meshLoaded callback for when the mesh has been loaded
  19374. */
  19375. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19376. private _setButtonValue;
  19377. private _changes;
  19378. private _checkChanges;
  19379. /**
  19380. * Disposes of th webVRCOntroller
  19381. */
  19382. dispose(): void;
  19383. }
  19384. }
  19385. declare module BABYLON {
  19386. /**
  19387. * The HemisphericLight simulates the ambient environment light,
  19388. * so the passed direction is the light reflection direction, not the incoming direction.
  19389. */
  19390. export class HemisphericLight extends Light {
  19391. /**
  19392. * The groundColor is the light in the opposite direction to the one specified during creation.
  19393. * 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.
  19394. */
  19395. groundColor: Color3;
  19396. /**
  19397. * The light reflection direction, not the incoming direction.
  19398. */
  19399. direction: Vector3;
  19400. /**
  19401. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19402. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19403. * The HemisphericLight can't cast shadows.
  19404. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19405. * @param name The friendly name of the light
  19406. * @param direction The direction of the light reflection
  19407. * @param scene The scene the light belongs to
  19408. */
  19409. constructor(name: string, direction: Vector3, scene: Scene);
  19410. protected _buildUniformLayout(): void;
  19411. /**
  19412. * Returns the string "HemisphericLight".
  19413. * @return The class name
  19414. */
  19415. getClassName(): string;
  19416. /**
  19417. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19418. * Returns the updated direction.
  19419. * @param target The target the direction should point to
  19420. * @return The computed direction
  19421. */
  19422. setDirectionToTarget(target: Vector3): Vector3;
  19423. /**
  19424. * Returns the shadow generator associated to the light.
  19425. * @returns Always null for hemispheric lights because it does not support shadows.
  19426. */
  19427. getShadowGenerator(): Nullable<IShadowGenerator>;
  19428. /**
  19429. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19430. * @param effect The effect to update
  19431. * @param lightIndex The index of the light in the effect to update
  19432. * @returns The hemispheric light
  19433. */
  19434. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19435. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19436. /**
  19437. * Computes the world matrix of the node
  19438. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19439. * @param useWasUpdatedFlag defines a reserved property
  19440. * @returns the world matrix
  19441. */
  19442. computeWorldMatrix(): Matrix;
  19443. /**
  19444. * Returns the integer 3.
  19445. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19446. */
  19447. getTypeID(): number;
  19448. /**
  19449. * Prepares the list of defines specific to the light type.
  19450. * @param defines the list of defines
  19451. * @param lightIndex defines the index of the light for the effect
  19452. */
  19453. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19454. }
  19455. }
  19456. declare module BABYLON {
  19457. /** @hidden */
  19458. export var vrMultiviewToSingleviewPixelShader: {
  19459. name: string;
  19460. shader: string;
  19461. };
  19462. }
  19463. declare module BABYLON {
  19464. /**
  19465. * Renders to multiple views with a single draw call
  19466. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19467. */
  19468. export class MultiviewRenderTarget extends RenderTargetTexture {
  19469. /**
  19470. * Creates a multiview render target
  19471. * @param scene scene used with the render target
  19472. * @param size the size of the render target (used for each view)
  19473. */
  19474. constructor(scene: Scene, size?: number | {
  19475. width: number;
  19476. height: number;
  19477. } | {
  19478. ratio: number;
  19479. });
  19480. /**
  19481. * @hidden
  19482. * @param faceIndex the face index, if its a cube texture
  19483. */
  19484. _bindFrameBuffer(faceIndex?: number): void;
  19485. /**
  19486. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19487. * @returns the view count
  19488. */
  19489. getViewCount(): number;
  19490. }
  19491. }
  19492. declare module BABYLON {
  19493. interface Engine {
  19494. /**
  19495. * Creates a new multiview render target
  19496. * @param width defines the width of the texture
  19497. * @param height defines the height of the texture
  19498. * @returns the created multiview texture
  19499. */
  19500. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19501. /**
  19502. * Binds a multiview framebuffer to be drawn to
  19503. * @param multiviewTexture texture to bind
  19504. */
  19505. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19506. }
  19507. interface Camera {
  19508. /**
  19509. * @hidden
  19510. * 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)
  19511. */
  19512. _useMultiviewToSingleView: boolean;
  19513. /**
  19514. * @hidden
  19515. * 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)
  19516. */
  19517. _multiviewTexture: Nullable<RenderTargetTexture>;
  19518. /**
  19519. * @hidden
  19520. * ensures the multiview texture of the camera exists and has the specified width/height
  19521. * @param width height to set on the multiview texture
  19522. * @param height width to set on the multiview texture
  19523. */
  19524. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19525. }
  19526. interface Scene {
  19527. /** @hidden */
  19528. _transformMatrixR: Matrix;
  19529. /** @hidden */
  19530. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19531. /** @hidden */
  19532. _createMultiviewUbo(): void;
  19533. /** @hidden */
  19534. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19535. /** @hidden */
  19536. _renderMultiviewToSingleView(camera: Camera): void;
  19537. }
  19538. }
  19539. declare module BABYLON {
  19540. /**
  19541. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19542. * This will not be used for webXR as it supports displaying texture arrays directly
  19543. */
  19544. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19545. /**
  19546. * Initializes a VRMultiviewToSingleview
  19547. * @param name name of the post process
  19548. * @param camera camera to be applied to
  19549. * @param scaleFactor scaling factor to the size of the output texture
  19550. */
  19551. constructor(name: string, camera: Camera, scaleFactor: number);
  19552. }
  19553. }
  19554. declare module BABYLON {
  19555. /**
  19556. * Interface used to define additional presentation attributes
  19557. */
  19558. export interface IVRPresentationAttributes {
  19559. /**
  19560. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19561. */
  19562. highRefreshRate: boolean;
  19563. /**
  19564. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19565. */
  19566. foveationLevel: number;
  19567. }
  19568. interface Engine {
  19569. /** @hidden */
  19570. _vrDisplay: any;
  19571. /** @hidden */
  19572. _vrSupported: boolean;
  19573. /** @hidden */
  19574. _oldSize: Size;
  19575. /** @hidden */
  19576. _oldHardwareScaleFactor: number;
  19577. /** @hidden */
  19578. _vrExclusivePointerMode: boolean;
  19579. /** @hidden */
  19580. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19581. /** @hidden */
  19582. _onVRDisplayPointerRestricted: () => void;
  19583. /** @hidden */
  19584. _onVRDisplayPointerUnrestricted: () => void;
  19585. /** @hidden */
  19586. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19587. /** @hidden */
  19588. _onVrDisplayDisconnect: Nullable<() => void>;
  19589. /** @hidden */
  19590. _onVrDisplayPresentChange: Nullable<() => void>;
  19591. /**
  19592. * Observable signaled when VR display mode changes
  19593. */
  19594. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19595. /**
  19596. * Observable signaled when VR request present is complete
  19597. */
  19598. onVRRequestPresentComplete: Observable<boolean>;
  19599. /**
  19600. * Observable signaled when VR request present starts
  19601. */
  19602. onVRRequestPresentStart: Observable<Engine>;
  19603. /**
  19604. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19605. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19606. */
  19607. isInVRExclusivePointerMode: boolean;
  19608. /**
  19609. * Gets a boolean indicating if a webVR device was detected
  19610. * @returns true if a webVR device was detected
  19611. */
  19612. isVRDevicePresent(): boolean;
  19613. /**
  19614. * Gets the current webVR device
  19615. * @returns the current webVR device (or null)
  19616. */
  19617. getVRDevice(): any;
  19618. /**
  19619. * Initializes a webVR display and starts listening to display change events
  19620. * The onVRDisplayChangedObservable will be notified upon these changes
  19621. * @returns A promise containing a VRDisplay and if vr is supported
  19622. */
  19623. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19624. /** @hidden */
  19625. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19626. /**
  19627. * Gets or sets the presentation attributes used to configure VR rendering
  19628. */
  19629. vrPresentationAttributes?: IVRPresentationAttributes;
  19630. /**
  19631. * Call this function to switch to webVR mode
  19632. * Will do nothing if webVR is not supported or if there is no webVR device
  19633. * @param options the webvr options provided to the camera. mainly used for multiview
  19634. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19635. */
  19636. enableVR(options: WebVROptions): void;
  19637. /** @hidden */
  19638. _onVRFullScreenTriggered(): void;
  19639. }
  19640. }
  19641. declare module BABYLON {
  19642. /**
  19643. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19644. * IMPORTANT!! The data is right-hand data.
  19645. * @export
  19646. * @interface DevicePose
  19647. */
  19648. export interface DevicePose {
  19649. /**
  19650. * The position of the device, values in array are [x,y,z].
  19651. */
  19652. readonly position: Nullable<Float32Array>;
  19653. /**
  19654. * The linearVelocity of the device, values in array are [x,y,z].
  19655. */
  19656. readonly linearVelocity: Nullable<Float32Array>;
  19657. /**
  19658. * The linearAcceleration of the device, values in array are [x,y,z].
  19659. */
  19660. readonly linearAcceleration: Nullable<Float32Array>;
  19661. /**
  19662. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19663. */
  19664. readonly orientation: Nullable<Float32Array>;
  19665. /**
  19666. * The angularVelocity of the device, values in array are [x,y,z].
  19667. */
  19668. readonly angularVelocity: Nullable<Float32Array>;
  19669. /**
  19670. * The angularAcceleration of the device, values in array are [x,y,z].
  19671. */
  19672. readonly angularAcceleration: Nullable<Float32Array>;
  19673. }
  19674. /**
  19675. * Interface representing a pose controlled object in Babylon.
  19676. * A pose controlled object has both regular pose values as well as pose values
  19677. * from an external device such as a VR head mounted display
  19678. */
  19679. export interface PoseControlled {
  19680. /**
  19681. * The position of the object in babylon space.
  19682. */
  19683. position: Vector3;
  19684. /**
  19685. * The rotation quaternion of the object in babylon space.
  19686. */
  19687. rotationQuaternion: Quaternion;
  19688. /**
  19689. * The position of the device in babylon space.
  19690. */
  19691. devicePosition?: Vector3;
  19692. /**
  19693. * The rotation quaternion of the device in babylon space.
  19694. */
  19695. deviceRotationQuaternion: Quaternion;
  19696. /**
  19697. * The raw pose coming from the device.
  19698. */
  19699. rawPose: Nullable<DevicePose>;
  19700. /**
  19701. * The scale of the device to be used when translating from device space to babylon space.
  19702. */
  19703. deviceScaleFactor: number;
  19704. /**
  19705. * Updates the poseControlled values based on the input device pose.
  19706. * @param poseData the pose data to update the object with
  19707. */
  19708. updateFromDevice(poseData: DevicePose): void;
  19709. }
  19710. /**
  19711. * Set of options to customize the webVRCamera
  19712. */
  19713. export interface WebVROptions {
  19714. /**
  19715. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19716. */
  19717. trackPosition?: boolean;
  19718. /**
  19719. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19720. */
  19721. positionScale?: number;
  19722. /**
  19723. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19724. */
  19725. displayName?: string;
  19726. /**
  19727. * Should the native controller meshes be initialized. (default: true)
  19728. */
  19729. controllerMeshes?: boolean;
  19730. /**
  19731. * Creating a default HemiLight only on controllers. (default: true)
  19732. */
  19733. defaultLightingOnControllers?: boolean;
  19734. /**
  19735. * If you don't want to use the default VR button of the helper. (default: false)
  19736. */
  19737. useCustomVRButton?: boolean;
  19738. /**
  19739. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19740. */
  19741. customVRButton?: HTMLButtonElement;
  19742. /**
  19743. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19744. */
  19745. rayLength?: number;
  19746. /**
  19747. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19748. */
  19749. defaultHeight?: number;
  19750. /**
  19751. * If multiview should be used if availible (default: false)
  19752. */
  19753. useMultiview?: boolean;
  19754. }
  19755. /**
  19756. * This represents a WebVR camera.
  19757. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19758. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19759. */
  19760. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19761. private webVROptions;
  19762. /**
  19763. * @hidden
  19764. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19765. */
  19766. _vrDevice: any;
  19767. /**
  19768. * The rawPose of the vrDevice.
  19769. */
  19770. rawPose: Nullable<DevicePose>;
  19771. private _onVREnabled;
  19772. private _specsVersion;
  19773. private _attached;
  19774. private _frameData;
  19775. protected _descendants: Array<Node>;
  19776. private _deviceRoomPosition;
  19777. /** @hidden */
  19778. _deviceRoomRotationQuaternion: Quaternion;
  19779. private _standingMatrix;
  19780. /**
  19781. * Represents device position in babylon space.
  19782. */
  19783. devicePosition: Vector3;
  19784. /**
  19785. * Represents device rotation in babylon space.
  19786. */
  19787. deviceRotationQuaternion: Quaternion;
  19788. /**
  19789. * The scale of the device to be used when translating from device space to babylon space.
  19790. */
  19791. deviceScaleFactor: number;
  19792. private _deviceToWorld;
  19793. private _worldToDevice;
  19794. /**
  19795. * References to the webVR controllers for the vrDevice.
  19796. */
  19797. controllers: Array<WebVRController>;
  19798. /**
  19799. * Emits an event when a controller is attached.
  19800. */
  19801. onControllersAttachedObservable: Observable<WebVRController[]>;
  19802. /**
  19803. * Emits an event when a controller's mesh has been loaded;
  19804. */
  19805. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19806. /**
  19807. * Emits an event when the HMD's pose has been updated.
  19808. */
  19809. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19810. private _poseSet;
  19811. /**
  19812. * If the rig cameras be used as parent instead of this camera.
  19813. */
  19814. rigParenting: boolean;
  19815. private _lightOnControllers;
  19816. private _defaultHeight?;
  19817. /**
  19818. * Instantiates a WebVRFreeCamera.
  19819. * @param name The name of the WebVRFreeCamera
  19820. * @param position The starting anchor position for the camera
  19821. * @param scene The scene the camera belongs to
  19822. * @param webVROptions a set of customizable options for the webVRCamera
  19823. */
  19824. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19825. /**
  19826. * Gets the device distance from the ground in meters.
  19827. * @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.
  19828. */
  19829. deviceDistanceToRoomGround(): number;
  19830. /**
  19831. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19832. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19833. */
  19834. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19835. /**
  19836. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19837. * @returns A promise with a boolean set to if the standing matrix is supported.
  19838. */
  19839. useStandingMatrixAsync(): Promise<boolean>;
  19840. /**
  19841. * Disposes the camera
  19842. */
  19843. dispose(): void;
  19844. /**
  19845. * Gets a vrController by name.
  19846. * @param name The name of the controller to retreive
  19847. * @returns the controller matching the name specified or null if not found
  19848. */
  19849. getControllerByName(name: string): Nullable<WebVRController>;
  19850. private _leftController;
  19851. /**
  19852. * The controller corresponding to the users left hand.
  19853. */
  19854. get leftController(): Nullable<WebVRController>;
  19855. private _rightController;
  19856. /**
  19857. * The controller corresponding to the users right hand.
  19858. */
  19859. get rightController(): Nullable<WebVRController>;
  19860. /**
  19861. * Casts a ray forward from the vrCamera's gaze.
  19862. * @param length Length of the ray (default: 100)
  19863. * @returns the ray corresponding to the gaze
  19864. */
  19865. getForwardRay(length?: number): Ray;
  19866. /**
  19867. * @hidden
  19868. * Updates the camera based on device's frame data
  19869. */
  19870. _checkInputs(): void;
  19871. /**
  19872. * Updates the poseControlled values based on the input device pose.
  19873. * @param poseData Pose coming from the device
  19874. */
  19875. updateFromDevice(poseData: DevicePose): void;
  19876. private _htmlElementAttached;
  19877. private _detachIfAttached;
  19878. /**
  19879. * WebVR's attach control will start broadcasting frames to the device.
  19880. * Note that in certain browsers (chrome for example) this function must be called
  19881. * within a user-interaction callback. Example:
  19882. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19883. *
  19884. * @param element html element to attach the vrDevice to
  19885. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19886. */
  19887. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19888. /**
  19889. * Detaches the camera from the html element and disables VR
  19890. *
  19891. * @param element html element to detach from
  19892. */
  19893. detachControl(element: HTMLElement): void;
  19894. /**
  19895. * @returns the name of this class
  19896. */
  19897. getClassName(): string;
  19898. /**
  19899. * Calls resetPose on the vrDisplay
  19900. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19901. */
  19902. resetToCurrentRotation(): void;
  19903. /**
  19904. * @hidden
  19905. * Updates the rig cameras (left and right eye)
  19906. */
  19907. _updateRigCameras(): void;
  19908. private _workingVector;
  19909. private _oneVector;
  19910. private _workingMatrix;
  19911. private updateCacheCalled;
  19912. private _correctPositionIfNotTrackPosition;
  19913. /**
  19914. * @hidden
  19915. * Updates the cached values of the camera
  19916. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19917. */
  19918. _updateCache(ignoreParentClass?: boolean): void;
  19919. /**
  19920. * @hidden
  19921. * Get current device position in babylon world
  19922. */
  19923. _computeDevicePosition(): void;
  19924. /**
  19925. * Updates the current device position and rotation in the babylon world
  19926. */
  19927. update(): void;
  19928. /**
  19929. * @hidden
  19930. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19931. * @returns an identity matrix
  19932. */
  19933. _getViewMatrix(): Matrix;
  19934. private _tmpMatrix;
  19935. /**
  19936. * This function is called by the two RIG cameras.
  19937. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19938. * @hidden
  19939. */
  19940. _getWebVRViewMatrix(): Matrix;
  19941. /** @hidden */
  19942. _getWebVRProjectionMatrix(): Matrix;
  19943. private _onGamepadConnectedObserver;
  19944. private _onGamepadDisconnectedObserver;
  19945. private _updateCacheWhenTrackingDisabledObserver;
  19946. /**
  19947. * Initializes the controllers and their meshes
  19948. */
  19949. initControllers(): void;
  19950. }
  19951. }
  19952. declare module BABYLON {
  19953. /**
  19954. * "Static Class" containing the most commonly used helper while dealing with material for
  19955. * rendering purpose.
  19956. *
  19957. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19958. *
  19959. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  19960. */
  19961. export class MaterialHelper {
  19962. /**
  19963. * Bind the current view position to an effect.
  19964. * @param effect The effect to be bound
  19965. * @param scene The scene the eyes position is used from
  19966. * @param variableName name of the shader variable that will hold the eye position
  19967. */
  19968. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  19969. /**
  19970. * Helps preparing the defines values about the UVs in used in the effect.
  19971. * UVs are shared as much as we can accross channels in the shaders.
  19972. * @param texture The texture we are preparing the UVs for
  19973. * @param defines The defines to update
  19974. * @param key The channel key "diffuse", "specular"... used in the shader
  19975. */
  19976. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  19977. /**
  19978. * Binds a texture matrix value to its corrsponding uniform
  19979. * @param texture The texture to bind the matrix for
  19980. * @param uniformBuffer The uniform buffer receivin the data
  19981. * @param key The channel key "diffuse", "specular"... used in the shader
  19982. */
  19983. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  19984. /**
  19985. * Gets the current status of the fog (should it be enabled?)
  19986. * @param mesh defines the mesh to evaluate for fog support
  19987. * @param scene defines the hosting scene
  19988. * @returns true if fog must be enabled
  19989. */
  19990. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  19991. /**
  19992. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  19993. * @param mesh defines the current mesh
  19994. * @param scene defines the current scene
  19995. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  19996. * @param pointsCloud defines if point cloud rendering has to be turned on
  19997. * @param fogEnabled defines if fog has to be turned on
  19998. * @param alphaTest defines if alpha testing has to be turned on
  19999. * @param defines defines the current list of defines
  20000. */
  20001. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20002. /**
  20003. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20004. * @param scene defines the current scene
  20005. * @param engine defines the current engine
  20006. * @param defines specifies the list of active defines
  20007. * @param useInstances defines if instances have to be turned on
  20008. * @param useClipPlane defines if clip plane have to be turned on
  20009. * @param useInstances defines if instances have to be turned on
  20010. * @param useThinInstances defines if thin instances have to be turned on
  20011. */
  20012. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20013. /**
  20014. * Prepares the defines for bones
  20015. * @param mesh The mesh containing the geometry data we will draw
  20016. * @param defines The defines to update
  20017. */
  20018. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20019. /**
  20020. * Prepares the defines for morph targets
  20021. * @param mesh The mesh containing the geometry data we will draw
  20022. * @param defines The defines to update
  20023. */
  20024. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20025. /**
  20026. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20027. * @param mesh The mesh containing the geometry data we will draw
  20028. * @param defines The defines to update
  20029. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20030. * @param useBones Precise whether bones should be used or not (override mesh info)
  20031. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20032. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20033. * @returns false if defines are considered not dirty and have not been checked
  20034. */
  20035. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20036. /**
  20037. * Prepares the defines related to multiview
  20038. * @param scene The scene we are intending to draw
  20039. * @param defines The defines to update
  20040. */
  20041. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20042. /**
  20043. * Prepares the defines related to the light information passed in parameter
  20044. * @param scene The scene we are intending to draw
  20045. * @param mesh The mesh the effect is compiling for
  20046. * @param light The light the effect is compiling for
  20047. * @param lightIndex The index of the light
  20048. * @param defines The defines to update
  20049. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20050. * @param state Defines the current state regarding what is needed (normals, etc...)
  20051. */
  20052. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20053. needNormals: boolean;
  20054. needRebuild: boolean;
  20055. shadowEnabled: boolean;
  20056. specularEnabled: boolean;
  20057. lightmapMode: boolean;
  20058. }): void;
  20059. /**
  20060. * Prepares the defines related to the light information passed in parameter
  20061. * @param scene The scene we are intending to draw
  20062. * @param mesh The mesh the effect is compiling for
  20063. * @param defines The defines to update
  20064. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20065. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20066. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20067. * @returns true if normals will be required for the rest of the effect
  20068. */
  20069. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20070. /**
  20071. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20072. * @param lightIndex defines the light index
  20073. * @param uniformsList The uniform list
  20074. * @param samplersList The sampler list
  20075. * @param projectedLightTexture defines if projected texture must be used
  20076. * @param uniformBuffersList defines an optional list of uniform buffers
  20077. */
  20078. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20079. /**
  20080. * Prepares the uniforms and samplers list to be used in the effect
  20081. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20082. * @param samplersList The sampler list
  20083. * @param defines The defines helping in the list generation
  20084. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20085. */
  20086. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20087. /**
  20088. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20089. * @param defines The defines to update while falling back
  20090. * @param fallbacks The authorized effect fallbacks
  20091. * @param maxSimultaneousLights The maximum number of lights allowed
  20092. * @param rank the current rank of the Effect
  20093. * @returns The newly affected rank
  20094. */
  20095. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20096. private static _TmpMorphInfluencers;
  20097. /**
  20098. * Prepares the list of attributes required for morph targets according to the effect defines.
  20099. * @param attribs The current list of supported attribs
  20100. * @param mesh The mesh to prepare the morph targets attributes for
  20101. * @param influencers The number of influencers
  20102. */
  20103. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20104. /**
  20105. * Prepares the list of attributes required for morph targets according to the effect defines.
  20106. * @param attribs The current list of supported attribs
  20107. * @param mesh The mesh to prepare the morph targets attributes for
  20108. * @param defines The current Defines of the effect
  20109. */
  20110. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20111. /**
  20112. * Prepares the list of attributes required for bones according to the effect defines.
  20113. * @param attribs The current list of supported attribs
  20114. * @param mesh The mesh to prepare the bones attributes for
  20115. * @param defines The current Defines of the effect
  20116. * @param fallbacks The current efffect fallback strategy
  20117. */
  20118. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20119. /**
  20120. * Check and prepare the list of attributes required for instances according to the effect defines.
  20121. * @param attribs The current list of supported attribs
  20122. * @param defines The current MaterialDefines of the effect
  20123. */
  20124. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20125. /**
  20126. * Add the list of attributes required for instances to the attribs array.
  20127. * @param attribs The current list of supported attribs
  20128. */
  20129. static PushAttributesForInstances(attribs: string[]): void;
  20130. /**
  20131. * Binds the light information to the effect.
  20132. * @param light The light containing the generator
  20133. * @param effect The effect we are binding the data to
  20134. * @param lightIndex The light index in the effect used to render
  20135. */
  20136. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20137. /**
  20138. * Binds the lights information from the scene to the effect for the given mesh.
  20139. * @param light Light to bind
  20140. * @param lightIndex Light index
  20141. * @param scene The scene where the light belongs to
  20142. * @param effect The effect we are binding the data to
  20143. * @param useSpecular Defines if specular is supported
  20144. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20145. */
  20146. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20147. /**
  20148. * Binds the lights information from the scene to the effect for the given mesh.
  20149. * @param scene The scene the lights belongs to
  20150. * @param mesh The mesh we are binding the information to render
  20151. * @param effect The effect we are binding the data to
  20152. * @param defines The generated defines for the effect
  20153. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20154. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20155. */
  20156. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20157. private static _tempFogColor;
  20158. /**
  20159. * Binds the fog information from the scene to the effect for the given mesh.
  20160. * @param scene The scene the lights belongs to
  20161. * @param mesh The mesh we are binding the information to render
  20162. * @param effect The effect we are binding the data to
  20163. * @param linearSpace Defines if the fog effect is applied in linear space
  20164. */
  20165. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20166. /**
  20167. * Binds the bones information from the mesh to the effect.
  20168. * @param mesh The mesh we are binding the information to render
  20169. * @param effect The effect we are binding the data to
  20170. */
  20171. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20172. /**
  20173. * Binds the morph targets information from the mesh to the effect.
  20174. * @param abstractMesh The mesh we are binding the information to render
  20175. * @param effect The effect we are binding the data to
  20176. */
  20177. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20178. /**
  20179. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20180. * @param defines The generated defines used in the effect
  20181. * @param effect The effect we are binding the data to
  20182. * @param scene The scene we are willing to render with logarithmic scale for
  20183. */
  20184. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20185. /**
  20186. * Binds the clip plane information from the scene to the effect.
  20187. * @param scene The scene the clip plane information are extracted from
  20188. * @param effect The effect we are binding the data to
  20189. */
  20190. static BindClipPlane(effect: Effect, scene: Scene): void;
  20191. }
  20192. }
  20193. declare module BABYLON {
  20194. /**
  20195. * Block used to expose an input value
  20196. */
  20197. export class InputBlock extends NodeMaterialBlock {
  20198. private _mode;
  20199. private _associatedVariableName;
  20200. private _storedValue;
  20201. private _valueCallback;
  20202. private _type;
  20203. private _animationType;
  20204. /** Gets or set a value used to limit the range of float values */
  20205. min: number;
  20206. /** Gets or set a value used to limit the range of float values */
  20207. max: number;
  20208. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20209. isBoolean: boolean;
  20210. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20211. matrixMode: number;
  20212. /** @hidden */
  20213. _systemValue: Nullable<NodeMaterialSystemValues>;
  20214. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20215. visibleInInspector: boolean;
  20216. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20217. isConstant: boolean;
  20218. /** Gets or sets the group to use to display this block in the Inspector */
  20219. groupInInspector: string;
  20220. /** Gets an observable raised when the value is changed */
  20221. onValueChangedObservable: Observable<InputBlock>;
  20222. /**
  20223. * Gets or sets the connection point type (default is float)
  20224. */
  20225. get type(): NodeMaterialBlockConnectionPointTypes;
  20226. /**
  20227. * Creates a new InputBlock
  20228. * @param name defines the block name
  20229. * @param target defines the target of that block (Vertex by default)
  20230. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20231. */
  20232. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20233. /**
  20234. * Gets the output component
  20235. */
  20236. get output(): NodeMaterialConnectionPoint;
  20237. /**
  20238. * Set the source of this connection point to a vertex attribute
  20239. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20240. * @returns the current connection point
  20241. */
  20242. setAsAttribute(attributeName?: string): InputBlock;
  20243. /**
  20244. * Set the source of this connection point to a system value
  20245. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20246. * @returns the current connection point
  20247. */
  20248. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20249. /**
  20250. * Gets or sets the value of that point.
  20251. * Please note that this value will be ignored if valueCallback is defined
  20252. */
  20253. get value(): any;
  20254. set value(value: any);
  20255. /**
  20256. * Gets or sets a callback used to get the value of that point.
  20257. * Please note that setting this value will force the connection point to ignore the value property
  20258. */
  20259. get valueCallback(): () => any;
  20260. set valueCallback(value: () => any);
  20261. /**
  20262. * Gets or sets the associated variable name in the shader
  20263. */
  20264. get associatedVariableName(): string;
  20265. set associatedVariableName(value: string);
  20266. /** Gets or sets the type of animation applied to the input */
  20267. get animationType(): AnimatedInputBlockTypes;
  20268. set animationType(value: AnimatedInputBlockTypes);
  20269. /**
  20270. * Gets a boolean indicating that this connection point not defined yet
  20271. */
  20272. get isUndefined(): boolean;
  20273. /**
  20274. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20275. * In this case the connection point name must be the name of the uniform to use.
  20276. * Can only be set on inputs
  20277. */
  20278. get isUniform(): boolean;
  20279. set isUniform(value: boolean);
  20280. /**
  20281. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20282. * In this case the connection point name must be the name of the attribute to use
  20283. * Can only be set on inputs
  20284. */
  20285. get isAttribute(): boolean;
  20286. set isAttribute(value: boolean);
  20287. /**
  20288. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20289. * Can only be set on exit points
  20290. */
  20291. get isVarying(): boolean;
  20292. set isVarying(value: boolean);
  20293. /**
  20294. * Gets a boolean indicating that the current connection point is a system value
  20295. */
  20296. get isSystemValue(): boolean;
  20297. /**
  20298. * Gets or sets the current well known value or null if not defined as a system value
  20299. */
  20300. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20301. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20302. /**
  20303. * Gets the current class name
  20304. * @returns the class name
  20305. */
  20306. getClassName(): string;
  20307. /**
  20308. * Animate the input if animationType !== None
  20309. * @param scene defines the rendering scene
  20310. */
  20311. animate(scene: Scene): void;
  20312. private _emitDefine;
  20313. initialize(state: NodeMaterialBuildState): void;
  20314. /**
  20315. * Set the input block to its default value (based on its type)
  20316. */
  20317. setDefaultValue(): void;
  20318. private _emitConstant;
  20319. /** @hidden */
  20320. get _noContextSwitch(): boolean;
  20321. private _emit;
  20322. /** @hidden */
  20323. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20324. /** @hidden */
  20325. _transmit(effect: Effect, scene: Scene): void;
  20326. protected _buildBlock(state: NodeMaterialBuildState): void;
  20327. protected _dumpPropertiesCode(): string;
  20328. dispose(): void;
  20329. serialize(): any;
  20330. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20331. }
  20332. }
  20333. declare module BABYLON {
  20334. /**
  20335. * Enum used to define the compatibility state between two connection points
  20336. */
  20337. export enum NodeMaterialConnectionPointCompatibilityStates {
  20338. /** Points are compatibles */
  20339. Compatible = 0,
  20340. /** Points are incompatible because of their types */
  20341. TypeIncompatible = 1,
  20342. /** Points are incompatible because of their targets (vertex vs fragment) */
  20343. TargetIncompatible = 2
  20344. }
  20345. /**
  20346. * Defines the direction of a connection point
  20347. */
  20348. export enum NodeMaterialConnectionPointDirection {
  20349. /** Input */
  20350. Input = 0,
  20351. /** Output */
  20352. Output = 1
  20353. }
  20354. /**
  20355. * Defines a connection point for a block
  20356. */
  20357. export class NodeMaterialConnectionPoint {
  20358. /** @hidden */
  20359. _ownerBlock: NodeMaterialBlock;
  20360. /** @hidden */
  20361. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20362. private _endpoints;
  20363. private _associatedVariableName;
  20364. private _direction;
  20365. /** @hidden */
  20366. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20367. /** @hidden */
  20368. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20369. private _type;
  20370. /** @hidden */
  20371. _enforceAssociatedVariableName: boolean;
  20372. /** Gets the direction of the point */
  20373. get direction(): NodeMaterialConnectionPointDirection;
  20374. /** Indicates that this connection point needs dual validation before being connected to another point */
  20375. needDualDirectionValidation: boolean;
  20376. /**
  20377. * Gets or sets the additional types supported by this connection point
  20378. */
  20379. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20380. /**
  20381. * Gets or sets the additional types excluded by this connection point
  20382. */
  20383. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20384. /**
  20385. * Observable triggered when this point is connected
  20386. */
  20387. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20388. /**
  20389. * Gets or sets the associated variable name in the shader
  20390. */
  20391. get associatedVariableName(): string;
  20392. set associatedVariableName(value: string);
  20393. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20394. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20395. /**
  20396. * Gets or sets the connection point type (default is float)
  20397. */
  20398. get type(): NodeMaterialBlockConnectionPointTypes;
  20399. set type(value: NodeMaterialBlockConnectionPointTypes);
  20400. /**
  20401. * Gets or sets the connection point name
  20402. */
  20403. name: string;
  20404. /**
  20405. * Gets or sets the connection point name
  20406. */
  20407. displayName: string;
  20408. /**
  20409. * Gets or sets a boolean indicating that this connection point can be omitted
  20410. */
  20411. isOptional: boolean;
  20412. /**
  20413. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20414. */
  20415. define: string;
  20416. /** @hidden */
  20417. _prioritizeVertex: boolean;
  20418. private _target;
  20419. /** Gets or sets the target of that connection point */
  20420. get target(): NodeMaterialBlockTargets;
  20421. set target(value: NodeMaterialBlockTargets);
  20422. /**
  20423. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20424. */
  20425. get isConnected(): boolean;
  20426. /**
  20427. * Gets a boolean indicating that the current point is connected to an input block
  20428. */
  20429. get isConnectedToInputBlock(): boolean;
  20430. /**
  20431. * Gets a the connected input block (if any)
  20432. */
  20433. get connectInputBlock(): Nullable<InputBlock>;
  20434. /** Get the other side of the connection (if any) */
  20435. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20436. /** Get the block that owns this connection point */
  20437. get ownerBlock(): NodeMaterialBlock;
  20438. /** Get the block connected on the other side of this connection (if any) */
  20439. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20440. /** Get the block connected on the endpoints of this connection (if any) */
  20441. get connectedBlocks(): Array<NodeMaterialBlock>;
  20442. /** Gets the list of connected endpoints */
  20443. get endpoints(): NodeMaterialConnectionPoint[];
  20444. /** Gets a boolean indicating if that output point is connected to at least one input */
  20445. get hasEndpoints(): boolean;
  20446. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20447. get isConnectedInVertexShader(): boolean;
  20448. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20449. get isConnectedInFragmentShader(): boolean;
  20450. /**
  20451. * Creates a block suitable to be used as an input for this input point.
  20452. * If null is returned, a block based on the point type will be created.
  20453. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  20454. */
  20455. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20456. /**
  20457. * Creates a new connection point
  20458. * @param name defines the connection point name
  20459. * @param ownerBlock defines the block hosting this connection point
  20460. * @param direction defines the direction of the connection point
  20461. */
  20462. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20463. /**
  20464. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20465. * @returns the class name
  20466. */
  20467. getClassName(): string;
  20468. /**
  20469. * Gets a boolean indicating if the current point can be connected to another point
  20470. * @param connectionPoint defines the other connection point
  20471. * @returns a boolean
  20472. */
  20473. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20474. /**
  20475. * Gets a number indicating if the current point can be connected to another point
  20476. * @param connectionPoint defines the other connection point
  20477. * @returns a number defining the compatibility state
  20478. */
  20479. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20480. /**
  20481. * Connect this point to another connection point
  20482. * @param connectionPoint defines the other connection point
  20483. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20484. * @returns the current connection point
  20485. */
  20486. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20487. /**
  20488. * Disconnect this point from one of his endpoint
  20489. * @param endpoint defines the other connection point
  20490. * @returns the current connection point
  20491. */
  20492. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20493. /**
  20494. * Serializes this point in a JSON representation
  20495. * @param isInput defines if the connection point is an input (default is true)
  20496. * @returns the serialized point object
  20497. */
  20498. serialize(isInput?: boolean): any;
  20499. /**
  20500. * Release resources
  20501. */
  20502. dispose(): void;
  20503. }
  20504. }
  20505. declare module BABYLON {
  20506. /**
  20507. * Enum used to define the material modes
  20508. */
  20509. export enum NodeMaterialModes {
  20510. /** Regular material */
  20511. Material = 0,
  20512. /** For post process */
  20513. PostProcess = 1,
  20514. /** For particle system */
  20515. Particle = 2
  20516. }
  20517. }
  20518. declare module BABYLON {
  20519. /**
  20520. * Block used to read a texture from a sampler
  20521. */
  20522. export class TextureBlock extends NodeMaterialBlock {
  20523. private _defineName;
  20524. private _linearDefineName;
  20525. private _gammaDefineName;
  20526. private _tempTextureRead;
  20527. private _samplerName;
  20528. private _transformedUVName;
  20529. private _textureTransformName;
  20530. private _textureInfoName;
  20531. private _mainUVName;
  20532. private _mainUVDefineName;
  20533. private _fragmentOnly;
  20534. /**
  20535. * Gets or sets the texture associated with the node
  20536. */
  20537. texture: Nullable<Texture>;
  20538. /**
  20539. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20540. */
  20541. convertToGammaSpace: boolean;
  20542. /**
  20543. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20544. */
  20545. convertToLinearSpace: boolean;
  20546. /**
  20547. * Create a new TextureBlock
  20548. * @param name defines the block name
  20549. */
  20550. constructor(name: string, fragmentOnly?: boolean);
  20551. /**
  20552. * Gets the current class name
  20553. * @returns the class name
  20554. */
  20555. getClassName(): string;
  20556. /**
  20557. * Gets the uv input component
  20558. */
  20559. get uv(): NodeMaterialConnectionPoint;
  20560. /**
  20561. * Gets the rgba output component
  20562. */
  20563. get rgba(): NodeMaterialConnectionPoint;
  20564. /**
  20565. * Gets the rgb output component
  20566. */
  20567. get rgb(): NodeMaterialConnectionPoint;
  20568. /**
  20569. * Gets the r output component
  20570. */
  20571. get r(): NodeMaterialConnectionPoint;
  20572. /**
  20573. * Gets the g output component
  20574. */
  20575. get g(): NodeMaterialConnectionPoint;
  20576. /**
  20577. * Gets the b output component
  20578. */
  20579. get b(): NodeMaterialConnectionPoint;
  20580. /**
  20581. * Gets the a output component
  20582. */
  20583. get a(): NodeMaterialConnectionPoint;
  20584. get target(): NodeMaterialBlockTargets;
  20585. autoConfigure(material: NodeMaterial): void;
  20586. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20587. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20588. isReady(): boolean;
  20589. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20590. private get _isMixed();
  20591. private _injectVertexCode;
  20592. private _writeTextureRead;
  20593. private _writeOutput;
  20594. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20595. protected _dumpPropertiesCode(): string;
  20596. serialize(): any;
  20597. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20598. }
  20599. }
  20600. declare module BABYLON {
  20601. /** @hidden */
  20602. export var reflectionFunction: {
  20603. name: string;
  20604. shader: string;
  20605. };
  20606. }
  20607. declare module BABYLON {
  20608. /**
  20609. * Base block used to read a reflection texture from a sampler
  20610. */
  20611. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20612. /** @hidden */
  20613. _define3DName: string;
  20614. /** @hidden */
  20615. _defineCubicName: string;
  20616. /** @hidden */
  20617. _defineExplicitName: string;
  20618. /** @hidden */
  20619. _defineProjectionName: string;
  20620. /** @hidden */
  20621. _defineLocalCubicName: string;
  20622. /** @hidden */
  20623. _defineSphericalName: string;
  20624. /** @hidden */
  20625. _definePlanarName: string;
  20626. /** @hidden */
  20627. _defineEquirectangularName: string;
  20628. /** @hidden */
  20629. _defineMirroredEquirectangularFixedName: string;
  20630. /** @hidden */
  20631. _defineEquirectangularFixedName: string;
  20632. /** @hidden */
  20633. _defineSkyboxName: string;
  20634. /** @hidden */
  20635. _defineOppositeZ: string;
  20636. /** @hidden */
  20637. _cubeSamplerName: string;
  20638. /** @hidden */
  20639. _2DSamplerName: string;
  20640. protected _positionUVWName: string;
  20641. protected _directionWName: string;
  20642. protected _reflectionVectorName: string;
  20643. /** @hidden */
  20644. _reflectionCoordsName: string;
  20645. /** @hidden */
  20646. _reflectionMatrixName: string;
  20647. protected _reflectionColorName: string;
  20648. /**
  20649. * Gets or sets the texture associated with the node
  20650. */
  20651. texture: Nullable<BaseTexture>;
  20652. /**
  20653. * Create a new ReflectionTextureBaseBlock
  20654. * @param name defines the block name
  20655. */
  20656. constructor(name: string);
  20657. /**
  20658. * Gets the current class name
  20659. * @returns the class name
  20660. */
  20661. getClassName(): string;
  20662. /**
  20663. * Gets the world position input component
  20664. */
  20665. abstract get position(): NodeMaterialConnectionPoint;
  20666. /**
  20667. * Gets the world position input component
  20668. */
  20669. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20670. /**
  20671. * Gets the world normal input component
  20672. */
  20673. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20674. /**
  20675. * Gets the world input component
  20676. */
  20677. abstract get world(): NodeMaterialConnectionPoint;
  20678. /**
  20679. * Gets the camera (or eye) position component
  20680. */
  20681. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20682. /**
  20683. * Gets the view input component
  20684. */
  20685. abstract get view(): NodeMaterialConnectionPoint;
  20686. protected _getTexture(): Nullable<BaseTexture>;
  20687. autoConfigure(material: NodeMaterial): void;
  20688. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20689. isReady(): boolean;
  20690. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20691. /**
  20692. * Gets the code to inject in the vertex shader
  20693. * @param state current state of the node material building
  20694. * @returns the shader code
  20695. */
  20696. handleVertexSide(state: NodeMaterialBuildState): string;
  20697. /**
  20698. * Handles the inits for the fragment code path
  20699. * @param state node material build state
  20700. */
  20701. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20702. /**
  20703. * Generates the reflection coords code for the fragment code path
  20704. * @param worldNormalVarName name of the world normal variable
  20705. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20706. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20707. * @returns the shader code
  20708. */
  20709. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20710. /**
  20711. * Generates the reflection color code for the fragment code path
  20712. * @param lodVarName name of the lod variable
  20713. * @param swizzleLookupTexture swizzle to use for the final color variable
  20714. * @returns the shader code
  20715. */
  20716. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20717. /**
  20718. * Generates the code corresponding to the connected output points
  20719. * @param state node material build state
  20720. * @param varName name of the variable to output
  20721. * @returns the shader code
  20722. */
  20723. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20724. protected _buildBlock(state: NodeMaterialBuildState): this;
  20725. protected _dumpPropertiesCode(): string;
  20726. serialize(): any;
  20727. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20728. }
  20729. }
  20730. declare module BABYLON {
  20731. /**
  20732. * Defines a connection point to be used for points with a custom object type
  20733. */
  20734. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20735. private _blockType;
  20736. private _blockName;
  20737. private _nameForCheking?;
  20738. /**
  20739. * Creates a new connection point
  20740. * @param name defines the connection point name
  20741. * @param ownerBlock defines the block hosting this connection point
  20742. * @param direction defines the direction of the connection point
  20743. */
  20744. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20745. /**
  20746. * Gets a number indicating if the current point can be connected to another point
  20747. * @param connectionPoint defines the other connection point
  20748. * @returns a number defining the compatibility state
  20749. */
  20750. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20751. /**
  20752. * Creates a block suitable to be used as an input for this input point.
  20753. * If null is returned, a block based on the point type will be created.
  20754. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  20755. */
  20756. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20757. }
  20758. }
  20759. declare module BABYLON {
  20760. /**
  20761. * Enum defining the type of properties that can be edited in the property pages in the NME
  20762. */
  20763. export enum PropertyTypeForEdition {
  20764. /** property is a boolean */
  20765. Boolean = 0,
  20766. /** property is a float */
  20767. Float = 1,
  20768. /** property is a Vector2 */
  20769. Vector2 = 2,
  20770. /** property is a list of values */
  20771. List = 3
  20772. }
  20773. /**
  20774. * Interface that defines an option in a variable of type list
  20775. */
  20776. export interface IEditablePropertyListOption {
  20777. /** label of the option */
  20778. "label": string;
  20779. /** value of the option */
  20780. "value": number;
  20781. }
  20782. /**
  20783. * Interface that defines the options available for an editable property
  20784. */
  20785. export interface IEditablePropertyOption {
  20786. /** min value */
  20787. "min"?: number;
  20788. /** max value */
  20789. "max"?: number;
  20790. /** notifiers: indicates which actions to take when the property is changed */
  20791. "notifiers"?: {
  20792. /** the material should be rebuilt */
  20793. "rebuild"?: boolean;
  20794. /** the preview should be updated */
  20795. "update"?: boolean;
  20796. };
  20797. /** list of the options for a variable of type list */
  20798. "options"?: IEditablePropertyListOption[];
  20799. }
  20800. /**
  20801. * Interface that describes an editable property
  20802. */
  20803. export interface IPropertyDescriptionForEdition {
  20804. /** name of the property */
  20805. "propertyName": string;
  20806. /** display name of the property */
  20807. "displayName": string;
  20808. /** type of the property */
  20809. "type": PropertyTypeForEdition;
  20810. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20811. "groupName": string;
  20812. /** options for the property */
  20813. "options": IEditablePropertyOption;
  20814. }
  20815. /**
  20816. * Decorator that flags a property in a node material block as being editable
  20817. */
  20818. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20819. }
  20820. declare module BABYLON {
  20821. /**
  20822. * Block used to implement the refraction part of the sub surface module of the PBR material
  20823. */
  20824. export class RefractionBlock extends NodeMaterialBlock {
  20825. /** @hidden */
  20826. _define3DName: string;
  20827. /** @hidden */
  20828. _refractionMatrixName: string;
  20829. /** @hidden */
  20830. _defineLODRefractionAlpha: string;
  20831. /** @hidden */
  20832. _defineLinearSpecularRefraction: string;
  20833. /** @hidden */
  20834. _defineOppositeZ: string;
  20835. /** @hidden */
  20836. _cubeSamplerName: string;
  20837. /** @hidden */
  20838. _2DSamplerName: string;
  20839. /** @hidden */
  20840. _vRefractionMicrosurfaceInfosName: string;
  20841. /** @hidden */
  20842. _vRefractionInfosName: string;
  20843. private _scene;
  20844. /**
  20845. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20846. * Materials half opaque for instance using refraction could benefit from this control.
  20847. */
  20848. linkRefractionWithTransparency: boolean;
  20849. /**
  20850. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20851. */
  20852. invertRefractionY: boolean;
  20853. /**
  20854. * Gets or sets the texture associated with the node
  20855. */
  20856. texture: Nullable<BaseTexture>;
  20857. /**
  20858. * Create a new RefractionBlock
  20859. * @param name defines the block name
  20860. */
  20861. constructor(name: string);
  20862. /**
  20863. * Gets the current class name
  20864. * @returns the class name
  20865. */
  20866. getClassName(): string;
  20867. /**
  20868. * Gets the intensity input component
  20869. */
  20870. get intensity(): NodeMaterialConnectionPoint;
  20871. /**
  20872. * Gets the index of refraction input component
  20873. */
  20874. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20875. /**
  20876. * Gets the tint at distance input component
  20877. */
  20878. get tintAtDistance(): NodeMaterialConnectionPoint;
  20879. /**
  20880. * Gets the view input component
  20881. */
  20882. get view(): NodeMaterialConnectionPoint;
  20883. /**
  20884. * Gets the refraction object output component
  20885. */
  20886. get refraction(): NodeMaterialConnectionPoint;
  20887. /**
  20888. * Returns true if the block has a texture
  20889. */
  20890. get hasTexture(): boolean;
  20891. protected _getTexture(): Nullable<BaseTexture>;
  20892. autoConfigure(material: NodeMaterial): void;
  20893. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20894. isReady(): boolean;
  20895. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20896. /**
  20897. * Gets the main code of the block (fragment side)
  20898. * @param state current state of the node material building
  20899. * @returns the shader code
  20900. */
  20901. getCode(state: NodeMaterialBuildState): string;
  20902. protected _buildBlock(state: NodeMaterialBuildState): this;
  20903. protected _dumpPropertiesCode(): string;
  20904. serialize(): any;
  20905. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20906. }
  20907. }
  20908. declare module BABYLON {
  20909. /**
  20910. * Base block used as input for post process
  20911. */
  20912. export class CurrentScreenBlock extends NodeMaterialBlock {
  20913. private _samplerName;
  20914. private _linearDefineName;
  20915. private _gammaDefineName;
  20916. private _mainUVName;
  20917. private _tempTextureRead;
  20918. /**
  20919. * Gets or sets the texture associated with the node
  20920. */
  20921. texture: Nullable<BaseTexture>;
  20922. /**
  20923. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20924. */
  20925. convertToGammaSpace: boolean;
  20926. /**
  20927. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20928. */
  20929. convertToLinearSpace: boolean;
  20930. /**
  20931. * Create a new CurrentScreenBlock
  20932. * @param name defines the block name
  20933. */
  20934. constructor(name: string);
  20935. /**
  20936. * Gets the current class name
  20937. * @returns the class name
  20938. */
  20939. getClassName(): string;
  20940. /**
  20941. * Gets the uv input component
  20942. */
  20943. get uv(): NodeMaterialConnectionPoint;
  20944. /**
  20945. * Gets the rgba output component
  20946. */
  20947. get rgba(): NodeMaterialConnectionPoint;
  20948. /**
  20949. * Gets the rgb output component
  20950. */
  20951. get rgb(): NodeMaterialConnectionPoint;
  20952. /**
  20953. * Gets the r output component
  20954. */
  20955. get r(): NodeMaterialConnectionPoint;
  20956. /**
  20957. * Gets the g output component
  20958. */
  20959. get g(): NodeMaterialConnectionPoint;
  20960. /**
  20961. * Gets the b output component
  20962. */
  20963. get b(): NodeMaterialConnectionPoint;
  20964. /**
  20965. * Gets the a output component
  20966. */
  20967. get a(): NodeMaterialConnectionPoint;
  20968. /**
  20969. * Initialize the block and prepare the context for build
  20970. * @param state defines the state that will be used for the build
  20971. */
  20972. initialize(state: NodeMaterialBuildState): void;
  20973. get target(): NodeMaterialBlockTargets;
  20974. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20975. isReady(): boolean;
  20976. private _injectVertexCode;
  20977. private _writeTextureRead;
  20978. private _writeOutput;
  20979. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20980. serialize(): any;
  20981. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20982. }
  20983. }
  20984. declare module BABYLON {
  20985. /**
  20986. * Base block used for the particle texture
  20987. */
  20988. export class ParticleTextureBlock extends NodeMaterialBlock {
  20989. private _samplerName;
  20990. private _linearDefineName;
  20991. private _gammaDefineName;
  20992. private _tempTextureRead;
  20993. /**
  20994. * Gets or sets the texture associated with the node
  20995. */
  20996. texture: Nullable<BaseTexture>;
  20997. /**
  20998. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20999. */
  21000. convertToGammaSpace: boolean;
  21001. /**
  21002. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21003. */
  21004. convertToLinearSpace: boolean;
  21005. /**
  21006. * Create a new ParticleTextureBlock
  21007. * @param name defines the block name
  21008. */
  21009. constructor(name: string);
  21010. /**
  21011. * Gets the current class name
  21012. * @returns the class name
  21013. */
  21014. getClassName(): string;
  21015. /**
  21016. * Gets the uv input component
  21017. */
  21018. get uv(): NodeMaterialConnectionPoint;
  21019. /**
  21020. * Gets the rgba output component
  21021. */
  21022. get rgba(): NodeMaterialConnectionPoint;
  21023. /**
  21024. * Gets the rgb output component
  21025. */
  21026. get rgb(): NodeMaterialConnectionPoint;
  21027. /**
  21028. * Gets the r output component
  21029. */
  21030. get r(): NodeMaterialConnectionPoint;
  21031. /**
  21032. * Gets the g output component
  21033. */
  21034. get g(): NodeMaterialConnectionPoint;
  21035. /**
  21036. * Gets the b output component
  21037. */
  21038. get b(): NodeMaterialConnectionPoint;
  21039. /**
  21040. * Gets the a output component
  21041. */
  21042. get a(): NodeMaterialConnectionPoint;
  21043. /**
  21044. * Initialize the block and prepare the context for build
  21045. * @param state defines the state that will be used for the build
  21046. */
  21047. initialize(state: NodeMaterialBuildState): void;
  21048. autoConfigure(material: NodeMaterial): void;
  21049. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21050. isReady(): boolean;
  21051. private _writeOutput;
  21052. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21053. serialize(): any;
  21054. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21055. }
  21056. }
  21057. declare module BABYLON {
  21058. /**
  21059. * Class used to store shared data between 2 NodeMaterialBuildState
  21060. */
  21061. export class NodeMaterialBuildStateSharedData {
  21062. /**
  21063. * Gets the list of emitted varyings
  21064. */
  21065. temps: string[];
  21066. /**
  21067. * Gets the list of emitted varyings
  21068. */
  21069. varyings: string[];
  21070. /**
  21071. * Gets the varying declaration string
  21072. */
  21073. varyingDeclaration: string;
  21074. /**
  21075. * Input blocks
  21076. */
  21077. inputBlocks: InputBlock[];
  21078. /**
  21079. * Input blocks
  21080. */
  21081. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21082. /**
  21083. * Bindable blocks (Blocks that need to set data to the effect)
  21084. */
  21085. bindableBlocks: NodeMaterialBlock[];
  21086. /**
  21087. * List of blocks that can provide a compilation fallback
  21088. */
  21089. blocksWithFallbacks: NodeMaterialBlock[];
  21090. /**
  21091. * List of blocks that can provide a define update
  21092. */
  21093. blocksWithDefines: NodeMaterialBlock[];
  21094. /**
  21095. * List of blocks that can provide a repeatable content
  21096. */
  21097. repeatableContentBlocks: NodeMaterialBlock[];
  21098. /**
  21099. * List of blocks that can provide a dynamic list of uniforms
  21100. */
  21101. dynamicUniformBlocks: NodeMaterialBlock[];
  21102. /**
  21103. * List of blocks that can block the isReady function for the material
  21104. */
  21105. blockingBlocks: NodeMaterialBlock[];
  21106. /**
  21107. * Gets the list of animated inputs
  21108. */
  21109. animatedInputs: InputBlock[];
  21110. /**
  21111. * Build Id used to avoid multiple recompilations
  21112. */
  21113. buildId: number;
  21114. /** List of emitted variables */
  21115. variableNames: {
  21116. [key: string]: number;
  21117. };
  21118. /** List of emitted defines */
  21119. defineNames: {
  21120. [key: string]: number;
  21121. };
  21122. /** Should emit comments? */
  21123. emitComments: boolean;
  21124. /** Emit build activity */
  21125. verbose: boolean;
  21126. /** Gets or sets the hosting scene */
  21127. scene: Scene;
  21128. /**
  21129. * Gets the compilation hints emitted at compilation time
  21130. */
  21131. hints: {
  21132. needWorldViewMatrix: boolean;
  21133. needWorldViewProjectionMatrix: boolean;
  21134. needAlphaBlending: boolean;
  21135. needAlphaTesting: boolean;
  21136. };
  21137. /**
  21138. * List of compilation checks
  21139. */
  21140. checks: {
  21141. emitVertex: boolean;
  21142. emitFragment: boolean;
  21143. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21144. };
  21145. /**
  21146. * Is vertex program allowed to be empty?
  21147. */
  21148. allowEmptyVertexProgram: boolean;
  21149. /** Creates a new shared data */
  21150. constructor();
  21151. /**
  21152. * Emits console errors and exceptions if there is a failing check
  21153. */
  21154. emitErrors(): void;
  21155. }
  21156. }
  21157. declare module BABYLON {
  21158. /**
  21159. * Class used to store node based material build state
  21160. */
  21161. export class NodeMaterialBuildState {
  21162. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21163. supportUniformBuffers: boolean;
  21164. /**
  21165. * Gets the list of emitted attributes
  21166. */
  21167. attributes: string[];
  21168. /**
  21169. * Gets the list of emitted uniforms
  21170. */
  21171. uniforms: string[];
  21172. /**
  21173. * Gets the list of emitted constants
  21174. */
  21175. constants: string[];
  21176. /**
  21177. * Gets the list of emitted samplers
  21178. */
  21179. samplers: string[];
  21180. /**
  21181. * Gets the list of emitted functions
  21182. */
  21183. functions: {
  21184. [key: string]: string;
  21185. };
  21186. /**
  21187. * Gets the list of emitted extensions
  21188. */
  21189. extensions: {
  21190. [key: string]: string;
  21191. };
  21192. /**
  21193. * Gets the target of the compilation state
  21194. */
  21195. target: NodeMaterialBlockTargets;
  21196. /**
  21197. * Gets the list of emitted counters
  21198. */
  21199. counters: {
  21200. [key: string]: number;
  21201. };
  21202. /**
  21203. * Shared data between multiple NodeMaterialBuildState instances
  21204. */
  21205. sharedData: NodeMaterialBuildStateSharedData;
  21206. /** @hidden */
  21207. _vertexState: NodeMaterialBuildState;
  21208. /** @hidden */
  21209. _attributeDeclaration: string;
  21210. /** @hidden */
  21211. _uniformDeclaration: string;
  21212. /** @hidden */
  21213. _constantDeclaration: string;
  21214. /** @hidden */
  21215. _samplerDeclaration: string;
  21216. /** @hidden */
  21217. _varyingTransfer: string;
  21218. /** @hidden */
  21219. _injectAtEnd: string;
  21220. private _repeatableContentAnchorIndex;
  21221. /** @hidden */
  21222. _builtCompilationString: string;
  21223. /**
  21224. * Gets the emitted compilation strings
  21225. */
  21226. compilationString: string;
  21227. /**
  21228. * Finalize the compilation strings
  21229. * @param state defines the current compilation state
  21230. */
  21231. finalize(state: NodeMaterialBuildState): void;
  21232. /** @hidden */
  21233. get _repeatableContentAnchor(): string;
  21234. /** @hidden */
  21235. _getFreeVariableName(prefix: string): string;
  21236. /** @hidden */
  21237. _getFreeDefineName(prefix: string): string;
  21238. /** @hidden */
  21239. _excludeVariableName(name: string): void;
  21240. /** @hidden */
  21241. _emit2DSampler(name: string): void;
  21242. /** @hidden */
  21243. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21244. /** @hidden */
  21245. _emitExtension(name: string, extension: string, define?: string): void;
  21246. /** @hidden */
  21247. _emitFunction(name: string, code: string, comments: string): void;
  21248. /** @hidden */
  21249. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21250. replaceStrings?: {
  21251. search: RegExp;
  21252. replace: string;
  21253. }[];
  21254. repeatKey?: string;
  21255. }): string;
  21256. /** @hidden */
  21257. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21258. repeatKey?: string;
  21259. removeAttributes?: boolean;
  21260. removeUniforms?: boolean;
  21261. removeVaryings?: boolean;
  21262. removeIfDef?: boolean;
  21263. replaceStrings?: {
  21264. search: RegExp;
  21265. replace: string;
  21266. }[];
  21267. }, storeKey?: string): void;
  21268. /** @hidden */
  21269. _registerTempVariable(name: string): boolean;
  21270. /** @hidden */
  21271. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21272. /** @hidden */
  21273. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21274. /** @hidden */
  21275. _emitFloat(value: number): string;
  21276. }
  21277. }
  21278. declare module BABYLON {
  21279. /**
  21280. * Helper class used to generate session unique ID
  21281. */
  21282. export class UniqueIdGenerator {
  21283. private static _UniqueIdCounter;
  21284. /**
  21285. * Gets an unique (relatively to the current scene) Id
  21286. */
  21287. static get UniqueId(): number;
  21288. }
  21289. }
  21290. declare module BABYLON {
  21291. /**
  21292. * Defines a block that can be used inside a node based material
  21293. */
  21294. export class NodeMaterialBlock {
  21295. private _buildId;
  21296. private _buildTarget;
  21297. private _target;
  21298. private _isFinalMerger;
  21299. private _isInput;
  21300. protected _isUnique: boolean;
  21301. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21302. inputsAreExclusive: boolean;
  21303. /** @hidden */
  21304. _codeVariableName: string;
  21305. /** @hidden */
  21306. _inputs: NodeMaterialConnectionPoint[];
  21307. /** @hidden */
  21308. _outputs: NodeMaterialConnectionPoint[];
  21309. /** @hidden */
  21310. _preparationId: number;
  21311. /**
  21312. * Gets or sets the name of the block
  21313. */
  21314. name: string;
  21315. /**
  21316. * Gets or sets the unique id of the node
  21317. */
  21318. uniqueId: number;
  21319. /**
  21320. * Gets or sets the comments associated with this block
  21321. */
  21322. comments: string;
  21323. /**
  21324. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21325. */
  21326. get isUnique(): boolean;
  21327. /**
  21328. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21329. */
  21330. get isFinalMerger(): boolean;
  21331. /**
  21332. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21333. */
  21334. get isInput(): boolean;
  21335. /**
  21336. * Gets or sets the build Id
  21337. */
  21338. get buildId(): number;
  21339. set buildId(value: number);
  21340. /**
  21341. * Gets or sets the target of the block
  21342. */
  21343. get target(): NodeMaterialBlockTargets;
  21344. set target(value: NodeMaterialBlockTargets);
  21345. /**
  21346. * Gets the list of input points
  21347. */
  21348. get inputs(): NodeMaterialConnectionPoint[];
  21349. /** Gets the list of output points */
  21350. get outputs(): NodeMaterialConnectionPoint[];
  21351. /**
  21352. * Find an input by its name
  21353. * @param name defines the name of the input to look for
  21354. * @returns the input or null if not found
  21355. */
  21356. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21357. /**
  21358. * Find an output by its name
  21359. * @param name defines the name of the outputto look for
  21360. * @returns the output or null if not found
  21361. */
  21362. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21363. /**
  21364. * Creates a new NodeMaterialBlock
  21365. * @param name defines the block name
  21366. * @param target defines the target of that block (Vertex by default)
  21367. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21368. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21369. */
  21370. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21371. /**
  21372. * Initialize the block and prepare the context for build
  21373. * @param state defines the state that will be used for the build
  21374. */
  21375. initialize(state: NodeMaterialBuildState): void;
  21376. /**
  21377. * Bind data to effect. Will only be called for blocks with isBindable === true
  21378. * @param effect defines the effect to bind data to
  21379. * @param nodeMaterial defines the hosting NodeMaterial
  21380. * @param mesh defines the mesh that will be rendered
  21381. * @param subMesh defines the submesh that will be rendered
  21382. */
  21383. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21384. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21385. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21386. protected _writeFloat(value: number): string;
  21387. /**
  21388. * Gets the current class name e.g. "NodeMaterialBlock"
  21389. * @returns the class name
  21390. */
  21391. getClassName(): string;
  21392. /**
  21393. * Register a new input. Must be called inside a block constructor
  21394. * @param name defines the connection point name
  21395. * @param type defines the connection point type
  21396. * @param isOptional defines a boolean indicating that this input can be omitted
  21397. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21398. * @param point an already created connection point. If not provided, create a new one
  21399. * @returns the current block
  21400. */
  21401. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21402. /**
  21403. * Register a new output. Must be called inside a block constructor
  21404. * @param name defines the connection point name
  21405. * @param type defines the connection point type
  21406. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21407. * @param point an already created connection point. If not provided, create a new one
  21408. * @returns the current block
  21409. */
  21410. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21411. /**
  21412. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21413. * @param forOutput defines an optional connection point to check compatibility with
  21414. * @returns the first available input or null
  21415. */
  21416. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21417. /**
  21418. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21419. * @param forBlock defines an optional block to check compatibility with
  21420. * @returns the first available input or null
  21421. */
  21422. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21423. /**
  21424. * Gets the sibling of the given output
  21425. * @param current defines the current output
  21426. * @returns the next output in the list or null
  21427. */
  21428. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21429. /**
  21430. * Connect current block with another block
  21431. * @param other defines the block to connect with
  21432. * @param options define the various options to help pick the right connections
  21433. * @returns the current block
  21434. */
  21435. connectTo(other: NodeMaterialBlock, options?: {
  21436. input?: string;
  21437. output?: string;
  21438. outputSwizzle?: string;
  21439. }): this | undefined;
  21440. protected _buildBlock(state: NodeMaterialBuildState): void;
  21441. /**
  21442. * Add uniforms, samplers and uniform buffers at compilation time
  21443. * @param state defines the state to update
  21444. * @param nodeMaterial defines the node material requesting the update
  21445. * @param defines defines the material defines to update
  21446. * @param uniformBuffers defines the list of uniform buffer names
  21447. */
  21448. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21449. /**
  21450. * Add potential fallbacks if shader compilation fails
  21451. * @param mesh defines the mesh to be rendered
  21452. * @param fallbacks defines the current prioritized list of fallbacks
  21453. */
  21454. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21455. /**
  21456. * Initialize defines for shader compilation
  21457. * @param mesh defines the mesh to be rendered
  21458. * @param nodeMaterial defines the node material requesting the update
  21459. * @param defines defines the material defines to update
  21460. * @param useInstances specifies that instances should be used
  21461. */
  21462. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21463. /**
  21464. * Update defines for shader compilation
  21465. * @param mesh defines the mesh to be rendered
  21466. * @param nodeMaterial defines the node material requesting the update
  21467. * @param defines defines the material defines to update
  21468. * @param useInstances specifies that instances should be used
  21469. * @param subMesh defines which submesh to render
  21470. */
  21471. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21472. /**
  21473. * Lets the block try to connect some inputs automatically
  21474. * @param material defines the hosting NodeMaterial
  21475. */
  21476. autoConfigure(material: NodeMaterial): void;
  21477. /**
  21478. * Function called when a block is declared as repeatable content generator
  21479. * @param vertexShaderState defines the current compilation state for the vertex shader
  21480. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21481. * @param mesh defines the mesh to be rendered
  21482. * @param defines defines the material defines to update
  21483. */
  21484. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21485. /**
  21486. * Checks if the block is ready
  21487. * @param mesh defines the mesh to be rendered
  21488. * @param nodeMaterial defines the node material requesting the update
  21489. * @param defines defines the material defines to update
  21490. * @param useInstances specifies that instances should be used
  21491. * @returns true if the block is ready
  21492. */
  21493. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21494. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21495. private _processBuild;
  21496. /**
  21497. * Compile the current node and generate the shader code
  21498. * @param state defines the current compilation state (uniforms, samplers, current string)
  21499. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21500. * @returns true if already built
  21501. */
  21502. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21503. protected _inputRename(name: string): string;
  21504. protected _outputRename(name: string): string;
  21505. protected _dumpPropertiesCode(): string;
  21506. /** @hidden */
  21507. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21508. /** @hidden */
  21509. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21510. /**
  21511. * Clone the current block to a new identical block
  21512. * @param scene defines the hosting scene
  21513. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21514. * @returns a copy of the current block
  21515. */
  21516. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21517. /**
  21518. * Serializes this block in a JSON representation
  21519. * @returns the serialized block object
  21520. */
  21521. serialize(): any;
  21522. /** @hidden */
  21523. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21524. private _deserializePortDisplayNames;
  21525. /**
  21526. * Release resources
  21527. */
  21528. dispose(): void;
  21529. }
  21530. }
  21531. declare module BABYLON {
  21532. /**
  21533. * Base class of materials working in push mode in babylon JS
  21534. * @hidden
  21535. */
  21536. export class PushMaterial extends Material {
  21537. protected _activeEffect: Effect;
  21538. protected _normalMatrix: Matrix;
  21539. /**
  21540. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  21541. * This means that the material can keep using a previous shader while a new one is being compiled.
  21542. * This is mostly used when shader parallel compilation is supported (true by default)
  21543. */
  21544. allowShaderHotSwapping: boolean;
  21545. constructor(name: string, scene: Scene);
  21546. getEffect(): Effect;
  21547. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21548. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21549. /**
  21550. * Binds the given world matrix to the active effect
  21551. *
  21552. * @param world the matrix to bind
  21553. */
  21554. bindOnlyWorldMatrix(world: Matrix): void;
  21555. /**
  21556. * Binds the given normal matrix to the active effect
  21557. *
  21558. * @param normalMatrix the matrix to bind
  21559. */
  21560. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21561. bind(world: Matrix, mesh?: Mesh): void;
  21562. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21563. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21564. }
  21565. }
  21566. declare module BABYLON {
  21567. /**
  21568. * Root class for all node material optimizers
  21569. */
  21570. export class NodeMaterialOptimizer {
  21571. /**
  21572. * Function used to optimize a NodeMaterial graph
  21573. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21574. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21575. */
  21576. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21577. }
  21578. }
  21579. declare module BABYLON {
  21580. /**
  21581. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21582. */
  21583. export class TransformBlock extends NodeMaterialBlock {
  21584. /**
  21585. * Defines the value to use to complement W value to transform it to a Vector4
  21586. */
  21587. complementW: number;
  21588. /**
  21589. * Defines the value to use to complement z value to transform it to a Vector4
  21590. */
  21591. complementZ: number;
  21592. /**
  21593. * Creates a new TransformBlock
  21594. * @param name defines the block name
  21595. */
  21596. constructor(name: string);
  21597. /**
  21598. * Gets the current class name
  21599. * @returns the class name
  21600. */
  21601. getClassName(): string;
  21602. /**
  21603. * Gets the vector input
  21604. */
  21605. get vector(): NodeMaterialConnectionPoint;
  21606. /**
  21607. * Gets the output component
  21608. */
  21609. get output(): NodeMaterialConnectionPoint;
  21610. /**
  21611. * Gets the xyz output component
  21612. */
  21613. get xyz(): NodeMaterialConnectionPoint;
  21614. /**
  21615. * Gets the matrix transform input
  21616. */
  21617. get transform(): NodeMaterialConnectionPoint;
  21618. protected _buildBlock(state: NodeMaterialBuildState): this;
  21619. /**
  21620. * Update defines for shader compilation
  21621. * @param mesh defines the mesh to be rendered
  21622. * @param nodeMaterial defines the node material requesting the update
  21623. * @param defines defines the material defines to update
  21624. * @param useInstances specifies that instances should be used
  21625. * @param subMesh defines which submesh to render
  21626. */
  21627. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21628. serialize(): any;
  21629. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21630. protected _dumpPropertiesCode(): string;
  21631. }
  21632. }
  21633. declare module BABYLON {
  21634. /**
  21635. * Block used to output the vertex position
  21636. */
  21637. export class VertexOutputBlock extends NodeMaterialBlock {
  21638. /**
  21639. * Creates a new VertexOutputBlock
  21640. * @param name defines the block name
  21641. */
  21642. constructor(name: string);
  21643. /**
  21644. * Gets the current class name
  21645. * @returns the class name
  21646. */
  21647. getClassName(): string;
  21648. /**
  21649. * Gets the vector input component
  21650. */
  21651. get vector(): NodeMaterialConnectionPoint;
  21652. protected _buildBlock(state: NodeMaterialBuildState): this;
  21653. }
  21654. }
  21655. declare module BABYLON {
  21656. /**
  21657. * Block used to output the final color
  21658. */
  21659. export class FragmentOutputBlock extends NodeMaterialBlock {
  21660. /**
  21661. * Create a new FragmentOutputBlock
  21662. * @param name defines the block name
  21663. */
  21664. constructor(name: string);
  21665. /**
  21666. * Gets the current class name
  21667. * @returns the class name
  21668. */
  21669. getClassName(): string;
  21670. /**
  21671. * Gets the rgba input component
  21672. */
  21673. get rgba(): NodeMaterialConnectionPoint;
  21674. /**
  21675. * Gets the rgb input component
  21676. */
  21677. get rgb(): NodeMaterialConnectionPoint;
  21678. /**
  21679. * Gets the a input component
  21680. */
  21681. get a(): NodeMaterialConnectionPoint;
  21682. protected _buildBlock(state: NodeMaterialBuildState): this;
  21683. }
  21684. }
  21685. declare module BABYLON {
  21686. /**
  21687. * Block used for the particle ramp gradient section
  21688. */
  21689. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21690. /**
  21691. * Create a new ParticleRampGradientBlock
  21692. * @param name defines the block name
  21693. */
  21694. constructor(name: string);
  21695. /**
  21696. * Gets the current class name
  21697. * @returns the class name
  21698. */
  21699. getClassName(): string;
  21700. /**
  21701. * Gets the color input component
  21702. */
  21703. get color(): NodeMaterialConnectionPoint;
  21704. /**
  21705. * Gets the rampColor output component
  21706. */
  21707. get rampColor(): NodeMaterialConnectionPoint;
  21708. /**
  21709. * Initialize the block and prepare the context for build
  21710. * @param state defines the state that will be used for the build
  21711. */
  21712. initialize(state: NodeMaterialBuildState): void;
  21713. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21714. }
  21715. }
  21716. declare module BABYLON {
  21717. /**
  21718. * Block used for the particle blend multiply section
  21719. */
  21720. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21721. /**
  21722. * Create a new ParticleBlendMultiplyBlock
  21723. * @param name defines the block name
  21724. */
  21725. constructor(name: string);
  21726. /**
  21727. * Gets the current class name
  21728. * @returns the class name
  21729. */
  21730. getClassName(): string;
  21731. /**
  21732. * Gets the color input component
  21733. */
  21734. get color(): NodeMaterialConnectionPoint;
  21735. /**
  21736. * Gets the alphaTexture input component
  21737. */
  21738. get alphaTexture(): NodeMaterialConnectionPoint;
  21739. /**
  21740. * Gets the alphaColor input component
  21741. */
  21742. get alphaColor(): NodeMaterialConnectionPoint;
  21743. /**
  21744. * Gets the blendColor output component
  21745. */
  21746. get blendColor(): NodeMaterialConnectionPoint;
  21747. /**
  21748. * Initialize the block and prepare the context for build
  21749. * @param state defines the state that will be used for the build
  21750. */
  21751. initialize(state: NodeMaterialBuildState): void;
  21752. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21753. }
  21754. }
  21755. declare module BABYLON {
  21756. /**
  21757. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21758. */
  21759. export class VectorMergerBlock extends NodeMaterialBlock {
  21760. /**
  21761. * Create a new VectorMergerBlock
  21762. * @param name defines the block name
  21763. */
  21764. constructor(name: string);
  21765. /**
  21766. * Gets the current class name
  21767. * @returns the class name
  21768. */
  21769. getClassName(): string;
  21770. /**
  21771. * Gets the xyz component (input)
  21772. */
  21773. get xyzIn(): NodeMaterialConnectionPoint;
  21774. /**
  21775. * Gets the xy component (input)
  21776. */
  21777. get xyIn(): NodeMaterialConnectionPoint;
  21778. /**
  21779. * Gets the x component (input)
  21780. */
  21781. get x(): NodeMaterialConnectionPoint;
  21782. /**
  21783. * Gets the y component (input)
  21784. */
  21785. get y(): NodeMaterialConnectionPoint;
  21786. /**
  21787. * Gets the z component (input)
  21788. */
  21789. get z(): NodeMaterialConnectionPoint;
  21790. /**
  21791. * Gets the w component (input)
  21792. */
  21793. get w(): NodeMaterialConnectionPoint;
  21794. /**
  21795. * Gets the xyzw component (output)
  21796. */
  21797. get xyzw(): NodeMaterialConnectionPoint;
  21798. /**
  21799. * Gets the xyz component (output)
  21800. */
  21801. get xyzOut(): NodeMaterialConnectionPoint;
  21802. /**
  21803. * Gets the xy component (output)
  21804. */
  21805. get xyOut(): NodeMaterialConnectionPoint;
  21806. /**
  21807. * Gets the xy component (output)
  21808. * @deprecated Please use xyOut instead.
  21809. */
  21810. get xy(): NodeMaterialConnectionPoint;
  21811. /**
  21812. * Gets the xyz component (output)
  21813. * @deprecated Please use xyzOut instead.
  21814. */
  21815. get xyz(): NodeMaterialConnectionPoint;
  21816. protected _buildBlock(state: NodeMaterialBuildState): this;
  21817. }
  21818. }
  21819. declare module BABYLON {
  21820. /**
  21821. * Block used to remap a float from a range to a new one
  21822. */
  21823. export class RemapBlock extends NodeMaterialBlock {
  21824. /**
  21825. * Gets or sets the source range
  21826. */
  21827. sourceRange: Vector2;
  21828. /**
  21829. * Gets or sets the target range
  21830. */
  21831. targetRange: Vector2;
  21832. /**
  21833. * Creates a new RemapBlock
  21834. * @param name defines the block name
  21835. */
  21836. constructor(name: string);
  21837. /**
  21838. * Gets the current class name
  21839. * @returns the class name
  21840. */
  21841. getClassName(): string;
  21842. /**
  21843. * Gets the input component
  21844. */
  21845. get input(): NodeMaterialConnectionPoint;
  21846. /**
  21847. * Gets the source min input component
  21848. */
  21849. get sourceMin(): NodeMaterialConnectionPoint;
  21850. /**
  21851. * Gets the source max input component
  21852. */
  21853. get sourceMax(): NodeMaterialConnectionPoint;
  21854. /**
  21855. * Gets the target min input component
  21856. */
  21857. get targetMin(): NodeMaterialConnectionPoint;
  21858. /**
  21859. * Gets the target max input component
  21860. */
  21861. get targetMax(): NodeMaterialConnectionPoint;
  21862. /**
  21863. * Gets the output component
  21864. */
  21865. get output(): NodeMaterialConnectionPoint;
  21866. protected _buildBlock(state: NodeMaterialBuildState): this;
  21867. protected _dumpPropertiesCode(): string;
  21868. serialize(): any;
  21869. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21870. }
  21871. }
  21872. declare module BABYLON {
  21873. /**
  21874. * Block used to multiply 2 values
  21875. */
  21876. export class MultiplyBlock extends NodeMaterialBlock {
  21877. /**
  21878. * Creates a new MultiplyBlock
  21879. * @param name defines the block name
  21880. */
  21881. constructor(name: string);
  21882. /**
  21883. * Gets the current class name
  21884. * @returns the class name
  21885. */
  21886. getClassName(): string;
  21887. /**
  21888. * Gets the left operand input component
  21889. */
  21890. get left(): NodeMaterialConnectionPoint;
  21891. /**
  21892. * Gets the right operand input component
  21893. */
  21894. get right(): NodeMaterialConnectionPoint;
  21895. /**
  21896. * Gets the output component
  21897. */
  21898. get output(): NodeMaterialConnectionPoint;
  21899. protected _buildBlock(state: NodeMaterialBuildState): this;
  21900. }
  21901. }
  21902. declare module BABYLON {
  21903. /**
  21904. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21905. */
  21906. export class ColorSplitterBlock extends NodeMaterialBlock {
  21907. /**
  21908. * Create a new ColorSplitterBlock
  21909. * @param name defines the block name
  21910. */
  21911. constructor(name: string);
  21912. /**
  21913. * Gets the current class name
  21914. * @returns the class name
  21915. */
  21916. getClassName(): string;
  21917. /**
  21918. * Gets the rgba component (input)
  21919. */
  21920. get rgba(): NodeMaterialConnectionPoint;
  21921. /**
  21922. * Gets the rgb component (input)
  21923. */
  21924. get rgbIn(): NodeMaterialConnectionPoint;
  21925. /**
  21926. * Gets the rgb component (output)
  21927. */
  21928. get rgbOut(): NodeMaterialConnectionPoint;
  21929. /**
  21930. * Gets the r component (output)
  21931. */
  21932. get r(): NodeMaterialConnectionPoint;
  21933. /**
  21934. * Gets the g component (output)
  21935. */
  21936. get g(): NodeMaterialConnectionPoint;
  21937. /**
  21938. * Gets the b component (output)
  21939. */
  21940. get b(): NodeMaterialConnectionPoint;
  21941. /**
  21942. * Gets the a component (output)
  21943. */
  21944. get a(): NodeMaterialConnectionPoint;
  21945. protected _inputRename(name: string): string;
  21946. protected _outputRename(name: string): string;
  21947. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21948. }
  21949. }
  21950. declare module BABYLON {
  21951. /**
  21952. * Interface used to configure the node material editor
  21953. */
  21954. export interface INodeMaterialEditorOptions {
  21955. /** Define the URl to load node editor script */
  21956. editorURL?: string;
  21957. }
  21958. /** @hidden */
  21959. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21960. NORMAL: boolean;
  21961. TANGENT: boolean;
  21962. UV1: boolean;
  21963. /** BONES */
  21964. NUM_BONE_INFLUENCERS: number;
  21965. BonesPerMesh: number;
  21966. BONETEXTURE: boolean;
  21967. /** MORPH TARGETS */
  21968. MORPHTARGETS: boolean;
  21969. MORPHTARGETS_NORMAL: boolean;
  21970. MORPHTARGETS_TANGENT: boolean;
  21971. MORPHTARGETS_UV: boolean;
  21972. NUM_MORPH_INFLUENCERS: number;
  21973. /** IMAGE PROCESSING */
  21974. IMAGEPROCESSING: boolean;
  21975. VIGNETTE: boolean;
  21976. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21977. VIGNETTEBLENDMODEOPAQUE: boolean;
  21978. TONEMAPPING: boolean;
  21979. TONEMAPPING_ACES: boolean;
  21980. CONTRAST: boolean;
  21981. EXPOSURE: boolean;
  21982. COLORCURVES: boolean;
  21983. COLORGRADING: boolean;
  21984. COLORGRADING3D: boolean;
  21985. SAMPLER3DGREENDEPTH: boolean;
  21986. SAMPLER3DBGRMAP: boolean;
  21987. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21988. /** MISC. */
  21989. BUMPDIRECTUV: number;
  21990. constructor();
  21991. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  21992. }
  21993. /**
  21994. * Class used to configure NodeMaterial
  21995. */
  21996. export interface INodeMaterialOptions {
  21997. /**
  21998. * Defines if blocks should emit comments
  21999. */
  22000. emitComments: boolean;
  22001. }
  22002. /**
  22003. * Class used to create a node based material built by assembling shader blocks
  22004. */
  22005. export class NodeMaterial extends PushMaterial {
  22006. private static _BuildIdGenerator;
  22007. private _options;
  22008. private _vertexCompilationState;
  22009. private _fragmentCompilationState;
  22010. private _sharedData;
  22011. private _buildId;
  22012. private _buildWasSuccessful;
  22013. private _cachedWorldViewMatrix;
  22014. private _cachedWorldViewProjectionMatrix;
  22015. private _optimizers;
  22016. private _animationFrame;
  22017. /** Define the Url to load node editor script */
  22018. static EditorURL: string;
  22019. /** Define the Url to load snippets */
  22020. static SnippetUrl: string;
  22021. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22022. static IgnoreTexturesAtLoadTime: boolean;
  22023. private BJSNODEMATERIALEDITOR;
  22024. /** Get the inspector from bundle or global */
  22025. private _getGlobalNodeMaterialEditor;
  22026. /**
  22027. * Snippet ID if the material was created from the snippet server
  22028. */
  22029. snippetId: string;
  22030. /**
  22031. * Gets or sets data used by visual editor
  22032. * @see https://nme.babylonjs.com
  22033. */
  22034. editorData: any;
  22035. /**
  22036. * 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)
  22037. */
  22038. ignoreAlpha: boolean;
  22039. /**
  22040. * Defines the maximum number of lights that can be used in the material
  22041. */
  22042. maxSimultaneousLights: number;
  22043. /**
  22044. * Observable raised when the material is built
  22045. */
  22046. onBuildObservable: Observable<NodeMaterial>;
  22047. /**
  22048. * Gets or sets the root nodes of the material vertex shader
  22049. */
  22050. _vertexOutputNodes: NodeMaterialBlock[];
  22051. /**
  22052. * Gets or sets the root nodes of the material fragment (pixel) shader
  22053. */
  22054. _fragmentOutputNodes: NodeMaterialBlock[];
  22055. /** Gets or sets options to control the node material overall behavior */
  22056. get options(): INodeMaterialOptions;
  22057. set options(options: INodeMaterialOptions);
  22058. /**
  22059. * Default configuration related to image processing available in the standard Material.
  22060. */
  22061. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22062. /**
  22063. * Gets the image processing configuration used either in this material.
  22064. */
  22065. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22066. /**
  22067. * Sets the Default image processing configuration used either in the this material.
  22068. *
  22069. * If sets to null, the scene one is in use.
  22070. */
  22071. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22072. /**
  22073. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22074. */
  22075. attachedBlocks: NodeMaterialBlock[];
  22076. /**
  22077. * Specifies the mode of the node material
  22078. * @hidden
  22079. */
  22080. _mode: NodeMaterialModes;
  22081. /**
  22082. * Gets the mode property
  22083. */
  22084. get mode(): NodeMaterialModes;
  22085. /**
  22086. * Create a new node based material
  22087. * @param name defines the material name
  22088. * @param scene defines the hosting scene
  22089. * @param options defines creation option
  22090. */
  22091. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22092. /**
  22093. * Gets the current class name of the material e.g. "NodeMaterial"
  22094. * @returns the class name
  22095. */
  22096. getClassName(): string;
  22097. /**
  22098. * Keep track of the image processing observer to allow dispose and replace.
  22099. */
  22100. private _imageProcessingObserver;
  22101. /**
  22102. * Attaches a new image processing configuration to the Standard Material.
  22103. * @param configuration
  22104. */
  22105. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22106. /**
  22107. * Get a block by its name
  22108. * @param name defines the name of the block to retrieve
  22109. * @returns the required block or null if not found
  22110. */
  22111. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22112. /**
  22113. * Get a block by its name
  22114. * @param predicate defines the predicate used to find the good candidate
  22115. * @returns the required block or null if not found
  22116. */
  22117. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22118. /**
  22119. * Get an input block by its name
  22120. * @param predicate defines the predicate used to find the good candidate
  22121. * @returns the required input block or null if not found
  22122. */
  22123. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22124. /**
  22125. * Gets the list of input blocks attached to this material
  22126. * @returns an array of InputBlocks
  22127. */
  22128. getInputBlocks(): InputBlock[];
  22129. /**
  22130. * Adds a new optimizer to the list of optimizers
  22131. * @param optimizer defines the optimizers to add
  22132. * @returns the current material
  22133. */
  22134. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22135. /**
  22136. * Remove an optimizer from the list of optimizers
  22137. * @param optimizer defines the optimizers to remove
  22138. * @returns the current material
  22139. */
  22140. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22141. /**
  22142. * Add a new block to the list of output nodes
  22143. * @param node defines the node to add
  22144. * @returns the current material
  22145. */
  22146. addOutputNode(node: NodeMaterialBlock): this;
  22147. /**
  22148. * Remove a block from the list of root nodes
  22149. * @param node defines the node to remove
  22150. * @returns the current material
  22151. */
  22152. removeOutputNode(node: NodeMaterialBlock): this;
  22153. private _addVertexOutputNode;
  22154. private _removeVertexOutputNode;
  22155. private _addFragmentOutputNode;
  22156. private _removeFragmentOutputNode;
  22157. /**
  22158. * Specifies if the material will require alpha blending
  22159. * @returns a boolean specifying if alpha blending is needed
  22160. */
  22161. needAlphaBlending(): boolean;
  22162. /**
  22163. * Specifies if this material should be rendered in alpha test mode
  22164. * @returns a boolean specifying if an alpha test is needed.
  22165. */
  22166. needAlphaTesting(): boolean;
  22167. private _initializeBlock;
  22168. private _resetDualBlocks;
  22169. /**
  22170. * Remove a block from the current node material
  22171. * @param block defines the block to remove
  22172. */
  22173. removeBlock(block: NodeMaterialBlock): void;
  22174. /**
  22175. * Build the material and generates the inner effect
  22176. * @param verbose defines if the build should log activity
  22177. */
  22178. build(verbose?: boolean): void;
  22179. /**
  22180. * Runs an otpimization phase to try to improve the shader code
  22181. */
  22182. optimize(): void;
  22183. private _prepareDefinesForAttributes;
  22184. /**
  22185. * Create a post process from the material
  22186. * @param camera The camera to apply the render pass to.
  22187. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22189. * @param engine The engine which the post process will be applied. (default: current engine)
  22190. * @param reusable If the post process can be reused on the same frame. (default: false)
  22191. * @param textureType Type of textures used when performing the post process. (default: 0)
  22192. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22193. * @returns the post process created
  22194. */
  22195. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22196. /**
  22197. * Create the post process effect from the material
  22198. * @param postProcess The post process to create the effect for
  22199. */
  22200. createEffectForPostProcess(postProcess: PostProcess): void;
  22201. private _createEffectOrPostProcess;
  22202. private _createEffectForParticles;
  22203. /**
  22204. * Create the effect to be used as the custom effect for a particle system
  22205. * @param particleSystem Particle system to create the effect for
  22206. * @param onCompiled defines a function to call when the effect creation is successful
  22207. * @param onError defines a function to call when the effect creation has failed
  22208. */
  22209. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22210. private _processDefines;
  22211. /**
  22212. * Get if the submesh is ready to be used and all its information available.
  22213. * Child classes can use it to update shaders
  22214. * @param mesh defines the mesh to check
  22215. * @param subMesh defines which submesh to check
  22216. * @param useInstances specifies that instances should be used
  22217. * @returns a boolean indicating that the submesh is ready or not
  22218. */
  22219. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22220. /**
  22221. * Get a string representing the shaders built by the current node graph
  22222. */
  22223. get compiledShaders(): string;
  22224. /**
  22225. * Binds the world matrix to the material
  22226. * @param world defines the world transformation matrix
  22227. */
  22228. bindOnlyWorldMatrix(world: Matrix): void;
  22229. /**
  22230. * Binds the submesh to this material by preparing the effect and shader to draw
  22231. * @param world defines the world transformation matrix
  22232. * @param mesh defines the mesh containing the submesh
  22233. * @param subMesh defines the submesh to bind the material to
  22234. */
  22235. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22236. /**
  22237. * Gets the active textures from the material
  22238. * @returns an array of textures
  22239. */
  22240. getActiveTextures(): BaseTexture[];
  22241. /**
  22242. * Gets the list of texture blocks
  22243. * @returns an array of texture blocks
  22244. */
  22245. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22246. /**
  22247. * Specifies if the material uses a texture
  22248. * @param texture defines the texture to check against the material
  22249. * @returns a boolean specifying if the material uses the texture
  22250. */
  22251. hasTexture(texture: BaseTexture): boolean;
  22252. /**
  22253. * Disposes the material
  22254. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22255. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22256. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22257. */
  22258. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22259. /** Creates the node editor window. */
  22260. private _createNodeEditor;
  22261. /**
  22262. * Launch the node material editor
  22263. * @param config Define the configuration of the editor
  22264. * @return a promise fulfilled when the node editor is visible
  22265. */
  22266. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22267. /**
  22268. * Clear the current material
  22269. */
  22270. clear(): void;
  22271. /**
  22272. * Clear the current material and set it to a default state
  22273. */
  22274. setToDefault(): void;
  22275. /**
  22276. * Clear the current material and set it to a default state for post process
  22277. */
  22278. setToDefaultPostProcess(): void;
  22279. /**
  22280. * Clear the current material and set it to a default state for particle
  22281. */
  22282. setToDefaultParticle(): void;
  22283. /**
  22284. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22285. * @param url defines the url to load from
  22286. * @returns a promise that will fullfil when the material is fully loaded
  22287. */
  22288. loadAsync(url: string): Promise<void>;
  22289. private _gatherBlocks;
  22290. /**
  22291. * Generate a string containing the code declaration required to create an equivalent of this material
  22292. * @returns a string
  22293. */
  22294. generateCode(): string;
  22295. /**
  22296. * Serializes this material in a JSON representation
  22297. * @returns the serialized material object
  22298. */
  22299. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22300. private _restoreConnections;
  22301. /**
  22302. * Clear the current graph and load a new one from a serialization object
  22303. * @param source defines the JSON representation of the material
  22304. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22305. */
  22306. loadFromSerialization(source: any, rootUrl?: string): void;
  22307. /**
  22308. * Makes a duplicate of the current material.
  22309. * @param name - name to use for the new material.
  22310. */
  22311. clone(name: string): NodeMaterial;
  22312. /**
  22313. * Creates a node material from parsed material data
  22314. * @param source defines the JSON representation of the material
  22315. * @param scene defines the hosting scene
  22316. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22317. * @returns a new node material
  22318. */
  22319. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22320. /**
  22321. * Creates a node material from a snippet saved in a remote file
  22322. * @param name defines the name of the material to create
  22323. * @param url defines the url to load from
  22324. * @param scene defines the hosting scene
  22325. * @returns a promise that will resolve to the new node material
  22326. */
  22327. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22328. /**
  22329. * Creates a node material from a snippet saved by the node material editor
  22330. * @param snippetId defines the snippet to load
  22331. * @param scene defines the hosting scene
  22332. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22333. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22334. * @returns a promise that will resolve to the new node material
  22335. */
  22336. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22337. /**
  22338. * Creates a new node material set to default basic configuration
  22339. * @param name defines the name of the material
  22340. * @param scene defines the hosting scene
  22341. * @returns a new NodeMaterial
  22342. */
  22343. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22344. }
  22345. }
  22346. declare module BABYLON {
  22347. /**
  22348. * Size options for a post process
  22349. */
  22350. export type PostProcessOptions = {
  22351. width: number;
  22352. height: number;
  22353. };
  22354. /**
  22355. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22356. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22357. */
  22358. export class PostProcess {
  22359. /** Name of the PostProcess. */
  22360. name: string;
  22361. /**
  22362. * Gets or sets the unique id of the post process
  22363. */
  22364. uniqueId: number;
  22365. /**
  22366. * Width of the texture to apply the post process on
  22367. */
  22368. width: number;
  22369. /**
  22370. * Height of the texture to apply the post process on
  22371. */
  22372. height: number;
  22373. /**
  22374. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22375. */
  22376. nodeMaterialSource: Nullable<NodeMaterial>;
  22377. /**
  22378. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22379. * @hidden
  22380. */
  22381. _outputTexture: Nullable<InternalTexture>;
  22382. /**
  22383. * Sampling mode used by the shader
  22384. * See https://doc.babylonjs.com/classes/3.1/texture
  22385. */
  22386. renderTargetSamplingMode: number;
  22387. /**
  22388. * Clear color to use when screen clearing
  22389. */
  22390. clearColor: Color4;
  22391. /**
  22392. * If the buffer needs to be cleared before applying the post process. (default: true)
  22393. * Should be set to false if shader will overwrite all previous pixels.
  22394. */
  22395. autoClear: boolean;
  22396. /**
  22397. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22398. */
  22399. alphaMode: number;
  22400. /**
  22401. * Sets the setAlphaBlendConstants of the babylon engine
  22402. */
  22403. alphaConstants: Color4;
  22404. /**
  22405. * Animations to be used for the post processing
  22406. */
  22407. animations: Animation[];
  22408. /**
  22409. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22410. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22411. */
  22412. enablePixelPerfectMode: boolean;
  22413. /**
  22414. * Force the postprocess to be applied without taking in account viewport
  22415. */
  22416. forceFullscreenViewport: boolean;
  22417. /**
  22418. * List of inspectable custom properties (used by the Inspector)
  22419. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22420. */
  22421. inspectableCustomProperties: IInspectable[];
  22422. /**
  22423. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22424. *
  22425. * | Value | Type | Description |
  22426. * | ----- | ----------------------------------- | ----------- |
  22427. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22428. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22429. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22430. *
  22431. */
  22432. scaleMode: number;
  22433. /**
  22434. * Force textures to be a power of two (default: false)
  22435. */
  22436. alwaysForcePOT: boolean;
  22437. private _samples;
  22438. /**
  22439. * Number of sample textures (default: 1)
  22440. */
  22441. get samples(): number;
  22442. set samples(n: number);
  22443. /**
  22444. * Modify the scale of the post process to be the same as the viewport (default: false)
  22445. */
  22446. adaptScaleToCurrentViewport: boolean;
  22447. private _camera;
  22448. private _scene;
  22449. private _engine;
  22450. private _options;
  22451. private _reusable;
  22452. private _textureType;
  22453. private _textureFormat;
  22454. /**
  22455. * Smart array of input and output textures for the post process.
  22456. * @hidden
  22457. */
  22458. _textures: SmartArray<InternalTexture>;
  22459. /**
  22460. * The index in _textures that corresponds to the output texture.
  22461. * @hidden
  22462. */
  22463. _currentRenderTextureInd: number;
  22464. private _effect;
  22465. private _samplers;
  22466. private _fragmentUrl;
  22467. private _vertexUrl;
  22468. private _parameters;
  22469. private _scaleRatio;
  22470. protected _indexParameters: any;
  22471. private _shareOutputWithPostProcess;
  22472. private _texelSize;
  22473. private _forcedOutputTexture;
  22474. /**
  22475. * Returns the fragment url or shader name used in the post process.
  22476. * @returns the fragment url or name in the shader store.
  22477. */
  22478. getEffectName(): string;
  22479. /**
  22480. * An event triggered when the postprocess is activated.
  22481. */
  22482. onActivateObservable: Observable<Camera>;
  22483. private _onActivateObserver;
  22484. /**
  22485. * A function that is added to the onActivateObservable
  22486. */
  22487. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22488. /**
  22489. * An event triggered when the postprocess changes its size.
  22490. */
  22491. onSizeChangedObservable: Observable<PostProcess>;
  22492. private _onSizeChangedObserver;
  22493. /**
  22494. * A function that is added to the onSizeChangedObservable
  22495. */
  22496. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22497. /**
  22498. * An event triggered when the postprocess applies its effect.
  22499. */
  22500. onApplyObservable: Observable<Effect>;
  22501. private _onApplyObserver;
  22502. /**
  22503. * A function that is added to the onApplyObservable
  22504. */
  22505. set onApply(callback: (effect: Effect) => void);
  22506. /**
  22507. * An event triggered before rendering the postprocess
  22508. */
  22509. onBeforeRenderObservable: Observable<Effect>;
  22510. private _onBeforeRenderObserver;
  22511. /**
  22512. * A function that is added to the onBeforeRenderObservable
  22513. */
  22514. set onBeforeRender(callback: (effect: Effect) => void);
  22515. /**
  22516. * An event triggered after rendering the postprocess
  22517. */
  22518. onAfterRenderObservable: Observable<Effect>;
  22519. private _onAfterRenderObserver;
  22520. /**
  22521. * A function that is added to the onAfterRenderObservable
  22522. */
  22523. set onAfterRender(callback: (efect: Effect) => void);
  22524. /**
  22525. * 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
  22526. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22527. */
  22528. get inputTexture(): InternalTexture;
  22529. set inputTexture(value: InternalTexture);
  22530. /**
  22531. * Gets the camera which post process is applied to.
  22532. * @returns The camera the post process is applied to.
  22533. */
  22534. getCamera(): Camera;
  22535. /**
  22536. * Gets the texel size of the postprocess.
  22537. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22538. */
  22539. get texelSize(): Vector2;
  22540. /**
  22541. * Creates a new instance PostProcess
  22542. * @param name The name of the PostProcess.
  22543. * @param fragmentUrl The url of the fragment shader to be used.
  22544. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22545. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22546. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22547. * @param camera The camera to apply the render pass to.
  22548. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22549. * @param engine The engine which the post process will be applied. (default: current engine)
  22550. * @param reusable If the post process can be reused on the same frame. (default: false)
  22551. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22552. * @param textureType Type of textures used when performing the post process. (default: 0)
  22553. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22554. * @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
  22555. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22556. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22557. */
  22558. constructor(
  22559. /** Name of the PostProcess. */
  22560. 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);
  22561. /**
  22562. * Gets a string idenfifying the name of the class
  22563. * @returns "PostProcess" string
  22564. */
  22565. getClassName(): string;
  22566. /**
  22567. * Gets the engine which this post process belongs to.
  22568. * @returns The engine the post process was enabled with.
  22569. */
  22570. getEngine(): Engine;
  22571. /**
  22572. * The effect that is created when initializing the post process.
  22573. * @returns The created effect corresponding the the postprocess.
  22574. */
  22575. getEffect(): Effect;
  22576. /**
  22577. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22578. * @param postProcess The post process to share the output with.
  22579. * @returns This post process.
  22580. */
  22581. shareOutputWith(postProcess: PostProcess): PostProcess;
  22582. /**
  22583. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22584. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22585. */
  22586. useOwnOutput(): void;
  22587. /**
  22588. * Updates the effect with the current post process compile time values and recompiles the shader.
  22589. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22590. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22591. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22592. * @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
  22593. * @param onCompiled Called when the shader has been compiled.
  22594. * @param onError Called if there is an error when compiling a shader.
  22595. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22596. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22597. */
  22598. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  22599. /**
  22600. * The post process is reusable if it can be used multiple times within one frame.
  22601. * @returns If the post process is reusable
  22602. */
  22603. isReusable(): boolean;
  22604. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22605. markTextureDirty(): void;
  22606. /**
  22607. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22608. * 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.
  22609. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22610. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22611. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22612. * @returns The target texture that was bound to be written to.
  22613. */
  22614. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22615. /**
  22616. * If the post process is supported.
  22617. */
  22618. get isSupported(): boolean;
  22619. /**
  22620. * The aspect ratio of the output texture.
  22621. */
  22622. get aspectRatio(): number;
  22623. /**
  22624. * Get a value indicating if the post-process is ready to be used
  22625. * @returns true if the post-process is ready (shader is compiled)
  22626. */
  22627. isReady(): boolean;
  22628. /**
  22629. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22630. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22631. */
  22632. apply(): Nullable<Effect>;
  22633. private _disposeTextures;
  22634. /**
  22635. * Disposes the post process.
  22636. * @param camera The camera to dispose the post process on.
  22637. */
  22638. dispose(camera?: Camera): void;
  22639. }
  22640. }
  22641. declare module BABYLON {
  22642. /** @hidden */
  22643. export var kernelBlurVaryingDeclaration: {
  22644. name: string;
  22645. shader: string;
  22646. };
  22647. }
  22648. declare module BABYLON {
  22649. /** @hidden */
  22650. export var kernelBlurFragment: {
  22651. name: string;
  22652. shader: string;
  22653. };
  22654. }
  22655. declare module BABYLON {
  22656. /** @hidden */
  22657. export var kernelBlurFragment2: {
  22658. name: string;
  22659. shader: string;
  22660. };
  22661. }
  22662. declare module BABYLON {
  22663. /** @hidden */
  22664. export var kernelBlurPixelShader: {
  22665. name: string;
  22666. shader: string;
  22667. };
  22668. }
  22669. declare module BABYLON {
  22670. /** @hidden */
  22671. export var kernelBlurVertex: {
  22672. name: string;
  22673. shader: string;
  22674. };
  22675. }
  22676. declare module BABYLON {
  22677. /** @hidden */
  22678. export var kernelBlurVertexShader: {
  22679. name: string;
  22680. shader: string;
  22681. };
  22682. }
  22683. declare module BABYLON {
  22684. /**
  22685. * The Blur Post Process which blurs an image based on a kernel and direction.
  22686. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22687. */
  22688. export class BlurPostProcess extends PostProcess {
  22689. /** The direction in which to blur the image. */
  22690. direction: Vector2;
  22691. private blockCompilation;
  22692. protected _kernel: number;
  22693. protected _idealKernel: number;
  22694. protected _packedFloat: boolean;
  22695. private _staticDefines;
  22696. /**
  22697. * Sets the length in pixels of the blur sample region
  22698. */
  22699. set kernel(v: number);
  22700. /**
  22701. * Gets the length in pixels of the blur sample region
  22702. */
  22703. get kernel(): number;
  22704. /**
  22705. * Sets wether or not the blur needs to unpack/repack floats
  22706. */
  22707. set packedFloat(v: boolean);
  22708. /**
  22709. * Gets wether or not the blur is unpacking/repacking floats
  22710. */
  22711. get packedFloat(): boolean;
  22712. /**
  22713. * Creates a new instance BlurPostProcess
  22714. * @param name The name of the effect.
  22715. * @param direction The direction in which to blur the image.
  22716. * @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.
  22717. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22718. * @param camera The camera to apply the render pass to.
  22719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22720. * @param engine The engine which the post process will be applied. (default: current engine)
  22721. * @param reusable If the post process can be reused on the same frame. (default: false)
  22722. * @param textureType Type of textures used when performing the post process. (default: 0)
  22723. * @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)
  22724. */
  22725. constructor(name: string,
  22726. /** The direction in which to blur the image. */
  22727. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22728. /**
  22729. * Updates the effect with the current post process compile time values and recompiles the shader.
  22730. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22731. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22732. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22733. * @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
  22734. * @param onCompiled Called when the shader has been compiled.
  22735. * @param onError Called if there is an error when compiling a shader.
  22736. */
  22737. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22738. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22739. /**
  22740. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22741. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22742. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22743. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22744. * The gaps between physical kernels are compensated for in the weighting of the samples
  22745. * @param idealKernel Ideal blur kernel.
  22746. * @return Nearest best kernel.
  22747. */
  22748. protected _nearestBestKernel(idealKernel: number): number;
  22749. /**
  22750. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22751. * @param x The point on the Gaussian distribution to sample.
  22752. * @return the value of the Gaussian function at x.
  22753. */
  22754. protected _gaussianWeight(x: number): number;
  22755. /**
  22756. * Generates a string that can be used as a floating point number in GLSL.
  22757. * @param x Value to print.
  22758. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22759. * @return GLSL float string.
  22760. */
  22761. protected _glslFloat(x: number, decimalFigures?: number): string;
  22762. }
  22763. }
  22764. declare module BABYLON {
  22765. /**
  22766. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22767. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22768. * You can then easily use it as a reflectionTexture on a flat surface.
  22769. * In case the surface is not a plane, please consider relying on reflection probes.
  22770. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22771. */
  22772. export class MirrorTexture extends RenderTargetTexture {
  22773. private scene;
  22774. /**
  22775. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22776. * 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.
  22777. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22778. */
  22779. mirrorPlane: Plane;
  22780. /**
  22781. * Define the blur ratio used to blur the reflection if needed.
  22782. */
  22783. set blurRatio(value: number);
  22784. get blurRatio(): number;
  22785. /**
  22786. * Define the adaptive blur kernel used to blur the reflection if needed.
  22787. * This will autocompute the closest best match for the `blurKernel`
  22788. */
  22789. set adaptiveBlurKernel(value: number);
  22790. /**
  22791. * Define the blur kernel used to blur the reflection if needed.
  22792. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22793. */
  22794. set blurKernel(value: number);
  22795. /**
  22796. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22797. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22798. */
  22799. set blurKernelX(value: number);
  22800. get blurKernelX(): number;
  22801. /**
  22802. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22803. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22804. */
  22805. set blurKernelY(value: number);
  22806. get blurKernelY(): number;
  22807. private _autoComputeBlurKernel;
  22808. protected _onRatioRescale(): void;
  22809. private _updateGammaSpace;
  22810. private _imageProcessingConfigChangeObserver;
  22811. private _transformMatrix;
  22812. private _mirrorMatrix;
  22813. private _savedViewMatrix;
  22814. private _blurX;
  22815. private _blurY;
  22816. private _adaptiveBlurKernel;
  22817. private _blurKernelX;
  22818. private _blurKernelY;
  22819. private _blurRatio;
  22820. /**
  22821. * Instantiates a Mirror Texture.
  22822. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22823. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22824. * You can then easily use it as a reflectionTexture on a flat surface.
  22825. * In case the surface is not a plane, please consider relying on reflection probes.
  22826. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22827. * @param name
  22828. * @param size
  22829. * @param scene
  22830. * @param generateMipMaps
  22831. * @param type
  22832. * @param samplingMode
  22833. * @param generateDepthBuffer
  22834. */
  22835. constructor(name: string, size: number | {
  22836. width: number;
  22837. height: number;
  22838. } | {
  22839. ratio: number;
  22840. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22841. private _preparePostProcesses;
  22842. /**
  22843. * Clone the mirror texture.
  22844. * @returns the cloned texture
  22845. */
  22846. clone(): MirrorTexture;
  22847. /**
  22848. * Serialize the texture to a JSON representation you could use in Parse later on
  22849. * @returns the serialized JSON representation
  22850. */
  22851. serialize(): any;
  22852. /**
  22853. * Dispose the texture and release its associated resources.
  22854. */
  22855. dispose(): void;
  22856. }
  22857. }
  22858. declare module BABYLON {
  22859. /**
  22860. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22861. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22862. */
  22863. export class Texture extends BaseTexture {
  22864. /**
  22865. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22866. */
  22867. static SerializeBuffers: boolean;
  22868. /** @hidden */
  22869. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22870. /** @hidden */
  22871. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22872. /** @hidden */
  22873. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22874. /** nearest is mag = nearest and min = nearest and mip = linear */
  22875. static readonly NEAREST_SAMPLINGMODE: number;
  22876. /** nearest is mag = nearest and min = nearest and mip = linear */
  22877. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22878. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22879. static readonly BILINEAR_SAMPLINGMODE: number;
  22880. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22881. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22882. /** Trilinear is mag = linear and min = linear and mip = linear */
  22883. static readonly TRILINEAR_SAMPLINGMODE: number;
  22884. /** Trilinear is mag = linear and min = linear and mip = linear */
  22885. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22886. /** mag = nearest and min = nearest and mip = nearest */
  22887. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22888. /** mag = nearest and min = linear and mip = nearest */
  22889. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22890. /** mag = nearest and min = linear and mip = linear */
  22891. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22892. /** mag = nearest and min = linear and mip = none */
  22893. static readonly NEAREST_LINEAR: number;
  22894. /** mag = nearest and min = nearest and mip = none */
  22895. static readonly NEAREST_NEAREST: number;
  22896. /** mag = linear and min = nearest and mip = nearest */
  22897. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22898. /** mag = linear and min = nearest and mip = linear */
  22899. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22900. /** mag = linear and min = linear and mip = none */
  22901. static readonly LINEAR_LINEAR: number;
  22902. /** mag = linear and min = nearest and mip = none */
  22903. static readonly LINEAR_NEAREST: number;
  22904. /** Explicit coordinates mode */
  22905. static readonly EXPLICIT_MODE: number;
  22906. /** Spherical coordinates mode */
  22907. static readonly SPHERICAL_MODE: number;
  22908. /** Planar coordinates mode */
  22909. static readonly PLANAR_MODE: number;
  22910. /** Cubic coordinates mode */
  22911. static readonly CUBIC_MODE: number;
  22912. /** Projection coordinates mode */
  22913. static readonly PROJECTION_MODE: number;
  22914. /** Inverse Cubic coordinates mode */
  22915. static readonly SKYBOX_MODE: number;
  22916. /** Inverse Cubic coordinates mode */
  22917. static readonly INVCUBIC_MODE: number;
  22918. /** Equirectangular coordinates mode */
  22919. static readonly EQUIRECTANGULAR_MODE: number;
  22920. /** Equirectangular Fixed coordinates mode */
  22921. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22922. /** Equirectangular Fixed Mirrored coordinates mode */
  22923. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22924. /** Texture is not repeating outside of 0..1 UVs */
  22925. static readonly CLAMP_ADDRESSMODE: number;
  22926. /** Texture is repeating outside of 0..1 UVs */
  22927. static readonly WRAP_ADDRESSMODE: number;
  22928. /** Texture is repeating and mirrored */
  22929. static readonly MIRROR_ADDRESSMODE: number;
  22930. /**
  22931. * 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
  22932. */
  22933. static UseSerializedUrlIfAny: boolean;
  22934. /**
  22935. * Define the url of the texture.
  22936. */
  22937. url: Nullable<string>;
  22938. /**
  22939. * Define an offset on the texture to offset the u coordinates of the UVs
  22940. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22941. */
  22942. uOffset: number;
  22943. /**
  22944. * Define an offset on the texture to offset the v coordinates of the UVs
  22945. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22946. */
  22947. vOffset: number;
  22948. /**
  22949. * Define an offset on the texture to scale the u coordinates of the UVs
  22950. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22951. */
  22952. uScale: number;
  22953. /**
  22954. * Define an offset on the texture to scale the v coordinates of the UVs
  22955. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22956. */
  22957. vScale: number;
  22958. /**
  22959. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22960. * @see http://doc.babylonjs.com/how_to/more_materials
  22961. */
  22962. uAng: number;
  22963. /**
  22964. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22965. * @see http://doc.babylonjs.com/how_to/more_materials
  22966. */
  22967. vAng: number;
  22968. /**
  22969. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22970. * @see http://doc.babylonjs.com/how_to/more_materials
  22971. */
  22972. wAng: number;
  22973. /**
  22974. * Defines the center of rotation (U)
  22975. */
  22976. uRotationCenter: number;
  22977. /**
  22978. * Defines the center of rotation (V)
  22979. */
  22980. vRotationCenter: number;
  22981. /**
  22982. * Defines the center of rotation (W)
  22983. */
  22984. wRotationCenter: number;
  22985. /**
  22986. * Are mip maps generated for this texture or not.
  22987. */
  22988. get noMipmap(): boolean;
  22989. /**
  22990. * List of inspectable custom properties (used by the Inspector)
  22991. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22992. */
  22993. inspectableCustomProperties: Nullable<IInspectable[]>;
  22994. private _noMipmap;
  22995. /** @hidden */
  22996. _invertY: boolean;
  22997. private _rowGenerationMatrix;
  22998. private _cachedTextureMatrix;
  22999. private _projectionModeMatrix;
  23000. private _t0;
  23001. private _t1;
  23002. private _t2;
  23003. private _cachedUOffset;
  23004. private _cachedVOffset;
  23005. private _cachedUScale;
  23006. private _cachedVScale;
  23007. private _cachedUAng;
  23008. private _cachedVAng;
  23009. private _cachedWAng;
  23010. private _cachedProjectionMatrixId;
  23011. private _cachedCoordinatesMode;
  23012. /** @hidden */
  23013. protected _initialSamplingMode: number;
  23014. /** @hidden */
  23015. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23016. private _deleteBuffer;
  23017. protected _format: Nullable<number>;
  23018. private _delayedOnLoad;
  23019. private _delayedOnError;
  23020. private _mimeType?;
  23021. /**
  23022. * Observable triggered once the texture has been loaded.
  23023. */
  23024. onLoadObservable: Observable<Texture>;
  23025. protected _isBlocking: boolean;
  23026. /**
  23027. * Is the texture preventing material to render while loading.
  23028. * If false, a default texture will be used instead of the loading one during the preparation step.
  23029. */
  23030. set isBlocking(value: boolean);
  23031. get isBlocking(): boolean;
  23032. /**
  23033. * Get the current sampling mode associated with the texture.
  23034. */
  23035. get samplingMode(): number;
  23036. /**
  23037. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23038. */
  23039. get invertY(): boolean;
  23040. /**
  23041. * Instantiates a new texture.
  23042. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23043. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23044. * @param url defines the url of the picture to load as a texture
  23045. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23046. * @param noMipmap defines if the texture will require mip maps or not
  23047. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23048. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23049. * @param onLoad defines a callback triggered when the texture has been loaded
  23050. * @param onError defines a callback triggered when an error occurred during the loading session
  23051. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23052. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23053. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23054. * @param mimeType defines an optional mime type information
  23055. */
  23056. 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);
  23057. /**
  23058. * Update the url (and optional buffer) of this texture if url was null during construction.
  23059. * @param url the url of the texture
  23060. * @param buffer the buffer of the texture (defaults to null)
  23061. * @param onLoad callback called when the texture is loaded (defaults to null)
  23062. */
  23063. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23064. /**
  23065. * Finish the loading sequence of a texture flagged as delayed load.
  23066. * @hidden
  23067. */
  23068. delayLoad(): void;
  23069. private _prepareRowForTextureGeneration;
  23070. /**
  23071. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23072. * @returns the transform matrix of the texture.
  23073. */
  23074. getTextureMatrix(uBase?: number): Matrix;
  23075. /**
  23076. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23077. * @returns The reflection texture transform
  23078. */
  23079. getReflectionTextureMatrix(): Matrix;
  23080. /**
  23081. * Clones the texture.
  23082. * @returns the cloned texture
  23083. */
  23084. clone(): Texture;
  23085. /**
  23086. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23087. * @returns The JSON representation of the texture
  23088. */
  23089. serialize(): any;
  23090. /**
  23091. * Get the current class name of the texture useful for serialization or dynamic coding.
  23092. * @returns "Texture"
  23093. */
  23094. getClassName(): string;
  23095. /**
  23096. * Dispose the texture and release its associated resources.
  23097. */
  23098. dispose(): void;
  23099. /**
  23100. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23101. * @param parsedTexture Define the JSON representation of the texture
  23102. * @param scene Define the scene the parsed texture should be instantiated in
  23103. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23104. * @returns The parsed texture if successful
  23105. */
  23106. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23107. /**
  23108. * Creates a texture from its base 64 representation.
  23109. * @param data Define the base64 payload without the data: prefix
  23110. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23111. * @param scene Define the scene the texture should belong to
  23112. * @param noMipmap Forces the texture to not create mip map information if true
  23113. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23114. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23115. * @param onLoad define a callback triggered when the texture has been loaded
  23116. * @param onError define a callback triggered when an error occurred during the loading session
  23117. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23118. * @returns the created texture
  23119. */
  23120. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23121. /**
  23122. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23123. * @param data Define the base64 payload without the data: prefix
  23124. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23125. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23126. * @param scene Define the scene the texture should belong to
  23127. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23128. * @param noMipmap Forces the texture to not create mip map information if true
  23129. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23130. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23131. * @param onLoad define a callback triggered when the texture has been loaded
  23132. * @param onError define a callback triggered when an error occurred during the loading session
  23133. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23134. * @returns the created texture
  23135. */
  23136. 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;
  23137. }
  23138. }
  23139. declare module BABYLON {
  23140. /**
  23141. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23142. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23143. */
  23144. export class PostProcessManager {
  23145. private _scene;
  23146. private _indexBuffer;
  23147. private _vertexBuffers;
  23148. /**
  23149. * Creates a new instance PostProcess
  23150. * @param scene The scene that the post process is associated with.
  23151. */
  23152. constructor(scene: Scene);
  23153. private _prepareBuffers;
  23154. private _buildIndexBuffer;
  23155. /**
  23156. * Rebuilds the vertex buffers of the manager.
  23157. * @hidden
  23158. */
  23159. _rebuild(): void;
  23160. /**
  23161. * Prepares a frame to be run through a post process.
  23162. * @param sourceTexture The input texture to the post procesess. (default: null)
  23163. * @param postProcesses An array of post processes to be run. (default: null)
  23164. * @returns True if the post processes were able to be run.
  23165. * @hidden
  23166. */
  23167. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23168. /**
  23169. * Manually render a set of post processes to a texture.
  23170. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23171. * @param postProcesses An array of post processes to be run.
  23172. * @param targetTexture The target texture to render to.
  23173. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23174. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23175. * @param lodLevel defines which lod of the texture to render to
  23176. */
  23177. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23178. /**
  23179. * Finalize the result of the output of the postprocesses.
  23180. * @param doNotPresent If true the result will not be displayed to the screen.
  23181. * @param targetTexture The target texture to render to.
  23182. * @param faceIndex The index of the face to bind the target texture to.
  23183. * @param postProcesses The array of post processes to render.
  23184. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23185. * @hidden
  23186. */
  23187. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23188. /**
  23189. * Disposes of the post process manager.
  23190. */
  23191. dispose(): void;
  23192. }
  23193. }
  23194. declare module BABYLON {
  23195. /**
  23196. * This Helps creating a texture that will be created from a camera in your scene.
  23197. * It is basically a dynamic texture that could be used to create special effects for instance.
  23198. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23199. */
  23200. export class RenderTargetTexture extends Texture {
  23201. isCube: boolean;
  23202. /**
  23203. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23204. */
  23205. static readonly REFRESHRATE_RENDER_ONCE: number;
  23206. /**
  23207. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23208. */
  23209. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23210. /**
  23211. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23212. * the central point of your effect and can save a lot of performances.
  23213. */
  23214. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23215. /**
  23216. * Use this predicate to dynamically define the list of mesh you want to render.
  23217. * If set, the renderList property will be overwritten.
  23218. */
  23219. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23220. private _renderList;
  23221. /**
  23222. * Use this list to define the list of mesh you want to render.
  23223. */
  23224. get renderList(): Nullable<Array<AbstractMesh>>;
  23225. set renderList(value: Nullable<Array<AbstractMesh>>);
  23226. /**
  23227. * Use this function to overload the renderList array at rendering time.
  23228. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23229. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23230. * the cube (if the RTT is a cube, else layerOrFace=0).
  23231. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23232. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23233. * hold dummy elements!
  23234. */
  23235. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23236. private _hookArray;
  23237. /**
  23238. * Define if particles should be rendered in your texture.
  23239. */
  23240. renderParticles: boolean;
  23241. /**
  23242. * Define if sprites should be rendered in your texture.
  23243. */
  23244. renderSprites: boolean;
  23245. /**
  23246. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23247. */
  23248. coordinatesMode: number;
  23249. /**
  23250. * Define the camera used to render the texture.
  23251. */
  23252. activeCamera: Nullable<Camera>;
  23253. /**
  23254. * Override the mesh isReady function with your own one.
  23255. */
  23256. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23257. /**
  23258. * Override the render function of the texture with your own one.
  23259. */
  23260. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23261. /**
  23262. * Define if camera post processes should be use while rendering the texture.
  23263. */
  23264. useCameraPostProcesses: boolean;
  23265. /**
  23266. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23267. */
  23268. ignoreCameraViewport: boolean;
  23269. private _postProcessManager;
  23270. private _postProcesses;
  23271. private _resizeObserver;
  23272. /**
  23273. * An event triggered when the texture is unbind.
  23274. */
  23275. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23276. /**
  23277. * An event triggered when the texture is unbind.
  23278. */
  23279. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23280. private _onAfterUnbindObserver;
  23281. /**
  23282. * Set a after unbind callback in the texture.
  23283. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23284. */
  23285. set onAfterUnbind(callback: () => void);
  23286. /**
  23287. * An event triggered before rendering the texture
  23288. */
  23289. onBeforeRenderObservable: Observable<number>;
  23290. private _onBeforeRenderObserver;
  23291. /**
  23292. * Set a before render callback in the texture.
  23293. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23294. */
  23295. set onBeforeRender(callback: (faceIndex: number) => void);
  23296. /**
  23297. * An event triggered after rendering the texture
  23298. */
  23299. onAfterRenderObservable: Observable<number>;
  23300. private _onAfterRenderObserver;
  23301. /**
  23302. * Set a after render callback in the texture.
  23303. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23304. */
  23305. set onAfterRender(callback: (faceIndex: number) => void);
  23306. /**
  23307. * An event triggered after the texture clear
  23308. */
  23309. onClearObservable: Observable<Engine>;
  23310. private _onClearObserver;
  23311. /**
  23312. * Set a clear callback in the texture.
  23313. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23314. */
  23315. set onClear(callback: (Engine: Engine) => void);
  23316. /**
  23317. * An event triggered when the texture is resized.
  23318. */
  23319. onResizeObservable: Observable<RenderTargetTexture>;
  23320. /**
  23321. * Define the clear color of the Render Target if it should be different from the scene.
  23322. */
  23323. clearColor: Color4;
  23324. protected _size: number | {
  23325. width: number;
  23326. height: number;
  23327. layers?: number;
  23328. };
  23329. protected _initialSizeParameter: number | {
  23330. width: number;
  23331. height: number;
  23332. } | {
  23333. ratio: number;
  23334. };
  23335. protected _sizeRatio: Nullable<number>;
  23336. /** @hidden */
  23337. _generateMipMaps: boolean;
  23338. protected _renderingManager: RenderingManager;
  23339. /** @hidden */
  23340. _waitingRenderList: string[];
  23341. protected _doNotChangeAspectRatio: boolean;
  23342. protected _currentRefreshId: number;
  23343. protected _refreshRate: number;
  23344. protected _textureMatrix: Matrix;
  23345. protected _samples: number;
  23346. protected _renderTargetOptions: RenderTargetCreationOptions;
  23347. /**
  23348. * Gets render target creation options that were used.
  23349. */
  23350. get renderTargetOptions(): RenderTargetCreationOptions;
  23351. protected _onRatioRescale(): void;
  23352. /**
  23353. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23354. * It must define where the camera used to render the texture is set
  23355. */
  23356. boundingBoxPosition: Vector3;
  23357. private _boundingBoxSize;
  23358. /**
  23359. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23360. * When defined, the cubemap will switch to local mode
  23361. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23362. * @example https://www.babylonjs-playground.com/#RNASML
  23363. */
  23364. set boundingBoxSize(value: Vector3);
  23365. get boundingBoxSize(): Vector3;
  23366. /**
  23367. * In case the RTT has been created with a depth texture, get the associated
  23368. * depth texture.
  23369. * Otherwise, return null.
  23370. */
  23371. get depthStencilTexture(): Nullable<InternalTexture>;
  23372. /**
  23373. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23374. * or used a shadow, depth texture...
  23375. * @param name The friendly name of the texture
  23376. * @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)
  23377. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23378. * @param generateMipMaps True if mip maps need to be generated after render.
  23379. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23380. * @param type The type of the buffer in the RTT (int, half float, float...)
  23381. * @param isCube True if a cube texture needs to be created
  23382. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23383. * @param generateDepthBuffer True to generate a depth buffer
  23384. * @param generateStencilBuffer True to generate a stencil buffer
  23385. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23386. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23387. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23388. */
  23389. constructor(name: string, size: number | {
  23390. width: number;
  23391. height: number;
  23392. layers?: number;
  23393. } | {
  23394. ratio: number;
  23395. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23396. /**
  23397. * Creates a depth stencil texture.
  23398. * This is only available in WebGL 2 or with the depth texture extension available.
  23399. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23400. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23401. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23402. */
  23403. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23404. private _processSizeParameter;
  23405. /**
  23406. * Define the number of samples to use in case of MSAA.
  23407. * It defaults to one meaning no MSAA has been enabled.
  23408. */
  23409. get samples(): number;
  23410. set samples(value: number);
  23411. /**
  23412. * Resets the refresh counter of the texture and start bak from scratch.
  23413. * Could be useful to regenerate the texture if it is setup to render only once.
  23414. */
  23415. resetRefreshCounter(): void;
  23416. /**
  23417. * Define the refresh rate of the texture or the rendering frequency.
  23418. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23419. */
  23420. get refreshRate(): number;
  23421. set refreshRate(value: number);
  23422. /**
  23423. * Adds a post process to the render target rendering passes.
  23424. * @param postProcess define the post process to add
  23425. */
  23426. addPostProcess(postProcess: PostProcess): void;
  23427. /**
  23428. * Clear all the post processes attached to the render target
  23429. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23430. */
  23431. clearPostProcesses(dispose?: boolean): void;
  23432. /**
  23433. * Remove one of the post process from the list of attached post processes to the texture
  23434. * @param postProcess define the post process to remove from the list
  23435. */
  23436. removePostProcess(postProcess: PostProcess): void;
  23437. /** @hidden */
  23438. _shouldRender(): boolean;
  23439. /**
  23440. * Gets the actual render size of the texture.
  23441. * @returns the width of the render size
  23442. */
  23443. getRenderSize(): number;
  23444. /**
  23445. * Gets the actual render width of the texture.
  23446. * @returns the width of the render size
  23447. */
  23448. getRenderWidth(): number;
  23449. /**
  23450. * Gets the actual render height of the texture.
  23451. * @returns the height of the render size
  23452. */
  23453. getRenderHeight(): number;
  23454. /**
  23455. * Gets the actual number of layers of the texture.
  23456. * @returns the number of layers
  23457. */
  23458. getRenderLayers(): number;
  23459. /**
  23460. * Get if the texture can be rescaled or not.
  23461. */
  23462. get canRescale(): boolean;
  23463. /**
  23464. * Resize the texture using a ratio.
  23465. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23466. */
  23467. scale(ratio: number): void;
  23468. /**
  23469. * Get the texture reflection matrix used to rotate/transform the reflection.
  23470. * @returns the reflection matrix
  23471. */
  23472. getReflectionTextureMatrix(): Matrix;
  23473. /**
  23474. * Resize the texture to a new desired size.
  23475. * Be carrefull as it will recreate all the data in the new texture.
  23476. * @param size Define the new size. It can be:
  23477. * - a number for squared texture,
  23478. * - an object containing { width: number, height: number }
  23479. * - or an object containing a ratio { ratio: number }
  23480. */
  23481. resize(size: number | {
  23482. width: number;
  23483. height: number;
  23484. } | {
  23485. ratio: number;
  23486. }): void;
  23487. private _defaultRenderListPrepared;
  23488. /**
  23489. * Renders all the objects from the render list into the texture.
  23490. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23491. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23492. */
  23493. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23494. private _bestReflectionRenderTargetDimension;
  23495. private _prepareRenderingManager;
  23496. /**
  23497. * @hidden
  23498. * @param faceIndex face index to bind to if this is a cubetexture
  23499. * @param layer defines the index of the texture to bind in the array
  23500. */
  23501. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23502. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23503. private renderToTarget;
  23504. /**
  23505. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23506. * This allowed control for front to back rendering or reversly depending of the special needs.
  23507. *
  23508. * @param renderingGroupId The rendering group id corresponding to its index
  23509. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23510. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23511. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23512. */
  23513. 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;
  23514. /**
  23515. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23516. *
  23517. * @param renderingGroupId The rendering group id corresponding to its index
  23518. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23519. */
  23520. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23521. /**
  23522. * Clones the texture.
  23523. * @returns the cloned texture
  23524. */
  23525. clone(): RenderTargetTexture;
  23526. /**
  23527. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23528. * @returns The JSON representation of the texture
  23529. */
  23530. serialize(): any;
  23531. /**
  23532. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23533. */
  23534. disposeFramebufferObjects(): void;
  23535. /**
  23536. * Dispose the texture and release its associated resources.
  23537. */
  23538. dispose(): void;
  23539. /** @hidden */
  23540. _rebuild(): void;
  23541. /**
  23542. * Clear the info related to rendering groups preventing retention point in material dispose.
  23543. */
  23544. freeRenderingGroups(): void;
  23545. /**
  23546. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23547. * @returns the view count
  23548. */
  23549. getViewCount(): number;
  23550. }
  23551. }
  23552. declare module BABYLON {
  23553. /**
  23554. * Class used to manipulate GUIDs
  23555. */
  23556. export class GUID {
  23557. /**
  23558. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23559. * Be aware Math.random() could cause collisions, but:
  23560. * "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"
  23561. * @returns a pseudo random id
  23562. */
  23563. static RandomId(): string;
  23564. }
  23565. }
  23566. declare module BABYLON {
  23567. /**
  23568. * Options to be used when creating a shadow depth material
  23569. */
  23570. export interface IIOptionShadowDepthMaterial {
  23571. /** Variables in the vertex shader code that need to have their names remapped.
  23572. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23573. * "var_name" should be either: worldPos or vNormalW
  23574. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23575. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23576. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23577. */
  23578. remappedVariables?: string[];
  23579. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23580. standalone?: boolean;
  23581. }
  23582. /**
  23583. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23584. */
  23585. export class ShadowDepthWrapper {
  23586. private _scene;
  23587. private _options?;
  23588. private _baseMaterial;
  23589. private _onEffectCreatedObserver;
  23590. private _subMeshToEffect;
  23591. private _subMeshToDepthEffect;
  23592. private _meshes;
  23593. /** @hidden */
  23594. _matriceNames: any;
  23595. /** Gets the standalone status of the wrapper */
  23596. get standalone(): boolean;
  23597. /** Gets the base material the wrapper is built upon */
  23598. get baseMaterial(): Material;
  23599. /**
  23600. * Instantiate a new shadow depth wrapper.
  23601. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23602. * generate the shadow depth map. For more information, please refer to the documentation:
  23603. * https://doc.babylonjs.com/babylon101/shadows
  23604. * @param baseMaterial Material to wrap
  23605. * @param scene Define the scene the material belongs to
  23606. * @param options Options used to create the wrapper
  23607. */
  23608. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23609. /**
  23610. * Gets the effect to use to generate the depth map
  23611. * @param subMesh subMesh to get the effect for
  23612. * @param shadowGenerator shadow generator to get the effect for
  23613. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23614. */
  23615. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23616. /**
  23617. * Specifies that the submesh is ready to be used for depth rendering
  23618. * @param subMesh submesh to check
  23619. * @param defines the list of defines to take into account when checking the effect
  23620. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23621. * @param useInstances specifies that instances should be used
  23622. * @returns a boolean indicating that the submesh is ready or not
  23623. */
  23624. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23625. /**
  23626. * Disposes the resources
  23627. */
  23628. dispose(): void;
  23629. private _makeEffect;
  23630. }
  23631. }
  23632. declare module BABYLON {
  23633. /**
  23634. * Options for compiling materials.
  23635. */
  23636. export interface IMaterialCompilationOptions {
  23637. /**
  23638. * Defines whether clip planes are enabled.
  23639. */
  23640. clipPlane: boolean;
  23641. /**
  23642. * Defines whether instances are enabled.
  23643. */
  23644. useInstances: boolean;
  23645. }
  23646. /**
  23647. * Options passed when calling customShaderNameResolve
  23648. */
  23649. export interface ICustomShaderNameResolveOptions {
  23650. /**
  23651. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  23652. */
  23653. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  23654. }
  23655. /**
  23656. * Base class for the main features of a material in Babylon.js
  23657. */
  23658. export class Material implements IAnimatable {
  23659. /**
  23660. * Returns the triangle fill mode
  23661. */
  23662. static readonly TriangleFillMode: number;
  23663. /**
  23664. * Returns the wireframe mode
  23665. */
  23666. static readonly WireFrameFillMode: number;
  23667. /**
  23668. * Returns the point fill mode
  23669. */
  23670. static readonly PointFillMode: number;
  23671. /**
  23672. * Returns the point list draw mode
  23673. */
  23674. static readonly PointListDrawMode: number;
  23675. /**
  23676. * Returns the line list draw mode
  23677. */
  23678. static readonly LineListDrawMode: number;
  23679. /**
  23680. * Returns the line loop draw mode
  23681. */
  23682. static readonly LineLoopDrawMode: number;
  23683. /**
  23684. * Returns the line strip draw mode
  23685. */
  23686. static readonly LineStripDrawMode: number;
  23687. /**
  23688. * Returns the triangle strip draw mode
  23689. */
  23690. static readonly TriangleStripDrawMode: number;
  23691. /**
  23692. * Returns the triangle fan draw mode
  23693. */
  23694. static readonly TriangleFanDrawMode: number;
  23695. /**
  23696. * Stores the clock-wise side orientation
  23697. */
  23698. static readonly ClockWiseSideOrientation: number;
  23699. /**
  23700. * Stores the counter clock-wise side orientation
  23701. */
  23702. static readonly CounterClockWiseSideOrientation: number;
  23703. /**
  23704. * The dirty texture flag value
  23705. */
  23706. static readonly TextureDirtyFlag: number;
  23707. /**
  23708. * The dirty light flag value
  23709. */
  23710. static readonly LightDirtyFlag: number;
  23711. /**
  23712. * The dirty fresnel flag value
  23713. */
  23714. static readonly FresnelDirtyFlag: number;
  23715. /**
  23716. * The dirty attribute flag value
  23717. */
  23718. static readonly AttributesDirtyFlag: number;
  23719. /**
  23720. * The dirty misc flag value
  23721. */
  23722. static readonly MiscDirtyFlag: number;
  23723. /**
  23724. * The all dirty flag value
  23725. */
  23726. static readonly AllDirtyFlag: number;
  23727. /**
  23728. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23729. */
  23730. static readonly MATERIAL_OPAQUE: number;
  23731. /**
  23732. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23733. */
  23734. static readonly MATERIAL_ALPHATEST: number;
  23735. /**
  23736. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23737. */
  23738. static readonly MATERIAL_ALPHABLEND: number;
  23739. /**
  23740. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23741. * They are also discarded below the alpha cutoff threshold to improve performances.
  23742. */
  23743. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23744. /**
  23745. * Custom callback helping to override the default shader used in the material.
  23746. */
  23747. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  23748. /**
  23749. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23750. */
  23751. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23752. /**
  23753. * The ID of the material
  23754. */
  23755. id: string;
  23756. /**
  23757. * Gets or sets the unique id of the material
  23758. */
  23759. uniqueId: number;
  23760. /**
  23761. * The name of the material
  23762. */
  23763. name: string;
  23764. /**
  23765. * Gets or sets user defined metadata
  23766. */
  23767. metadata: any;
  23768. /**
  23769. * For internal use only. Please do not use.
  23770. */
  23771. reservedDataStore: any;
  23772. /**
  23773. * Specifies if the ready state should be checked on each call
  23774. */
  23775. checkReadyOnEveryCall: boolean;
  23776. /**
  23777. * Specifies if the ready state should be checked once
  23778. */
  23779. checkReadyOnlyOnce: boolean;
  23780. /**
  23781. * The state of the material
  23782. */
  23783. state: string;
  23784. /**
  23785. * The alpha value of the material
  23786. */
  23787. protected _alpha: number;
  23788. /**
  23789. * List of inspectable custom properties (used by the Inspector)
  23790. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23791. */
  23792. inspectableCustomProperties: IInspectable[];
  23793. /**
  23794. * Sets the alpha value of the material
  23795. */
  23796. set alpha(value: number);
  23797. /**
  23798. * Gets the alpha value of the material
  23799. */
  23800. get alpha(): number;
  23801. /**
  23802. * Specifies if back face culling is enabled
  23803. */
  23804. protected _backFaceCulling: boolean;
  23805. /**
  23806. * Sets the back-face culling state
  23807. */
  23808. set backFaceCulling(value: boolean);
  23809. /**
  23810. * Gets the back-face culling state
  23811. */
  23812. get backFaceCulling(): boolean;
  23813. /**
  23814. * Stores the value for side orientation
  23815. */
  23816. sideOrientation: number;
  23817. /**
  23818. * Callback triggered when the material is compiled
  23819. */
  23820. onCompiled: Nullable<(effect: Effect) => void>;
  23821. /**
  23822. * Callback triggered when an error occurs
  23823. */
  23824. onError: Nullable<(effect: Effect, errors: string) => void>;
  23825. /**
  23826. * Callback triggered to get the render target textures
  23827. */
  23828. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23829. /**
  23830. * Gets a boolean indicating that current material needs to register RTT
  23831. */
  23832. get hasRenderTargetTextures(): boolean;
  23833. /**
  23834. * Specifies if the material should be serialized
  23835. */
  23836. doNotSerialize: boolean;
  23837. /**
  23838. * @hidden
  23839. */
  23840. _storeEffectOnSubMeshes: boolean;
  23841. /**
  23842. * Stores the animations for the material
  23843. */
  23844. animations: Nullable<Array<Animation>>;
  23845. /**
  23846. * An event triggered when the material is disposed
  23847. */
  23848. onDisposeObservable: Observable<Material>;
  23849. /**
  23850. * An observer which watches for dispose events
  23851. */
  23852. private _onDisposeObserver;
  23853. private _onUnBindObservable;
  23854. /**
  23855. * Called during a dispose event
  23856. */
  23857. set onDispose(callback: () => void);
  23858. private _onBindObservable;
  23859. /**
  23860. * An event triggered when the material is bound
  23861. */
  23862. get onBindObservable(): Observable<AbstractMesh>;
  23863. /**
  23864. * An observer which watches for bind events
  23865. */
  23866. private _onBindObserver;
  23867. /**
  23868. * Called during a bind event
  23869. */
  23870. set onBind(callback: (Mesh: AbstractMesh) => void);
  23871. /**
  23872. * An event triggered when the material is unbound
  23873. */
  23874. get onUnBindObservable(): Observable<Material>;
  23875. protected _onEffectCreatedObservable: Nullable<Observable<{
  23876. effect: Effect;
  23877. subMesh: Nullable<SubMesh>;
  23878. }>>;
  23879. /**
  23880. * An event triggered when the effect is (re)created
  23881. */
  23882. get onEffectCreatedObservable(): Observable<{
  23883. effect: Effect;
  23884. subMesh: Nullable<SubMesh>;
  23885. }>;
  23886. /**
  23887. * Stores the value of the alpha mode
  23888. */
  23889. private _alphaMode;
  23890. /**
  23891. * Sets the value of the alpha mode.
  23892. *
  23893. * | Value | Type | Description |
  23894. * | --- | --- | --- |
  23895. * | 0 | ALPHA_DISABLE | |
  23896. * | 1 | ALPHA_ADD | |
  23897. * | 2 | ALPHA_COMBINE | |
  23898. * | 3 | ALPHA_SUBTRACT | |
  23899. * | 4 | ALPHA_MULTIPLY | |
  23900. * | 5 | ALPHA_MAXIMIZED | |
  23901. * | 6 | ALPHA_ONEONE | |
  23902. * | 7 | ALPHA_PREMULTIPLIED | |
  23903. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23904. * | 9 | ALPHA_INTERPOLATE | |
  23905. * | 10 | ALPHA_SCREENMODE | |
  23906. *
  23907. */
  23908. set alphaMode(value: number);
  23909. /**
  23910. * Gets the value of the alpha mode
  23911. */
  23912. get alphaMode(): number;
  23913. /**
  23914. * Stores the state of the need depth pre-pass value
  23915. */
  23916. private _needDepthPrePass;
  23917. /**
  23918. * Sets the need depth pre-pass value
  23919. */
  23920. set needDepthPrePass(value: boolean);
  23921. /**
  23922. * Gets the depth pre-pass value
  23923. */
  23924. get needDepthPrePass(): boolean;
  23925. /**
  23926. * Specifies if depth writing should be disabled
  23927. */
  23928. disableDepthWrite: boolean;
  23929. /**
  23930. * Specifies if color writing should be disabled
  23931. */
  23932. disableColorWrite: boolean;
  23933. /**
  23934. * Specifies if depth writing should be forced
  23935. */
  23936. forceDepthWrite: boolean;
  23937. /**
  23938. * Specifies the depth function that should be used. 0 means the default engine function
  23939. */
  23940. depthFunction: number;
  23941. /**
  23942. * Specifies if there should be a separate pass for culling
  23943. */
  23944. separateCullingPass: boolean;
  23945. /**
  23946. * Stores the state specifing if fog should be enabled
  23947. */
  23948. private _fogEnabled;
  23949. /**
  23950. * Sets the state for enabling fog
  23951. */
  23952. set fogEnabled(value: boolean);
  23953. /**
  23954. * Gets the value of the fog enabled state
  23955. */
  23956. get fogEnabled(): boolean;
  23957. /**
  23958. * Stores the size of points
  23959. */
  23960. pointSize: number;
  23961. /**
  23962. * Stores the z offset value
  23963. */
  23964. zOffset: number;
  23965. get wireframe(): boolean;
  23966. /**
  23967. * Sets the state of wireframe mode
  23968. */
  23969. set wireframe(value: boolean);
  23970. /**
  23971. * Gets the value specifying if point clouds are enabled
  23972. */
  23973. get pointsCloud(): boolean;
  23974. /**
  23975. * Sets the state of point cloud mode
  23976. */
  23977. set pointsCloud(value: boolean);
  23978. /**
  23979. * Gets the material fill mode
  23980. */
  23981. get fillMode(): number;
  23982. /**
  23983. * Sets the material fill mode
  23984. */
  23985. set fillMode(value: number);
  23986. /**
  23987. * @hidden
  23988. * Stores the effects for the material
  23989. */
  23990. _effect: Nullable<Effect>;
  23991. /**
  23992. * Specifies if uniform buffers should be used
  23993. */
  23994. private _useUBO;
  23995. /**
  23996. * Stores a reference to the scene
  23997. */
  23998. private _scene;
  23999. /**
  24000. * Stores the fill mode state
  24001. */
  24002. private _fillMode;
  24003. /**
  24004. * Specifies if the depth write state should be cached
  24005. */
  24006. private _cachedDepthWriteState;
  24007. /**
  24008. * Specifies if the color write state should be cached
  24009. */
  24010. private _cachedColorWriteState;
  24011. /**
  24012. * Specifies if the depth function state should be cached
  24013. */
  24014. private _cachedDepthFunctionState;
  24015. /**
  24016. * Stores the uniform buffer
  24017. */
  24018. protected _uniformBuffer: UniformBuffer;
  24019. /** @hidden */
  24020. _indexInSceneMaterialArray: number;
  24021. /** @hidden */
  24022. meshMap: Nullable<{
  24023. [id: string]: AbstractMesh | undefined;
  24024. }>;
  24025. /**
  24026. * Creates a material instance
  24027. * @param name defines the name of the material
  24028. * @param scene defines the scene to reference
  24029. * @param doNotAdd specifies if the material should be added to the scene
  24030. */
  24031. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24032. /**
  24033. * Returns a string representation of the current material
  24034. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24035. * @returns a string with material information
  24036. */
  24037. toString(fullDetails?: boolean): string;
  24038. /**
  24039. * Gets the class name of the material
  24040. * @returns a string with the class name of the material
  24041. */
  24042. getClassName(): string;
  24043. /**
  24044. * Specifies if updates for the material been locked
  24045. */
  24046. get isFrozen(): boolean;
  24047. /**
  24048. * Locks updates for the material
  24049. */
  24050. freeze(): void;
  24051. /**
  24052. * Unlocks updates for the material
  24053. */
  24054. unfreeze(): void;
  24055. /**
  24056. * Specifies if the material is ready to be used
  24057. * @param mesh defines the mesh to check
  24058. * @param useInstances specifies if instances should be used
  24059. * @returns a boolean indicating if the material is ready to be used
  24060. */
  24061. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24062. /**
  24063. * Specifies that the submesh is ready to be used
  24064. * @param mesh defines the mesh to check
  24065. * @param subMesh defines which submesh to check
  24066. * @param useInstances specifies that instances should be used
  24067. * @returns a boolean indicating that the submesh is ready or not
  24068. */
  24069. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24070. /**
  24071. * Returns the material effect
  24072. * @returns the effect associated with the material
  24073. */
  24074. getEffect(): Nullable<Effect>;
  24075. /**
  24076. * Returns the current scene
  24077. * @returns a Scene
  24078. */
  24079. getScene(): Scene;
  24080. /**
  24081. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24082. */
  24083. protected _forceAlphaTest: boolean;
  24084. /**
  24085. * The transparency mode of the material.
  24086. */
  24087. protected _transparencyMode: Nullable<number>;
  24088. /**
  24089. * Gets the current transparency mode.
  24090. */
  24091. get transparencyMode(): Nullable<number>;
  24092. /**
  24093. * Sets the transparency mode of the material.
  24094. *
  24095. * | Value | Type | Description |
  24096. * | ----- | ----------------------------------- | ----------- |
  24097. * | 0 | OPAQUE | |
  24098. * | 1 | ALPHATEST | |
  24099. * | 2 | ALPHABLEND | |
  24100. * | 3 | ALPHATESTANDBLEND | |
  24101. *
  24102. */
  24103. set transparencyMode(value: Nullable<number>);
  24104. /**
  24105. * Returns true if alpha blending should be disabled.
  24106. */
  24107. protected get _disableAlphaBlending(): boolean;
  24108. /**
  24109. * Specifies whether or not this material should be rendered in alpha blend mode.
  24110. * @returns a boolean specifying if alpha blending is needed
  24111. */
  24112. needAlphaBlending(): boolean;
  24113. /**
  24114. * Specifies if the mesh will require alpha blending
  24115. * @param mesh defines the mesh to check
  24116. * @returns a boolean specifying if alpha blending is needed for the mesh
  24117. */
  24118. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24119. /**
  24120. * Specifies whether or not this material should be rendered in alpha test mode.
  24121. * @returns a boolean specifying if an alpha test is needed.
  24122. */
  24123. needAlphaTesting(): boolean;
  24124. /**
  24125. * Specifies if material alpha testing should be turned on for the mesh
  24126. * @param mesh defines the mesh to check
  24127. */
  24128. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24129. /**
  24130. * Gets the texture used for the alpha test
  24131. * @returns the texture to use for alpha testing
  24132. */
  24133. getAlphaTestTexture(): Nullable<BaseTexture>;
  24134. /**
  24135. * Marks the material to indicate that it needs to be re-calculated
  24136. */
  24137. markDirty(): void;
  24138. /** @hidden */
  24139. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24140. /**
  24141. * Binds the material to the mesh
  24142. * @param world defines the world transformation matrix
  24143. * @param mesh defines the mesh to bind the material to
  24144. */
  24145. bind(world: Matrix, mesh?: Mesh): void;
  24146. /**
  24147. * Binds the submesh to the material
  24148. * @param world defines the world transformation matrix
  24149. * @param mesh defines the mesh containing the submesh
  24150. * @param subMesh defines the submesh to bind the material to
  24151. */
  24152. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24153. /**
  24154. * Binds the world matrix to the material
  24155. * @param world defines the world transformation matrix
  24156. */
  24157. bindOnlyWorldMatrix(world: Matrix): void;
  24158. /**
  24159. * Binds the scene's uniform buffer to the effect.
  24160. * @param effect defines the effect to bind to the scene uniform buffer
  24161. * @param sceneUbo defines the uniform buffer storing scene data
  24162. */
  24163. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24164. /**
  24165. * Binds the view matrix to the effect
  24166. * @param effect defines the effect to bind the view matrix to
  24167. */
  24168. bindView(effect: Effect): void;
  24169. /**
  24170. * Binds the view projection matrix to the effect
  24171. * @param effect defines the effect to bind the view projection matrix to
  24172. */
  24173. bindViewProjection(effect: Effect): void;
  24174. /**
  24175. * Processes to execute after binding the material to a mesh
  24176. * @param mesh defines the rendered mesh
  24177. */
  24178. protected _afterBind(mesh?: Mesh): void;
  24179. /**
  24180. * Unbinds the material from the mesh
  24181. */
  24182. unbind(): void;
  24183. /**
  24184. * Gets the active textures from the material
  24185. * @returns an array of textures
  24186. */
  24187. getActiveTextures(): BaseTexture[];
  24188. /**
  24189. * Specifies if the material uses a texture
  24190. * @param texture defines the texture to check against the material
  24191. * @returns a boolean specifying if the material uses the texture
  24192. */
  24193. hasTexture(texture: BaseTexture): boolean;
  24194. /**
  24195. * Makes a duplicate of the material, and gives it a new name
  24196. * @param name defines the new name for the duplicated material
  24197. * @returns the cloned material
  24198. */
  24199. clone(name: string): Nullable<Material>;
  24200. /**
  24201. * Gets the meshes bound to the material
  24202. * @returns an array of meshes bound to the material
  24203. */
  24204. getBindedMeshes(): AbstractMesh[];
  24205. /**
  24206. * Force shader compilation
  24207. * @param mesh defines the mesh associated with this material
  24208. * @param onCompiled defines a function to execute once the material is compiled
  24209. * @param options defines the options to configure the compilation
  24210. * @param onError defines a function to execute if the material fails compiling
  24211. */
  24212. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24213. /**
  24214. * Force shader compilation
  24215. * @param mesh defines the mesh that will use this material
  24216. * @param options defines additional options for compiling the shaders
  24217. * @returns a promise that resolves when the compilation completes
  24218. */
  24219. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24220. private static readonly _AllDirtyCallBack;
  24221. private static readonly _ImageProcessingDirtyCallBack;
  24222. private static readonly _TextureDirtyCallBack;
  24223. private static readonly _FresnelDirtyCallBack;
  24224. private static readonly _MiscDirtyCallBack;
  24225. private static readonly _LightsDirtyCallBack;
  24226. private static readonly _AttributeDirtyCallBack;
  24227. private static _FresnelAndMiscDirtyCallBack;
  24228. private static _TextureAndMiscDirtyCallBack;
  24229. private static readonly _DirtyCallbackArray;
  24230. private static readonly _RunDirtyCallBacks;
  24231. /**
  24232. * Marks a define in the material to indicate that it needs to be re-computed
  24233. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24234. */
  24235. markAsDirty(flag: number): void;
  24236. /**
  24237. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24238. * @param func defines a function which checks material defines against the submeshes
  24239. */
  24240. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24241. /**
  24242. * Indicates that we need to re-calculated for all submeshes
  24243. */
  24244. protected _markAllSubMeshesAsAllDirty(): void;
  24245. /**
  24246. * Indicates that image processing needs to be re-calculated for all submeshes
  24247. */
  24248. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24249. /**
  24250. * Indicates that textures need to be re-calculated for all submeshes
  24251. */
  24252. protected _markAllSubMeshesAsTexturesDirty(): void;
  24253. /**
  24254. * Indicates that fresnel needs to be re-calculated for all submeshes
  24255. */
  24256. protected _markAllSubMeshesAsFresnelDirty(): void;
  24257. /**
  24258. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24259. */
  24260. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24261. /**
  24262. * Indicates that lights need to be re-calculated for all submeshes
  24263. */
  24264. protected _markAllSubMeshesAsLightsDirty(): void;
  24265. /**
  24266. * Indicates that attributes need to be re-calculated for all submeshes
  24267. */
  24268. protected _markAllSubMeshesAsAttributesDirty(): void;
  24269. /**
  24270. * Indicates that misc needs to be re-calculated for all submeshes
  24271. */
  24272. protected _markAllSubMeshesAsMiscDirty(): void;
  24273. /**
  24274. * Indicates that textures and misc need to be re-calculated for all submeshes
  24275. */
  24276. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24277. /**
  24278. * Disposes the material
  24279. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24280. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24281. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24282. */
  24283. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24284. /** @hidden */
  24285. private releaseVertexArrayObject;
  24286. /**
  24287. * Serializes this material
  24288. * @returns the serialized material object
  24289. */
  24290. serialize(): any;
  24291. /**
  24292. * Creates a material from parsed material data
  24293. * @param parsedMaterial defines parsed material data
  24294. * @param scene defines the hosting scene
  24295. * @param rootUrl defines the root URL to use to load textures
  24296. * @returns a new material
  24297. */
  24298. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24299. }
  24300. }
  24301. declare module BABYLON {
  24302. /**
  24303. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24304. * separate meshes. This can be use to improve performances.
  24305. * @see http://doc.babylonjs.com/how_to/multi_materials
  24306. */
  24307. export class MultiMaterial extends Material {
  24308. private _subMaterials;
  24309. /**
  24310. * Gets or Sets the list of Materials used within the multi material.
  24311. * They need to be ordered according to the submeshes order in the associated mesh
  24312. */
  24313. get subMaterials(): Nullable<Material>[];
  24314. set subMaterials(value: Nullable<Material>[]);
  24315. /**
  24316. * Function used to align with Node.getChildren()
  24317. * @returns the list of Materials used within the multi material
  24318. */
  24319. getChildren(): Nullable<Material>[];
  24320. /**
  24321. * Instantiates a new Multi Material
  24322. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24323. * separate meshes. This can be use to improve performances.
  24324. * @see http://doc.babylonjs.com/how_to/multi_materials
  24325. * @param name Define the name in the scene
  24326. * @param scene Define the scene the material belongs to
  24327. */
  24328. constructor(name: string, scene: Scene);
  24329. private _hookArray;
  24330. /**
  24331. * Get one of the submaterial by its index in the submaterials array
  24332. * @param index The index to look the sub material at
  24333. * @returns The Material if the index has been defined
  24334. */
  24335. getSubMaterial(index: number): Nullable<Material>;
  24336. /**
  24337. * Get the list of active textures for the whole sub materials list.
  24338. * @returns All the textures that will be used during the rendering
  24339. */
  24340. getActiveTextures(): BaseTexture[];
  24341. /**
  24342. * Gets the current class name of the material e.g. "MultiMaterial"
  24343. * Mainly use in serialization.
  24344. * @returns the class name
  24345. */
  24346. getClassName(): string;
  24347. /**
  24348. * Checks if the material is ready to render the requested sub mesh
  24349. * @param mesh Define the mesh the submesh belongs to
  24350. * @param subMesh Define the sub mesh to look readyness for
  24351. * @param useInstances Define whether or not the material is used with instances
  24352. * @returns true if ready, otherwise false
  24353. */
  24354. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24355. /**
  24356. * Clones the current material and its related sub materials
  24357. * @param name Define the name of the newly cloned material
  24358. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24359. * @returns the cloned material
  24360. */
  24361. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24362. /**
  24363. * Serializes the materials into a JSON representation.
  24364. * @returns the JSON representation
  24365. */
  24366. serialize(): any;
  24367. /**
  24368. * Dispose the material and release its associated resources
  24369. * @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)
  24370. * @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)
  24371. * @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)
  24372. */
  24373. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24374. /**
  24375. * Creates a MultiMaterial from parsed MultiMaterial data.
  24376. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24377. * @param scene defines the hosting scene
  24378. * @returns a new MultiMaterial
  24379. */
  24380. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24381. }
  24382. }
  24383. declare module BABYLON {
  24384. /**
  24385. * Defines a subdivision inside a mesh
  24386. */
  24387. export class SubMesh implements ICullable {
  24388. /** the material index to use */
  24389. materialIndex: number;
  24390. /** vertex index start */
  24391. verticesStart: number;
  24392. /** vertices count */
  24393. verticesCount: number;
  24394. /** index start */
  24395. indexStart: number;
  24396. /** indices count */
  24397. indexCount: number;
  24398. /** @hidden */
  24399. _materialDefines: Nullable<MaterialDefines>;
  24400. /** @hidden */
  24401. _materialEffect: Nullable<Effect>;
  24402. /** @hidden */
  24403. _effectOverride: Nullable<Effect>;
  24404. /**
  24405. * Gets material defines used by the effect associated to the sub mesh
  24406. */
  24407. get materialDefines(): Nullable<MaterialDefines>;
  24408. /**
  24409. * Sets material defines used by the effect associated to the sub mesh
  24410. */
  24411. set materialDefines(defines: Nullable<MaterialDefines>);
  24412. /**
  24413. * Gets associated effect
  24414. */
  24415. get effect(): Nullable<Effect>;
  24416. /**
  24417. * Sets associated effect (effect used to render this submesh)
  24418. * @param effect defines the effect to associate with
  24419. * @param defines defines the set of defines used to compile this effect
  24420. */
  24421. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24422. /** @hidden */
  24423. _linesIndexCount: number;
  24424. private _mesh;
  24425. private _renderingMesh;
  24426. private _boundingInfo;
  24427. private _linesIndexBuffer;
  24428. /** @hidden */
  24429. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24430. /** @hidden */
  24431. _trianglePlanes: Plane[];
  24432. /** @hidden */
  24433. _lastColliderTransformMatrix: Nullable<Matrix>;
  24434. /** @hidden */
  24435. _renderId: number;
  24436. /** @hidden */
  24437. _alphaIndex: number;
  24438. /** @hidden */
  24439. _distanceToCamera: number;
  24440. /** @hidden */
  24441. _id: number;
  24442. private _currentMaterial;
  24443. /**
  24444. * Add a new submesh to a mesh
  24445. * @param materialIndex defines the material index to use
  24446. * @param verticesStart defines vertex index start
  24447. * @param verticesCount defines vertices count
  24448. * @param indexStart defines index start
  24449. * @param indexCount defines indices count
  24450. * @param mesh defines the parent mesh
  24451. * @param renderingMesh defines an optional rendering mesh
  24452. * @param createBoundingBox defines if bounding box should be created for this submesh
  24453. * @returns the new submesh
  24454. */
  24455. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24456. /**
  24457. * Creates a new submesh
  24458. * @param materialIndex defines the material index to use
  24459. * @param verticesStart defines vertex index start
  24460. * @param verticesCount defines vertices count
  24461. * @param indexStart defines index start
  24462. * @param indexCount defines indices count
  24463. * @param mesh defines the parent mesh
  24464. * @param renderingMesh defines an optional rendering mesh
  24465. * @param createBoundingBox defines if bounding box should be created for this submesh
  24466. */
  24467. constructor(
  24468. /** the material index to use */
  24469. materialIndex: number,
  24470. /** vertex index start */
  24471. verticesStart: number,
  24472. /** vertices count */
  24473. verticesCount: number,
  24474. /** index start */
  24475. indexStart: number,
  24476. /** indices count */
  24477. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  24478. /**
  24479. * Returns true if this submesh covers the entire parent mesh
  24480. * @ignorenaming
  24481. */
  24482. get IsGlobal(): boolean;
  24483. /**
  24484. * Returns the submesh BoudingInfo object
  24485. * @returns current bounding info (or mesh's one if the submesh is global)
  24486. */
  24487. getBoundingInfo(): BoundingInfo;
  24488. /**
  24489. * Sets the submesh BoundingInfo
  24490. * @param boundingInfo defines the new bounding info to use
  24491. * @returns the SubMesh
  24492. */
  24493. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24494. /**
  24495. * Returns the mesh of the current submesh
  24496. * @return the parent mesh
  24497. */
  24498. getMesh(): AbstractMesh;
  24499. /**
  24500. * Returns the rendering mesh of the submesh
  24501. * @returns the rendering mesh (could be different from parent mesh)
  24502. */
  24503. getRenderingMesh(): Mesh;
  24504. /**
  24505. * Returns the replacement mesh of the submesh
  24506. * @returns the replacement mesh (could be different from parent mesh)
  24507. */
  24508. getReplacementMesh(): Nullable<AbstractMesh>;
  24509. /**
  24510. * Returns the effective mesh of the submesh
  24511. * @returns the effective mesh (could be different from parent mesh)
  24512. */
  24513. getEffectiveMesh(): AbstractMesh;
  24514. /**
  24515. * Returns the submesh material
  24516. * @returns null or the current material
  24517. */
  24518. getMaterial(): Nullable<Material>;
  24519. /**
  24520. * Sets a new updated BoundingInfo object to the submesh
  24521. * @param data defines an optional position array to use to determine the bounding info
  24522. * @returns the SubMesh
  24523. */
  24524. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24525. /** @hidden */
  24526. _checkCollision(collider: Collider): boolean;
  24527. /**
  24528. * Updates the submesh BoundingInfo
  24529. * @param world defines the world matrix to use to update the bounding info
  24530. * @returns the submesh
  24531. */
  24532. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24533. /**
  24534. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24535. * @param frustumPlanes defines the frustum planes
  24536. * @returns true if the submesh is intersecting with the frustum
  24537. */
  24538. isInFrustum(frustumPlanes: Plane[]): boolean;
  24539. /**
  24540. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24541. * @param frustumPlanes defines the frustum planes
  24542. * @returns true if the submesh is inside the frustum
  24543. */
  24544. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24545. /**
  24546. * Renders the submesh
  24547. * @param enableAlphaMode defines if alpha needs to be used
  24548. * @returns the submesh
  24549. */
  24550. render(enableAlphaMode: boolean): SubMesh;
  24551. /**
  24552. * @hidden
  24553. */
  24554. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24555. /**
  24556. * Checks if the submesh intersects with a ray
  24557. * @param ray defines the ray to test
  24558. * @returns true is the passed ray intersects the submesh bounding box
  24559. */
  24560. canIntersects(ray: Ray): boolean;
  24561. /**
  24562. * Intersects current submesh with a ray
  24563. * @param ray defines the ray to test
  24564. * @param positions defines mesh's positions array
  24565. * @param indices defines mesh's indices array
  24566. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24567. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24568. * @returns intersection info or null if no intersection
  24569. */
  24570. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24571. /** @hidden */
  24572. private _intersectLines;
  24573. /** @hidden */
  24574. private _intersectUnIndexedLines;
  24575. /** @hidden */
  24576. private _intersectTriangles;
  24577. /** @hidden */
  24578. private _intersectUnIndexedTriangles;
  24579. /** @hidden */
  24580. _rebuild(): void;
  24581. /**
  24582. * Creates a new submesh from the passed mesh
  24583. * @param newMesh defines the new hosting mesh
  24584. * @param newRenderingMesh defines an optional rendering mesh
  24585. * @returns the new submesh
  24586. */
  24587. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24588. /**
  24589. * Release associated resources
  24590. */
  24591. dispose(): void;
  24592. /**
  24593. * Gets the class name
  24594. * @returns the string "SubMesh".
  24595. */
  24596. getClassName(): string;
  24597. /**
  24598. * Creates a new submesh from indices data
  24599. * @param materialIndex the index of the main mesh material
  24600. * @param startIndex the index where to start the copy in the mesh indices array
  24601. * @param indexCount the number of indices to copy then from the startIndex
  24602. * @param mesh the main mesh to create the submesh from
  24603. * @param renderingMesh the optional rendering mesh
  24604. * @returns a new submesh
  24605. */
  24606. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24607. }
  24608. }
  24609. declare module BABYLON {
  24610. /**
  24611. * Class used to represent data loading progression
  24612. */
  24613. export class SceneLoaderFlags {
  24614. private static _ForceFullSceneLoadingForIncremental;
  24615. private static _ShowLoadingScreen;
  24616. private static _CleanBoneMatrixWeights;
  24617. private static _loggingLevel;
  24618. /**
  24619. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24620. */
  24621. static get ForceFullSceneLoadingForIncremental(): boolean;
  24622. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24623. /**
  24624. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24625. */
  24626. static get ShowLoadingScreen(): boolean;
  24627. static set ShowLoadingScreen(value: boolean);
  24628. /**
  24629. * Defines the current logging level (while loading the scene)
  24630. * @ignorenaming
  24631. */
  24632. static get loggingLevel(): number;
  24633. static set loggingLevel(value: number);
  24634. /**
  24635. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24636. */
  24637. static get CleanBoneMatrixWeights(): boolean;
  24638. static set CleanBoneMatrixWeights(value: boolean);
  24639. }
  24640. }
  24641. declare module BABYLON {
  24642. /**
  24643. * Class used to store geometry data (vertex buffers + index buffer)
  24644. */
  24645. export class Geometry implements IGetSetVerticesData {
  24646. /**
  24647. * Gets or sets the ID of the geometry
  24648. */
  24649. id: string;
  24650. /**
  24651. * Gets or sets the unique ID of the geometry
  24652. */
  24653. uniqueId: number;
  24654. /**
  24655. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24656. */
  24657. delayLoadState: number;
  24658. /**
  24659. * Gets the file containing the data to load when running in delay load state
  24660. */
  24661. delayLoadingFile: Nullable<string>;
  24662. /**
  24663. * Callback called when the geometry is updated
  24664. */
  24665. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24666. private _scene;
  24667. private _engine;
  24668. private _meshes;
  24669. private _totalVertices;
  24670. /** @hidden */
  24671. _indices: IndicesArray;
  24672. /** @hidden */
  24673. _vertexBuffers: {
  24674. [key: string]: VertexBuffer;
  24675. };
  24676. private _isDisposed;
  24677. private _extend;
  24678. private _boundingBias;
  24679. /** @hidden */
  24680. _delayInfo: Array<string>;
  24681. private _indexBuffer;
  24682. private _indexBufferIsUpdatable;
  24683. /** @hidden */
  24684. _boundingInfo: Nullable<BoundingInfo>;
  24685. /** @hidden */
  24686. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24687. /** @hidden */
  24688. _softwareSkinningFrameId: number;
  24689. private _vertexArrayObjects;
  24690. private _updatable;
  24691. /** @hidden */
  24692. _positions: Nullable<Vector3[]>;
  24693. /**
  24694. * 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
  24695. */
  24696. get boundingBias(): Vector2;
  24697. /**
  24698. * 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
  24699. */
  24700. set boundingBias(value: Vector2);
  24701. /**
  24702. * Static function used to attach a new empty geometry to a mesh
  24703. * @param mesh defines the mesh to attach the geometry to
  24704. * @returns the new Geometry
  24705. */
  24706. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24707. /** Get the list of meshes using this geometry */
  24708. get meshes(): Mesh[];
  24709. /**
  24710. * Creates a new geometry
  24711. * @param id defines the unique ID
  24712. * @param scene defines the hosting scene
  24713. * @param vertexData defines the VertexData used to get geometry data
  24714. * @param updatable defines if geometry must be updatable (false by default)
  24715. * @param mesh defines the mesh that will be associated with the geometry
  24716. */
  24717. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24718. /**
  24719. * Gets the current extend of the geometry
  24720. */
  24721. get extend(): {
  24722. minimum: Vector3;
  24723. maximum: Vector3;
  24724. };
  24725. /**
  24726. * Gets the hosting scene
  24727. * @returns the hosting Scene
  24728. */
  24729. getScene(): Scene;
  24730. /**
  24731. * Gets the hosting engine
  24732. * @returns the hosting Engine
  24733. */
  24734. getEngine(): Engine;
  24735. /**
  24736. * Defines if the geometry is ready to use
  24737. * @returns true if the geometry is ready to be used
  24738. */
  24739. isReady(): boolean;
  24740. /**
  24741. * Gets a value indicating that the geometry should not be serialized
  24742. */
  24743. get doNotSerialize(): boolean;
  24744. /** @hidden */
  24745. _rebuild(): void;
  24746. /**
  24747. * Affects all geometry data in one call
  24748. * @param vertexData defines the geometry data
  24749. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24750. */
  24751. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24752. /**
  24753. * Set specific vertex data
  24754. * @param kind defines the data kind (Position, normal, etc...)
  24755. * @param data defines the vertex data to use
  24756. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24757. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24758. */
  24759. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24760. /**
  24761. * Removes a specific vertex data
  24762. * @param kind defines the data kind (Position, normal, etc...)
  24763. */
  24764. removeVerticesData(kind: string): void;
  24765. /**
  24766. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24767. * @param buffer defines the vertex buffer to use
  24768. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24769. */
  24770. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24771. /**
  24772. * Update a specific vertex buffer
  24773. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24774. * It will do nothing if the buffer is not updatable
  24775. * @param kind defines the data kind (Position, normal, etc...)
  24776. * @param data defines the data to use
  24777. * @param offset defines the offset in the target buffer where to store the data
  24778. * @param useBytes set to true if the offset is in bytes
  24779. */
  24780. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24781. /**
  24782. * Update a specific vertex buffer
  24783. * This function will create a new buffer if the current one is not updatable
  24784. * @param kind defines the data kind (Position, normal, etc...)
  24785. * @param data defines the data to use
  24786. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24787. */
  24788. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24789. private _updateBoundingInfo;
  24790. /** @hidden */
  24791. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24792. /**
  24793. * Gets total number of vertices
  24794. * @returns the total number of vertices
  24795. */
  24796. getTotalVertices(): number;
  24797. /**
  24798. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24799. * @param kind defines the data kind (Position, normal, etc...)
  24800. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24801. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24802. * @returns a float array containing vertex data
  24803. */
  24804. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24805. /**
  24806. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24807. * @param kind defines the data kind (Position, normal, etc...)
  24808. * @returns true if the vertex buffer with the specified kind is updatable
  24809. */
  24810. isVertexBufferUpdatable(kind: string): boolean;
  24811. /**
  24812. * Gets a specific vertex buffer
  24813. * @param kind defines the data kind (Position, normal, etc...)
  24814. * @returns a VertexBuffer
  24815. */
  24816. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24817. /**
  24818. * Returns all vertex buffers
  24819. * @return an object holding all vertex buffers indexed by kind
  24820. */
  24821. getVertexBuffers(): Nullable<{
  24822. [key: string]: VertexBuffer;
  24823. }>;
  24824. /**
  24825. * Gets a boolean indicating if specific vertex buffer is present
  24826. * @param kind defines the data kind (Position, normal, etc...)
  24827. * @returns true if data is present
  24828. */
  24829. isVerticesDataPresent(kind: string): boolean;
  24830. /**
  24831. * Gets a list of all attached data kinds (Position, normal, etc...)
  24832. * @returns a list of string containing all kinds
  24833. */
  24834. getVerticesDataKinds(): string[];
  24835. /**
  24836. * Update index buffer
  24837. * @param indices defines the indices to store in the index buffer
  24838. * @param offset defines the offset in the target buffer where to store the data
  24839. * @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)
  24840. */
  24841. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24842. /**
  24843. * Creates a new index buffer
  24844. * @param indices defines the indices to store in the index buffer
  24845. * @param totalVertices defines the total number of vertices (could be null)
  24846. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24847. */
  24848. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24849. /**
  24850. * Return the total number of indices
  24851. * @returns the total number of indices
  24852. */
  24853. getTotalIndices(): number;
  24854. /**
  24855. * Gets the index buffer array
  24856. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24857. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24858. * @returns the index buffer array
  24859. */
  24860. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24861. /**
  24862. * Gets the index buffer
  24863. * @return the index buffer
  24864. */
  24865. getIndexBuffer(): Nullable<DataBuffer>;
  24866. /** @hidden */
  24867. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24868. /**
  24869. * Release the associated resources for a specific mesh
  24870. * @param mesh defines the source mesh
  24871. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24872. */
  24873. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24874. /**
  24875. * Apply current geometry to a given mesh
  24876. * @param mesh defines the mesh to apply geometry to
  24877. */
  24878. applyToMesh(mesh: Mesh): void;
  24879. private _updateExtend;
  24880. private _applyToMesh;
  24881. private notifyUpdate;
  24882. /**
  24883. * Load the geometry if it was flagged as delay loaded
  24884. * @param scene defines the hosting scene
  24885. * @param onLoaded defines a callback called when the geometry is loaded
  24886. */
  24887. load(scene: Scene, onLoaded?: () => void): void;
  24888. private _queueLoad;
  24889. /**
  24890. * Invert the geometry to move from a right handed system to a left handed one.
  24891. */
  24892. toLeftHanded(): void;
  24893. /** @hidden */
  24894. _resetPointsArrayCache(): void;
  24895. /** @hidden */
  24896. _generatePointsArray(): boolean;
  24897. /**
  24898. * Gets a value indicating if the geometry is disposed
  24899. * @returns true if the geometry was disposed
  24900. */
  24901. isDisposed(): boolean;
  24902. private _disposeVertexArrayObjects;
  24903. /**
  24904. * Free all associated resources
  24905. */
  24906. dispose(): void;
  24907. /**
  24908. * Clone the current geometry into a new geometry
  24909. * @param id defines the unique ID of the new geometry
  24910. * @returns a new geometry object
  24911. */
  24912. copy(id: string): Geometry;
  24913. /**
  24914. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24915. * @return a JSON representation of the current geometry data (without the vertices data)
  24916. */
  24917. serialize(): any;
  24918. private toNumberArray;
  24919. /**
  24920. * Serialize all vertices data into a JSON oject
  24921. * @returns a JSON representation of the current geometry data
  24922. */
  24923. serializeVerticeData(): any;
  24924. /**
  24925. * Extracts a clone of a mesh geometry
  24926. * @param mesh defines the source mesh
  24927. * @param id defines the unique ID of the new geometry object
  24928. * @returns the new geometry object
  24929. */
  24930. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24931. /**
  24932. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24933. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24934. * Be aware Math.random() could cause collisions, but:
  24935. * "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"
  24936. * @returns a string containing a new GUID
  24937. */
  24938. static RandomId(): string;
  24939. /** @hidden */
  24940. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24941. private static _CleanMatricesWeights;
  24942. /**
  24943. * Create a new geometry from persisted data (Using .babylon file format)
  24944. * @param parsedVertexData defines the persisted data
  24945. * @param scene defines the hosting scene
  24946. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24947. * @returns the new geometry object
  24948. */
  24949. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24950. }
  24951. }
  24952. declare module BABYLON {
  24953. /**
  24954. * Define an interface for all classes that will get and set the data on vertices
  24955. */
  24956. export interface IGetSetVerticesData {
  24957. /**
  24958. * Gets a boolean indicating if specific vertex data is present
  24959. * @param kind defines the vertex data kind to use
  24960. * @returns true is data kind is present
  24961. */
  24962. isVerticesDataPresent(kind: string): boolean;
  24963. /**
  24964. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24965. * @param kind defines the data kind (Position, normal, etc...)
  24966. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24967. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24968. * @returns a float array containing vertex data
  24969. */
  24970. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24971. /**
  24972. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24973. * @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.
  24974. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24975. * @returns the indices array or an empty array if the mesh has no geometry
  24976. */
  24977. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24978. /**
  24979. * Set specific vertex data
  24980. * @param kind defines the data kind (Position, normal, etc...)
  24981. * @param data defines the vertex data to use
  24982. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24983. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24984. */
  24985. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  24986. /**
  24987. * Update a specific associated vertex buffer
  24988. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24989. * - VertexBuffer.PositionKind
  24990. * - VertexBuffer.UVKind
  24991. * - VertexBuffer.UV2Kind
  24992. * - VertexBuffer.UV3Kind
  24993. * - VertexBuffer.UV4Kind
  24994. * - VertexBuffer.UV5Kind
  24995. * - VertexBuffer.UV6Kind
  24996. * - VertexBuffer.ColorKind
  24997. * - VertexBuffer.MatricesIndicesKind
  24998. * - VertexBuffer.MatricesIndicesExtraKind
  24999. * - VertexBuffer.MatricesWeightsKind
  25000. * - VertexBuffer.MatricesWeightsExtraKind
  25001. * @param data defines the data source
  25002. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25003. * @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)
  25004. */
  25005. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25006. /**
  25007. * Creates a new index buffer
  25008. * @param indices defines the indices to store in the index buffer
  25009. * @param totalVertices defines the total number of vertices (could be null)
  25010. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25011. */
  25012. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25013. }
  25014. /**
  25015. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25016. */
  25017. export class VertexData {
  25018. /**
  25019. * Mesh side orientation : usually the external or front surface
  25020. */
  25021. static readonly FRONTSIDE: number;
  25022. /**
  25023. * Mesh side orientation : usually the internal or back surface
  25024. */
  25025. static readonly BACKSIDE: number;
  25026. /**
  25027. * Mesh side orientation : both internal and external or front and back surfaces
  25028. */
  25029. static readonly DOUBLESIDE: number;
  25030. /**
  25031. * Mesh side orientation : by default, `FRONTSIDE`
  25032. */
  25033. static readonly DEFAULTSIDE: number;
  25034. /**
  25035. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25036. */
  25037. positions: Nullable<FloatArray>;
  25038. /**
  25039. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25040. */
  25041. normals: Nullable<FloatArray>;
  25042. /**
  25043. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25044. */
  25045. tangents: Nullable<FloatArray>;
  25046. /**
  25047. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25048. */
  25049. uvs: Nullable<FloatArray>;
  25050. /**
  25051. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25052. */
  25053. uvs2: Nullable<FloatArray>;
  25054. /**
  25055. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25056. */
  25057. uvs3: Nullable<FloatArray>;
  25058. /**
  25059. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25060. */
  25061. uvs4: Nullable<FloatArray>;
  25062. /**
  25063. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25064. */
  25065. uvs5: Nullable<FloatArray>;
  25066. /**
  25067. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25068. */
  25069. uvs6: Nullable<FloatArray>;
  25070. /**
  25071. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25072. */
  25073. colors: Nullable<FloatArray>;
  25074. /**
  25075. * 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).
  25076. */
  25077. matricesIndices: Nullable<FloatArray>;
  25078. /**
  25079. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25080. */
  25081. matricesWeights: Nullable<FloatArray>;
  25082. /**
  25083. * An array extending the number of possible indices
  25084. */
  25085. matricesIndicesExtra: Nullable<FloatArray>;
  25086. /**
  25087. * An array extending the number of possible weights when the number of indices is extended
  25088. */
  25089. matricesWeightsExtra: Nullable<FloatArray>;
  25090. /**
  25091. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25092. */
  25093. indices: Nullable<IndicesArray>;
  25094. /**
  25095. * Uses the passed data array to set the set the values for the specified kind of data
  25096. * @param data a linear array of floating numbers
  25097. * @param kind the type of data that is being set, eg positions, colors etc
  25098. */
  25099. set(data: FloatArray, kind: string): void;
  25100. /**
  25101. * Associates the vertexData to the passed Mesh.
  25102. * Sets it as updatable or not (default `false`)
  25103. * @param mesh the mesh the vertexData is applied to
  25104. * @param updatable when used and having the value true allows new data to update the vertexData
  25105. * @returns the VertexData
  25106. */
  25107. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25108. /**
  25109. * Associates the vertexData to the passed Geometry.
  25110. * Sets it as updatable or not (default `false`)
  25111. * @param geometry the geometry the vertexData is applied to
  25112. * @param updatable when used and having the value true allows new data to update the vertexData
  25113. * @returns VertexData
  25114. */
  25115. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25116. /**
  25117. * Updates the associated mesh
  25118. * @param mesh the mesh to be updated
  25119. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25120. * @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
  25121. * @returns VertexData
  25122. */
  25123. updateMesh(mesh: Mesh): VertexData;
  25124. /**
  25125. * Updates the associated geometry
  25126. * @param geometry the geometry to be updated
  25127. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25128. * @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
  25129. * @returns VertexData.
  25130. */
  25131. updateGeometry(geometry: Geometry): VertexData;
  25132. private _applyTo;
  25133. private _update;
  25134. /**
  25135. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25136. * @param matrix the transforming matrix
  25137. * @returns the VertexData
  25138. */
  25139. transform(matrix: Matrix): VertexData;
  25140. /**
  25141. * Merges the passed VertexData into the current one
  25142. * @param other the VertexData to be merged into the current one
  25143. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25144. * @returns the modified VertexData
  25145. */
  25146. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25147. private _mergeElement;
  25148. private _validate;
  25149. /**
  25150. * Serializes the VertexData
  25151. * @returns a serialized object
  25152. */
  25153. serialize(): any;
  25154. /**
  25155. * Extracts the vertexData from a mesh
  25156. * @param mesh the mesh from which to extract the VertexData
  25157. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25158. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25159. * @returns the object VertexData associated to the passed mesh
  25160. */
  25161. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25162. /**
  25163. * Extracts the vertexData from the geometry
  25164. * @param geometry the geometry from which to extract the VertexData
  25165. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25166. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25167. * @returns the object VertexData associated to the passed mesh
  25168. */
  25169. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25170. private static _ExtractFrom;
  25171. /**
  25172. * Creates the VertexData for a Ribbon
  25173. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25174. * * pathArray array of paths, each of which an array of successive Vector3
  25175. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25176. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25177. * * 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
  25178. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25179. * * 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)
  25180. * * 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)
  25181. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25182. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25183. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25184. * @returns the VertexData of the ribbon
  25185. */
  25186. static CreateRibbon(options: {
  25187. pathArray: Vector3[][];
  25188. closeArray?: boolean;
  25189. closePath?: boolean;
  25190. offset?: number;
  25191. sideOrientation?: number;
  25192. frontUVs?: Vector4;
  25193. backUVs?: Vector4;
  25194. invertUV?: boolean;
  25195. uvs?: Vector2[];
  25196. colors?: Color4[];
  25197. }): VertexData;
  25198. /**
  25199. * Creates the VertexData for a box
  25200. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25201. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25202. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25203. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25204. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25205. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25206. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25207. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25208. * * 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)
  25209. * * 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)
  25210. * @returns the VertexData of the box
  25211. */
  25212. static CreateBox(options: {
  25213. size?: number;
  25214. width?: number;
  25215. height?: number;
  25216. depth?: number;
  25217. faceUV?: Vector4[];
  25218. faceColors?: Color4[];
  25219. sideOrientation?: number;
  25220. frontUVs?: Vector4;
  25221. backUVs?: Vector4;
  25222. }): VertexData;
  25223. /**
  25224. * Creates the VertexData for a tiled box
  25225. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25226. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25227. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25228. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25229. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25230. * @returns the VertexData of the box
  25231. */
  25232. static CreateTiledBox(options: {
  25233. pattern?: number;
  25234. width?: number;
  25235. height?: number;
  25236. depth?: number;
  25237. tileSize?: number;
  25238. tileWidth?: number;
  25239. tileHeight?: number;
  25240. alignHorizontal?: number;
  25241. alignVertical?: number;
  25242. faceUV?: Vector4[];
  25243. faceColors?: Color4[];
  25244. sideOrientation?: number;
  25245. }): VertexData;
  25246. /**
  25247. * Creates the VertexData for a tiled plane
  25248. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25249. * * pattern a limited pattern arrangement depending on the number
  25250. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25251. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25252. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25253. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25254. * * 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)
  25255. * * 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)
  25256. * @returns the VertexData of the tiled plane
  25257. */
  25258. static CreateTiledPlane(options: {
  25259. pattern?: number;
  25260. tileSize?: number;
  25261. tileWidth?: number;
  25262. tileHeight?: number;
  25263. size?: number;
  25264. width?: number;
  25265. height?: number;
  25266. alignHorizontal?: number;
  25267. alignVertical?: number;
  25268. sideOrientation?: number;
  25269. frontUVs?: Vector4;
  25270. backUVs?: Vector4;
  25271. }): VertexData;
  25272. /**
  25273. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25274. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25275. * * segments sets the number of horizontal strips optional, default 32
  25276. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25277. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25278. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25279. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25280. * * 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
  25281. * * 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
  25282. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25283. * * 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)
  25284. * * 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)
  25285. * @returns the VertexData of the ellipsoid
  25286. */
  25287. static CreateSphere(options: {
  25288. segments?: number;
  25289. diameter?: number;
  25290. diameterX?: number;
  25291. diameterY?: number;
  25292. diameterZ?: number;
  25293. arc?: number;
  25294. slice?: number;
  25295. sideOrientation?: number;
  25296. frontUVs?: Vector4;
  25297. backUVs?: Vector4;
  25298. }): VertexData;
  25299. /**
  25300. * Creates the VertexData for a cylinder, cone or prism
  25301. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25302. * * height sets the height (y direction) of the cylinder, optional, default 2
  25303. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25304. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25305. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25306. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25307. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25308. * * 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
  25309. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25310. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25311. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25312. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25313. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25314. * * 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)
  25315. * * 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)
  25316. * @returns the VertexData of the cylinder, cone or prism
  25317. */
  25318. static CreateCylinder(options: {
  25319. height?: number;
  25320. diameterTop?: number;
  25321. diameterBottom?: number;
  25322. diameter?: number;
  25323. tessellation?: number;
  25324. subdivisions?: number;
  25325. arc?: number;
  25326. faceColors?: Color4[];
  25327. faceUV?: Vector4[];
  25328. hasRings?: boolean;
  25329. enclose?: boolean;
  25330. sideOrientation?: number;
  25331. frontUVs?: Vector4;
  25332. backUVs?: Vector4;
  25333. }): VertexData;
  25334. /**
  25335. * Creates the VertexData for a torus
  25336. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25337. * * diameter the diameter of the torus, optional default 1
  25338. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25339. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25340. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25341. * * 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)
  25342. * * 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)
  25343. * @returns the VertexData of the torus
  25344. */
  25345. static CreateTorus(options: {
  25346. diameter?: number;
  25347. thickness?: number;
  25348. tessellation?: number;
  25349. sideOrientation?: number;
  25350. frontUVs?: Vector4;
  25351. backUVs?: Vector4;
  25352. }): VertexData;
  25353. /**
  25354. * Creates the VertexData of the LineSystem
  25355. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25356. * - lines an array of lines, each line being an array of successive Vector3
  25357. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25358. * @returns the VertexData of the LineSystem
  25359. */
  25360. static CreateLineSystem(options: {
  25361. lines: Vector3[][];
  25362. colors?: Nullable<Color4[][]>;
  25363. }): VertexData;
  25364. /**
  25365. * Create the VertexData for a DashedLines
  25366. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25367. * - points an array successive Vector3
  25368. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25369. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25370. * - dashNb the intended total number of dashes, optional, default 200
  25371. * @returns the VertexData for the DashedLines
  25372. */
  25373. static CreateDashedLines(options: {
  25374. points: Vector3[];
  25375. dashSize?: number;
  25376. gapSize?: number;
  25377. dashNb?: number;
  25378. }): VertexData;
  25379. /**
  25380. * Creates the VertexData for a Ground
  25381. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25382. * - width the width (x direction) of the ground, optional, default 1
  25383. * - height the height (z direction) of the ground, optional, default 1
  25384. * - subdivisions the number of subdivisions per side, optional, default 1
  25385. * @returns the VertexData of the Ground
  25386. */
  25387. static CreateGround(options: {
  25388. width?: number;
  25389. height?: number;
  25390. subdivisions?: number;
  25391. subdivisionsX?: number;
  25392. subdivisionsY?: number;
  25393. }): VertexData;
  25394. /**
  25395. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25396. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25397. * * xmin the ground minimum X coordinate, optional, default -1
  25398. * * zmin the ground minimum Z coordinate, optional, default -1
  25399. * * xmax the ground maximum X coordinate, optional, default 1
  25400. * * zmax the ground maximum Z coordinate, optional, default 1
  25401. * * 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}
  25402. * * 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}
  25403. * @returns the VertexData of the TiledGround
  25404. */
  25405. static CreateTiledGround(options: {
  25406. xmin: number;
  25407. zmin: number;
  25408. xmax: number;
  25409. zmax: number;
  25410. subdivisions?: {
  25411. w: number;
  25412. h: number;
  25413. };
  25414. precision?: {
  25415. w: number;
  25416. h: number;
  25417. };
  25418. }): VertexData;
  25419. /**
  25420. * Creates the VertexData of the Ground designed from a heightmap
  25421. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25422. * * width the width (x direction) of the ground
  25423. * * height the height (z direction) of the ground
  25424. * * subdivisions the number of subdivisions per side
  25425. * * minHeight the minimum altitude on the ground, optional, default 0
  25426. * * maxHeight the maximum altitude on the ground, optional default 1
  25427. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25428. * * buffer the array holding the image color data
  25429. * * bufferWidth the width of image
  25430. * * bufferHeight the height of image
  25431. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25432. * @returns the VertexData of the Ground designed from a heightmap
  25433. */
  25434. static CreateGroundFromHeightMap(options: {
  25435. width: number;
  25436. height: number;
  25437. subdivisions: number;
  25438. minHeight: number;
  25439. maxHeight: number;
  25440. colorFilter: Color3;
  25441. buffer: Uint8Array;
  25442. bufferWidth: number;
  25443. bufferHeight: number;
  25444. alphaFilter: number;
  25445. }): VertexData;
  25446. /**
  25447. * Creates the VertexData for a Plane
  25448. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25449. * * size sets the width and height of the plane to the value of size, optional default 1
  25450. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25451. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25452. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25453. * * 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)
  25454. * * 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)
  25455. * @returns the VertexData of the box
  25456. */
  25457. static CreatePlane(options: {
  25458. size?: number;
  25459. width?: number;
  25460. height?: number;
  25461. sideOrientation?: number;
  25462. frontUVs?: Vector4;
  25463. backUVs?: Vector4;
  25464. }): VertexData;
  25465. /**
  25466. * Creates the VertexData of the Disc or regular Polygon
  25467. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25468. * * radius the radius of the disc, optional default 0.5
  25469. * * tessellation the number of polygon sides, optional, default 64
  25470. * * 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
  25471. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25472. * * 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)
  25473. * * 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)
  25474. * @returns the VertexData of the box
  25475. */
  25476. static CreateDisc(options: {
  25477. radius?: number;
  25478. tessellation?: number;
  25479. arc?: number;
  25480. sideOrientation?: number;
  25481. frontUVs?: Vector4;
  25482. backUVs?: Vector4;
  25483. }): VertexData;
  25484. /**
  25485. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25486. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25487. * @param polygon a mesh built from polygonTriangulation.build()
  25488. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25489. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25490. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25491. * @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)
  25492. * @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)
  25493. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25494. * @returns the VertexData of the Polygon
  25495. */
  25496. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25497. /**
  25498. * Creates the VertexData of the IcoSphere
  25499. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25500. * * radius the radius of the IcoSphere, optional default 1
  25501. * * radiusX allows stretching in the x direction, optional, default radius
  25502. * * radiusY allows stretching in the y direction, optional, default radius
  25503. * * radiusZ allows stretching in the z direction, optional, default radius
  25504. * * flat when true creates a flat shaded mesh, optional, default true
  25505. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25506. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25507. * * 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)
  25508. * * 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)
  25509. * @returns the VertexData of the IcoSphere
  25510. */
  25511. static CreateIcoSphere(options: {
  25512. radius?: number;
  25513. radiusX?: number;
  25514. radiusY?: number;
  25515. radiusZ?: number;
  25516. flat?: boolean;
  25517. subdivisions?: number;
  25518. sideOrientation?: number;
  25519. frontUVs?: Vector4;
  25520. backUVs?: Vector4;
  25521. }): VertexData;
  25522. /**
  25523. * Creates the VertexData for a Polyhedron
  25524. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25525. * * type provided types are:
  25526. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25527. * * 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)
  25528. * * size the size of the IcoSphere, optional default 1
  25529. * * sizeX allows stretching in the x direction, optional, default size
  25530. * * sizeY allows stretching in the y direction, optional, default size
  25531. * * sizeZ allows stretching in the z direction, optional, default size
  25532. * * 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
  25533. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25534. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25535. * * flat when true creates a flat shaded mesh, optional, default true
  25536. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25537. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25538. * * 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)
  25539. * * 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)
  25540. * @returns the VertexData of the Polyhedron
  25541. */
  25542. static CreatePolyhedron(options: {
  25543. type?: number;
  25544. size?: number;
  25545. sizeX?: number;
  25546. sizeY?: number;
  25547. sizeZ?: number;
  25548. custom?: any;
  25549. faceUV?: Vector4[];
  25550. faceColors?: Color4[];
  25551. flat?: boolean;
  25552. sideOrientation?: number;
  25553. frontUVs?: Vector4;
  25554. backUVs?: Vector4;
  25555. }): VertexData;
  25556. /**
  25557. * Creates the VertexData for a TorusKnot
  25558. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25559. * * radius the radius of the torus knot, optional, default 2
  25560. * * tube the thickness of the tube, optional, default 0.5
  25561. * * radialSegments the number of sides on each tube segments, optional, default 32
  25562. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25563. * * p the number of windings around the z axis, optional, default 2
  25564. * * q the number of windings around the x axis, optional, default 3
  25565. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25566. * * 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)
  25567. * * 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)
  25568. * @returns the VertexData of the Torus Knot
  25569. */
  25570. static CreateTorusKnot(options: {
  25571. radius?: number;
  25572. tube?: number;
  25573. radialSegments?: number;
  25574. tubularSegments?: number;
  25575. p?: number;
  25576. q?: number;
  25577. sideOrientation?: number;
  25578. frontUVs?: Vector4;
  25579. backUVs?: Vector4;
  25580. }): VertexData;
  25581. /**
  25582. * Compute normals for given positions and indices
  25583. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25584. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25585. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25586. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25587. * * facetNormals : optional array of facet normals (vector3)
  25588. * * facetPositions : optional array of facet positions (vector3)
  25589. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25590. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25591. * * bInfo : optional bounding info, required for facetPartitioning computation
  25592. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25593. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25594. * * useRightHandedSystem: optional boolean to for right handed system computation
  25595. * * depthSort : optional boolean to enable the facet depth sort computation
  25596. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25597. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25598. */
  25599. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25600. facetNormals?: any;
  25601. facetPositions?: any;
  25602. facetPartitioning?: any;
  25603. ratio?: number;
  25604. bInfo?: any;
  25605. bbSize?: Vector3;
  25606. subDiv?: any;
  25607. useRightHandedSystem?: boolean;
  25608. depthSort?: boolean;
  25609. distanceTo?: Vector3;
  25610. depthSortedFacets?: any;
  25611. }): void;
  25612. /** @hidden */
  25613. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25614. /**
  25615. * Applies VertexData created from the imported parameters to the geometry
  25616. * @param parsedVertexData the parsed data from an imported file
  25617. * @param geometry the geometry to apply the VertexData to
  25618. */
  25619. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25620. }
  25621. }
  25622. declare module BABYLON {
  25623. /**
  25624. * Defines a target to use with MorphTargetManager
  25625. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25626. */
  25627. export class MorphTarget implements IAnimatable {
  25628. /** defines the name of the target */
  25629. name: string;
  25630. /**
  25631. * Gets or sets the list of animations
  25632. */
  25633. animations: Animation[];
  25634. private _scene;
  25635. private _positions;
  25636. private _normals;
  25637. private _tangents;
  25638. private _uvs;
  25639. private _influence;
  25640. private _uniqueId;
  25641. /**
  25642. * Observable raised when the influence changes
  25643. */
  25644. onInfluenceChanged: Observable<boolean>;
  25645. /** @hidden */
  25646. _onDataLayoutChanged: Observable<void>;
  25647. /**
  25648. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25649. */
  25650. get influence(): number;
  25651. set influence(influence: number);
  25652. /**
  25653. * Gets or sets the id of the morph Target
  25654. */
  25655. id: string;
  25656. private _animationPropertiesOverride;
  25657. /**
  25658. * Gets or sets the animation properties override
  25659. */
  25660. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25661. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25662. /**
  25663. * Creates a new MorphTarget
  25664. * @param name defines the name of the target
  25665. * @param influence defines the influence to use
  25666. * @param scene defines the scene the morphtarget belongs to
  25667. */
  25668. constructor(
  25669. /** defines the name of the target */
  25670. name: string, influence?: number, scene?: Nullable<Scene>);
  25671. /**
  25672. * Gets the unique ID of this manager
  25673. */
  25674. get uniqueId(): number;
  25675. /**
  25676. * Gets a boolean defining if the target contains position data
  25677. */
  25678. get hasPositions(): boolean;
  25679. /**
  25680. * Gets a boolean defining if the target contains normal data
  25681. */
  25682. get hasNormals(): boolean;
  25683. /**
  25684. * Gets a boolean defining if the target contains tangent data
  25685. */
  25686. get hasTangents(): boolean;
  25687. /**
  25688. * Gets a boolean defining if the target contains texture coordinates data
  25689. */
  25690. get hasUVs(): boolean;
  25691. /**
  25692. * Affects position data to this target
  25693. * @param data defines the position data to use
  25694. */
  25695. setPositions(data: Nullable<FloatArray>): void;
  25696. /**
  25697. * Gets the position data stored in this target
  25698. * @returns a FloatArray containing the position data (or null if not present)
  25699. */
  25700. getPositions(): Nullable<FloatArray>;
  25701. /**
  25702. * Affects normal data to this target
  25703. * @param data defines the normal data to use
  25704. */
  25705. setNormals(data: Nullable<FloatArray>): void;
  25706. /**
  25707. * Gets the normal data stored in this target
  25708. * @returns a FloatArray containing the normal data (or null if not present)
  25709. */
  25710. getNormals(): Nullable<FloatArray>;
  25711. /**
  25712. * Affects tangent data to this target
  25713. * @param data defines the tangent data to use
  25714. */
  25715. setTangents(data: Nullable<FloatArray>): void;
  25716. /**
  25717. * Gets the tangent data stored in this target
  25718. * @returns a FloatArray containing the tangent data (or null if not present)
  25719. */
  25720. getTangents(): Nullable<FloatArray>;
  25721. /**
  25722. * Affects texture coordinates data to this target
  25723. * @param data defines the texture coordinates data to use
  25724. */
  25725. setUVs(data: Nullable<FloatArray>): void;
  25726. /**
  25727. * Gets the texture coordinates data stored in this target
  25728. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25729. */
  25730. getUVs(): Nullable<FloatArray>;
  25731. /**
  25732. * Clone the current target
  25733. * @returns a new MorphTarget
  25734. */
  25735. clone(): MorphTarget;
  25736. /**
  25737. * Serializes the current target into a Serialization object
  25738. * @returns the serialized object
  25739. */
  25740. serialize(): any;
  25741. /**
  25742. * Returns the string "MorphTarget"
  25743. * @returns "MorphTarget"
  25744. */
  25745. getClassName(): string;
  25746. /**
  25747. * Creates a new target from serialized data
  25748. * @param serializationObject defines the serialized data to use
  25749. * @returns a new MorphTarget
  25750. */
  25751. static Parse(serializationObject: any): MorphTarget;
  25752. /**
  25753. * Creates a MorphTarget from mesh data
  25754. * @param mesh defines the source mesh
  25755. * @param name defines the name to use for the new target
  25756. * @param influence defines the influence to attach to the target
  25757. * @returns a new MorphTarget
  25758. */
  25759. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25760. }
  25761. }
  25762. declare module BABYLON {
  25763. /**
  25764. * This class is used to deform meshes using morphing between different targets
  25765. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25766. */
  25767. export class MorphTargetManager {
  25768. private _targets;
  25769. private _targetInfluenceChangedObservers;
  25770. private _targetDataLayoutChangedObservers;
  25771. private _activeTargets;
  25772. private _scene;
  25773. private _influences;
  25774. private _supportsNormals;
  25775. private _supportsTangents;
  25776. private _supportsUVs;
  25777. private _vertexCount;
  25778. private _uniqueId;
  25779. private _tempInfluences;
  25780. /**
  25781. * Gets or sets a boolean indicating if normals must be morphed
  25782. */
  25783. enableNormalMorphing: boolean;
  25784. /**
  25785. * Gets or sets a boolean indicating if tangents must be morphed
  25786. */
  25787. enableTangentMorphing: boolean;
  25788. /**
  25789. * Gets or sets a boolean indicating if UV must be morphed
  25790. */
  25791. enableUVMorphing: boolean;
  25792. /**
  25793. * Creates a new MorphTargetManager
  25794. * @param scene defines the current scene
  25795. */
  25796. constructor(scene?: Nullable<Scene>);
  25797. /**
  25798. * Gets the unique ID of this manager
  25799. */
  25800. get uniqueId(): number;
  25801. /**
  25802. * Gets the number of vertices handled by this manager
  25803. */
  25804. get vertexCount(): number;
  25805. /**
  25806. * Gets a boolean indicating if this manager supports morphing of normals
  25807. */
  25808. get supportsNormals(): boolean;
  25809. /**
  25810. * Gets a boolean indicating if this manager supports morphing of tangents
  25811. */
  25812. get supportsTangents(): boolean;
  25813. /**
  25814. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25815. */
  25816. get supportsUVs(): boolean;
  25817. /**
  25818. * Gets the number of targets stored in this manager
  25819. */
  25820. get numTargets(): number;
  25821. /**
  25822. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25823. */
  25824. get numInfluencers(): number;
  25825. /**
  25826. * Gets the list of influences (one per target)
  25827. */
  25828. get influences(): Float32Array;
  25829. /**
  25830. * Gets the active target at specified index. An active target is a target with an influence > 0
  25831. * @param index defines the index to check
  25832. * @returns the requested target
  25833. */
  25834. getActiveTarget(index: number): MorphTarget;
  25835. /**
  25836. * Gets the target at specified index
  25837. * @param index defines the index to check
  25838. * @returns the requested target
  25839. */
  25840. getTarget(index: number): MorphTarget;
  25841. /**
  25842. * Add a new target to this manager
  25843. * @param target defines the target to add
  25844. */
  25845. addTarget(target: MorphTarget): void;
  25846. /**
  25847. * Removes a target from the manager
  25848. * @param target defines the target to remove
  25849. */
  25850. removeTarget(target: MorphTarget): void;
  25851. /**
  25852. * Clone the current manager
  25853. * @returns a new MorphTargetManager
  25854. */
  25855. clone(): MorphTargetManager;
  25856. /**
  25857. * Serializes the current manager into a Serialization object
  25858. * @returns the serialized object
  25859. */
  25860. serialize(): any;
  25861. private _syncActiveTargets;
  25862. /**
  25863. * Syncrhonize the targets with all the meshes using this morph target manager
  25864. */
  25865. synchronize(): void;
  25866. /**
  25867. * Creates a new MorphTargetManager from serialized data
  25868. * @param serializationObject defines the serialized data
  25869. * @param scene defines the hosting scene
  25870. * @returns the new MorphTargetManager
  25871. */
  25872. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25873. }
  25874. }
  25875. declare module BABYLON {
  25876. /**
  25877. * Class used to represent a specific level of detail of a mesh
  25878. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25879. */
  25880. export class MeshLODLevel {
  25881. /** Defines the distance where this level should start being displayed */
  25882. distance: number;
  25883. /** Defines the mesh to use to render this level */
  25884. mesh: Nullable<Mesh>;
  25885. /**
  25886. * Creates a new LOD level
  25887. * @param distance defines the distance where this level should star being displayed
  25888. * @param mesh defines the mesh to use to render this level
  25889. */
  25890. constructor(
  25891. /** Defines the distance where this level should start being displayed */
  25892. distance: number,
  25893. /** Defines the mesh to use to render this level */
  25894. mesh: Nullable<Mesh>);
  25895. }
  25896. }
  25897. declare module BABYLON {
  25898. /**
  25899. * Mesh representing the gorund
  25900. */
  25901. export class GroundMesh extends Mesh {
  25902. /** If octree should be generated */
  25903. generateOctree: boolean;
  25904. private _heightQuads;
  25905. /** @hidden */
  25906. _subdivisionsX: number;
  25907. /** @hidden */
  25908. _subdivisionsY: number;
  25909. /** @hidden */
  25910. _width: number;
  25911. /** @hidden */
  25912. _height: number;
  25913. /** @hidden */
  25914. _minX: number;
  25915. /** @hidden */
  25916. _maxX: number;
  25917. /** @hidden */
  25918. _minZ: number;
  25919. /** @hidden */
  25920. _maxZ: number;
  25921. constructor(name: string, scene: Scene);
  25922. /**
  25923. * "GroundMesh"
  25924. * @returns "GroundMesh"
  25925. */
  25926. getClassName(): string;
  25927. /**
  25928. * The minimum of x and y subdivisions
  25929. */
  25930. get subdivisions(): number;
  25931. /**
  25932. * X subdivisions
  25933. */
  25934. get subdivisionsX(): number;
  25935. /**
  25936. * Y subdivisions
  25937. */
  25938. get subdivisionsY(): number;
  25939. /**
  25940. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25941. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25942. * @param chunksCount the number of subdivisions for x and y
  25943. * @param octreeBlocksSize (Default: 32)
  25944. */
  25945. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25946. /**
  25947. * Returns a height (y) value in the Worl system :
  25948. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25949. * @param x x coordinate
  25950. * @param z z coordinate
  25951. * @returns the ground y position if (x, z) are outside the ground surface.
  25952. */
  25953. getHeightAtCoordinates(x: number, z: number): number;
  25954. /**
  25955. * Returns a normalized vector (Vector3) orthogonal to the ground
  25956. * at the ground coordinates (x, z) expressed in the World system.
  25957. * @param x x coordinate
  25958. * @param z z coordinate
  25959. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25960. */
  25961. getNormalAtCoordinates(x: number, z: number): Vector3;
  25962. /**
  25963. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25964. * at the ground coordinates (x, z) expressed in the World system.
  25965. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25966. * @param x x coordinate
  25967. * @param z z coordinate
  25968. * @param ref vector to store the result
  25969. * @returns the GroundMesh.
  25970. */
  25971. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25972. /**
  25973. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25974. * if the ground has been updated.
  25975. * This can be used in the render loop.
  25976. * @returns the GroundMesh.
  25977. */
  25978. updateCoordinateHeights(): GroundMesh;
  25979. private _getFacetAt;
  25980. private _initHeightQuads;
  25981. private _computeHeightQuads;
  25982. /**
  25983. * Serializes this ground mesh
  25984. * @param serializationObject object to write serialization to
  25985. */
  25986. serialize(serializationObject: any): void;
  25987. /**
  25988. * Parses a serialized ground mesh
  25989. * @param parsedMesh the serialized mesh
  25990. * @param scene the scene to create the ground mesh in
  25991. * @returns the created ground mesh
  25992. */
  25993. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25994. }
  25995. }
  25996. declare module BABYLON {
  25997. /**
  25998. * Interface for Physics-Joint data
  25999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26000. */
  26001. export interface PhysicsJointData {
  26002. /**
  26003. * The main pivot of the joint
  26004. */
  26005. mainPivot?: Vector3;
  26006. /**
  26007. * The connected pivot of the joint
  26008. */
  26009. connectedPivot?: Vector3;
  26010. /**
  26011. * The main axis of the joint
  26012. */
  26013. mainAxis?: Vector3;
  26014. /**
  26015. * The connected axis of the joint
  26016. */
  26017. connectedAxis?: Vector3;
  26018. /**
  26019. * The collision of the joint
  26020. */
  26021. collision?: boolean;
  26022. /**
  26023. * Native Oimo/Cannon/Energy data
  26024. */
  26025. nativeParams?: any;
  26026. }
  26027. /**
  26028. * This is a holder class for the physics joint created by the physics plugin
  26029. * It holds a set of functions to control the underlying joint
  26030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26031. */
  26032. export class PhysicsJoint {
  26033. /**
  26034. * The type of the physics joint
  26035. */
  26036. type: number;
  26037. /**
  26038. * The data for the physics joint
  26039. */
  26040. jointData: PhysicsJointData;
  26041. private _physicsJoint;
  26042. protected _physicsPlugin: IPhysicsEnginePlugin;
  26043. /**
  26044. * Initializes the physics joint
  26045. * @param type The type of the physics joint
  26046. * @param jointData The data for the physics joint
  26047. */
  26048. constructor(
  26049. /**
  26050. * The type of the physics joint
  26051. */
  26052. type: number,
  26053. /**
  26054. * The data for the physics joint
  26055. */
  26056. jointData: PhysicsJointData);
  26057. /**
  26058. * Gets the physics joint
  26059. */
  26060. get physicsJoint(): any;
  26061. /**
  26062. * Sets the physics joint
  26063. */
  26064. set physicsJoint(newJoint: any);
  26065. /**
  26066. * Sets the physics plugin
  26067. */
  26068. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26069. /**
  26070. * Execute a function that is physics-plugin specific.
  26071. * @param {Function} func the function that will be executed.
  26072. * It accepts two parameters: the physics world and the physics joint
  26073. */
  26074. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26075. /**
  26076. * Distance-Joint type
  26077. */
  26078. static DistanceJoint: number;
  26079. /**
  26080. * Hinge-Joint type
  26081. */
  26082. static HingeJoint: number;
  26083. /**
  26084. * Ball-and-Socket joint type
  26085. */
  26086. static BallAndSocketJoint: number;
  26087. /**
  26088. * Wheel-Joint type
  26089. */
  26090. static WheelJoint: number;
  26091. /**
  26092. * Slider-Joint type
  26093. */
  26094. static SliderJoint: number;
  26095. /**
  26096. * Prismatic-Joint type
  26097. */
  26098. static PrismaticJoint: number;
  26099. /**
  26100. * Universal-Joint type
  26101. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26102. */
  26103. static UniversalJoint: number;
  26104. /**
  26105. * Hinge-Joint 2 type
  26106. */
  26107. static Hinge2Joint: number;
  26108. /**
  26109. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26110. */
  26111. static PointToPointJoint: number;
  26112. /**
  26113. * Spring-Joint type
  26114. */
  26115. static SpringJoint: number;
  26116. /**
  26117. * Lock-Joint type
  26118. */
  26119. static LockJoint: number;
  26120. }
  26121. /**
  26122. * A class representing a physics distance joint
  26123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26124. */
  26125. export class DistanceJoint extends PhysicsJoint {
  26126. /**
  26127. *
  26128. * @param jointData The data for the Distance-Joint
  26129. */
  26130. constructor(jointData: DistanceJointData);
  26131. /**
  26132. * Update the predefined distance.
  26133. * @param maxDistance The maximum preferred distance
  26134. * @param minDistance The minimum preferred distance
  26135. */
  26136. updateDistance(maxDistance: number, minDistance?: number): void;
  26137. }
  26138. /**
  26139. * Represents a Motor-Enabled Joint
  26140. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26141. */
  26142. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26143. /**
  26144. * Initializes the Motor-Enabled Joint
  26145. * @param type The type of the joint
  26146. * @param jointData The physica joint data for the joint
  26147. */
  26148. constructor(type: number, jointData: PhysicsJointData);
  26149. /**
  26150. * Set the motor values.
  26151. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26152. * @param force the force to apply
  26153. * @param maxForce max force for this motor.
  26154. */
  26155. setMotor(force?: number, maxForce?: number): void;
  26156. /**
  26157. * Set the motor's limits.
  26158. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26159. * @param upperLimit The upper limit of the motor
  26160. * @param lowerLimit The lower limit of the motor
  26161. */
  26162. setLimit(upperLimit: number, lowerLimit?: number): void;
  26163. }
  26164. /**
  26165. * This class represents a single physics Hinge-Joint
  26166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26167. */
  26168. export class HingeJoint extends MotorEnabledJoint {
  26169. /**
  26170. * Initializes the Hinge-Joint
  26171. * @param jointData The joint data for the Hinge-Joint
  26172. */
  26173. constructor(jointData: PhysicsJointData);
  26174. /**
  26175. * Set the motor values.
  26176. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26177. * @param {number} force the force to apply
  26178. * @param {number} maxForce max force for this motor.
  26179. */
  26180. setMotor(force?: number, maxForce?: number): void;
  26181. /**
  26182. * Set the motor's limits.
  26183. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26184. * @param upperLimit The upper limit of the motor
  26185. * @param lowerLimit The lower limit of the motor
  26186. */
  26187. setLimit(upperLimit: number, lowerLimit?: number): void;
  26188. }
  26189. /**
  26190. * This class represents a dual hinge physics joint (same as wheel joint)
  26191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26192. */
  26193. export class Hinge2Joint extends MotorEnabledJoint {
  26194. /**
  26195. * Initializes the Hinge2-Joint
  26196. * @param jointData The joint data for the Hinge2-Joint
  26197. */
  26198. constructor(jointData: PhysicsJointData);
  26199. /**
  26200. * Set the motor values.
  26201. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26202. * @param {number} targetSpeed the speed the motor is to reach
  26203. * @param {number} maxForce max force for this motor.
  26204. * @param {motorIndex} the motor's index, 0 or 1.
  26205. */
  26206. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26207. /**
  26208. * Set the motor limits.
  26209. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26210. * @param {number} upperLimit the upper limit
  26211. * @param {number} lowerLimit lower limit
  26212. * @param {motorIndex} the motor's index, 0 or 1.
  26213. */
  26214. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26215. }
  26216. /**
  26217. * Interface for a motor enabled joint
  26218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26219. */
  26220. export interface IMotorEnabledJoint {
  26221. /**
  26222. * Physics joint
  26223. */
  26224. physicsJoint: any;
  26225. /**
  26226. * Sets the motor of the motor-enabled joint
  26227. * @param force The force of the motor
  26228. * @param maxForce The maximum force of the motor
  26229. * @param motorIndex The index of the motor
  26230. */
  26231. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26232. /**
  26233. * Sets the limit of the motor
  26234. * @param upperLimit The upper limit of the motor
  26235. * @param lowerLimit The lower limit of the motor
  26236. * @param motorIndex The index of the motor
  26237. */
  26238. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26239. }
  26240. /**
  26241. * Joint data for a Distance-Joint
  26242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26243. */
  26244. export interface DistanceJointData extends PhysicsJointData {
  26245. /**
  26246. * Max distance the 2 joint objects can be apart
  26247. */
  26248. maxDistance: number;
  26249. }
  26250. /**
  26251. * Joint data from a spring joint
  26252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26253. */
  26254. export interface SpringJointData extends PhysicsJointData {
  26255. /**
  26256. * Length of the spring
  26257. */
  26258. length: number;
  26259. /**
  26260. * Stiffness of the spring
  26261. */
  26262. stiffness: number;
  26263. /**
  26264. * Damping of the spring
  26265. */
  26266. damping: number;
  26267. /** this callback will be called when applying the force to the impostors. */
  26268. forceApplicationCallback: () => void;
  26269. }
  26270. }
  26271. declare module BABYLON {
  26272. /**
  26273. * Holds the data for the raycast result
  26274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26275. */
  26276. export class PhysicsRaycastResult {
  26277. private _hasHit;
  26278. private _hitDistance;
  26279. private _hitNormalWorld;
  26280. private _hitPointWorld;
  26281. private _rayFromWorld;
  26282. private _rayToWorld;
  26283. /**
  26284. * Gets if there was a hit
  26285. */
  26286. get hasHit(): boolean;
  26287. /**
  26288. * Gets the distance from the hit
  26289. */
  26290. get hitDistance(): number;
  26291. /**
  26292. * Gets the hit normal/direction in the world
  26293. */
  26294. get hitNormalWorld(): Vector3;
  26295. /**
  26296. * Gets the hit point in the world
  26297. */
  26298. get hitPointWorld(): Vector3;
  26299. /**
  26300. * Gets the ray "start point" of the ray in the world
  26301. */
  26302. get rayFromWorld(): Vector3;
  26303. /**
  26304. * Gets the ray "end point" of the ray in the world
  26305. */
  26306. get rayToWorld(): Vector3;
  26307. /**
  26308. * Sets the hit data (normal & point in world space)
  26309. * @param hitNormalWorld defines the normal in world space
  26310. * @param hitPointWorld defines the point in world space
  26311. */
  26312. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26313. /**
  26314. * Sets the distance from the start point to the hit point
  26315. * @param distance
  26316. */
  26317. setHitDistance(distance: number): void;
  26318. /**
  26319. * Calculates the distance manually
  26320. */
  26321. calculateHitDistance(): void;
  26322. /**
  26323. * Resets all the values to default
  26324. * @param from The from point on world space
  26325. * @param to The to point on world space
  26326. */
  26327. reset(from?: Vector3, to?: Vector3): void;
  26328. }
  26329. /**
  26330. * Interface for the size containing width and height
  26331. */
  26332. interface IXYZ {
  26333. /**
  26334. * X
  26335. */
  26336. x: number;
  26337. /**
  26338. * Y
  26339. */
  26340. y: number;
  26341. /**
  26342. * Z
  26343. */
  26344. z: number;
  26345. }
  26346. }
  26347. declare module BABYLON {
  26348. /**
  26349. * Interface used to describe a physics joint
  26350. */
  26351. export interface PhysicsImpostorJoint {
  26352. /** Defines the main impostor to which the joint is linked */
  26353. mainImpostor: PhysicsImpostor;
  26354. /** Defines the impostor that is connected to the main impostor using this joint */
  26355. connectedImpostor: PhysicsImpostor;
  26356. /** Defines the joint itself */
  26357. joint: PhysicsJoint;
  26358. }
  26359. /** @hidden */
  26360. export interface IPhysicsEnginePlugin {
  26361. world: any;
  26362. name: string;
  26363. setGravity(gravity: Vector3): void;
  26364. setTimeStep(timeStep: number): void;
  26365. getTimeStep(): number;
  26366. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26367. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26368. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26369. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26370. removePhysicsBody(impostor: PhysicsImpostor): void;
  26371. generateJoint(joint: PhysicsImpostorJoint): void;
  26372. removeJoint(joint: PhysicsImpostorJoint): void;
  26373. isSupported(): boolean;
  26374. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26375. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26376. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26377. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26378. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26379. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26380. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26381. getBodyMass(impostor: PhysicsImpostor): number;
  26382. getBodyFriction(impostor: PhysicsImpostor): number;
  26383. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26384. getBodyRestitution(impostor: PhysicsImpostor): number;
  26385. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26386. getBodyPressure?(impostor: PhysicsImpostor): number;
  26387. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26388. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26389. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26390. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26391. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26392. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26393. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26394. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26395. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26396. sleepBody(impostor: PhysicsImpostor): void;
  26397. wakeUpBody(impostor: PhysicsImpostor): void;
  26398. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26399. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26400. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26401. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26402. getRadius(impostor: PhysicsImpostor): number;
  26403. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26404. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26405. dispose(): void;
  26406. }
  26407. /**
  26408. * Interface used to define a physics engine
  26409. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26410. */
  26411. export interface IPhysicsEngine {
  26412. /**
  26413. * Gets the gravity vector used by the simulation
  26414. */
  26415. gravity: Vector3;
  26416. /**
  26417. * Sets the gravity vector used by the simulation
  26418. * @param gravity defines the gravity vector to use
  26419. */
  26420. setGravity(gravity: Vector3): void;
  26421. /**
  26422. * Set the time step of the physics engine.
  26423. * Default is 1/60.
  26424. * To slow it down, enter 1/600 for example.
  26425. * To speed it up, 1/30
  26426. * @param newTimeStep the new timestep to apply to this world.
  26427. */
  26428. setTimeStep(newTimeStep: number): void;
  26429. /**
  26430. * Get the time step of the physics engine.
  26431. * @returns the current time step
  26432. */
  26433. getTimeStep(): number;
  26434. /**
  26435. * Set the sub time step of the physics engine.
  26436. * Default is 0 meaning there is no sub steps
  26437. * To increase physics resolution precision, set a small value (like 1 ms)
  26438. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26439. */
  26440. setSubTimeStep(subTimeStep: number): void;
  26441. /**
  26442. * Get the sub time step of the physics engine.
  26443. * @returns the current sub time step
  26444. */
  26445. getSubTimeStep(): number;
  26446. /**
  26447. * Release all resources
  26448. */
  26449. dispose(): void;
  26450. /**
  26451. * Gets the name of the current physics plugin
  26452. * @returns the name of the plugin
  26453. */
  26454. getPhysicsPluginName(): string;
  26455. /**
  26456. * Adding a new impostor for the impostor tracking.
  26457. * This will be done by the impostor itself.
  26458. * @param impostor the impostor to add
  26459. */
  26460. addImpostor(impostor: PhysicsImpostor): void;
  26461. /**
  26462. * Remove an impostor from the engine.
  26463. * This impostor and its mesh will not longer be updated by the physics engine.
  26464. * @param impostor the impostor to remove
  26465. */
  26466. removeImpostor(impostor: PhysicsImpostor): void;
  26467. /**
  26468. * Add a joint to the physics engine
  26469. * @param mainImpostor defines the main impostor to which the joint is added.
  26470. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26471. * @param joint defines the joint that will connect both impostors.
  26472. */
  26473. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26474. /**
  26475. * Removes a joint from the simulation
  26476. * @param mainImpostor defines the impostor used with the joint
  26477. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26478. * @param joint defines the joint to remove
  26479. */
  26480. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26481. /**
  26482. * Gets the current plugin used to run the simulation
  26483. * @returns current plugin
  26484. */
  26485. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26486. /**
  26487. * Gets the list of physic impostors
  26488. * @returns an array of PhysicsImpostor
  26489. */
  26490. getImpostors(): Array<PhysicsImpostor>;
  26491. /**
  26492. * Gets the impostor for a physics enabled object
  26493. * @param object defines the object impersonated by the impostor
  26494. * @returns the PhysicsImpostor or null if not found
  26495. */
  26496. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26497. /**
  26498. * Gets the impostor for a physics body object
  26499. * @param body defines physics body used by the impostor
  26500. * @returns the PhysicsImpostor or null if not found
  26501. */
  26502. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26503. /**
  26504. * Does a raycast in the physics world
  26505. * @param from when should the ray start?
  26506. * @param to when should the ray end?
  26507. * @returns PhysicsRaycastResult
  26508. */
  26509. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26510. /**
  26511. * Called by the scene. No need to call it.
  26512. * @param delta defines the timespam between frames
  26513. */
  26514. _step(delta: number): void;
  26515. }
  26516. }
  26517. declare module BABYLON {
  26518. /**
  26519. * The interface for the physics imposter parameters
  26520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26521. */
  26522. export interface PhysicsImpostorParameters {
  26523. /**
  26524. * The mass of the physics imposter
  26525. */
  26526. mass: number;
  26527. /**
  26528. * The friction of the physics imposter
  26529. */
  26530. friction?: number;
  26531. /**
  26532. * The coefficient of restitution of the physics imposter
  26533. */
  26534. restitution?: number;
  26535. /**
  26536. * The native options of the physics imposter
  26537. */
  26538. nativeOptions?: any;
  26539. /**
  26540. * Specifies if the parent should be ignored
  26541. */
  26542. ignoreParent?: boolean;
  26543. /**
  26544. * Specifies if bi-directional transformations should be disabled
  26545. */
  26546. disableBidirectionalTransformation?: boolean;
  26547. /**
  26548. * The pressure inside the physics imposter, soft object only
  26549. */
  26550. pressure?: number;
  26551. /**
  26552. * The stiffness the physics imposter, soft object only
  26553. */
  26554. stiffness?: number;
  26555. /**
  26556. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26557. */
  26558. velocityIterations?: number;
  26559. /**
  26560. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26561. */
  26562. positionIterations?: number;
  26563. /**
  26564. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26565. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26566. * Add to fix multiple points
  26567. */
  26568. fixedPoints?: number;
  26569. /**
  26570. * The collision margin around a soft object
  26571. */
  26572. margin?: number;
  26573. /**
  26574. * The collision margin around a soft object
  26575. */
  26576. damping?: number;
  26577. /**
  26578. * The path for a rope based on an extrusion
  26579. */
  26580. path?: any;
  26581. /**
  26582. * The shape of an extrusion used for a rope based on an extrusion
  26583. */
  26584. shape?: any;
  26585. }
  26586. /**
  26587. * Interface for a physics-enabled object
  26588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26589. */
  26590. export interface IPhysicsEnabledObject {
  26591. /**
  26592. * The position of the physics-enabled object
  26593. */
  26594. position: Vector3;
  26595. /**
  26596. * The rotation of the physics-enabled object
  26597. */
  26598. rotationQuaternion: Nullable<Quaternion>;
  26599. /**
  26600. * The scale of the physics-enabled object
  26601. */
  26602. scaling: Vector3;
  26603. /**
  26604. * The rotation of the physics-enabled object
  26605. */
  26606. rotation?: Vector3;
  26607. /**
  26608. * The parent of the physics-enabled object
  26609. */
  26610. parent?: any;
  26611. /**
  26612. * The bounding info of the physics-enabled object
  26613. * @returns The bounding info of the physics-enabled object
  26614. */
  26615. getBoundingInfo(): BoundingInfo;
  26616. /**
  26617. * Computes the world matrix
  26618. * @param force Specifies if the world matrix should be computed by force
  26619. * @returns A world matrix
  26620. */
  26621. computeWorldMatrix(force: boolean): Matrix;
  26622. /**
  26623. * Gets the world matrix
  26624. * @returns A world matrix
  26625. */
  26626. getWorldMatrix?(): Matrix;
  26627. /**
  26628. * Gets the child meshes
  26629. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26630. * @returns An array of abstract meshes
  26631. */
  26632. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26633. /**
  26634. * Gets the vertex data
  26635. * @param kind The type of vertex data
  26636. * @returns A nullable array of numbers, or a float32 array
  26637. */
  26638. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26639. /**
  26640. * Gets the indices from the mesh
  26641. * @returns A nullable array of index arrays
  26642. */
  26643. getIndices?(): Nullable<IndicesArray>;
  26644. /**
  26645. * Gets the scene from the mesh
  26646. * @returns the indices array or null
  26647. */
  26648. getScene?(): Scene;
  26649. /**
  26650. * Gets the absolute position from the mesh
  26651. * @returns the absolute position
  26652. */
  26653. getAbsolutePosition(): Vector3;
  26654. /**
  26655. * Gets the absolute pivot point from the mesh
  26656. * @returns the absolute pivot point
  26657. */
  26658. getAbsolutePivotPoint(): Vector3;
  26659. /**
  26660. * Rotates the mesh
  26661. * @param axis The axis of rotation
  26662. * @param amount The amount of rotation
  26663. * @param space The space of the rotation
  26664. * @returns The rotation transform node
  26665. */
  26666. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26667. /**
  26668. * Translates the mesh
  26669. * @param axis The axis of translation
  26670. * @param distance The distance of translation
  26671. * @param space The space of the translation
  26672. * @returns The transform node
  26673. */
  26674. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26675. /**
  26676. * Sets the absolute position of the mesh
  26677. * @param absolutePosition The absolute position of the mesh
  26678. * @returns The transform node
  26679. */
  26680. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26681. /**
  26682. * Gets the class name of the mesh
  26683. * @returns The class name
  26684. */
  26685. getClassName(): string;
  26686. }
  26687. /**
  26688. * Represents a physics imposter
  26689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26690. */
  26691. export class PhysicsImpostor {
  26692. /**
  26693. * The physics-enabled object used as the physics imposter
  26694. */
  26695. object: IPhysicsEnabledObject;
  26696. /**
  26697. * The type of the physics imposter
  26698. */
  26699. type: number;
  26700. private _options;
  26701. private _scene?;
  26702. /**
  26703. * The default object size of the imposter
  26704. */
  26705. static DEFAULT_OBJECT_SIZE: Vector3;
  26706. /**
  26707. * The identity quaternion of the imposter
  26708. */
  26709. static IDENTITY_QUATERNION: Quaternion;
  26710. /** @hidden */
  26711. _pluginData: any;
  26712. private _physicsEngine;
  26713. private _physicsBody;
  26714. private _bodyUpdateRequired;
  26715. private _onBeforePhysicsStepCallbacks;
  26716. private _onAfterPhysicsStepCallbacks;
  26717. /** @hidden */
  26718. _onPhysicsCollideCallbacks: Array<{
  26719. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26720. otherImpostors: Array<PhysicsImpostor>;
  26721. }>;
  26722. private _deltaPosition;
  26723. private _deltaRotation;
  26724. private _deltaRotationConjugated;
  26725. /** @hidden */
  26726. _isFromLine: boolean;
  26727. private _parent;
  26728. private _isDisposed;
  26729. private static _tmpVecs;
  26730. private static _tmpQuat;
  26731. /**
  26732. * Specifies if the physics imposter is disposed
  26733. */
  26734. get isDisposed(): boolean;
  26735. /**
  26736. * Gets the mass of the physics imposter
  26737. */
  26738. get mass(): number;
  26739. set mass(value: number);
  26740. /**
  26741. * Gets the coefficient of friction
  26742. */
  26743. get friction(): number;
  26744. /**
  26745. * Sets the coefficient of friction
  26746. */
  26747. set friction(value: number);
  26748. /**
  26749. * Gets the coefficient of restitution
  26750. */
  26751. get restitution(): number;
  26752. /**
  26753. * Sets the coefficient of restitution
  26754. */
  26755. set restitution(value: number);
  26756. /**
  26757. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26758. */
  26759. get pressure(): number;
  26760. /**
  26761. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26762. */
  26763. set pressure(value: number);
  26764. /**
  26765. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26766. */
  26767. get stiffness(): number;
  26768. /**
  26769. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26770. */
  26771. set stiffness(value: number);
  26772. /**
  26773. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26774. */
  26775. get velocityIterations(): number;
  26776. /**
  26777. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26778. */
  26779. set velocityIterations(value: number);
  26780. /**
  26781. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26782. */
  26783. get positionIterations(): number;
  26784. /**
  26785. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26786. */
  26787. set positionIterations(value: number);
  26788. /**
  26789. * The unique id of the physics imposter
  26790. * set by the physics engine when adding this impostor to the array
  26791. */
  26792. uniqueId: number;
  26793. /**
  26794. * @hidden
  26795. */
  26796. soft: boolean;
  26797. /**
  26798. * @hidden
  26799. */
  26800. segments: number;
  26801. private _joints;
  26802. /**
  26803. * Initializes the physics imposter
  26804. * @param object The physics-enabled object used as the physics imposter
  26805. * @param type The type of the physics imposter
  26806. * @param _options The options for the physics imposter
  26807. * @param _scene The Babylon scene
  26808. */
  26809. constructor(
  26810. /**
  26811. * The physics-enabled object used as the physics imposter
  26812. */
  26813. object: IPhysicsEnabledObject,
  26814. /**
  26815. * The type of the physics imposter
  26816. */
  26817. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26818. /**
  26819. * This function will completly initialize this impostor.
  26820. * It will create a new body - but only if this mesh has no parent.
  26821. * If it has, this impostor will not be used other than to define the impostor
  26822. * of the child mesh.
  26823. * @hidden
  26824. */
  26825. _init(): void;
  26826. private _getPhysicsParent;
  26827. /**
  26828. * Should a new body be generated.
  26829. * @returns boolean specifying if body initialization is required
  26830. */
  26831. isBodyInitRequired(): boolean;
  26832. /**
  26833. * Sets the updated scaling
  26834. * @param updated Specifies if the scaling is updated
  26835. */
  26836. setScalingUpdated(): void;
  26837. /**
  26838. * Force a regeneration of this or the parent's impostor's body.
  26839. * Use under cautious - This will remove all joints already implemented.
  26840. */
  26841. forceUpdate(): void;
  26842. /**
  26843. * Gets the body that holds this impostor. Either its own, or its parent.
  26844. */
  26845. get physicsBody(): any;
  26846. /**
  26847. * Get the parent of the physics imposter
  26848. * @returns Physics imposter or null
  26849. */
  26850. get parent(): Nullable<PhysicsImpostor>;
  26851. /**
  26852. * Sets the parent of the physics imposter
  26853. */
  26854. set parent(value: Nullable<PhysicsImpostor>);
  26855. /**
  26856. * Set the physics body. Used mainly by the physics engine/plugin
  26857. */
  26858. set physicsBody(physicsBody: any);
  26859. /**
  26860. * Resets the update flags
  26861. */
  26862. resetUpdateFlags(): void;
  26863. /**
  26864. * Gets the object extend size
  26865. * @returns the object extend size
  26866. */
  26867. getObjectExtendSize(): Vector3;
  26868. /**
  26869. * Gets the object center
  26870. * @returns The object center
  26871. */
  26872. getObjectCenter(): Vector3;
  26873. /**
  26874. * Get a specific parameter from the options parameters
  26875. * @param paramName The object parameter name
  26876. * @returns The object parameter
  26877. */
  26878. getParam(paramName: string): any;
  26879. /**
  26880. * Sets a specific parameter in the options given to the physics plugin
  26881. * @param paramName The parameter name
  26882. * @param value The value of the parameter
  26883. */
  26884. setParam(paramName: string, value: number): void;
  26885. /**
  26886. * Specifically change the body's mass option. Won't recreate the physics body object
  26887. * @param mass The mass of the physics imposter
  26888. */
  26889. setMass(mass: number): void;
  26890. /**
  26891. * Gets the linear velocity
  26892. * @returns linear velocity or null
  26893. */
  26894. getLinearVelocity(): Nullable<Vector3>;
  26895. /**
  26896. * Sets the linear velocity
  26897. * @param velocity linear velocity or null
  26898. */
  26899. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26900. /**
  26901. * Gets the angular velocity
  26902. * @returns angular velocity or null
  26903. */
  26904. getAngularVelocity(): Nullable<Vector3>;
  26905. /**
  26906. * Sets the angular velocity
  26907. * @param velocity The velocity or null
  26908. */
  26909. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26910. /**
  26911. * Execute a function with the physics plugin native code
  26912. * Provide a function the will have two variables - the world object and the physics body object
  26913. * @param func The function to execute with the physics plugin native code
  26914. */
  26915. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26916. /**
  26917. * Register a function that will be executed before the physics world is stepping forward
  26918. * @param func The function to execute before the physics world is stepped forward
  26919. */
  26920. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26921. /**
  26922. * Unregister a function that will be executed before the physics world is stepping forward
  26923. * @param func The function to execute before the physics world is stepped forward
  26924. */
  26925. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26926. /**
  26927. * Register a function that will be executed after the physics step
  26928. * @param func The function to execute after physics step
  26929. */
  26930. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26931. /**
  26932. * Unregisters a function that will be executed after the physics step
  26933. * @param func The function to execute after physics step
  26934. */
  26935. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26936. /**
  26937. * register a function that will be executed when this impostor collides against a different body
  26938. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26939. * @param func Callback that is executed on collision
  26940. */
  26941. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26942. /**
  26943. * Unregisters the physics imposter on contact
  26944. * @param collideAgainst The physics object to collide against
  26945. * @param func Callback to execute on collision
  26946. */
  26947. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26948. private _tmpQuat;
  26949. private _tmpQuat2;
  26950. /**
  26951. * Get the parent rotation
  26952. * @returns The parent rotation
  26953. */
  26954. getParentsRotation(): Quaternion;
  26955. /**
  26956. * this function is executed by the physics engine.
  26957. */
  26958. beforeStep: () => void;
  26959. /**
  26960. * this function is executed by the physics engine
  26961. */
  26962. afterStep: () => void;
  26963. /**
  26964. * Legacy collision detection event support
  26965. */
  26966. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26967. /**
  26968. * event and body object due to cannon's event-based architecture.
  26969. */
  26970. onCollide: (e: {
  26971. body: any;
  26972. }) => void;
  26973. /**
  26974. * Apply a force
  26975. * @param force The force to apply
  26976. * @param contactPoint The contact point for the force
  26977. * @returns The physics imposter
  26978. */
  26979. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26980. /**
  26981. * Apply an impulse
  26982. * @param force The impulse force
  26983. * @param contactPoint The contact point for the impulse force
  26984. * @returns The physics imposter
  26985. */
  26986. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26987. /**
  26988. * A help function to create a joint
  26989. * @param otherImpostor A physics imposter used to create a joint
  26990. * @param jointType The type of joint
  26991. * @param jointData The data for the joint
  26992. * @returns The physics imposter
  26993. */
  26994. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26995. /**
  26996. * Add a joint to this impostor with a different impostor
  26997. * @param otherImpostor A physics imposter used to add a joint
  26998. * @param joint The joint to add
  26999. * @returns The physics imposter
  27000. */
  27001. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27002. /**
  27003. * Add an anchor to a cloth impostor
  27004. * @param otherImpostor rigid impostor to anchor to
  27005. * @param width ratio across width from 0 to 1
  27006. * @param height ratio up height from 0 to 1
  27007. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27008. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27009. * @returns impostor the soft imposter
  27010. */
  27011. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27012. /**
  27013. * Add a hook to a rope impostor
  27014. * @param otherImpostor rigid impostor to anchor to
  27015. * @param length ratio across rope from 0 to 1
  27016. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27017. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27018. * @returns impostor the rope imposter
  27019. */
  27020. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27021. /**
  27022. * Will keep this body still, in a sleep mode.
  27023. * @returns the physics imposter
  27024. */
  27025. sleep(): PhysicsImpostor;
  27026. /**
  27027. * Wake the body up.
  27028. * @returns The physics imposter
  27029. */
  27030. wakeUp(): PhysicsImpostor;
  27031. /**
  27032. * Clones the physics imposter
  27033. * @param newObject The physics imposter clones to this physics-enabled object
  27034. * @returns A nullable physics imposter
  27035. */
  27036. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27037. /**
  27038. * Disposes the physics imposter
  27039. */
  27040. dispose(): void;
  27041. /**
  27042. * Sets the delta position
  27043. * @param position The delta position amount
  27044. */
  27045. setDeltaPosition(position: Vector3): void;
  27046. /**
  27047. * Sets the delta rotation
  27048. * @param rotation The delta rotation amount
  27049. */
  27050. setDeltaRotation(rotation: Quaternion): void;
  27051. /**
  27052. * Gets the box size of the physics imposter and stores the result in the input parameter
  27053. * @param result Stores the box size
  27054. * @returns The physics imposter
  27055. */
  27056. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27057. /**
  27058. * Gets the radius of the physics imposter
  27059. * @returns Radius of the physics imposter
  27060. */
  27061. getRadius(): number;
  27062. /**
  27063. * Sync a bone with this impostor
  27064. * @param bone The bone to sync to the impostor.
  27065. * @param boneMesh The mesh that the bone is influencing.
  27066. * @param jointPivot The pivot of the joint / bone in local space.
  27067. * @param distToJoint Optional distance from the impostor to the joint.
  27068. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27069. */
  27070. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27071. /**
  27072. * Sync impostor to a bone
  27073. * @param bone The bone that the impostor will be synced to.
  27074. * @param boneMesh The mesh that the bone is influencing.
  27075. * @param jointPivot The pivot of the joint / bone in local space.
  27076. * @param distToJoint Optional distance from the impostor to the joint.
  27077. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27078. * @param boneAxis Optional vector3 axis the bone is aligned with
  27079. */
  27080. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27081. /**
  27082. * No-Imposter type
  27083. */
  27084. static NoImpostor: number;
  27085. /**
  27086. * Sphere-Imposter type
  27087. */
  27088. static SphereImpostor: number;
  27089. /**
  27090. * Box-Imposter type
  27091. */
  27092. static BoxImpostor: number;
  27093. /**
  27094. * Plane-Imposter type
  27095. */
  27096. static PlaneImpostor: number;
  27097. /**
  27098. * Mesh-imposter type
  27099. */
  27100. static MeshImpostor: number;
  27101. /**
  27102. * Capsule-Impostor type (Ammo.js plugin only)
  27103. */
  27104. static CapsuleImpostor: number;
  27105. /**
  27106. * Cylinder-Imposter type
  27107. */
  27108. static CylinderImpostor: number;
  27109. /**
  27110. * Particle-Imposter type
  27111. */
  27112. static ParticleImpostor: number;
  27113. /**
  27114. * Heightmap-Imposter type
  27115. */
  27116. static HeightmapImpostor: number;
  27117. /**
  27118. * ConvexHull-Impostor type (Ammo.js plugin only)
  27119. */
  27120. static ConvexHullImpostor: number;
  27121. /**
  27122. * Custom-Imposter type (Ammo.js plugin only)
  27123. */
  27124. static CustomImpostor: number;
  27125. /**
  27126. * Rope-Imposter type
  27127. */
  27128. static RopeImpostor: number;
  27129. /**
  27130. * Cloth-Imposter type
  27131. */
  27132. static ClothImpostor: number;
  27133. /**
  27134. * Softbody-Imposter type
  27135. */
  27136. static SoftbodyImpostor: number;
  27137. }
  27138. }
  27139. declare module BABYLON {
  27140. /**
  27141. * @hidden
  27142. **/
  27143. export class _CreationDataStorage {
  27144. closePath?: boolean;
  27145. closeArray?: boolean;
  27146. idx: number[];
  27147. dashSize: number;
  27148. gapSize: number;
  27149. path3D: Path3D;
  27150. pathArray: Vector3[][];
  27151. arc: number;
  27152. radius: number;
  27153. cap: number;
  27154. tessellation: number;
  27155. }
  27156. /**
  27157. * @hidden
  27158. **/
  27159. class _InstanceDataStorage {
  27160. visibleInstances: any;
  27161. batchCache: _InstancesBatch;
  27162. instancesBufferSize: number;
  27163. instancesBuffer: Nullable<Buffer>;
  27164. instancesData: Float32Array;
  27165. overridenInstanceCount: number;
  27166. isFrozen: boolean;
  27167. previousBatch: Nullable<_InstancesBatch>;
  27168. hardwareInstancedRendering: boolean;
  27169. sideOrientation: number;
  27170. manualUpdate: boolean;
  27171. }
  27172. /**
  27173. * @hidden
  27174. **/
  27175. export class _InstancesBatch {
  27176. mustReturn: boolean;
  27177. visibleInstances: Nullable<InstancedMesh[]>[];
  27178. renderSelf: boolean[];
  27179. hardwareInstancedRendering: boolean[];
  27180. }
  27181. /**
  27182. * @hidden
  27183. **/
  27184. class _ThinInstanceDataStorage {
  27185. instancesCount: number;
  27186. matrixBuffer: Nullable<Buffer>;
  27187. matrixBufferSize: number;
  27188. matrixData: Nullable<Float32Array>;
  27189. boundingVectors: Array<Vector3>;
  27190. }
  27191. /**
  27192. * Class used to represent renderable models
  27193. */
  27194. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27195. /**
  27196. * Mesh side orientation : usually the external or front surface
  27197. */
  27198. static readonly FRONTSIDE: number;
  27199. /**
  27200. * Mesh side orientation : usually the internal or back surface
  27201. */
  27202. static readonly BACKSIDE: number;
  27203. /**
  27204. * Mesh side orientation : both internal and external or front and back surfaces
  27205. */
  27206. static readonly DOUBLESIDE: number;
  27207. /**
  27208. * Mesh side orientation : by default, `FRONTSIDE`
  27209. */
  27210. static readonly DEFAULTSIDE: number;
  27211. /**
  27212. * Mesh cap setting : no cap
  27213. */
  27214. static readonly NO_CAP: number;
  27215. /**
  27216. * Mesh cap setting : one cap at the beginning of the mesh
  27217. */
  27218. static readonly CAP_START: number;
  27219. /**
  27220. * Mesh cap setting : one cap at the end of the mesh
  27221. */
  27222. static readonly CAP_END: number;
  27223. /**
  27224. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27225. */
  27226. static readonly CAP_ALL: number;
  27227. /**
  27228. * Mesh pattern setting : no flip or rotate
  27229. */
  27230. static readonly NO_FLIP: number;
  27231. /**
  27232. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27233. */
  27234. static readonly FLIP_TILE: number;
  27235. /**
  27236. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27237. */
  27238. static readonly ROTATE_TILE: number;
  27239. /**
  27240. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27241. */
  27242. static readonly FLIP_ROW: number;
  27243. /**
  27244. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27245. */
  27246. static readonly ROTATE_ROW: number;
  27247. /**
  27248. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27249. */
  27250. static readonly FLIP_N_ROTATE_TILE: number;
  27251. /**
  27252. * Mesh pattern setting : rotate pattern and rotate
  27253. */
  27254. static readonly FLIP_N_ROTATE_ROW: number;
  27255. /**
  27256. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27257. */
  27258. static readonly CENTER: number;
  27259. /**
  27260. * Mesh tile positioning : part tiles on left
  27261. */
  27262. static readonly LEFT: number;
  27263. /**
  27264. * Mesh tile positioning : part tiles on right
  27265. */
  27266. static readonly RIGHT: number;
  27267. /**
  27268. * Mesh tile positioning : part tiles on top
  27269. */
  27270. static readonly TOP: number;
  27271. /**
  27272. * Mesh tile positioning : part tiles on bottom
  27273. */
  27274. static readonly BOTTOM: number;
  27275. /**
  27276. * Gets the default side orientation.
  27277. * @param orientation the orientation to value to attempt to get
  27278. * @returns the default orientation
  27279. * @hidden
  27280. */
  27281. static _GetDefaultSideOrientation(orientation?: number): number;
  27282. private _internalMeshDataInfo;
  27283. /**
  27284. * An event triggered before rendering the mesh
  27285. */
  27286. get onBeforeRenderObservable(): Observable<Mesh>;
  27287. /**
  27288. * An event triggered before binding the mesh
  27289. */
  27290. get onBeforeBindObservable(): Observable<Mesh>;
  27291. /**
  27292. * An event triggered after rendering the mesh
  27293. */
  27294. get onAfterRenderObservable(): Observable<Mesh>;
  27295. /**
  27296. * An event triggered before drawing the mesh
  27297. */
  27298. get onBeforeDrawObservable(): Observable<Mesh>;
  27299. private _onBeforeDrawObserver;
  27300. /**
  27301. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27302. */
  27303. set onBeforeDraw(callback: () => void);
  27304. get hasInstances(): boolean;
  27305. get hasThinInstances(): boolean;
  27306. /**
  27307. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27308. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27309. */
  27310. delayLoadState: number;
  27311. /**
  27312. * Gets the list of instances created from this mesh
  27313. * it is not supposed to be modified manually.
  27314. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27315. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27316. */
  27317. instances: InstancedMesh[];
  27318. /**
  27319. * Gets the file containing delay loading data for this mesh
  27320. */
  27321. delayLoadingFile: string;
  27322. /** @hidden */
  27323. _binaryInfo: any;
  27324. /**
  27325. * User defined function used to change how LOD level selection is done
  27326. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27327. */
  27328. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27329. /**
  27330. * Gets or sets the morph target manager
  27331. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27332. */
  27333. get morphTargetManager(): Nullable<MorphTargetManager>;
  27334. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27335. /** @hidden */
  27336. _creationDataStorage: Nullable<_CreationDataStorage>;
  27337. /** @hidden */
  27338. _geometry: Nullable<Geometry>;
  27339. /** @hidden */
  27340. _delayInfo: Array<string>;
  27341. /** @hidden */
  27342. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27343. /** @hidden */
  27344. _instanceDataStorage: _InstanceDataStorage;
  27345. /** @hidden */
  27346. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  27347. private _effectiveMaterial;
  27348. /** @hidden */
  27349. _shouldGenerateFlatShading: boolean;
  27350. /** @hidden */
  27351. _originalBuilderSideOrientation: number;
  27352. /**
  27353. * Use this property to change the original side orientation defined at construction time
  27354. */
  27355. overrideMaterialSideOrientation: Nullable<number>;
  27356. /**
  27357. * Gets the source mesh (the one used to clone this one from)
  27358. */
  27359. get source(): Nullable<Mesh>;
  27360. /**
  27361. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27362. */
  27363. get isUnIndexed(): boolean;
  27364. set isUnIndexed(value: boolean);
  27365. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27366. get worldMatrixInstancedBuffer(): Float32Array;
  27367. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27368. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27369. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27370. /**
  27371. * @constructor
  27372. * @param name The value used by scene.getMeshByName() to do a lookup.
  27373. * @param scene The scene to add this mesh to.
  27374. * @param parent The parent of this mesh, if it has one
  27375. * @param source An optional Mesh from which geometry is shared, cloned.
  27376. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27377. * When false, achieved by calling a clone(), also passing False.
  27378. * This will make creation of children, recursive.
  27379. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27380. */
  27381. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27382. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27383. doNotInstantiate: boolean;
  27384. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27385. /**
  27386. * Gets the class name
  27387. * @returns the string "Mesh".
  27388. */
  27389. getClassName(): string;
  27390. /** @hidden */
  27391. get _isMesh(): boolean;
  27392. /**
  27393. * Returns a description of this mesh
  27394. * @param fullDetails define if full details about this mesh must be used
  27395. * @returns a descriptive string representing this mesh
  27396. */
  27397. toString(fullDetails?: boolean): string;
  27398. /** @hidden */
  27399. _unBindEffect(): void;
  27400. /**
  27401. * Gets a boolean indicating if this mesh has LOD
  27402. */
  27403. get hasLODLevels(): boolean;
  27404. /**
  27405. * Gets the list of MeshLODLevel associated with the current mesh
  27406. * @returns an array of MeshLODLevel
  27407. */
  27408. getLODLevels(): MeshLODLevel[];
  27409. private _sortLODLevels;
  27410. /**
  27411. * Add a mesh as LOD level triggered at the given distance.
  27412. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27413. * @param distance The distance from the center of the object to show this level
  27414. * @param mesh The mesh to be added as LOD level (can be null)
  27415. * @return This mesh (for chaining)
  27416. */
  27417. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27418. /**
  27419. * Returns the LOD level mesh at the passed distance or null if not found.
  27420. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27421. * @param distance The distance from the center of the object to show this level
  27422. * @returns a Mesh or `null`
  27423. */
  27424. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27425. /**
  27426. * Remove a mesh from the LOD array
  27427. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27428. * @param mesh defines the mesh to be removed
  27429. * @return This mesh (for chaining)
  27430. */
  27431. removeLODLevel(mesh: Mesh): Mesh;
  27432. /**
  27433. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27434. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27435. * @param camera defines the camera to use to compute distance
  27436. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27437. * @return This mesh (for chaining)
  27438. */
  27439. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27440. /**
  27441. * Gets the mesh internal Geometry object
  27442. */
  27443. get geometry(): Nullable<Geometry>;
  27444. /**
  27445. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27446. * @returns the total number of vertices
  27447. */
  27448. getTotalVertices(): number;
  27449. /**
  27450. * Returns the content of an associated vertex buffer
  27451. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27452. * - VertexBuffer.PositionKind
  27453. * - VertexBuffer.UVKind
  27454. * - VertexBuffer.UV2Kind
  27455. * - VertexBuffer.UV3Kind
  27456. * - VertexBuffer.UV4Kind
  27457. * - VertexBuffer.UV5Kind
  27458. * - VertexBuffer.UV6Kind
  27459. * - VertexBuffer.ColorKind
  27460. * - VertexBuffer.MatricesIndicesKind
  27461. * - VertexBuffer.MatricesIndicesExtraKind
  27462. * - VertexBuffer.MatricesWeightsKind
  27463. * - VertexBuffer.MatricesWeightsExtraKind
  27464. * @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
  27465. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27466. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27467. */
  27468. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27469. /**
  27470. * Returns the mesh VertexBuffer object from the requested `kind`
  27471. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27472. * - VertexBuffer.PositionKind
  27473. * - VertexBuffer.NormalKind
  27474. * - VertexBuffer.UVKind
  27475. * - VertexBuffer.UV2Kind
  27476. * - VertexBuffer.UV3Kind
  27477. * - VertexBuffer.UV4Kind
  27478. * - VertexBuffer.UV5Kind
  27479. * - VertexBuffer.UV6Kind
  27480. * - VertexBuffer.ColorKind
  27481. * - VertexBuffer.MatricesIndicesKind
  27482. * - VertexBuffer.MatricesIndicesExtraKind
  27483. * - VertexBuffer.MatricesWeightsKind
  27484. * - VertexBuffer.MatricesWeightsExtraKind
  27485. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27486. */
  27487. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27488. /**
  27489. * Tests if a specific vertex buffer is associated with this mesh
  27490. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27491. * - VertexBuffer.PositionKind
  27492. * - VertexBuffer.NormalKind
  27493. * - VertexBuffer.UVKind
  27494. * - VertexBuffer.UV2Kind
  27495. * - VertexBuffer.UV3Kind
  27496. * - VertexBuffer.UV4Kind
  27497. * - VertexBuffer.UV5Kind
  27498. * - VertexBuffer.UV6Kind
  27499. * - VertexBuffer.ColorKind
  27500. * - VertexBuffer.MatricesIndicesKind
  27501. * - VertexBuffer.MatricesIndicesExtraKind
  27502. * - VertexBuffer.MatricesWeightsKind
  27503. * - VertexBuffer.MatricesWeightsExtraKind
  27504. * @returns a boolean
  27505. */
  27506. isVerticesDataPresent(kind: string): boolean;
  27507. /**
  27508. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27509. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27510. * - VertexBuffer.PositionKind
  27511. * - VertexBuffer.UVKind
  27512. * - VertexBuffer.UV2Kind
  27513. * - VertexBuffer.UV3Kind
  27514. * - VertexBuffer.UV4Kind
  27515. * - VertexBuffer.UV5Kind
  27516. * - VertexBuffer.UV6Kind
  27517. * - VertexBuffer.ColorKind
  27518. * - VertexBuffer.MatricesIndicesKind
  27519. * - VertexBuffer.MatricesIndicesExtraKind
  27520. * - VertexBuffer.MatricesWeightsKind
  27521. * - VertexBuffer.MatricesWeightsExtraKind
  27522. * @returns a boolean
  27523. */
  27524. isVertexBufferUpdatable(kind: string): boolean;
  27525. /**
  27526. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27527. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27528. * - VertexBuffer.PositionKind
  27529. * - VertexBuffer.NormalKind
  27530. * - VertexBuffer.UVKind
  27531. * - VertexBuffer.UV2Kind
  27532. * - VertexBuffer.UV3Kind
  27533. * - VertexBuffer.UV4Kind
  27534. * - VertexBuffer.UV5Kind
  27535. * - VertexBuffer.UV6Kind
  27536. * - VertexBuffer.ColorKind
  27537. * - VertexBuffer.MatricesIndicesKind
  27538. * - VertexBuffer.MatricesIndicesExtraKind
  27539. * - VertexBuffer.MatricesWeightsKind
  27540. * - VertexBuffer.MatricesWeightsExtraKind
  27541. * @returns an array of strings
  27542. */
  27543. getVerticesDataKinds(): string[];
  27544. /**
  27545. * Returns a positive integer : the total number of indices in this mesh geometry.
  27546. * @returns the numner of indices or zero if the mesh has no geometry.
  27547. */
  27548. getTotalIndices(): number;
  27549. /**
  27550. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27551. * @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.
  27552. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27553. * @returns the indices array or an empty array if the mesh has no geometry
  27554. */
  27555. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27556. get isBlocked(): boolean;
  27557. /**
  27558. * Determine if the current mesh is ready to be rendered
  27559. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27560. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27561. * @returns true if all associated assets are ready (material, textures, shaders)
  27562. */
  27563. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27564. /**
  27565. * 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.
  27566. */
  27567. get areNormalsFrozen(): boolean;
  27568. /**
  27569. * 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.
  27570. * @returns the current mesh
  27571. */
  27572. freezeNormals(): Mesh;
  27573. /**
  27574. * 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
  27575. * @returns the current mesh
  27576. */
  27577. unfreezeNormals(): Mesh;
  27578. /**
  27579. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27580. */
  27581. set overridenInstanceCount(count: number);
  27582. /** @hidden */
  27583. _preActivate(): Mesh;
  27584. /** @hidden */
  27585. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27586. /** @hidden */
  27587. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27588. protected _afterComputeWorldMatrix(): void;
  27589. /**
  27590. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27591. * This means the mesh underlying bounding box and sphere are recomputed.
  27592. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27593. * @returns the current mesh
  27594. */
  27595. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27596. /** @hidden */
  27597. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27598. /**
  27599. * This function will subdivide the mesh into multiple submeshes
  27600. * @param count defines the expected number of submeshes
  27601. */
  27602. subdivide(count: number): void;
  27603. /**
  27604. * Copy a FloatArray into a specific associated vertex buffer
  27605. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27606. * - VertexBuffer.PositionKind
  27607. * - VertexBuffer.UVKind
  27608. * - VertexBuffer.UV2Kind
  27609. * - VertexBuffer.UV3Kind
  27610. * - VertexBuffer.UV4Kind
  27611. * - VertexBuffer.UV5Kind
  27612. * - VertexBuffer.UV6Kind
  27613. * - VertexBuffer.ColorKind
  27614. * - VertexBuffer.MatricesIndicesKind
  27615. * - VertexBuffer.MatricesIndicesExtraKind
  27616. * - VertexBuffer.MatricesWeightsKind
  27617. * - VertexBuffer.MatricesWeightsExtraKind
  27618. * @param data defines the data source
  27619. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27620. * @param stride defines the data stride size (can be null)
  27621. * @returns the current mesh
  27622. */
  27623. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27624. /**
  27625. * Delete a vertex buffer associated with this mesh
  27626. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27627. * - VertexBuffer.PositionKind
  27628. * - VertexBuffer.UVKind
  27629. * - VertexBuffer.UV2Kind
  27630. * - VertexBuffer.UV3Kind
  27631. * - VertexBuffer.UV4Kind
  27632. * - VertexBuffer.UV5Kind
  27633. * - VertexBuffer.UV6Kind
  27634. * - VertexBuffer.ColorKind
  27635. * - VertexBuffer.MatricesIndicesKind
  27636. * - VertexBuffer.MatricesIndicesExtraKind
  27637. * - VertexBuffer.MatricesWeightsKind
  27638. * - VertexBuffer.MatricesWeightsExtraKind
  27639. */
  27640. removeVerticesData(kind: string): void;
  27641. /**
  27642. * Flags an associated vertex buffer as updatable
  27643. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27644. * - VertexBuffer.PositionKind
  27645. * - VertexBuffer.UVKind
  27646. * - VertexBuffer.UV2Kind
  27647. * - VertexBuffer.UV3Kind
  27648. * - VertexBuffer.UV4Kind
  27649. * - VertexBuffer.UV5Kind
  27650. * - VertexBuffer.UV6Kind
  27651. * - VertexBuffer.ColorKind
  27652. * - VertexBuffer.MatricesIndicesKind
  27653. * - VertexBuffer.MatricesIndicesExtraKind
  27654. * - VertexBuffer.MatricesWeightsKind
  27655. * - VertexBuffer.MatricesWeightsExtraKind
  27656. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27657. */
  27658. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27659. /**
  27660. * Sets the mesh global Vertex Buffer
  27661. * @param buffer defines the buffer to use
  27662. * @returns the current mesh
  27663. */
  27664. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27665. /**
  27666. * Update a specific associated vertex buffer
  27667. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27668. * - VertexBuffer.PositionKind
  27669. * - VertexBuffer.UVKind
  27670. * - VertexBuffer.UV2Kind
  27671. * - VertexBuffer.UV3Kind
  27672. * - VertexBuffer.UV4Kind
  27673. * - VertexBuffer.UV5Kind
  27674. * - VertexBuffer.UV6Kind
  27675. * - VertexBuffer.ColorKind
  27676. * - VertexBuffer.MatricesIndicesKind
  27677. * - VertexBuffer.MatricesIndicesExtraKind
  27678. * - VertexBuffer.MatricesWeightsKind
  27679. * - VertexBuffer.MatricesWeightsExtraKind
  27680. * @param data defines the data source
  27681. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27682. * @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)
  27683. * @returns the current mesh
  27684. */
  27685. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27686. /**
  27687. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27688. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27689. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27690. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27691. * @returns the current mesh
  27692. */
  27693. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27694. /**
  27695. * Creates a un-shared specific occurence of the geometry for the mesh.
  27696. * @returns the current mesh
  27697. */
  27698. makeGeometryUnique(): Mesh;
  27699. /**
  27700. * Set the index buffer of this mesh
  27701. * @param indices defines the source data
  27702. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27703. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27704. * @returns the current mesh
  27705. */
  27706. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27707. /**
  27708. * Update the current index buffer
  27709. * @param indices defines the source data
  27710. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27711. * @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)
  27712. * @returns the current mesh
  27713. */
  27714. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27715. /**
  27716. * Invert the geometry to move from a right handed system to a left handed one.
  27717. * @returns the current mesh
  27718. */
  27719. toLeftHanded(): Mesh;
  27720. /** @hidden */
  27721. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27722. /** @hidden */
  27723. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27724. /**
  27725. * Registers for this mesh a javascript function called just before the rendering process
  27726. * @param func defines the function to call before rendering this mesh
  27727. * @returns the current mesh
  27728. */
  27729. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27730. /**
  27731. * Disposes a previously registered javascript function called before the rendering
  27732. * @param func defines the function to remove
  27733. * @returns the current mesh
  27734. */
  27735. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27736. /**
  27737. * Registers for this mesh a javascript function called just after the rendering is complete
  27738. * @param func defines the function to call after rendering this mesh
  27739. * @returns the current mesh
  27740. */
  27741. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27742. /**
  27743. * Disposes a previously registered javascript function called after the rendering.
  27744. * @param func defines the function to remove
  27745. * @returns the current mesh
  27746. */
  27747. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27748. /** @hidden */
  27749. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27750. /** @hidden */
  27751. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27752. /** @hidden */
  27753. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  27754. /** @hidden */
  27755. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27756. /** @hidden */
  27757. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27758. /** @hidden */
  27759. _rebuild(): void;
  27760. /** @hidden */
  27761. _freeze(): void;
  27762. /** @hidden */
  27763. _unFreeze(): void;
  27764. /**
  27765. * 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
  27766. * @param subMesh defines the subMesh to render
  27767. * @param enableAlphaMode defines if alpha mode can be changed
  27768. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27769. * @returns the current mesh
  27770. */
  27771. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27772. private _onBeforeDraw;
  27773. /**
  27774. * Renormalize the mesh and patch it up if there are no weights
  27775. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27776. * However in the case of zero weights then we set just a single influence to 1.
  27777. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27778. */
  27779. cleanMatrixWeights(): void;
  27780. private normalizeSkinFourWeights;
  27781. private normalizeSkinWeightsAndExtra;
  27782. /**
  27783. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27784. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27785. * the user know there was an issue with importing the mesh
  27786. * @returns a validation object with skinned, valid and report string
  27787. */
  27788. validateSkinning(): {
  27789. skinned: boolean;
  27790. valid: boolean;
  27791. report: string;
  27792. };
  27793. /** @hidden */
  27794. _checkDelayState(): Mesh;
  27795. private _queueLoad;
  27796. /**
  27797. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27798. * A mesh is in the frustum if its bounding box intersects the frustum
  27799. * @param frustumPlanes defines the frustum to test
  27800. * @returns true if the mesh is in the frustum planes
  27801. */
  27802. isInFrustum(frustumPlanes: Plane[]): boolean;
  27803. /**
  27804. * Sets the mesh material by the material or multiMaterial `id` property
  27805. * @param id is a string identifying the material or the multiMaterial
  27806. * @returns the current mesh
  27807. */
  27808. setMaterialByID(id: string): Mesh;
  27809. /**
  27810. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27811. * @returns an array of IAnimatable
  27812. */
  27813. getAnimatables(): IAnimatable[];
  27814. /**
  27815. * Modifies the mesh geometry according to the passed transformation matrix.
  27816. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27817. * The mesh normals are modified using the same transformation.
  27818. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27819. * @param transform defines the transform matrix to use
  27820. * @see http://doc.babylonjs.com/resources/baking_transformations
  27821. * @returns the current mesh
  27822. */
  27823. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27824. /**
  27825. * Modifies the mesh geometry according to its own current World Matrix.
  27826. * The mesh World Matrix is then reset.
  27827. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27828. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27829. * @see http://doc.babylonjs.com/resources/baking_transformations
  27830. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27831. * @returns the current mesh
  27832. */
  27833. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27834. /** @hidden */
  27835. get _positions(): Nullable<Vector3[]>;
  27836. /** @hidden */
  27837. _resetPointsArrayCache(): Mesh;
  27838. /** @hidden */
  27839. _generatePointsArray(): boolean;
  27840. /**
  27841. * Returns a new Mesh object generated from the current mesh properties.
  27842. * This method must not get confused with createInstance()
  27843. * @param name is a string, the name given to the new mesh
  27844. * @param newParent can be any Node object (default `null`)
  27845. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27846. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27847. * @returns a new mesh
  27848. */
  27849. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27850. /**
  27851. * Releases resources associated with this mesh.
  27852. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27853. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27854. */
  27855. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27856. /** @hidden */
  27857. _disposeInstanceSpecificData(): void;
  27858. /** @hidden */
  27859. _disposeThinInstanceSpecificData(): void;
  27860. /**
  27861. * Modifies the mesh geometry according to a displacement map.
  27862. * 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.
  27863. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27864. * @param url is a string, the URL from the image file is to be downloaded.
  27865. * @param minHeight is the lower limit of the displacement.
  27866. * @param maxHeight is the upper limit of the displacement.
  27867. * @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.
  27868. * @param uvOffset is an optional vector2 used to offset UV.
  27869. * @param uvScale is an optional vector2 used to scale UV.
  27870. * @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.
  27871. * @returns the Mesh.
  27872. */
  27873. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27874. /**
  27875. * Modifies the mesh geometry according to a displacementMap buffer.
  27876. * 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.
  27877. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27878. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27879. * @param heightMapWidth is the width of the buffer image.
  27880. * @param heightMapHeight is the height of the buffer image.
  27881. * @param minHeight is the lower limit of the displacement.
  27882. * @param maxHeight is the upper limit of the displacement.
  27883. * @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.
  27884. * @param uvOffset is an optional vector2 used to offset UV.
  27885. * @param uvScale is an optional vector2 used to scale UV.
  27886. * @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.
  27887. * @returns the Mesh.
  27888. */
  27889. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27890. /**
  27891. * Modify the mesh to get a flat shading rendering.
  27892. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27893. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27894. * @returns current mesh
  27895. */
  27896. convertToFlatShadedMesh(): Mesh;
  27897. /**
  27898. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27899. * In other words, more vertices, no more indices and a single bigger VBO.
  27900. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27901. * @returns current mesh
  27902. */
  27903. convertToUnIndexedMesh(): Mesh;
  27904. /**
  27905. * Inverses facet orientations.
  27906. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27907. * @param flipNormals will also inverts the normals
  27908. * @returns current mesh
  27909. */
  27910. flipFaces(flipNormals?: boolean): Mesh;
  27911. /**
  27912. * Increase the number of facets and hence vertices in a mesh
  27913. * Vertex normals are interpolated from existing vertex normals
  27914. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27915. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27916. */
  27917. increaseVertices(numberPerEdge: number): void;
  27918. /**
  27919. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27920. * This will undo any application of covertToFlatShadedMesh
  27921. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27922. */
  27923. forceSharedVertices(): void;
  27924. /** @hidden */
  27925. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27926. /** @hidden */
  27927. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27928. /**
  27929. * Creates a new InstancedMesh object from the mesh model.
  27930. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27931. * @param name defines the name of the new instance
  27932. * @returns a new InstancedMesh
  27933. */
  27934. createInstance(name: string): InstancedMesh;
  27935. /**
  27936. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27937. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27938. * @returns the current mesh
  27939. */
  27940. synchronizeInstances(): Mesh;
  27941. /**
  27942. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27943. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27944. * This should be used together with the simplification to avoid disappearing triangles.
  27945. * @param successCallback an optional success callback to be called after the optimization finished.
  27946. * @returns the current mesh
  27947. */
  27948. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27949. /**
  27950. * Serialize current mesh
  27951. * @param serializationObject defines the object which will receive the serialization data
  27952. */
  27953. serialize(serializationObject: any): void;
  27954. /** @hidden */
  27955. _syncGeometryWithMorphTargetManager(): void;
  27956. /** @hidden */
  27957. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  27958. /**
  27959. * Returns a new Mesh object parsed from the source provided.
  27960. * @param parsedMesh is the source
  27961. * @param scene defines the hosting scene
  27962. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27963. * @returns a new Mesh
  27964. */
  27965. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27966. /**
  27967. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27968. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27969. * @param name defines the name of the mesh to create
  27970. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27971. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27972. * @param closePath creates a seam between the first and the last points of each path of the path array
  27973. * @param offset is taken in account only if the `pathArray` is containing a single path
  27974. * @param scene defines the hosting scene
  27975. * @param updatable defines if the mesh must be flagged as updatable
  27976. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27977. * @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)
  27978. * @returns a new Mesh
  27979. */
  27980. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27981. /**
  27982. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27983. * @param name defines the name of the mesh to create
  27984. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27985. * @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
  27986. * @param scene defines the hosting scene
  27987. * @param updatable defines if the mesh must be flagged as updatable
  27988. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27989. * @returns a new Mesh
  27990. */
  27991. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27992. /**
  27993. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27994. * @param name defines the name of the mesh to create
  27995. * @param size sets the size (float) of each box side (default 1)
  27996. * @param scene defines the hosting scene
  27997. * @param updatable defines if the mesh must be flagged as updatable
  27998. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27999. * @returns a new Mesh
  28000. */
  28001. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28002. /**
  28003. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28004. * @param name defines the name of the mesh to create
  28005. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28006. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28007. * @param scene defines the hosting scene
  28008. * @param updatable defines if the mesh must be flagged as updatable
  28009. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28010. * @returns a new Mesh
  28011. */
  28012. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28013. /**
  28014. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28015. * @param name defines the name of the mesh to create
  28016. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28017. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28018. * @param scene defines the hosting scene
  28019. * @returns a new Mesh
  28020. */
  28021. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28022. /**
  28023. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28024. * @param name defines the name of the mesh to create
  28025. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28026. * @param diameterTop set the top cap diameter (floats, default 1)
  28027. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28028. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28029. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28030. * @param scene defines the hosting scene
  28031. * @param updatable defines if the mesh must be flagged as updatable
  28032. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28033. * @returns a new Mesh
  28034. */
  28035. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28036. /**
  28037. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28038. * @param name defines the name of the mesh to create
  28039. * @param diameter sets the diameter size (float) of the torus (default 1)
  28040. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28041. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28042. * @param scene defines the hosting scene
  28043. * @param updatable defines if the mesh must be flagged as updatable
  28044. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28045. * @returns a new Mesh
  28046. */
  28047. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28048. /**
  28049. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28050. * @param name defines the name of the mesh to create
  28051. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28052. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28053. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28054. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28055. * @param p the number of windings on X axis (positive integers, default 2)
  28056. * @param q the number of windings on Y axis (positive integers, default 3)
  28057. * @param scene defines the hosting scene
  28058. * @param updatable defines if the mesh must be flagged as updatable
  28059. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28060. * @returns a new Mesh
  28061. */
  28062. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28063. /**
  28064. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28065. * @param name defines the name of the mesh to create
  28066. * @param points is an array successive Vector3
  28067. * @param scene defines the hosting scene
  28068. * @param updatable defines if the mesh must be flagged as updatable
  28069. * @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).
  28070. * @returns a new Mesh
  28071. */
  28072. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28073. /**
  28074. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28075. * @param name defines the name of the mesh to create
  28076. * @param points is an array successive Vector3
  28077. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28078. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28079. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28080. * @param scene defines the hosting scene
  28081. * @param updatable defines if the mesh must be flagged as updatable
  28082. * @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)
  28083. * @returns a new Mesh
  28084. */
  28085. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28086. /**
  28087. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28088. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28089. * 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.
  28090. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28091. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28092. * Remember you can only change the shape positions, not their number when updating a polygon.
  28093. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28094. * @param name defines the name of the mesh to create
  28095. * @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
  28096. * @param scene defines the hosting scene
  28097. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28098. * @param updatable defines if the mesh must be flagged as updatable
  28099. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28100. * @param earcutInjection can be used to inject your own earcut reference
  28101. * @returns a new Mesh
  28102. */
  28103. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28104. /**
  28105. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28106. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28107. * @param name defines the name of the mesh to create
  28108. * @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
  28109. * @param depth defines the height of extrusion
  28110. * @param scene defines the hosting scene
  28111. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28112. * @param updatable defines if the mesh must be flagged as updatable
  28113. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28114. * @param earcutInjection can be used to inject your own earcut reference
  28115. * @returns a new Mesh
  28116. */
  28117. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28118. /**
  28119. * Creates an extruded shape mesh.
  28120. * 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
  28121. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28122. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28123. * @param name defines the name of the mesh to create
  28124. * @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
  28125. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28126. * @param scale is the value to scale the shape
  28127. * @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
  28128. * @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
  28129. * @param scene defines the hosting scene
  28130. * @param updatable defines if the mesh must be flagged as updatable
  28131. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28132. * @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)
  28133. * @returns a new Mesh
  28134. */
  28135. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28136. /**
  28137. * Creates an custom extruded shape mesh.
  28138. * The custom extrusion is a parametric shape.
  28139. * It has no predefined shape. Its final shape will depend on the input parameters.
  28140. * Please consider using the same method from the MeshBuilder class instead
  28141. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28142. * @param name defines the name of the mesh to create
  28143. * @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
  28144. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28145. * @param scaleFunction is a custom Javascript function called on each path point
  28146. * @param rotationFunction is a custom Javascript function called on each path point
  28147. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28148. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28149. * @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
  28150. * @param scene defines the hosting scene
  28151. * @param updatable defines if the mesh must be flagged as updatable
  28152. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28153. * @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)
  28154. * @returns a new Mesh
  28155. */
  28156. 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;
  28157. /**
  28158. * Creates lathe mesh.
  28159. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28160. * Please consider using the same method from the MeshBuilder class instead
  28161. * @param name defines the name of the mesh to create
  28162. * @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
  28163. * @param radius is the radius value of the lathe
  28164. * @param tessellation is the side number of the lathe.
  28165. * @param scene defines the hosting scene
  28166. * @param updatable defines if the mesh must be flagged as updatable
  28167. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28168. * @returns a new Mesh
  28169. */
  28170. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28171. /**
  28172. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28173. * @param name defines the name of the mesh to create
  28174. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28175. * @param scene defines the hosting scene
  28176. * @param updatable defines if the mesh must be flagged as updatable
  28177. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28178. * @returns a new Mesh
  28179. */
  28180. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28181. /**
  28182. * Creates a ground mesh.
  28183. * Please consider using the same method from the MeshBuilder class instead
  28184. * @param name defines the name of the mesh to create
  28185. * @param width set the width of the ground
  28186. * @param height set the height of the ground
  28187. * @param subdivisions sets the number of subdivisions per side
  28188. * @param scene defines the hosting scene
  28189. * @param updatable defines if the mesh must be flagged as updatable
  28190. * @returns a new Mesh
  28191. */
  28192. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28193. /**
  28194. * Creates a tiled ground mesh.
  28195. * Please consider using the same method from the MeshBuilder class instead
  28196. * @param name defines the name of the mesh to create
  28197. * @param xmin set the ground minimum X coordinate
  28198. * @param zmin set the ground minimum Y coordinate
  28199. * @param xmax set the ground maximum X coordinate
  28200. * @param zmax set the ground maximum Z coordinate
  28201. * @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
  28202. * @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
  28203. * @param scene defines the hosting scene
  28204. * @param updatable defines if the mesh must be flagged as updatable
  28205. * @returns a new Mesh
  28206. */
  28207. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28208. w: number;
  28209. h: number;
  28210. }, precision: {
  28211. w: number;
  28212. h: number;
  28213. }, scene: Scene, updatable?: boolean): Mesh;
  28214. /**
  28215. * Creates a ground mesh from a height map.
  28216. * Please consider using the same method from the MeshBuilder class instead
  28217. * @see http://doc.babylonjs.com/babylon101/height_map
  28218. * @param name defines the name of the mesh to create
  28219. * @param url sets the URL of the height map image resource
  28220. * @param width set the ground width size
  28221. * @param height set the ground height size
  28222. * @param subdivisions sets the number of subdivision per side
  28223. * @param minHeight is the minimum altitude on the ground
  28224. * @param maxHeight is the maximum altitude on the ground
  28225. * @param scene defines the hosting scene
  28226. * @param updatable defines if the mesh must be flagged as updatable
  28227. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28228. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28229. * @returns a new Mesh
  28230. */
  28231. 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;
  28232. /**
  28233. * Creates a tube mesh.
  28234. * The tube is a parametric shape.
  28235. * It has no predefined shape. Its final shape will depend on the input parameters.
  28236. * Please consider using the same method from the MeshBuilder class instead
  28237. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28238. * @param name defines the name of the mesh to create
  28239. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28240. * @param radius sets the tube radius size
  28241. * @param tessellation is the number of sides on the tubular surface
  28242. * @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
  28243. * @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
  28244. * @param scene defines the hosting scene
  28245. * @param updatable defines if the mesh must be flagged as updatable
  28246. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28247. * @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)
  28248. * @returns a new Mesh
  28249. */
  28250. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28251. (i: number, distance: number): number;
  28252. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28253. /**
  28254. * Creates a polyhedron mesh.
  28255. * Please consider using the same method from the MeshBuilder class instead.
  28256. * * 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
  28257. * * The parameter `size` (positive float, default 1) sets the polygon size
  28258. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28259. * * 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`
  28260. * * 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
  28261. * * 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)`)
  28262. * * 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
  28263. * * 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
  28264. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28265. * * 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
  28266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28267. * @param name defines the name of the mesh to create
  28268. * @param options defines the options used to create the mesh
  28269. * @param scene defines the hosting scene
  28270. * @returns a new Mesh
  28271. */
  28272. static CreatePolyhedron(name: string, options: {
  28273. type?: number;
  28274. size?: number;
  28275. sizeX?: number;
  28276. sizeY?: number;
  28277. sizeZ?: number;
  28278. custom?: any;
  28279. faceUV?: Vector4[];
  28280. faceColors?: Color4[];
  28281. updatable?: boolean;
  28282. sideOrientation?: number;
  28283. }, scene: Scene): Mesh;
  28284. /**
  28285. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28286. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28287. * * 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`)
  28288. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28289. * * 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
  28290. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28291. * * 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
  28292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28293. * @param name defines the name of the mesh
  28294. * @param options defines the options used to create the mesh
  28295. * @param scene defines the hosting scene
  28296. * @returns a new Mesh
  28297. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28298. */
  28299. static CreateIcoSphere(name: string, options: {
  28300. radius?: number;
  28301. flat?: boolean;
  28302. subdivisions?: number;
  28303. sideOrientation?: number;
  28304. updatable?: boolean;
  28305. }, scene: Scene): Mesh;
  28306. /**
  28307. * Creates a decal mesh.
  28308. * Please consider using the same method from the MeshBuilder class instead.
  28309. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28310. * @param name defines the name of the mesh
  28311. * @param sourceMesh defines the mesh receiving the decal
  28312. * @param position sets the position of the decal in world coordinates
  28313. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28314. * @param size sets the decal scaling
  28315. * @param angle sets the angle to rotate the decal
  28316. * @returns a new Mesh
  28317. */
  28318. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28319. /**
  28320. * Prepare internal position array for software CPU skinning
  28321. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28322. */
  28323. setPositionsForCPUSkinning(): Float32Array;
  28324. /**
  28325. * Prepare internal normal array for software CPU skinning
  28326. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28327. */
  28328. setNormalsForCPUSkinning(): Float32Array;
  28329. /**
  28330. * Updates the vertex buffer by applying transformation from the bones
  28331. * @param skeleton defines the skeleton to apply to current mesh
  28332. * @returns the current mesh
  28333. */
  28334. applySkeleton(skeleton: Skeleton): Mesh;
  28335. /**
  28336. * 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
  28337. * @param meshes defines the list of meshes to scan
  28338. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28339. */
  28340. static MinMax(meshes: AbstractMesh[]): {
  28341. min: Vector3;
  28342. max: Vector3;
  28343. };
  28344. /**
  28345. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28346. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28347. * @returns a vector3
  28348. */
  28349. static Center(meshesOrMinMaxVector: {
  28350. min: Vector3;
  28351. max: Vector3;
  28352. } | AbstractMesh[]): Vector3;
  28353. /**
  28354. * Merge the array of meshes into a single mesh for performance reasons.
  28355. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28356. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28357. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28358. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28359. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28360. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28361. * @returns a new mesh
  28362. */
  28363. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28364. /** @hidden */
  28365. addInstance(instance: InstancedMesh): void;
  28366. /** @hidden */
  28367. removeInstance(instance: InstancedMesh): void;
  28368. }
  28369. }
  28370. declare module BABYLON {
  28371. /**
  28372. * This is the base class of all the camera used in the application.
  28373. * @see http://doc.babylonjs.com/features/cameras
  28374. */
  28375. export class Camera extends Node {
  28376. /** @hidden */
  28377. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28378. /**
  28379. * This is the default projection mode used by the cameras.
  28380. * It helps recreating a feeling of perspective and better appreciate depth.
  28381. * This is the best way to simulate real life cameras.
  28382. */
  28383. static readonly PERSPECTIVE_CAMERA: number;
  28384. /**
  28385. * This helps creating camera with an orthographic mode.
  28386. * 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.
  28387. */
  28388. static readonly ORTHOGRAPHIC_CAMERA: number;
  28389. /**
  28390. * This is the default FOV mode for perspective cameras.
  28391. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28392. */
  28393. static readonly FOVMODE_VERTICAL_FIXED: number;
  28394. /**
  28395. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28396. */
  28397. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28398. /**
  28399. * This specifies ther is no need for a camera rig.
  28400. * Basically only one eye is rendered corresponding to the camera.
  28401. */
  28402. static readonly RIG_MODE_NONE: number;
  28403. /**
  28404. * Simulates a camera Rig with one blue eye and one red eye.
  28405. * This can be use with 3d blue and red glasses.
  28406. */
  28407. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28408. /**
  28409. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28410. */
  28411. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28412. /**
  28413. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28414. */
  28415. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28416. /**
  28417. * Defines that both eyes of the camera will be rendered over under each other.
  28418. */
  28419. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28420. /**
  28421. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28422. */
  28423. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28424. /**
  28425. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28426. */
  28427. static readonly RIG_MODE_VR: number;
  28428. /**
  28429. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28430. */
  28431. static readonly RIG_MODE_WEBVR: number;
  28432. /**
  28433. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28434. */
  28435. static readonly RIG_MODE_CUSTOM: number;
  28436. /**
  28437. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28438. */
  28439. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28440. /**
  28441. * Define the input manager associated with the camera.
  28442. */
  28443. inputs: CameraInputsManager<Camera>;
  28444. /** @hidden */
  28445. _position: Vector3;
  28446. /**
  28447. * Define the current local position of the camera in the scene
  28448. */
  28449. get position(): Vector3;
  28450. set position(newPosition: Vector3);
  28451. /**
  28452. * The vector the camera should consider as up.
  28453. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28454. */
  28455. upVector: Vector3;
  28456. /**
  28457. * Define the current limit on the left side for an orthographic camera
  28458. * In scene unit
  28459. */
  28460. orthoLeft: Nullable<number>;
  28461. /**
  28462. * Define the current limit on the right side for an orthographic camera
  28463. * In scene unit
  28464. */
  28465. orthoRight: Nullable<number>;
  28466. /**
  28467. * Define the current limit on the bottom side for an orthographic camera
  28468. * In scene unit
  28469. */
  28470. orthoBottom: Nullable<number>;
  28471. /**
  28472. * Define the current limit on the top side for an orthographic camera
  28473. * In scene unit
  28474. */
  28475. orthoTop: Nullable<number>;
  28476. /**
  28477. * Field Of View is set in Radians. (default is 0.8)
  28478. */
  28479. fov: number;
  28480. /**
  28481. * Define the minimum distance the camera can see from.
  28482. * This is important to note that the depth buffer are not infinite and the closer it starts
  28483. * the more your scene might encounter depth fighting issue.
  28484. */
  28485. minZ: number;
  28486. /**
  28487. * Define the maximum distance the camera can see to.
  28488. * This is important to note that the depth buffer are not infinite and the further it end
  28489. * the more your scene might encounter depth fighting issue.
  28490. */
  28491. maxZ: number;
  28492. /**
  28493. * Define the default inertia of the camera.
  28494. * This helps giving a smooth feeling to the camera movement.
  28495. */
  28496. inertia: number;
  28497. /**
  28498. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28499. */
  28500. mode: number;
  28501. /**
  28502. * Define whether the camera is intermediate.
  28503. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28504. */
  28505. isIntermediate: boolean;
  28506. /**
  28507. * Define the viewport of the camera.
  28508. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28509. */
  28510. viewport: Viewport;
  28511. /**
  28512. * Restricts the camera to viewing objects with the same layerMask.
  28513. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28514. */
  28515. layerMask: number;
  28516. /**
  28517. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28518. */
  28519. fovMode: number;
  28520. /**
  28521. * Rig mode of the camera.
  28522. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28523. * This is normally controlled byt the camera themselves as internal use.
  28524. */
  28525. cameraRigMode: number;
  28526. /**
  28527. * Defines the distance between both "eyes" in case of a RIG
  28528. */
  28529. interaxialDistance: number;
  28530. /**
  28531. * Defines if stereoscopic rendering is done side by side or over under.
  28532. */
  28533. isStereoscopicSideBySide: boolean;
  28534. /**
  28535. * 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
  28536. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28537. * else in the scene. (Eg. security camera)
  28538. *
  28539. * 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)
  28540. */
  28541. customRenderTargets: RenderTargetTexture[];
  28542. /**
  28543. * When set, the camera will render to this render target instead of the default canvas
  28544. *
  28545. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28546. */
  28547. outputRenderTarget: Nullable<RenderTargetTexture>;
  28548. /**
  28549. * Observable triggered when the camera view matrix has changed.
  28550. */
  28551. onViewMatrixChangedObservable: Observable<Camera>;
  28552. /**
  28553. * Observable triggered when the camera Projection matrix has changed.
  28554. */
  28555. onProjectionMatrixChangedObservable: Observable<Camera>;
  28556. /**
  28557. * Observable triggered when the inputs have been processed.
  28558. */
  28559. onAfterCheckInputsObservable: Observable<Camera>;
  28560. /**
  28561. * Observable triggered when reset has been called and applied to the camera.
  28562. */
  28563. onRestoreStateObservable: Observable<Camera>;
  28564. /**
  28565. * Is this camera a part of a rig system?
  28566. */
  28567. isRigCamera: boolean;
  28568. /**
  28569. * If isRigCamera set to true this will be set with the parent camera.
  28570. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28571. */
  28572. rigParent?: Camera;
  28573. /** @hidden */
  28574. _cameraRigParams: any;
  28575. /** @hidden */
  28576. _rigCameras: Camera[];
  28577. /** @hidden */
  28578. _rigPostProcess: Nullable<PostProcess>;
  28579. protected _webvrViewMatrix: Matrix;
  28580. /** @hidden */
  28581. _skipRendering: boolean;
  28582. /** @hidden */
  28583. _projectionMatrix: Matrix;
  28584. /** @hidden */
  28585. _postProcesses: Nullable<PostProcess>[];
  28586. /** @hidden */
  28587. _activeMeshes: SmartArray<AbstractMesh>;
  28588. protected _globalPosition: Vector3;
  28589. /** @hidden */
  28590. _computedViewMatrix: Matrix;
  28591. private _doNotComputeProjectionMatrix;
  28592. private _transformMatrix;
  28593. private _frustumPlanes;
  28594. private _refreshFrustumPlanes;
  28595. private _storedFov;
  28596. private _stateStored;
  28597. /**
  28598. * Instantiates a new camera object.
  28599. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28600. * @see http://doc.babylonjs.com/features/cameras
  28601. * @param name Defines the name of the camera in the scene
  28602. * @param position Defines the position of the camera
  28603. * @param scene Defines the scene the camera belongs too
  28604. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28605. */
  28606. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28607. /**
  28608. * Store current camera state (fov, position, etc..)
  28609. * @returns the camera
  28610. */
  28611. storeState(): Camera;
  28612. /**
  28613. * Restores the camera state values if it has been stored. You must call storeState() first
  28614. */
  28615. protected _restoreStateValues(): boolean;
  28616. /**
  28617. * Restored camera state. You must call storeState() first.
  28618. * @returns true if restored and false otherwise
  28619. */
  28620. restoreState(): boolean;
  28621. /**
  28622. * Gets the class name of the camera.
  28623. * @returns the class name
  28624. */
  28625. getClassName(): string;
  28626. /** @hidden */
  28627. readonly _isCamera: boolean;
  28628. /**
  28629. * Gets a string representation of the camera useful for debug purpose.
  28630. * @param fullDetails Defines that a more verboe level of logging is required
  28631. * @returns the string representation
  28632. */
  28633. toString(fullDetails?: boolean): string;
  28634. /**
  28635. * Gets the current world space position of the camera.
  28636. */
  28637. get globalPosition(): Vector3;
  28638. /**
  28639. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28640. * @returns the active meshe list
  28641. */
  28642. getActiveMeshes(): SmartArray<AbstractMesh>;
  28643. /**
  28644. * Check whether a mesh is part of the current active mesh list of the camera
  28645. * @param mesh Defines the mesh to check
  28646. * @returns true if active, false otherwise
  28647. */
  28648. isActiveMesh(mesh: Mesh): boolean;
  28649. /**
  28650. * Is this camera ready to be used/rendered
  28651. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28652. * @return true if the camera is ready
  28653. */
  28654. isReady(completeCheck?: boolean): boolean;
  28655. /** @hidden */
  28656. _initCache(): void;
  28657. /** @hidden */
  28658. _updateCache(ignoreParentClass?: boolean): void;
  28659. /** @hidden */
  28660. _isSynchronized(): boolean;
  28661. /** @hidden */
  28662. _isSynchronizedViewMatrix(): boolean;
  28663. /** @hidden */
  28664. _isSynchronizedProjectionMatrix(): boolean;
  28665. /**
  28666. * Attach the input controls to a specific dom element to get the input from.
  28667. * @param element Defines the element the controls should be listened from
  28668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28669. */
  28670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28671. /**
  28672. * Detach the current controls from the specified dom element.
  28673. * @param element Defines the element to stop listening the inputs from
  28674. */
  28675. detachControl(element: HTMLElement): void;
  28676. /**
  28677. * Update the camera state according to the different inputs gathered during the frame.
  28678. */
  28679. update(): void;
  28680. /** @hidden */
  28681. _checkInputs(): void;
  28682. /** @hidden */
  28683. get rigCameras(): Camera[];
  28684. /**
  28685. * Gets the post process used by the rig cameras
  28686. */
  28687. get rigPostProcess(): Nullable<PostProcess>;
  28688. /**
  28689. * Internal, gets the first post proces.
  28690. * @returns the first post process to be run on this camera.
  28691. */
  28692. _getFirstPostProcess(): Nullable<PostProcess>;
  28693. private _cascadePostProcessesToRigCams;
  28694. /**
  28695. * Attach a post process to the camera.
  28696. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28697. * @param postProcess The post process to attach to the camera
  28698. * @param insertAt The position of the post process in case several of them are in use in the scene
  28699. * @returns the position the post process has been inserted at
  28700. */
  28701. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28702. /**
  28703. * Detach a post process to the camera.
  28704. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28705. * @param postProcess The post process to detach from the camera
  28706. */
  28707. detachPostProcess(postProcess: PostProcess): void;
  28708. /**
  28709. * Gets the current world matrix of the camera
  28710. */
  28711. getWorldMatrix(): Matrix;
  28712. /** @hidden */
  28713. _getViewMatrix(): Matrix;
  28714. /**
  28715. * Gets the current view matrix of the camera.
  28716. * @param force forces the camera to recompute the matrix without looking at the cached state
  28717. * @returns the view matrix
  28718. */
  28719. getViewMatrix(force?: boolean): Matrix;
  28720. /**
  28721. * Freeze the projection matrix.
  28722. * It will prevent the cache check of the camera projection compute and can speed up perf
  28723. * if no parameter of the camera are meant to change
  28724. * @param projection Defines manually a projection if necessary
  28725. */
  28726. freezeProjectionMatrix(projection?: Matrix): void;
  28727. /**
  28728. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28729. */
  28730. unfreezeProjectionMatrix(): void;
  28731. /**
  28732. * Gets the current projection matrix of the camera.
  28733. * @param force forces the camera to recompute the matrix without looking at the cached state
  28734. * @returns the projection matrix
  28735. */
  28736. getProjectionMatrix(force?: boolean): Matrix;
  28737. /**
  28738. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28739. * @returns a Matrix
  28740. */
  28741. getTransformationMatrix(): Matrix;
  28742. private _updateFrustumPlanes;
  28743. /**
  28744. * Checks if a cullable object (mesh...) is in the camera frustum
  28745. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28746. * @param target The object to check
  28747. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28748. * @returns true if the object is in frustum otherwise false
  28749. */
  28750. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28751. /**
  28752. * Checks if a cullable object (mesh...) is in the camera frustum
  28753. * Unlike isInFrustum this cheks the full bounding box
  28754. * @param target The object to check
  28755. * @returns true if the object is in frustum otherwise false
  28756. */
  28757. isCompletelyInFrustum(target: ICullable): boolean;
  28758. /**
  28759. * Gets a ray in the forward direction from the camera.
  28760. * @param length Defines the length of the ray to create
  28761. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28762. * @param origin Defines the start point of the ray which defaults to the camera position
  28763. * @returns the forward ray
  28764. */
  28765. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28766. /**
  28767. * Releases resources associated with this node.
  28768. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28769. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28770. */
  28771. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28772. /** @hidden */
  28773. _isLeftCamera: boolean;
  28774. /**
  28775. * Gets the left camera of a rig setup in case of Rigged Camera
  28776. */
  28777. get isLeftCamera(): boolean;
  28778. /** @hidden */
  28779. _isRightCamera: boolean;
  28780. /**
  28781. * Gets the right camera of a rig setup in case of Rigged Camera
  28782. */
  28783. get isRightCamera(): boolean;
  28784. /**
  28785. * Gets the left camera of a rig setup in case of Rigged Camera
  28786. */
  28787. get leftCamera(): Nullable<FreeCamera>;
  28788. /**
  28789. * Gets the right camera of a rig setup in case of Rigged Camera
  28790. */
  28791. get rightCamera(): Nullable<FreeCamera>;
  28792. /**
  28793. * Gets the left camera target of a rig setup in case of Rigged Camera
  28794. * @returns the target position
  28795. */
  28796. getLeftTarget(): Nullable<Vector3>;
  28797. /**
  28798. * Gets the right camera target of a rig setup in case of Rigged Camera
  28799. * @returns the target position
  28800. */
  28801. getRightTarget(): Nullable<Vector3>;
  28802. /**
  28803. * @hidden
  28804. */
  28805. setCameraRigMode(mode: number, rigParams: any): void;
  28806. /** @hidden */
  28807. static _setStereoscopicRigMode(camera: Camera): void;
  28808. /** @hidden */
  28809. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28810. /** @hidden */
  28811. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28812. /** @hidden */
  28813. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28814. /** @hidden */
  28815. _getVRProjectionMatrix(): Matrix;
  28816. protected _updateCameraRotationMatrix(): void;
  28817. protected _updateWebVRCameraRotationMatrix(): void;
  28818. /**
  28819. * This function MUST be overwritten by the different WebVR cameras available.
  28820. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28821. * @hidden
  28822. */
  28823. _getWebVRProjectionMatrix(): Matrix;
  28824. /**
  28825. * This function MUST be overwritten by the different WebVR cameras available.
  28826. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28827. * @hidden
  28828. */
  28829. _getWebVRViewMatrix(): Matrix;
  28830. /** @hidden */
  28831. setCameraRigParameter(name: string, value: any): void;
  28832. /**
  28833. * needs to be overridden by children so sub has required properties to be copied
  28834. * @hidden
  28835. */
  28836. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28837. /**
  28838. * May need to be overridden by children
  28839. * @hidden
  28840. */
  28841. _updateRigCameras(): void;
  28842. /** @hidden */
  28843. _setupInputs(): void;
  28844. /**
  28845. * Serialiaze the camera setup to a json represention
  28846. * @returns the JSON representation
  28847. */
  28848. serialize(): any;
  28849. /**
  28850. * Clones the current camera.
  28851. * @param name The cloned camera name
  28852. * @returns the cloned camera
  28853. */
  28854. clone(name: string): Camera;
  28855. /**
  28856. * Gets the direction of the camera relative to a given local axis.
  28857. * @param localAxis Defines the reference axis to provide a relative direction.
  28858. * @return the direction
  28859. */
  28860. getDirection(localAxis: Vector3): Vector3;
  28861. /**
  28862. * Returns the current camera absolute rotation
  28863. */
  28864. get absoluteRotation(): Quaternion;
  28865. /**
  28866. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28867. * @param localAxis Defines the reference axis to provide a relative direction.
  28868. * @param result Defines the vector to store the result in
  28869. */
  28870. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28871. /**
  28872. * Gets a camera constructor for a given camera type
  28873. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28874. * @param name The name of the camera the result will be able to instantiate
  28875. * @param scene The scene the result will construct the camera in
  28876. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28877. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28878. * @returns a factory method to construc the camera
  28879. */
  28880. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28881. /**
  28882. * Compute the world matrix of the camera.
  28883. * @returns the camera world matrix
  28884. */
  28885. computeWorldMatrix(): Matrix;
  28886. /**
  28887. * Parse a JSON and creates the camera from the parsed information
  28888. * @param parsedCamera The JSON to parse
  28889. * @param scene The scene to instantiate the camera in
  28890. * @returns the newly constructed camera
  28891. */
  28892. static Parse(parsedCamera: any, scene: Scene): Camera;
  28893. }
  28894. }
  28895. declare module BABYLON {
  28896. /**
  28897. * Class containing static functions to help procedurally build meshes
  28898. */
  28899. export class DiscBuilder {
  28900. /**
  28901. * Creates a plane polygonal mesh. By default, this is a disc
  28902. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28903. * * 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
  28904. * * 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
  28905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28906. * * 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
  28907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28908. * @param name defines the name of the mesh
  28909. * @param options defines the options used to create the mesh
  28910. * @param scene defines the hosting scene
  28911. * @returns the plane polygonal mesh
  28912. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28913. */
  28914. static CreateDisc(name: string, options: {
  28915. radius?: number;
  28916. tessellation?: number;
  28917. arc?: number;
  28918. updatable?: boolean;
  28919. sideOrientation?: number;
  28920. frontUVs?: Vector4;
  28921. backUVs?: Vector4;
  28922. }, scene?: Nullable<Scene>): Mesh;
  28923. }
  28924. }
  28925. declare module BABYLON {
  28926. /**
  28927. * Options to be used when creating a FresnelParameters.
  28928. */
  28929. export type IFresnelParametersCreationOptions = {
  28930. /**
  28931. * Define the color used on edges (grazing angle)
  28932. */
  28933. leftColor?: Color3;
  28934. /**
  28935. * Define the color used on center
  28936. */
  28937. rightColor?: Color3;
  28938. /**
  28939. * Define bias applied to computed fresnel term
  28940. */
  28941. bias?: number;
  28942. /**
  28943. * Defined the power exponent applied to fresnel term
  28944. */
  28945. power?: number;
  28946. /**
  28947. * Define if the fresnel effect is enable or not.
  28948. */
  28949. isEnabled?: boolean;
  28950. };
  28951. /**
  28952. * Serialized format for FresnelParameters.
  28953. */
  28954. export type IFresnelParametersSerialized = {
  28955. /**
  28956. * Define the color used on edges (grazing angle) [as an array]
  28957. */
  28958. leftColor: number[];
  28959. /**
  28960. * Define the color used on center [as an array]
  28961. */
  28962. rightColor: number[];
  28963. /**
  28964. * Define bias applied to computed fresnel term
  28965. */
  28966. bias: number;
  28967. /**
  28968. * Defined the power exponent applied to fresnel term
  28969. */
  28970. power?: number;
  28971. /**
  28972. * Define if the fresnel effect is enable or not.
  28973. */
  28974. isEnabled: boolean;
  28975. };
  28976. /**
  28977. * This represents all the required information to add a fresnel effect on a material:
  28978. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28979. */
  28980. export class FresnelParameters {
  28981. private _isEnabled;
  28982. /**
  28983. * Define if the fresnel effect is enable or not.
  28984. */
  28985. get isEnabled(): boolean;
  28986. set isEnabled(value: boolean);
  28987. /**
  28988. * Define the color used on edges (grazing angle)
  28989. */
  28990. leftColor: Color3;
  28991. /**
  28992. * Define the color used on center
  28993. */
  28994. rightColor: Color3;
  28995. /**
  28996. * Define bias applied to computed fresnel term
  28997. */
  28998. bias: number;
  28999. /**
  29000. * Defined the power exponent applied to fresnel term
  29001. */
  29002. power: number;
  29003. /**
  29004. * Creates a new FresnelParameters object.
  29005. *
  29006. * @param options provide your own settings to optionally to override defaults
  29007. */
  29008. constructor(options?: IFresnelParametersCreationOptions);
  29009. /**
  29010. * Clones the current fresnel and its valuues
  29011. * @returns a clone fresnel configuration
  29012. */
  29013. clone(): FresnelParameters;
  29014. /**
  29015. * Determines equality between FresnelParameters objects
  29016. * @param otherFresnelParameters defines the second operand
  29017. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29018. */
  29019. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29020. /**
  29021. * Serializes the current fresnel parameters to a JSON representation.
  29022. * @return the JSON serialization
  29023. */
  29024. serialize(): IFresnelParametersSerialized;
  29025. /**
  29026. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29027. * @param parsedFresnelParameters Define the JSON representation
  29028. * @returns the parsed parameters
  29029. */
  29030. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29031. }
  29032. }
  29033. declare module BABYLON {
  29034. /**
  29035. * This groups all the flags used to control the materials channel.
  29036. */
  29037. export class MaterialFlags {
  29038. private static _DiffuseTextureEnabled;
  29039. /**
  29040. * Are diffuse textures enabled in the application.
  29041. */
  29042. static get DiffuseTextureEnabled(): boolean;
  29043. static set DiffuseTextureEnabled(value: boolean);
  29044. private static _AmbientTextureEnabled;
  29045. /**
  29046. * Are ambient textures enabled in the application.
  29047. */
  29048. static get AmbientTextureEnabled(): boolean;
  29049. static set AmbientTextureEnabled(value: boolean);
  29050. private static _OpacityTextureEnabled;
  29051. /**
  29052. * Are opacity textures enabled in the application.
  29053. */
  29054. static get OpacityTextureEnabled(): boolean;
  29055. static set OpacityTextureEnabled(value: boolean);
  29056. private static _ReflectionTextureEnabled;
  29057. /**
  29058. * Are reflection textures enabled in the application.
  29059. */
  29060. static get ReflectionTextureEnabled(): boolean;
  29061. static set ReflectionTextureEnabled(value: boolean);
  29062. private static _EmissiveTextureEnabled;
  29063. /**
  29064. * Are emissive textures enabled in the application.
  29065. */
  29066. static get EmissiveTextureEnabled(): boolean;
  29067. static set EmissiveTextureEnabled(value: boolean);
  29068. private static _SpecularTextureEnabled;
  29069. /**
  29070. * Are specular textures enabled in the application.
  29071. */
  29072. static get SpecularTextureEnabled(): boolean;
  29073. static set SpecularTextureEnabled(value: boolean);
  29074. private static _BumpTextureEnabled;
  29075. /**
  29076. * Are bump textures enabled in the application.
  29077. */
  29078. static get BumpTextureEnabled(): boolean;
  29079. static set BumpTextureEnabled(value: boolean);
  29080. private static _LightmapTextureEnabled;
  29081. /**
  29082. * Are lightmap textures enabled in the application.
  29083. */
  29084. static get LightmapTextureEnabled(): boolean;
  29085. static set LightmapTextureEnabled(value: boolean);
  29086. private static _RefractionTextureEnabled;
  29087. /**
  29088. * Are refraction textures enabled in the application.
  29089. */
  29090. static get RefractionTextureEnabled(): boolean;
  29091. static set RefractionTextureEnabled(value: boolean);
  29092. private static _ColorGradingTextureEnabled;
  29093. /**
  29094. * Are color grading textures enabled in the application.
  29095. */
  29096. static get ColorGradingTextureEnabled(): boolean;
  29097. static set ColorGradingTextureEnabled(value: boolean);
  29098. private static _FresnelEnabled;
  29099. /**
  29100. * Are fresnels enabled in the application.
  29101. */
  29102. static get FresnelEnabled(): boolean;
  29103. static set FresnelEnabled(value: boolean);
  29104. private static _ClearCoatTextureEnabled;
  29105. /**
  29106. * Are clear coat textures enabled in the application.
  29107. */
  29108. static get ClearCoatTextureEnabled(): boolean;
  29109. static set ClearCoatTextureEnabled(value: boolean);
  29110. private static _ClearCoatBumpTextureEnabled;
  29111. /**
  29112. * Are clear coat bump textures enabled in the application.
  29113. */
  29114. static get ClearCoatBumpTextureEnabled(): boolean;
  29115. static set ClearCoatBumpTextureEnabled(value: boolean);
  29116. private static _ClearCoatTintTextureEnabled;
  29117. /**
  29118. * Are clear coat tint textures enabled in the application.
  29119. */
  29120. static get ClearCoatTintTextureEnabled(): boolean;
  29121. static set ClearCoatTintTextureEnabled(value: boolean);
  29122. private static _SheenTextureEnabled;
  29123. /**
  29124. * Are sheen textures enabled in the application.
  29125. */
  29126. static get SheenTextureEnabled(): boolean;
  29127. static set SheenTextureEnabled(value: boolean);
  29128. private static _AnisotropicTextureEnabled;
  29129. /**
  29130. * Are anisotropic textures enabled in the application.
  29131. */
  29132. static get AnisotropicTextureEnabled(): boolean;
  29133. static set AnisotropicTextureEnabled(value: boolean);
  29134. private static _ThicknessTextureEnabled;
  29135. /**
  29136. * Are thickness textures enabled in the application.
  29137. */
  29138. static get ThicknessTextureEnabled(): boolean;
  29139. static set ThicknessTextureEnabled(value: boolean);
  29140. }
  29141. }
  29142. declare module BABYLON {
  29143. /** @hidden */
  29144. export var defaultFragmentDeclaration: {
  29145. name: string;
  29146. shader: string;
  29147. };
  29148. }
  29149. declare module BABYLON {
  29150. /** @hidden */
  29151. export var defaultUboDeclaration: {
  29152. name: string;
  29153. shader: string;
  29154. };
  29155. }
  29156. declare module BABYLON {
  29157. /** @hidden */
  29158. export var lightFragmentDeclaration: {
  29159. name: string;
  29160. shader: string;
  29161. };
  29162. }
  29163. declare module BABYLON {
  29164. /** @hidden */
  29165. export var lightUboDeclaration: {
  29166. name: string;
  29167. shader: string;
  29168. };
  29169. }
  29170. declare module BABYLON {
  29171. /** @hidden */
  29172. export var lightsFragmentFunctions: {
  29173. name: string;
  29174. shader: string;
  29175. };
  29176. }
  29177. declare module BABYLON {
  29178. /** @hidden */
  29179. export var shadowsFragmentFunctions: {
  29180. name: string;
  29181. shader: string;
  29182. };
  29183. }
  29184. declare module BABYLON {
  29185. /** @hidden */
  29186. export var fresnelFunction: {
  29187. name: string;
  29188. shader: string;
  29189. };
  29190. }
  29191. declare module BABYLON {
  29192. /** @hidden */
  29193. export var bumpFragmentMainFunctions: {
  29194. name: string;
  29195. shader: string;
  29196. };
  29197. }
  29198. declare module BABYLON {
  29199. /** @hidden */
  29200. export var bumpFragmentFunctions: {
  29201. name: string;
  29202. shader: string;
  29203. };
  29204. }
  29205. declare module BABYLON {
  29206. /** @hidden */
  29207. export var logDepthDeclaration: {
  29208. name: string;
  29209. shader: string;
  29210. };
  29211. }
  29212. declare module BABYLON {
  29213. /** @hidden */
  29214. export var bumpFragment: {
  29215. name: string;
  29216. shader: string;
  29217. };
  29218. }
  29219. declare module BABYLON {
  29220. /** @hidden */
  29221. export var depthPrePass: {
  29222. name: string;
  29223. shader: string;
  29224. };
  29225. }
  29226. declare module BABYLON {
  29227. /** @hidden */
  29228. export var lightFragment: {
  29229. name: string;
  29230. shader: string;
  29231. };
  29232. }
  29233. declare module BABYLON {
  29234. /** @hidden */
  29235. export var logDepthFragment: {
  29236. name: string;
  29237. shader: string;
  29238. };
  29239. }
  29240. declare module BABYLON {
  29241. /** @hidden */
  29242. export var defaultPixelShader: {
  29243. name: string;
  29244. shader: string;
  29245. };
  29246. }
  29247. declare module BABYLON {
  29248. /** @hidden */
  29249. export var defaultVertexDeclaration: {
  29250. name: string;
  29251. shader: string;
  29252. };
  29253. }
  29254. declare module BABYLON {
  29255. /** @hidden */
  29256. export var bumpVertexDeclaration: {
  29257. name: string;
  29258. shader: string;
  29259. };
  29260. }
  29261. declare module BABYLON {
  29262. /** @hidden */
  29263. export var bumpVertex: {
  29264. name: string;
  29265. shader: string;
  29266. };
  29267. }
  29268. declare module BABYLON {
  29269. /** @hidden */
  29270. export var fogVertex: {
  29271. name: string;
  29272. shader: string;
  29273. };
  29274. }
  29275. declare module BABYLON {
  29276. /** @hidden */
  29277. export var shadowsVertex: {
  29278. name: string;
  29279. shader: string;
  29280. };
  29281. }
  29282. declare module BABYLON {
  29283. /** @hidden */
  29284. export var pointCloudVertex: {
  29285. name: string;
  29286. shader: string;
  29287. };
  29288. }
  29289. declare module BABYLON {
  29290. /** @hidden */
  29291. export var logDepthVertex: {
  29292. name: string;
  29293. shader: string;
  29294. };
  29295. }
  29296. declare module BABYLON {
  29297. /** @hidden */
  29298. export var defaultVertexShader: {
  29299. name: string;
  29300. shader: string;
  29301. };
  29302. }
  29303. declare module BABYLON {
  29304. /** @hidden */
  29305. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29306. MAINUV1: boolean;
  29307. MAINUV2: boolean;
  29308. DIFFUSE: boolean;
  29309. DIFFUSEDIRECTUV: number;
  29310. AMBIENT: boolean;
  29311. AMBIENTDIRECTUV: number;
  29312. OPACITY: boolean;
  29313. OPACITYDIRECTUV: number;
  29314. OPACITYRGB: boolean;
  29315. REFLECTION: boolean;
  29316. EMISSIVE: boolean;
  29317. EMISSIVEDIRECTUV: number;
  29318. SPECULAR: boolean;
  29319. SPECULARDIRECTUV: number;
  29320. BUMP: boolean;
  29321. BUMPDIRECTUV: number;
  29322. PARALLAX: boolean;
  29323. PARALLAXOCCLUSION: boolean;
  29324. SPECULAROVERALPHA: boolean;
  29325. CLIPPLANE: boolean;
  29326. CLIPPLANE2: boolean;
  29327. CLIPPLANE3: boolean;
  29328. CLIPPLANE4: boolean;
  29329. CLIPPLANE5: boolean;
  29330. CLIPPLANE6: boolean;
  29331. ALPHATEST: boolean;
  29332. DEPTHPREPASS: boolean;
  29333. ALPHAFROMDIFFUSE: boolean;
  29334. POINTSIZE: boolean;
  29335. FOG: boolean;
  29336. SPECULARTERM: boolean;
  29337. DIFFUSEFRESNEL: boolean;
  29338. OPACITYFRESNEL: boolean;
  29339. REFLECTIONFRESNEL: boolean;
  29340. REFRACTIONFRESNEL: boolean;
  29341. EMISSIVEFRESNEL: boolean;
  29342. FRESNEL: boolean;
  29343. NORMAL: boolean;
  29344. UV1: boolean;
  29345. UV2: boolean;
  29346. VERTEXCOLOR: boolean;
  29347. VERTEXALPHA: boolean;
  29348. NUM_BONE_INFLUENCERS: number;
  29349. BonesPerMesh: number;
  29350. BONETEXTURE: boolean;
  29351. INSTANCES: boolean;
  29352. THIN_INSTANCES: boolean;
  29353. GLOSSINESS: boolean;
  29354. ROUGHNESS: boolean;
  29355. EMISSIVEASILLUMINATION: boolean;
  29356. LINKEMISSIVEWITHDIFFUSE: boolean;
  29357. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29358. LIGHTMAP: boolean;
  29359. LIGHTMAPDIRECTUV: number;
  29360. OBJECTSPACE_NORMALMAP: boolean;
  29361. USELIGHTMAPASSHADOWMAP: boolean;
  29362. REFLECTIONMAP_3D: boolean;
  29363. REFLECTIONMAP_SPHERICAL: boolean;
  29364. REFLECTIONMAP_PLANAR: boolean;
  29365. REFLECTIONMAP_CUBIC: boolean;
  29366. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29367. REFLECTIONMAP_PROJECTION: boolean;
  29368. REFLECTIONMAP_SKYBOX: boolean;
  29369. REFLECTIONMAP_EXPLICIT: boolean;
  29370. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29371. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29372. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29373. INVERTCUBICMAP: boolean;
  29374. LOGARITHMICDEPTH: boolean;
  29375. REFRACTION: boolean;
  29376. REFRACTIONMAP_3D: boolean;
  29377. REFLECTIONOVERALPHA: boolean;
  29378. TWOSIDEDLIGHTING: boolean;
  29379. SHADOWFLOAT: boolean;
  29380. MORPHTARGETS: boolean;
  29381. MORPHTARGETS_NORMAL: boolean;
  29382. MORPHTARGETS_TANGENT: boolean;
  29383. MORPHTARGETS_UV: boolean;
  29384. NUM_MORPH_INFLUENCERS: number;
  29385. NONUNIFORMSCALING: boolean;
  29386. PREMULTIPLYALPHA: boolean;
  29387. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29388. ALPHABLEND: boolean;
  29389. RGBDLIGHTMAP: boolean;
  29390. RGBDREFLECTION: boolean;
  29391. RGBDREFRACTION: boolean;
  29392. IMAGEPROCESSING: boolean;
  29393. VIGNETTE: boolean;
  29394. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29395. VIGNETTEBLENDMODEOPAQUE: boolean;
  29396. TONEMAPPING: boolean;
  29397. TONEMAPPING_ACES: boolean;
  29398. CONTRAST: boolean;
  29399. COLORCURVES: boolean;
  29400. COLORGRADING: boolean;
  29401. COLORGRADING3D: boolean;
  29402. SAMPLER3DGREENDEPTH: boolean;
  29403. SAMPLER3DBGRMAP: boolean;
  29404. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29405. MULTIVIEW: boolean;
  29406. /**
  29407. * If the reflection texture on this material is in linear color space
  29408. * @hidden
  29409. */
  29410. IS_REFLECTION_LINEAR: boolean;
  29411. /**
  29412. * If the refraction texture on this material is in linear color space
  29413. * @hidden
  29414. */
  29415. IS_REFRACTION_LINEAR: boolean;
  29416. EXPOSURE: boolean;
  29417. constructor();
  29418. setReflectionMode(modeToEnable: string): void;
  29419. }
  29420. /**
  29421. * This is the default material used in Babylon. It is the best trade off between quality
  29422. * and performances.
  29423. * @see http://doc.babylonjs.com/babylon101/materials
  29424. */
  29425. export class StandardMaterial extends PushMaterial {
  29426. private _diffuseTexture;
  29427. /**
  29428. * The basic texture of the material as viewed under a light.
  29429. */
  29430. diffuseTexture: Nullable<BaseTexture>;
  29431. private _ambientTexture;
  29432. /**
  29433. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29434. */
  29435. ambientTexture: Nullable<BaseTexture>;
  29436. private _opacityTexture;
  29437. /**
  29438. * Define the transparency of the material from a texture.
  29439. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29440. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29441. */
  29442. opacityTexture: Nullable<BaseTexture>;
  29443. private _reflectionTexture;
  29444. /**
  29445. * Define the texture used to display the reflection.
  29446. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29447. */
  29448. reflectionTexture: Nullable<BaseTexture>;
  29449. private _emissiveTexture;
  29450. /**
  29451. * Define texture of the material as if self lit.
  29452. * This will be mixed in the final result even in the absence of light.
  29453. */
  29454. emissiveTexture: Nullable<BaseTexture>;
  29455. private _specularTexture;
  29456. /**
  29457. * Define how the color and intensity of the highlight given by the light in the material.
  29458. */
  29459. specularTexture: Nullable<BaseTexture>;
  29460. private _bumpTexture;
  29461. /**
  29462. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29463. * 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.
  29464. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29465. */
  29466. bumpTexture: Nullable<BaseTexture>;
  29467. private _lightmapTexture;
  29468. /**
  29469. * Complex lighting can be computationally expensive to compute at runtime.
  29470. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29471. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29472. */
  29473. lightmapTexture: Nullable<BaseTexture>;
  29474. private _refractionTexture;
  29475. /**
  29476. * Define the texture used to display the refraction.
  29477. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29478. */
  29479. refractionTexture: Nullable<BaseTexture>;
  29480. /**
  29481. * The color of the material lit by the environmental background lighting.
  29482. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29483. */
  29484. ambientColor: Color3;
  29485. /**
  29486. * The basic color of the material as viewed under a light.
  29487. */
  29488. diffuseColor: Color3;
  29489. /**
  29490. * Define how the color and intensity of the highlight given by the light in the material.
  29491. */
  29492. specularColor: Color3;
  29493. /**
  29494. * Define the color of the material as if self lit.
  29495. * This will be mixed in the final result even in the absence of light.
  29496. */
  29497. emissiveColor: Color3;
  29498. /**
  29499. * Defines how sharp are the highlights in the material.
  29500. * The bigger the value the sharper giving a more glossy feeling to the result.
  29501. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29502. */
  29503. specularPower: number;
  29504. private _useAlphaFromDiffuseTexture;
  29505. /**
  29506. * Does the transparency come from the diffuse texture alpha channel.
  29507. */
  29508. useAlphaFromDiffuseTexture: boolean;
  29509. private _useEmissiveAsIllumination;
  29510. /**
  29511. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29512. */
  29513. useEmissiveAsIllumination: boolean;
  29514. private _linkEmissiveWithDiffuse;
  29515. /**
  29516. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29517. * the emissive level when the final color is close to one.
  29518. */
  29519. linkEmissiveWithDiffuse: boolean;
  29520. private _useSpecularOverAlpha;
  29521. /**
  29522. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29523. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29524. */
  29525. useSpecularOverAlpha: boolean;
  29526. private _useReflectionOverAlpha;
  29527. /**
  29528. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29529. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29530. */
  29531. useReflectionOverAlpha: boolean;
  29532. private _disableLighting;
  29533. /**
  29534. * Does lights from the scene impacts this material.
  29535. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29536. */
  29537. disableLighting: boolean;
  29538. private _useObjectSpaceNormalMap;
  29539. /**
  29540. * Allows using an object space normal map (instead of tangent space).
  29541. */
  29542. useObjectSpaceNormalMap: boolean;
  29543. private _useParallax;
  29544. /**
  29545. * Is parallax enabled or not.
  29546. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29547. */
  29548. useParallax: boolean;
  29549. private _useParallaxOcclusion;
  29550. /**
  29551. * Is parallax occlusion enabled or not.
  29552. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29553. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29554. */
  29555. useParallaxOcclusion: boolean;
  29556. /**
  29557. * 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.
  29558. */
  29559. parallaxScaleBias: number;
  29560. private _roughness;
  29561. /**
  29562. * Helps to define how blurry the reflections should appears in the material.
  29563. */
  29564. roughness: number;
  29565. /**
  29566. * In case of refraction, define the value of the index of refraction.
  29567. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29568. */
  29569. indexOfRefraction: number;
  29570. /**
  29571. * Invert the refraction texture alongside the y axis.
  29572. * It can be useful with procedural textures or probe for instance.
  29573. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29574. */
  29575. invertRefractionY: boolean;
  29576. /**
  29577. * Defines the alpha limits in alpha test mode.
  29578. */
  29579. alphaCutOff: number;
  29580. private _useLightmapAsShadowmap;
  29581. /**
  29582. * In case of light mapping, define whether the map contains light or shadow informations.
  29583. */
  29584. useLightmapAsShadowmap: boolean;
  29585. private _diffuseFresnelParameters;
  29586. /**
  29587. * Define the diffuse fresnel parameters of the material.
  29588. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29589. */
  29590. diffuseFresnelParameters: FresnelParameters;
  29591. private _opacityFresnelParameters;
  29592. /**
  29593. * Define the opacity fresnel parameters of the material.
  29594. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29595. */
  29596. opacityFresnelParameters: FresnelParameters;
  29597. private _reflectionFresnelParameters;
  29598. /**
  29599. * Define the reflection fresnel parameters of the material.
  29600. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29601. */
  29602. reflectionFresnelParameters: FresnelParameters;
  29603. private _refractionFresnelParameters;
  29604. /**
  29605. * Define the refraction fresnel parameters of the material.
  29606. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29607. */
  29608. refractionFresnelParameters: FresnelParameters;
  29609. private _emissiveFresnelParameters;
  29610. /**
  29611. * Define the emissive fresnel parameters of the material.
  29612. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29613. */
  29614. emissiveFresnelParameters: FresnelParameters;
  29615. private _useReflectionFresnelFromSpecular;
  29616. /**
  29617. * If true automatically deducts the fresnels values from the material specularity.
  29618. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29619. */
  29620. useReflectionFresnelFromSpecular: boolean;
  29621. private _useGlossinessFromSpecularMapAlpha;
  29622. /**
  29623. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29624. */
  29625. useGlossinessFromSpecularMapAlpha: boolean;
  29626. private _maxSimultaneousLights;
  29627. /**
  29628. * Defines the maximum number of lights that can be used in the material
  29629. */
  29630. maxSimultaneousLights: number;
  29631. private _invertNormalMapX;
  29632. /**
  29633. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29634. */
  29635. invertNormalMapX: boolean;
  29636. private _invertNormalMapY;
  29637. /**
  29638. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29639. */
  29640. invertNormalMapY: boolean;
  29641. private _twoSidedLighting;
  29642. /**
  29643. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29644. */
  29645. twoSidedLighting: boolean;
  29646. /**
  29647. * Default configuration related to image processing available in the standard Material.
  29648. */
  29649. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29650. /**
  29651. * Gets the image processing configuration used either in this material.
  29652. */
  29653. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29654. /**
  29655. * Sets the Default image processing configuration used either in the this material.
  29656. *
  29657. * If sets to null, the scene one is in use.
  29658. */
  29659. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29660. /**
  29661. * Keep track of the image processing observer to allow dispose and replace.
  29662. */
  29663. private _imageProcessingObserver;
  29664. /**
  29665. * Attaches a new image processing configuration to the Standard Material.
  29666. * @param configuration
  29667. */
  29668. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29669. /**
  29670. * Gets wether the color curves effect is enabled.
  29671. */
  29672. get cameraColorCurvesEnabled(): boolean;
  29673. /**
  29674. * Sets wether the color curves effect is enabled.
  29675. */
  29676. set cameraColorCurvesEnabled(value: boolean);
  29677. /**
  29678. * Gets wether the color grading effect is enabled.
  29679. */
  29680. get cameraColorGradingEnabled(): boolean;
  29681. /**
  29682. * Gets wether the color grading effect is enabled.
  29683. */
  29684. set cameraColorGradingEnabled(value: boolean);
  29685. /**
  29686. * Gets wether tonemapping is enabled or not.
  29687. */
  29688. get cameraToneMappingEnabled(): boolean;
  29689. /**
  29690. * Sets wether tonemapping is enabled or not
  29691. */
  29692. set cameraToneMappingEnabled(value: boolean);
  29693. /**
  29694. * The camera exposure used on this material.
  29695. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29696. * This corresponds to a photographic exposure.
  29697. */
  29698. get cameraExposure(): number;
  29699. /**
  29700. * The camera exposure used on this material.
  29701. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29702. * This corresponds to a photographic exposure.
  29703. */
  29704. set cameraExposure(value: number);
  29705. /**
  29706. * Gets The camera contrast used on this material.
  29707. */
  29708. get cameraContrast(): number;
  29709. /**
  29710. * Sets The camera contrast used on this material.
  29711. */
  29712. set cameraContrast(value: number);
  29713. /**
  29714. * Gets the Color Grading 2D Lookup Texture.
  29715. */
  29716. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29717. /**
  29718. * Sets the Color Grading 2D Lookup Texture.
  29719. */
  29720. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29721. /**
  29722. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29723. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29724. * 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;
  29725. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29726. */
  29727. get cameraColorCurves(): Nullable<ColorCurves>;
  29728. /**
  29729. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29730. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29731. * 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;
  29732. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29733. */
  29734. set cameraColorCurves(value: Nullable<ColorCurves>);
  29735. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29736. protected _worldViewProjectionMatrix: Matrix;
  29737. protected _globalAmbientColor: Color3;
  29738. protected _useLogarithmicDepth: boolean;
  29739. protected _rebuildInParallel: boolean;
  29740. /**
  29741. * Instantiates a new standard material.
  29742. * This is the default material used in Babylon. It is the best trade off between quality
  29743. * and performances.
  29744. * @see http://doc.babylonjs.com/babylon101/materials
  29745. * @param name Define the name of the material in the scene
  29746. * @param scene Define the scene the material belong to
  29747. */
  29748. constructor(name: string, scene: Scene);
  29749. /**
  29750. * Gets a boolean indicating that current material needs to register RTT
  29751. */
  29752. get hasRenderTargetTextures(): boolean;
  29753. /**
  29754. * Gets the current class name of the material e.g. "StandardMaterial"
  29755. * Mainly use in serialization.
  29756. * @returns the class name
  29757. */
  29758. getClassName(): string;
  29759. /**
  29760. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29761. * You can try switching to logarithmic depth.
  29762. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29763. */
  29764. get useLogarithmicDepth(): boolean;
  29765. set useLogarithmicDepth(value: boolean);
  29766. /**
  29767. * Specifies if the material will require alpha blending
  29768. * @returns a boolean specifying if alpha blending is needed
  29769. */
  29770. needAlphaBlending(): boolean;
  29771. /**
  29772. * Specifies if this material should be rendered in alpha test mode
  29773. * @returns a boolean specifying if an alpha test is needed.
  29774. */
  29775. needAlphaTesting(): boolean;
  29776. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29777. /**
  29778. * Get the texture used for alpha test purpose.
  29779. * @returns the diffuse texture in case of the standard material.
  29780. */
  29781. getAlphaTestTexture(): Nullable<BaseTexture>;
  29782. /**
  29783. * Get if the submesh is ready to be used and all its information available.
  29784. * Child classes can use it to update shaders
  29785. * @param mesh defines the mesh to check
  29786. * @param subMesh defines which submesh to check
  29787. * @param useInstances specifies that instances should be used
  29788. * @returns a boolean indicating that the submesh is ready or not
  29789. */
  29790. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29791. /**
  29792. * Builds the material UBO layouts.
  29793. * Used internally during the effect preparation.
  29794. */
  29795. buildUniformLayout(): void;
  29796. /**
  29797. * Unbinds the material from the mesh
  29798. */
  29799. unbind(): void;
  29800. /**
  29801. * Binds the submesh to this material by preparing the effect and shader to draw
  29802. * @param world defines the world transformation matrix
  29803. * @param mesh defines the mesh containing the submesh
  29804. * @param subMesh defines the submesh to bind the material to
  29805. */
  29806. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29807. /**
  29808. * Get the list of animatables in the material.
  29809. * @returns the list of animatables object used in the material
  29810. */
  29811. getAnimatables(): IAnimatable[];
  29812. /**
  29813. * Gets the active textures from the material
  29814. * @returns an array of textures
  29815. */
  29816. getActiveTextures(): BaseTexture[];
  29817. /**
  29818. * Specifies if the material uses a texture
  29819. * @param texture defines the texture to check against the material
  29820. * @returns a boolean specifying if the material uses the texture
  29821. */
  29822. hasTexture(texture: BaseTexture): boolean;
  29823. /**
  29824. * Disposes the material
  29825. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29826. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29827. */
  29828. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  29829. /**
  29830. * Makes a duplicate of the material, and gives it a new name
  29831. * @param name defines the new name for the duplicated material
  29832. * @returns the cloned material
  29833. */
  29834. clone(name: string): StandardMaterial;
  29835. /**
  29836. * Serializes this material in a JSON representation
  29837. * @returns the serialized material object
  29838. */
  29839. serialize(): any;
  29840. /**
  29841. * Creates a standard material from parsed material data
  29842. * @param source defines the JSON representation of the material
  29843. * @param scene defines the hosting scene
  29844. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29845. * @returns a new standard material
  29846. */
  29847. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  29848. /**
  29849. * Are diffuse textures enabled in the application.
  29850. */
  29851. static get DiffuseTextureEnabled(): boolean;
  29852. static set DiffuseTextureEnabled(value: boolean);
  29853. /**
  29854. * Are ambient textures enabled in the application.
  29855. */
  29856. static get AmbientTextureEnabled(): boolean;
  29857. static set AmbientTextureEnabled(value: boolean);
  29858. /**
  29859. * Are opacity textures enabled in the application.
  29860. */
  29861. static get OpacityTextureEnabled(): boolean;
  29862. static set OpacityTextureEnabled(value: boolean);
  29863. /**
  29864. * Are reflection textures enabled in the application.
  29865. */
  29866. static get ReflectionTextureEnabled(): boolean;
  29867. static set ReflectionTextureEnabled(value: boolean);
  29868. /**
  29869. * Are emissive textures enabled in the application.
  29870. */
  29871. static get EmissiveTextureEnabled(): boolean;
  29872. static set EmissiveTextureEnabled(value: boolean);
  29873. /**
  29874. * Are specular textures enabled in the application.
  29875. */
  29876. static get SpecularTextureEnabled(): boolean;
  29877. static set SpecularTextureEnabled(value: boolean);
  29878. /**
  29879. * Are bump textures enabled in the application.
  29880. */
  29881. static get BumpTextureEnabled(): boolean;
  29882. static set BumpTextureEnabled(value: boolean);
  29883. /**
  29884. * Are lightmap textures enabled in the application.
  29885. */
  29886. static get LightmapTextureEnabled(): boolean;
  29887. static set LightmapTextureEnabled(value: boolean);
  29888. /**
  29889. * Are refraction textures enabled in the application.
  29890. */
  29891. static get RefractionTextureEnabled(): boolean;
  29892. static set RefractionTextureEnabled(value: boolean);
  29893. /**
  29894. * Are color grading textures enabled in the application.
  29895. */
  29896. static get ColorGradingTextureEnabled(): boolean;
  29897. static set ColorGradingTextureEnabled(value: boolean);
  29898. /**
  29899. * Are fresnels enabled in the application.
  29900. */
  29901. static get FresnelEnabled(): boolean;
  29902. static set FresnelEnabled(value: boolean);
  29903. }
  29904. }
  29905. declare module BABYLON {
  29906. /**
  29907. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  29908. *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.
  29909. * The SPS is also a particle system. It provides some methods to manage the particles.
  29910. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  29911. *
  29912. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  29913. */
  29914. export class SolidParticleSystem implements IDisposable {
  29915. /**
  29916. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  29917. * Example : var p = SPS.particles[i];
  29918. */
  29919. particles: SolidParticle[];
  29920. /**
  29921. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  29922. */
  29923. nbParticles: number;
  29924. /**
  29925. * If the particles must ever face the camera (default false). Useful for planar particles.
  29926. */
  29927. billboard: boolean;
  29928. /**
  29929. * Recompute normals when adding a shape
  29930. */
  29931. recomputeNormals: boolean;
  29932. /**
  29933. * This a counter ofr your own usage. It's not set by any SPS functions.
  29934. */
  29935. counter: number;
  29936. /**
  29937. * The SPS name. This name is also given to the underlying mesh.
  29938. */
  29939. name: string;
  29940. /**
  29941. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  29942. */
  29943. mesh: Mesh;
  29944. /**
  29945. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  29946. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  29947. */
  29948. vars: any;
  29949. /**
  29950. * This array is populated when the SPS is set as 'pickable'.
  29951. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  29952. * Each element of this array is an object `{idx: int, faceId: int}`.
  29953. * `idx` is the picked particle index in the `SPS.particles` array
  29954. * `faceId` is the picked face index counted within this particle.
  29955. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  29956. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  29957. * Use the method SPS.pickedParticle(pickingInfo) instead.
  29958. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29959. */
  29960. pickedParticles: {
  29961. idx: number;
  29962. faceId: number;
  29963. }[];
  29964. /**
  29965. * This array is populated when the SPS is set as 'pickable'
  29966. * Each key of this array is a submesh index.
  29967. * Each element of this array is a second array defined like this :
  29968. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  29969. * Each element of this second array is an object `{idx: int, faceId: int}`.
  29970. * `idx` is the picked particle index in the `SPS.particles` array
  29971. * `faceId` is the picked face index counted within this particle.
  29972. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  29973. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29974. */
  29975. pickedBySubMesh: {
  29976. idx: number;
  29977. faceId: number;
  29978. }[][];
  29979. /**
  29980. * This array is populated when `enableDepthSort` is set to true.
  29981. * Each element of this array is an instance of the class DepthSortedParticle.
  29982. */
  29983. depthSortedParticles: DepthSortedParticle[];
  29984. /**
  29985. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  29986. * @hidden
  29987. */
  29988. _bSphereOnly: boolean;
  29989. /**
  29990. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  29991. * @hidden
  29992. */
  29993. _bSphereRadiusFactor: number;
  29994. private _scene;
  29995. private _positions;
  29996. private _indices;
  29997. private _normals;
  29998. private _colors;
  29999. private _uvs;
  30000. private _indices32;
  30001. private _positions32;
  30002. private _normals32;
  30003. private _fixedNormal32;
  30004. private _colors32;
  30005. private _uvs32;
  30006. private _index;
  30007. private _updatable;
  30008. private _pickable;
  30009. private _isVisibilityBoxLocked;
  30010. private _alwaysVisible;
  30011. private _depthSort;
  30012. private _expandable;
  30013. private _shapeCounter;
  30014. private _copy;
  30015. private _color;
  30016. private _computeParticleColor;
  30017. private _computeParticleTexture;
  30018. private _computeParticleRotation;
  30019. private _computeParticleVertex;
  30020. private _computeBoundingBox;
  30021. private _depthSortParticles;
  30022. private _camera;
  30023. private _mustUnrotateFixedNormals;
  30024. private _particlesIntersect;
  30025. private _needs32Bits;
  30026. private _isNotBuilt;
  30027. private _lastParticleId;
  30028. private _idxOfId;
  30029. private _multimaterialEnabled;
  30030. private _useModelMaterial;
  30031. private _indicesByMaterial;
  30032. private _materialIndexes;
  30033. private _depthSortFunction;
  30034. private _materialSortFunction;
  30035. private _materials;
  30036. private _multimaterial;
  30037. private _materialIndexesById;
  30038. private _defaultMaterial;
  30039. private _autoUpdateSubMeshes;
  30040. private _tmpVertex;
  30041. /**
  30042. * Creates a SPS (Solid Particle System) object.
  30043. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30044. * @param scene (Scene) is the scene in which the SPS is added.
  30045. * @param options defines the options of the sps e.g.
  30046. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30047. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30048. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30049. * * 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.
  30050. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30051. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30052. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30053. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30054. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30055. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30056. */
  30057. constructor(name: string, scene: Scene, options?: {
  30058. updatable?: boolean;
  30059. isPickable?: boolean;
  30060. enableDepthSort?: boolean;
  30061. particleIntersection?: boolean;
  30062. boundingSphereOnly?: boolean;
  30063. bSphereRadiusFactor?: number;
  30064. expandable?: boolean;
  30065. useModelMaterial?: boolean;
  30066. enableMultiMaterial?: boolean;
  30067. });
  30068. /**
  30069. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30070. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30071. * @returns the created mesh
  30072. */
  30073. buildMesh(): Mesh;
  30074. /**
  30075. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30076. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30077. * Thus the particles generated from `digest()` have their property `position` set yet.
  30078. * @param mesh ( Mesh ) is the mesh to be digested
  30079. * @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
  30080. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30081. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30082. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30083. * @returns the current SPS
  30084. */
  30085. digest(mesh: Mesh, options?: {
  30086. facetNb?: number;
  30087. number?: number;
  30088. delta?: number;
  30089. storage?: [];
  30090. }): SolidParticleSystem;
  30091. /**
  30092. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30093. * @hidden
  30094. */
  30095. private _unrotateFixedNormals;
  30096. /**
  30097. * Resets the temporary working copy particle
  30098. * @hidden
  30099. */
  30100. private _resetCopy;
  30101. /**
  30102. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30103. * @param p the current index in the positions array to be updated
  30104. * @param ind the current index in the indices array
  30105. * @param shape a Vector3 array, the shape geometry
  30106. * @param positions the positions array to be updated
  30107. * @param meshInd the shape indices array
  30108. * @param indices the indices array to be updated
  30109. * @param meshUV the shape uv array
  30110. * @param uvs the uv array to be updated
  30111. * @param meshCol the shape color array
  30112. * @param colors the color array to be updated
  30113. * @param meshNor the shape normals array
  30114. * @param normals the normals array to be updated
  30115. * @param idx the particle index
  30116. * @param idxInShape the particle index in its shape
  30117. * @param options the addShape() method passed options
  30118. * @model the particle model
  30119. * @hidden
  30120. */
  30121. private _meshBuilder;
  30122. /**
  30123. * Returns a shape Vector3 array from positions float array
  30124. * @param positions float array
  30125. * @returns a vector3 array
  30126. * @hidden
  30127. */
  30128. private _posToShape;
  30129. /**
  30130. * Returns a shapeUV array from a float uvs (array deep copy)
  30131. * @param uvs as a float array
  30132. * @returns a shapeUV array
  30133. * @hidden
  30134. */
  30135. private _uvsToShapeUV;
  30136. /**
  30137. * Adds a new particle object in the particles array
  30138. * @param idx particle index in particles array
  30139. * @param id particle id
  30140. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30141. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30142. * @param model particle ModelShape object
  30143. * @param shapeId model shape identifier
  30144. * @param idxInShape index of the particle in the current model
  30145. * @param bInfo model bounding info object
  30146. * @param storage target storage array, if any
  30147. * @hidden
  30148. */
  30149. private _addParticle;
  30150. /**
  30151. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30152. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30153. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30154. * @param nb (positive integer) the number of particles to be created from this model
  30155. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30156. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30157. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30158. * @returns the number of shapes in the system
  30159. */
  30160. addShape(mesh: Mesh, nb: number, options?: {
  30161. positionFunction?: any;
  30162. vertexFunction?: any;
  30163. storage?: [];
  30164. }): number;
  30165. /**
  30166. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30167. * @hidden
  30168. */
  30169. private _rebuildParticle;
  30170. /**
  30171. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30172. * @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.
  30173. * @returns the SPS.
  30174. */
  30175. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30176. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30177. * Returns an array with the removed particles.
  30178. * 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.
  30179. * The SPS can't be empty so at least one particle needs to remain in place.
  30180. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30181. * @param start index of the first particle to remove
  30182. * @param end index of the last particle to remove (included)
  30183. * @returns an array populated with the removed particles
  30184. */
  30185. removeParticles(start: number, end: number): SolidParticle[];
  30186. /**
  30187. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30188. * @param solidParticleArray an array populated with Solid Particles objects
  30189. * @returns the SPS
  30190. */
  30191. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30192. /**
  30193. * Creates a new particle and modifies the SPS mesh geometry :
  30194. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30195. * - calls _addParticle() to populate the particle array
  30196. * factorized code from addShape() and insertParticlesFromArray()
  30197. * @param idx particle index in the particles array
  30198. * @param i particle index in its shape
  30199. * @param modelShape particle ModelShape object
  30200. * @param shape shape vertex array
  30201. * @param meshInd shape indices array
  30202. * @param meshUV shape uv array
  30203. * @param meshCol shape color array
  30204. * @param meshNor shape normals array
  30205. * @param bbInfo shape bounding info
  30206. * @param storage target particle storage
  30207. * @options addShape() passed options
  30208. * @hidden
  30209. */
  30210. private _insertNewParticle;
  30211. /**
  30212. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30213. * This method calls `updateParticle()` for each particle of the SPS.
  30214. * For an animated SPS, it is usually called within the render loop.
  30215. * 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.
  30216. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30217. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30218. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30219. * @returns the SPS.
  30220. */
  30221. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30222. /**
  30223. * Disposes the SPS.
  30224. */
  30225. dispose(): void;
  30226. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30227. * idx is the particle index in the SPS
  30228. * faceId is the picked face index counted within this particle.
  30229. * Returns null if the pickInfo can't identify a picked particle.
  30230. * @param pickingInfo (PickingInfo object)
  30231. * @returns {idx: number, faceId: number} or null
  30232. */
  30233. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30234. idx: number;
  30235. faceId: number;
  30236. }>;
  30237. /**
  30238. * Returns a SolidParticle object from its identifier : particle.id
  30239. * @param id (integer) the particle Id
  30240. * @returns the searched particle or null if not found in the SPS.
  30241. */
  30242. getParticleById(id: number): Nullable<SolidParticle>;
  30243. /**
  30244. * Returns a new array populated with the particles having the passed shapeId.
  30245. * @param shapeId (integer) the shape identifier
  30246. * @returns a new solid particle array
  30247. */
  30248. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30249. /**
  30250. * Populates the passed array "ref" with the particles having the passed shapeId.
  30251. * @param shapeId the shape identifier
  30252. * @returns the SPS
  30253. * @param ref
  30254. */
  30255. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30256. /**
  30257. * Computes the required SubMeshes according the materials assigned to the particles.
  30258. * @returns the solid particle system.
  30259. * Does nothing if called before the SPS mesh is built.
  30260. */
  30261. computeSubMeshes(): SolidParticleSystem;
  30262. /**
  30263. * Sorts the solid particles by material when MultiMaterial is enabled.
  30264. * Updates the indices32 array.
  30265. * Updates the indicesByMaterial array.
  30266. * Updates the mesh indices array.
  30267. * @returns the SPS
  30268. * @hidden
  30269. */
  30270. private _sortParticlesByMaterial;
  30271. /**
  30272. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30273. * @hidden
  30274. */
  30275. private _setMaterialIndexesById;
  30276. /**
  30277. * Returns an array with unique values of Materials from the passed array
  30278. * @param array the material array to be checked and filtered
  30279. * @hidden
  30280. */
  30281. private _filterUniqueMaterialId;
  30282. /**
  30283. * Sets a new Standard Material as _defaultMaterial if not already set.
  30284. * @hidden
  30285. */
  30286. private _setDefaultMaterial;
  30287. /**
  30288. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30289. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30290. * @returns the SPS.
  30291. */
  30292. refreshVisibleSize(): SolidParticleSystem;
  30293. /**
  30294. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30295. * @param size the size (float) of the visibility box
  30296. * note : this doesn't lock the SPS mesh bounding box.
  30297. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30298. */
  30299. setVisibilityBox(size: number): void;
  30300. /**
  30301. * Gets whether the SPS as always visible or not
  30302. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30303. */
  30304. get isAlwaysVisible(): boolean;
  30305. /**
  30306. * Sets the SPS as always visible or not
  30307. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30308. */
  30309. set isAlwaysVisible(val: boolean);
  30310. /**
  30311. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30312. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30313. */
  30314. set isVisibilityBoxLocked(val: boolean);
  30315. /**
  30316. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30317. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30318. */
  30319. get isVisibilityBoxLocked(): boolean;
  30320. /**
  30321. * Tells to `setParticles()` to compute the particle rotations or not.
  30322. * Default value : true. The SPS is faster when it's set to false.
  30323. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30324. */
  30325. set computeParticleRotation(val: boolean);
  30326. /**
  30327. * Tells to `setParticles()` to compute the particle colors or not.
  30328. * Default value : true. The SPS is faster when it's set to false.
  30329. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30330. */
  30331. set computeParticleColor(val: boolean);
  30332. set computeParticleTexture(val: boolean);
  30333. /**
  30334. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30335. * Default value : false. The SPS is faster when it's set to false.
  30336. * Note : the particle custom vertex positions aren't stored values.
  30337. */
  30338. set computeParticleVertex(val: boolean);
  30339. /**
  30340. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30341. */
  30342. set computeBoundingBox(val: boolean);
  30343. /**
  30344. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30345. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30346. * Default : `true`
  30347. */
  30348. set depthSortParticles(val: boolean);
  30349. /**
  30350. * Gets if `setParticles()` computes the particle rotations or not.
  30351. * Default value : true. The SPS is faster when it's set to false.
  30352. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30353. */
  30354. get computeParticleRotation(): boolean;
  30355. /**
  30356. * Gets if `setParticles()` computes the particle colors or not.
  30357. * Default value : true. The SPS is faster when it's set to false.
  30358. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30359. */
  30360. get computeParticleColor(): boolean;
  30361. /**
  30362. * Gets if `setParticles()` computes the particle textures or not.
  30363. * Default value : true. The SPS is faster when it's set to false.
  30364. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30365. */
  30366. get computeParticleTexture(): boolean;
  30367. /**
  30368. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30369. * Default value : false. The SPS is faster when it's set to false.
  30370. * Note : the particle custom vertex positions aren't stored values.
  30371. */
  30372. get computeParticleVertex(): boolean;
  30373. /**
  30374. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30375. */
  30376. get computeBoundingBox(): boolean;
  30377. /**
  30378. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30379. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30380. * Default : `true`
  30381. */
  30382. get depthSortParticles(): boolean;
  30383. /**
  30384. * Gets if the SPS is created as expandable at construction time.
  30385. * Default : `false`
  30386. */
  30387. get expandable(): boolean;
  30388. /**
  30389. * Gets if the SPS supports the Multi Materials
  30390. */
  30391. get multimaterialEnabled(): boolean;
  30392. /**
  30393. * Gets if the SPS uses the model materials for its own multimaterial.
  30394. */
  30395. get useModelMaterial(): boolean;
  30396. /**
  30397. * The SPS used material array.
  30398. */
  30399. get materials(): Material[];
  30400. /**
  30401. * Sets the SPS MultiMaterial from the passed materials.
  30402. * Note : the passed array is internally copied and not used then by reference.
  30403. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30404. */
  30405. setMultiMaterial(materials: Material[]): void;
  30406. /**
  30407. * The SPS computed multimaterial object
  30408. */
  30409. get multimaterial(): MultiMaterial;
  30410. set multimaterial(mm: MultiMaterial);
  30411. /**
  30412. * If the subMeshes must be updated on the next call to setParticles()
  30413. */
  30414. get autoUpdateSubMeshes(): boolean;
  30415. set autoUpdateSubMeshes(val: boolean);
  30416. /**
  30417. * This function does nothing. It may be overwritten to set all the particle first values.
  30418. * The SPS doesn't call this function, you may have to call it by your own.
  30419. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30420. */
  30421. initParticles(): void;
  30422. /**
  30423. * This function does nothing. It may be overwritten to recycle a particle.
  30424. * The SPS doesn't call this function, you may have to call it by your own.
  30425. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30426. * @param particle The particle to recycle
  30427. * @returns the recycled particle
  30428. */
  30429. recycleParticle(particle: SolidParticle): SolidParticle;
  30430. /**
  30431. * Updates a particle : this function should be overwritten by the user.
  30432. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30433. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30434. * @example : just set a particle position or velocity and recycle conditions
  30435. * @param particle The particle to update
  30436. * @returns the updated particle
  30437. */
  30438. updateParticle(particle: SolidParticle): SolidParticle;
  30439. /**
  30440. * Updates a vertex of a particle : it can be overwritten by the user.
  30441. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30442. * @param particle the current particle
  30443. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30444. * @param pt the index of the current vertex in the particle shape
  30445. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30446. * @example : just set a vertex particle position or color
  30447. * @returns the sps
  30448. */
  30449. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30450. /**
  30451. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30452. * This does nothing and may be overwritten by the user.
  30453. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30454. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30455. * @param update the boolean update value actually passed to setParticles()
  30456. */
  30457. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30458. /**
  30459. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30460. * This will be passed three parameters.
  30461. * This does nothing and may be overwritten by the user.
  30462. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30463. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30464. * @param update the boolean update value actually passed to setParticles()
  30465. */
  30466. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30467. }
  30468. }
  30469. declare module BABYLON {
  30470. /**
  30471. * Represents one particle of a solid particle system.
  30472. */
  30473. export class SolidParticle {
  30474. /**
  30475. * particle global index
  30476. */
  30477. idx: number;
  30478. /**
  30479. * particle identifier
  30480. */
  30481. id: number;
  30482. /**
  30483. * The color of the particle
  30484. */
  30485. color: Nullable<Color4>;
  30486. /**
  30487. * The world space position of the particle.
  30488. */
  30489. position: Vector3;
  30490. /**
  30491. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30492. */
  30493. rotation: Vector3;
  30494. /**
  30495. * The world space rotation quaternion of the particle.
  30496. */
  30497. rotationQuaternion: Nullable<Quaternion>;
  30498. /**
  30499. * The scaling of the particle.
  30500. */
  30501. scaling: Vector3;
  30502. /**
  30503. * The uvs of the particle.
  30504. */
  30505. uvs: Vector4;
  30506. /**
  30507. * The current speed of the particle.
  30508. */
  30509. velocity: Vector3;
  30510. /**
  30511. * The pivot point in the particle local space.
  30512. */
  30513. pivot: Vector3;
  30514. /**
  30515. * Must the particle be translated from its pivot point in its local space ?
  30516. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30517. * Default : false
  30518. */
  30519. translateFromPivot: boolean;
  30520. /**
  30521. * Is the particle active or not ?
  30522. */
  30523. alive: boolean;
  30524. /**
  30525. * Is the particle visible or not ?
  30526. */
  30527. isVisible: boolean;
  30528. /**
  30529. * Index of this particle in the global "positions" array (Internal use)
  30530. * @hidden
  30531. */
  30532. _pos: number;
  30533. /**
  30534. * @hidden Index of this particle in the global "indices" array (Internal use)
  30535. */
  30536. _ind: number;
  30537. /**
  30538. * @hidden ModelShape of this particle (Internal use)
  30539. */
  30540. _model: ModelShape;
  30541. /**
  30542. * ModelShape id of this particle
  30543. */
  30544. shapeId: number;
  30545. /**
  30546. * Index of the particle in its shape id
  30547. */
  30548. idxInShape: number;
  30549. /**
  30550. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30551. */
  30552. _modelBoundingInfo: BoundingInfo;
  30553. /**
  30554. * @hidden Particle BoundingInfo object (Internal use)
  30555. */
  30556. _boundingInfo: BoundingInfo;
  30557. /**
  30558. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30559. */
  30560. _sps: SolidParticleSystem;
  30561. /**
  30562. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30563. */
  30564. _stillInvisible: boolean;
  30565. /**
  30566. * @hidden Last computed particle rotation matrix
  30567. */
  30568. _rotationMatrix: number[];
  30569. /**
  30570. * Parent particle Id, if any.
  30571. * Default null.
  30572. */
  30573. parentId: Nullable<number>;
  30574. /**
  30575. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30576. */
  30577. materialIndex: Nullable<number>;
  30578. /**
  30579. * Custom object or properties.
  30580. */
  30581. props: Nullable<any>;
  30582. /**
  30583. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30584. * The possible values are :
  30585. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30586. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30587. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30588. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30589. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30590. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30591. * */
  30592. cullingStrategy: number;
  30593. /**
  30594. * @hidden Internal global position in the SPS.
  30595. */
  30596. _globalPosition: Vector3;
  30597. /**
  30598. * Creates a Solid Particle object.
  30599. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30600. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30601. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30602. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30603. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30604. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30605. * @param shapeId (integer) is the model shape identifier in the SPS.
  30606. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30607. * @param sps defines the sps it is associated to
  30608. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30609. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30610. */
  30611. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30612. /**
  30613. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30614. * @param target the particle target
  30615. * @returns the current particle
  30616. */
  30617. copyToRef(target: SolidParticle): SolidParticle;
  30618. /**
  30619. * Legacy support, changed scale to scaling
  30620. */
  30621. get scale(): Vector3;
  30622. /**
  30623. * Legacy support, changed scale to scaling
  30624. */
  30625. set scale(scale: Vector3);
  30626. /**
  30627. * Legacy support, changed quaternion to rotationQuaternion
  30628. */
  30629. get quaternion(): Nullable<Quaternion>;
  30630. /**
  30631. * Legacy support, changed quaternion to rotationQuaternion
  30632. */
  30633. set quaternion(q: Nullable<Quaternion>);
  30634. /**
  30635. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30636. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30637. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30638. * @returns true if it intersects
  30639. */
  30640. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30641. /**
  30642. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30643. * A particle is in the frustum if its bounding box intersects the frustum
  30644. * @param frustumPlanes defines the frustum to test
  30645. * @returns true if the particle is in the frustum planes
  30646. */
  30647. isInFrustum(frustumPlanes: Plane[]): boolean;
  30648. /**
  30649. * get the rotation matrix of the particle
  30650. * @hidden
  30651. */
  30652. getRotationMatrix(m: Matrix): void;
  30653. }
  30654. /**
  30655. * Represents the shape of the model used by one particle of a solid particle system.
  30656. * SPS internal tool, don't use it manually.
  30657. */
  30658. export class ModelShape {
  30659. /**
  30660. * The shape id
  30661. * @hidden
  30662. */
  30663. shapeID: number;
  30664. /**
  30665. * flat array of model positions (internal use)
  30666. * @hidden
  30667. */
  30668. _shape: Vector3[];
  30669. /**
  30670. * flat array of model UVs (internal use)
  30671. * @hidden
  30672. */
  30673. _shapeUV: number[];
  30674. /**
  30675. * color array of the model
  30676. * @hidden
  30677. */
  30678. _shapeColors: number[];
  30679. /**
  30680. * indices array of the model
  30681. * @hidden
  30682. */
  30683. _indices: number[];
  30684. /**
  30685. * normals array of the model
  30686. * @hidden
  30687. */
  30688. _normals: number[];
  30689. /**
  30690. * length of the shape in the model indices array (internal use)
  30691. * @hidden
  30692. */
  30693. _indicesLength: number;
  30694. /**
  30695. * Custom position function (internal use)
  30696. * @hidden
  30697. */
  30698. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30699. /**
  30700. * Custom vertex function (internal use)
  30701. * @hidden
  30702. */
  30703. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30704. /**
  30705. * Model material (internal use)
  30706. * @hidden
  30707. */
  30708. _material: Nullable<Material>;
  30709. /**
  30710. * 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.
  30711. * SPS internal tool, don't use it manually.
  30712. * @hidden
  30713. */
  30714. 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>);
  30715. }
  30716. /**
  30717. * Represents a Depth Sorted Particle in the solid particle system.
  30718. * @hidden
  30719. */
  30720. export class DepthSortedParticle {
  30721. /**
  30722. * Particle index
  30723. */
  30724. idx: number;
  30725. /**
  30726. * Index of the particle in the "indices" array
  30727. */
  30728. ind: number;
  30729. /**
  30730. * Length of the particle shape in the "indices" array
  30731. */
  30732. indicesLength: number;
  30733. /**
  30734. * Squared distance from the particle to the camera
  30735. */
  30736. sqDistance: number;
  30737. /**
  30738. * Material index when used with MultiMaterials
  30739. */
  30740. materialIndex: number;
  30741. /**
  30742. * Creates a new sorted particle
  30743. * @param materialIndex
  30744. */
  30745. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30746. }
  30747. /**
  30748. * Represents a solid particle vertex
  30749. */
  30750. export class SolidParticleVertex {
  30751. /**
  30752. * Vertex position
  30753. */
  30754. position: Vector3;
  30755. /**
  30756. * Vertex color
  30757. */
  30758. color: Color4;
  30759. /**
  30760. * Vertex UV
  30761. */
  30762. uv: Vector2;
  30763. /**
  30764. * Creates a new solid particle vertex
  30765. */
  30766. constructor();
  30767. /** Vertex x coordinate */
  30768. get x(): number;
  30769. set x(val: number);
  30770. /** Vertex y coordinate */
  30771. get y(): number;
  30772. set y(val: number);
  30773. /** Vertex z coordinate */
  30774. get z(): number;
  30775. set z(val: number);
  30776. }
  30777. }
  30778. declare module BABYLON {
  30779. /**
  30780. * @hidden
  30781. */
  30782. export class _MeshCollisionData {
  30783. _checkCollisions: boolean;
  30784. _collisionMask: number;
  30785. _collisionGroup: number;
  30786. _surroundingMeshes: Nullable<AbstractMesh[]>;
  30787. _collider: Nullable<Collider>;
  30788. _oldPositionForCollisions: Vector3;
  30789. _diffPositionForCollisions: Vector3;
  30790. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  30791. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  30792. }
  30793. }
  30794. declare module BABYLON {
  30795. /** @hidden */
  30796. class _FacetDataStorage {
  30797. facetPositions: Vector3[];
  30798. facetNormals: Vector3[];
  30799. facetPartitioning: number[][];
  30800. facetNb: number;
  30801. partitioningSubdivisions: number;
  30802. partitioningBBoxRatio: number;
  30803. facetDataEnabled: boolean;
  30804. facetParameters: any;
  30805. bbSize: Vector3;
  30806. subDiv: {
  30807. max: number;
  30808. X: number;
  30809. Y: number;
  30810. Z: number;
  30811. };
  30812. facetDepthSort: boolean;
  30813. facetDepthSortEnabled: boolean;
  30814. depthSortedIndices: IndicesArray;
  30815. depthSortedFacets: {
  30816. ind: number;
  30817. sqDistance: number;
  30818. }[];
  30819. facetDepthSortFunction: (f1: {
  30820. ind: number;
  30821. sqDistance: number;
  30822. }, f2: {
  30823. ind: number;
  30824. sqDistance: number;
  30825. }) => number;
  30826. facetDepthSortFrom: Vector3;
  30827. facetDepthSortOrigin: Vector3;
  30828. invertedMatrix: Matrix;
  30829. }
  30830. /**
  30831. * @hidden
  30832. **/
  30833. class _InternalAbstractMeshDataInfo {
  30834. _hasVertexAlpha: boolean;
  30835. _useVertexColors: boolean;
  30836. _numBoneInfluencers: number;
  30837. _applyFog: boolean;
  30838. _receiveShadows: boolean;
  30839. _facetData: _FacetDataStorage;
  30840. _visibility: number;
  30841. _skeleton: Nullable<Skeleton>;
  30842. _layerMask: number;
  30843. _computeBonesUsingShaders: boolean;
  30844. _isActive: boolean;
  30845. _onlyForInstances: boolean;
  30846. _isActiveIntermediate: boolean;
  30847. _onlyForInstancesIntermediate: boolean;
  30848. _actAsRegularMesh: boolean;
  30849. }
  30850. /**
  30851. * Class used to store all common mesh properties
  30852. */
  30853. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  30854. /** No occlusion */
  30855. static OCCLUSION_TYPE_NONE: number;
  30856. /** Occlusion set to optimisitic */
  30857. static OCCLUSION_TYPE_OPTIMISTIC: number;
  30858. /** Occlusion set to strict */
  30859. static OCCLUSION_TYPE_STRICT: number;
  30860. /** Use an accurante occlusion algorithm */
  30861. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  30862. /** Use a conservative occlusion algorithm */
  30863. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  30864. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  30865. * Test order :
  30866. * Is the bounding sphere outside the frustum ?
  30867. * If not, are the bounding box vertices outside the frustum ?
  30868. * It not, then the cullable object is in the frustum.
  30869. */
  30870. static readonly CULLINGSTRATEGY_STANDARD: number;
  30871. /** Culling strategy : Bounding Sphere Only.
  30872. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  30873. * It's also less accurate than the standard because some not visible objects can still be selected.
  30874. * Test : is the bounding sphere outside the frustum ?
  30875. * If not, then the cullable object is in the frustum.
  30876. */
  30877. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  30878. /** Culling strategy : Optimistic Inclusion.
  30879. * This in an inclusion test first, then the standard exclusion test.
  30880. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  30881. * 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.
  30882. * Anyway, it's as accurate as the standard strategy.
  30883. * Test :
  30884. * Is the cullable object bounding sphere center in the frustum ?
  30885. * If not, apply the default culling strategy.
  30886. */
  30887. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  30888. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  30889. * This in an inclusion test first, then the bounding sphere only exclusion test.
  30890. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  30891. * 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.
  30892. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  30893. * Test :
  30894. * Is the cullable object bounding sphere center in the frustum ?
  30895. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  30896. */
  30897. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  30898. /**
  30899. * No billboard
  30900. */
  30901. static get BILLBOARDMODE_NONE(): number;
  30902. /** Billboard on X axis */
  30903. static get BILLBOARDMODE_X(): number;
  30904. /** Billboard on Y axis */
  30905. static get BILLBOARDMODE_Y(): number;
  30906. /** Billboard on Z axis */
  30907. static get BILLBOARDMODE_Z(): number;
  30908. /** Billboard on all axes */
  30909. static get BILLBOARDMODE_ALL(): number;
  30910. /** Billboard on using position instead of orientation */
  30911. static get BILLBOARDMODE_USE_POSITION(): number;
  30912. /** @hidden */
  30913. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  30914. /**
  30915. * The culling strategy to use to check whether the mesh must be rendered or not.
  30916. * This value can be changed at any time and will be used on the next render mesh selection.
  30917. * The possible values are :
  30918. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30919. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30920. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30921. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30922. * Please read each static variable documentation to get details about the culling process.
  30923. * */
  30924. cullingStrategy: number;
  30925. /**
  30926. * Gets the number of facets in the mesh
  30927. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30928. */
  30929. get facetNb(): number;
  30930. /**
  30931. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  30932. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30933. */
  30934. get partitioningSubdivisions(): number;
  30935. set partitioningSubdivisions(nb: number);
  30936. /**
  30937. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  30938. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  30939. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30940. */
  30941. get partitioningBBoxRatio(): number;
  30942. set partitioningBBoxRatio(ratio: number);
  30943. /**
  30944. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  30945. * Works only for updatable meshes.
  30946. * Doesn't work with multi-materials
  30947. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30948. */
  30949. get mustDepthSortFacets(): boolean;
  30950. set mustDepthSortFacets(sort: boolean);
  30951. /**
  30952. * The location (Vector3) where the facet depth sort must be computed from.
  30953. * By default, the active camera position.
  30954. * Used only when facet depth sort is enabled
  30955. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30956. */
  30957. get facetDepthSortFrom(): Vector3;
  30958. set facetDepthSortFrom(location: Vector3);
  30959. /**
  30960. * gets a boolean indicating if facetData is enabled
  30961. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30962. */
  30963. get isFacetDataEnabled(): boolean;
  30964. /** @hidden */
  30965. _updateNonUniformScalingState(value: boolean): boolean;
  30966. /**
  30967. * An event triggered when this mesh collides with another one
  30968. */
  30969. onCollideObservable: Observable<AbstractMesh>;
  30970. /** Set a function to call when this mesh collides with another one */
  30971. set onCollide(callback: () => void);
  30972. /**
  30973. * An event triggered when the collision's position changes
  30974. */
  30975. onCollisionPositionChangeObservable: Observable<Vector3>;
  30976. /** Set a function to call when the collision's position changes */
  30977. set onCollisionPositionChange(callback: () => void);
  30978. /**
  30979. * An event triggered when material is changed
  30980. */
  30981. onMaterialChangedObservable: Observable<AbstractMesh>;
  30982. /**
  30983. * Gets or sets the orientation for POV movement & rotation
  30984. */
  30985. definedFacingForward: boolean;
  30986. /** @hidden */
  30987. _occlusionQuery: Nullable<WebGLQuery>;
  30988. /** @hidden */
  30989. _renderingGroup: Nullable<RenderingGroup>;
  30990. /**
  30991. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30992. */
  30993. get visibility(): number;
  30994. /**
  30995. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30996. */
  30997. set visibility(value: number);
  30998. /** Gets or sets the alpha index used to sort transparent meshes
  30999. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31000. */
  31001. alphaIndex: number;
  31002. /**
  31003. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31004. */
  31005. isVisible: boolean;
  31006. /**
  31007. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31008. */
  31009. isPickable: boolean;
  31010. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31011. showSubMeshesBoundingBox: boolean;
  31012. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31013. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31014. */
  31015. isBlocker: boolean;
  31016. /**
  31017. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31018. */
  31019. enablePointerMoveEvents: boolean;
  31020. /**
  31021. * Specifies the rendering group id for this mesh (0 by default)
  31022. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31023. */
  31024. renderingGroupId: number;
  31025. private _material;
  31026. /** Gets or sets current material */
  31027. get material(): Nullable<Material>;
  31028. set material(value: Nullable<Material>);
  31029. /**
  31030. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31031. * @see http://doc.babylonjs.com/babylon101/shadows
  31032. */
  31033. get receiveShadows(): boolean;
  31034. set receiveShadows(value: boolean);
  31035. /** Defines color to use when rendering outline */
  31036. outlineColor: Color3;
  31037. /** Define width to use when rendering outline */
  31038. outlineWidth: number;
  31039. /** Defines color to use when rendering overlay */
  31040. overlayColor: Color3;
  31041. /** Defines alpha to use when rendering overlay */
  31042. overlayAlpha: number;
  31043. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31044. get hasVertexAlpha(): boolean;
  31045. set hasVertexAlpha(value: boolean);
  31046. /** 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) */
  31047. get useVertexColors(): boolean;
  31048. set useVertexColors(value: boolean);
  31049. /**
  31050. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31051. */
  31052. get computeBonesUsingShaders(): boolean;
  31053. set computeBonesUsingShaders(value: boolean);
  31054. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31055. get numBoneInfluencers(): number;
  31056. set numBoneInfluencers(value: number);
  31057. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31058. get applyFog(): boolean;
  31059. set applyFog(value: boolean);
  31060. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31061. useOctreeForRenderingSelection: boolean;
  31062. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31063. useOctreeForPicking: boolean;
  31064. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31065. useOctreeForCollisions: boolean;
  31066. /**
  31067. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31068. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31069. */
  31070. get layerMask(): number;
  31071. set layerMask(value: number);
  31072. /**
  31073. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31074. */
  31075. alwaysSelectAsActiveMesh: boolean;
  31076. /**
  31077. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31078. */
  31079. doNotSyncBoundingInfo: boolean;
  31080. /**
  31081. * Gets or sets the current action manager
  31082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31083. */
  31084. actionManager: Nullable<AbstractActionManager>;
  31085. private _meshCollisionData;
  31086. /**
  31087. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31088. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31089. */
  31090. ellipsoid: Vector3;
  31091. /**
  31092. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31093. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31094. */
  31095. ellipsoidOffset: Vector3;
  31096. /**
  31097. * Gets or sets a collision mask used to mask collisions (default is -1).
  31098. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31099. */
  31100. get collisionMask(): number;
  31101. set collisionMask(mask: number);
  31102. /**
  31103. * Gets or sets the current collision group mask (-1 by default).
  31104. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31105. */
  31106. get collisionGroup(): number;
  31107. set collisionGroup(mask: number);
  31108. /**
  31109. * Gets or sets current surrounding meshes (null by default).
  31110. *
  31111. * By default collision detection is tested against every mesh in the scene.
  31112. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31113. * meshes will be tested for the collision.
  31114. *
  31115. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31116. */
  31117. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31118. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31119. /**
  31120. * Defines edge width used when edgesRenderer is enabled
  31121. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31122. */
  31123. edgesWidth: number;
  31124. /**
  31125. * Defines edge color used when edgesRenderer is enabled
  31126. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31127. */
  31128. edgesColor: Color4;
  31129. /** @hidden */
  31130. _edgesRenderer: Nullable<IEdgesRenderer>;
  31131. /** @hidden */
  31132. _masterMesh: Nullable<AbstractMesh>;
  31133. /** @hidden */
  31134. _boundingInfo: Nullable<BoundingInfo>;
  31135. /** @hidden */
  31136. _renderId: number;
  31137. /**
  31138. * Gets or sets the list of subMeshes
  31139. * @see http://doc.babylonjs.com/how_to/multi_materials
  31140. */
  31141. subMeshes: SubMesh[];
  31142. /** @hidden */
  31143. _intersectionsInProgress: AbstractMesh[];
  31144. /** @hidden */
  31145. _unIndexed: boolean;
  31146. /** @hidden */
  31147. _lightSources: Light[];
  31148. /** Gets the list of lights affecting that mesh */
  31149. get lightSources(): Light[];
  31150. /** @hidden */
  31151. get _positions(): Nullable<Vector3[]>;
  31152. /** @hidden */
  31153. _waitingData: {
  31154. lods: Nullable<any>;
  31155. actions: Nullable<any>;
  31156. freezeWorldMatrix: Nullable<boolean>;
  31157. };
  31158. /** @hidden */
  31159. _bonesTransformMatrices: Nullable<Float32Array>;
  31160. /** @hidden */
  31161. _transformMatrixTexture: Nullable<RawTexture>;
  31162. /**
  31163. * Gets or sets a skeleton to apply skining transformations
  31164. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31165. */
  31166. set skeleton(value: Nullable<Skeleton>);
  31167. get skeleton(): Nullable<Skeleton>;
  31168. /**
  31169. * An event triggered when the mesh is rebuilt.
  31170. */
  31171. onRebuildObservable: Observable<AbstractMesh>;
  31172. /**
  31173. * Creates a new AbstractMesh
  31174. * @param name defines the name of the mesh
  31175. * @param scene defines the hosting scene
  31176. */
  31177. constructor(name: string, scene?: Nullable<Scene>);
  31178. /**
  31179. * Returns the string "AbstractMesh"
  31180. * @returns "AbstractMesh"
  31181. */
  31182. getClassName(): string;
  31183. /**
  31184. * Gets a string representation of the current mesh
  31185. * @param fullDetails defines a boolean indicating if full details must be included
  31186. * @returns a string representation of the current mesh
  31187. */
  31188. toString(fullDetails?: boolean): string;
  31189. /**
  31190. * @hidden
  31191. */
  31192. protected _getEffectiveParent(): Nullable<Node>;
  31193. /** @hidden */
  31194. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31195. /** @hidden */
  31196. _rebuild(): void;
  31197. /** @hidden */
  31198. _resyncLightSources(): void;
  31199. /** @hidden */
  31200. _resyncLightSource(light: Light): void;
  31201. /** @hidden */
  31202. _unBindEffect(): void;
  31203. /** @hidden */
  31204. _removeLightSource(light: Light, dispose: boolean): void;
  31205. private _markSubMeshesAsDirty;
  31206. /** @hidden */
  31207. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31208. /** @hidden */
  31209. _markSubMeshesAsAttributesDirty(): void;
  31210. /** @hidden */
  31211. _markSubMeshesAsMiscDirty(): void;
  31212. /**
  31213. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31214. */
  31215. get scaling(): Vector3;
  31216. set scaling(newScaling: Vector3);
  31217. /**
  31218. * Returns true if the mesh is blocked. Implemented by child classes
  31219. */
  31220. get isBlocked(): boolean;
  31221. /**
  31222. * Returns the mesh itself by default. Implemented by child classes
  31223. * @param camera defines the camera to use to pick the right LOD level
  31224. * @returns the currentAbstractMesh
  31225. */
  31226. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31227. /**
  31228. * Returns 0 by default. Implemented by child classes
  31229. * @returns an integer
  31230. */
  31231. getTotalVertices(): number;
  31232. /**
  31233. * Returns a positive integer : the total number of indices in this mesh geometry.
  31234. * @returns the numner of indices or zero if the mesh has no geometry.
  31235. */
  31236. getTotalIndices(): number;
  31237. /**
  31238. * Returns null by default. Implemented by child classes
  31239. * @returns null
  31240. */
  31241. getIndices(): Nullable<IndicesArray>;
  31242. /**
  31243. * Returns the array of the requested vertex data kind. Implemented by child classes
  31244. * @param kind defines the vertex data kind to use
  31245. * @returns null
  31246. */
  31247. getVerticesData(kind: string): Nullable<FloatArray>;
  31248. /**
  31249. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31250. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31251. * Note that a new underlying VertexBuffer object is created each call.
  31252. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31253. * @param kind defines vertex data kind:
  31254. * * VertexBuffer.PositionKind
  31255. * * VertexBuffer.UVKind
  31256. * * VertexBuffer.UV2Kind
  31257. * * VertexBuffer.UV3Kind
  31258. * * VertexBuffer.UV4Kind
  31259. * * VertexBuffer.UV5Kind
  31260. * * VertexBuffer.UV6Kind
  31261. * * VertexBuffer.ColorKind
  31262. * * VertexBuffer.MatricesIndicesKind
  31263. * * VertexBuffer.MatricesIndicesExtraKind
  31264. * * VertexBuffer.MatricesWeightsKind
  31265. * * VertexBuffer.MatricesWeightsExtraKind
  31266. * @param data defines the data source
  31267. * @param updatable defines if the data must be flagged as updatable (or static)
  31268. * @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
  31269. * @returns the current mesh
  31270. */
  31271. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31272. /**
  31273. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31274. * If the mesh has no geometry, it is simply returned as it is.
  31275. * @param kind defines vertex data kind:
  31276. * * VertexBuffer.PositionKind
  31277. * * VertexBuffer.UVKind
  31278. * * VertexBuffer.UV2Kind
  31279. * * VertexBuffer.UV3Kind
  31280. * * VertexBuffer.UV4Kind
  31281. * * VertexBuffer.UV5Kind
  31282. * * VertexBuffer.UV6Kind
  31283. * * VertexBuffer.ColorKind
  31284. * * VertexBuffer.MatricesIndicesKind
  31285. * * VertexBuffer.MatricesIndicesExtraKind
  31286. * * VertexBuffer.MatricesWeightsKind
  31287. * * VertexBuffer.MatricesWeightsExtraKind
  31288. * @param data defines the data source
  31289. * @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
  31290. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31291. * @returns the current mesh
  31292. */
  31293. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31294. /**
  31295. * Sets the mesh indices,
  31296. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31297. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31298. * @param totalVertices Defines the total number of vertices
  31299. * @returns the current mesh
  31300. */
  31301. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31302. /**
  31303. * Gets a boolean indicating if specific vertex data is present
  31304. * @param kind defines the vertex data kind to use
  31305. * @returns true is data kind is present
  31306. */
  31307. isVerticesDataPresent(kind: string): boolean;
  31308. /**
  31309. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31310. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31311. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31312. * @returns a BoundingInfo
  31313. */
  31314. getBoundingInfo(): BoundingInfo;
  31315. /**
  31316. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31317. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31318. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31319. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31320. * @returns the current mesh
  31321. */
  31322. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31323. /**
  31324. * Overwrite the current bounding info
  31325. * @param boundingInfo defines the new bounding info
  31326. * @returns the current mesh
  31327. */
  31328. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31329. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31330. get useBones(): boolean;
  31331. /** @hidden */
  31332. _preActivate(): void;
  31333. /** @hidden */
  31334. _preActivateForIntermediateRendering(renderId: number): void;
  31335. /** @hidden */
  31336. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31337. /** @hidden */
  31338. _postActivate(): void;
  31339. /** @hidden */
  31340. _freeze(): void;
  31341. /** @hidden */
  31342. _unFreeze(): void;
  31343. /**
  31344. * Gets the current world matrix
  31345. * @returns a Matrix
  31346. */
  31347. getWorldMatrix(): Matrix;
  31348. /** @hidden */
  31349. _getWorldMatrixDeterminant(): number;
  31350. /**
  31351. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31352. */
  31353. get isAnInstance(): boolean;
  31354. /**
  31355. * Gets a boolean indicating if this mesh has instances
  31356. */
  31357. get hasInstances(): boolean;
  31358. /**
  31359. * Gets a boolean indicating if this mesh has thin instances
  31360. */
  31361. get hasThinInstances(): boolean;
  31362. /**
  31363. * Perform relative position change from the point of view of behind the front of the mesh.
  31364. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31365. * Supports definition of mesh facing forward or backward
  31366. * @param amountRight defines the distance on the right axis
  31367. * @param amountUp defines the distance on the up axis
  31368. * @param amountForward defines the distance on the forward axis
  31369. * @returns the current mesh
  31370. */
  31371. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31372. /**
  31373. * Calculate relative position change from the point of view of behind the front of the mesh.
  31374. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31375. * Supports definition of mesh facing forward or backward
  31376. * @param amountRight defines the distance on the right axis
  31377. * @param amountUp defines the distance on the up axis
  31378. * @param amountForward defines the distance on the forward axis
  31379. * @returns the new displacement vector
  31380. */
  31381. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31382. /**
  31383. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31384. * Supports definition of mesh facing forward or backward
  31385. * @param flipBack defines the flip
  31386. * @param twirlClockwise defines the twirl
  31387. * @param tiltRight defines the tilt
  31388. * @returns the current mesh
  31389. */
  31390. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31391. /**
  31392. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31393. * Supports definition of mesh facing forward or backward.
  31394. * @param flipBack defines the flip
  31395. * @param twirlClockwise defines the twirl
  31396. * @param tiltRight defines the tilt
  31397. * @returns the new rotation vector
  31398. */
  31399. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31400. /**
  31401. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31402. * This means the mesh underlying bounding box and sphere are recomputed.
  31403. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31404. * @returns the current mesh
  31405. */
  31406. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31407. /** @hidden */
  31408. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31409. /** @hidden */
  31410. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31411. /** @hidden */
  31412. _updateBoundingInfo(): AbstractMesh;
  31413. /** @hidden */
  31414. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31415. /** @hidden */
  31416. protected _afterComputeWorldMatrix(): void;
  31417. /** @hidden */
  31418. get _effectiveMesh(): AbstractMesh;
  31419. /**
  31420. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31421. * A mesh is in the frustum if its bounding box intersects the frustum
  31422. * @param frustumPlanes defines the frustum to test
  31423. * @returns true if the mesh is in the frustum planes
  31424. */
  31425. isInFrustum(frustumPlanes: Plane[]): boolean;
  31426. /**
  31427. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31428. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31429. * @param frustumPlanes defines the frustum to test
  31430. * @returns true if the mesh is completely in the frustum planes
  31431. */
  31432. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31433. /**
  31434. * True if the mesh intersects another mesh or a SolidParticle object
  31435. * @param mesh defines a target mesh or SolidParticle to test
  31436. * @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)
  31437. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31438. * @returns true if there is an intersection
  31439. */
  31440. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31441. /**
  31442. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31443. * @param point defines the point to test
  31444. * @returns true if there is an intersection
  31445. */
  31446. intersectsPoint(point: Vector3): boolean;
  31447. /**
  31448. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31449. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31450. */
  31451. get checkCollisions(): boolean;
  31452. set checkCollisions(collisionEnabled: boolean);
  31453. /**
  31454. * Gets Collider object used to compute collisions (not physics)
  31455. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31456. */
  31457. get collider(): Nullable<Collider>;
  31458. /**
  31459. * Move the mesh using collision engine
  31460. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31461. * @param displacement defines the requested displacement vector
  31462. * @returns the current mesh
  31463. */
  31464. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31465. private _onCollisionPositionChange;
  31466. /** @hidden */
  31467. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31468. /** @hidden */
  31469. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31470. /** @hidden */
  31471. _checkCollision(collider: Collider): AbstractMesh;
  31472. /** @hidden */
  31473. _generatePointsArray(): boolean;
  31474. /**
  31475. * Checks if the passed Ray intersects with the mesh
  31476. * @param ray defines the ray to use
  31477. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31478. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31479. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31480. * @returns the picking info
  31481. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31482. */
  31483. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31484. /**
  31485. * Clones the current mesh
  31486. * @param name defines the mesh name
  31487. * @param newParent defines the new mesh parent
  31488. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31489. * @returns the new mesh
  31490. */
  31491. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31492. /**
  31493. * Disposes all the submeshes of the current meshnp
  31494. * @returns the current mesh
  31495. */
  31496. releaseSubMeshes(): AbstractMesh;
  31497. /**
  31498. * Releases resources associated with this abstract mesh.
  31499. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31500. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31501. */
  31502. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31503. /**
  31504. * Adds the passed mesh as a child to the current mesh
  31505. * @param mesh defines the child mesh
  31506. * @returns the current mesh
  31507. */
  31508. addChild(mesh: AbstractMesh): AbstractMesh;
  31509. /**
  31510. * Removes the passed mesh from the current mesh children list
  31511. * @param mesh defines the child mesh
  31512. * @returns the current mesh
  31513. */
  31514. removeChild(mesh: AbstractMesh): AbstractMesh;
  31515. /** @hidden */
  31516. private _initFacetData;
  31517. /**
  31518. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31519. * This method can be called within the render loop.
  31520. * 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
  31521. * @returns the current mesh
  31522. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31523. */
  31524. updateFacetData(): AbstractMesh;
  31525. /**
  31526. * Returns the facetLocalNormals array.
  31527. * The normals are expressed in the mesh local spac
  31528. * @returns an array of Vector3
  31529. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31530. */
  31531. getFacetLocalNormals(): Vector3[];
  31532. /**
  31533. * Returns the facetLocalPositions array.
  31534. * The facet positions are expressed in the mesh local space
  31535. * @returns an array of Vector3
  31536. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31537. */
  31538. getFacetLocalPositions(): Vector3[];
  31539. /**
  31540. * Returns the facetLocalPartioning array
  31541. * @returns an array of array of numbers
  31542. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31543. */
  31544. getFacetLocalPartitioning(): number[][];
  31545. /**
  31546. * Returns the i-th facet position in the world system.
  31547. * This method allocates a new Vector3 per call
  31548. * @param i defines the facet index
  31549. * @returns a new Vector3
  31550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31551. */
  31552. getFacetPosition(i: number): Vector3;
  31553. /**
  31554. * Sets the reference Vector3 with the i-th facet position in the world system
  31555. * @param i defines the facet index
  31556. * @param ref defines the target vector
  31557. * @returns the current mesh
  31558. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31559. */
  31560. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31561. /**
  31562. * Returns the i-th facet normal in the world system.
  31563. * This method allocates a new Vector3 per call
  31564. * @param i defines the facet index
  31565. * @returns a new Vector3
  31566. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31567. */
  31568. getFacetNormal(i: number): Vector3;
  31569. /**
  31570. * Sets the reference Vector3 with the i-th facet normal in the world system
  31571. * @param i defines the facet index
  31572. * @param ref defines the target vector
  31573. * @returns the current mesh
  31574. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31575. */
  31576. getFacetNormalToRef(i: number, ref: Vector3): this;
  31577. /**
  31578. * 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)
  31579. * @param x defines x coordinate
  31580. * @param y defines y coordinate
  31581. * @param z defines z coordinate
  31582. * @returns the array of facet indexes
  31583. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31584. */
  31585. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31586. /**
  31587. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31588. * @param projected sets as the (x,y,z) world projection on the facet
  31589. * @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
  31590. * @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
  31591. * @param x defines x coordinate
  31592. * @param y defines y coordinate
  31593. * @param z defines z coordinate
  31594. * @returns the face index if found (or null instead)
  31595. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31596. */
  31597. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31598. /**
  31599. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31600. * @param projected sets as the (x,y,z) local projection on the facet
  31601. * @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
  31602. * @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
  31603. * @param x defines x coordinate
  31604. * @param y defines y coordinate
  31605. * @param z defines z coordinate
  31606. * @returns the face index if found (or null instead)
  31607. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31608. */
  31609. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31610. /**
  31611. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31612. * @returns the parameters
  31613. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31614. */
  31615. getFacetDataParameters(): any;
  31616. /**
  31617. * Disables the feature FacetData and frees the related memory
  31618. * @returns the current mesh
  31619. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31620. */
  31621. disableFacetData(): AbstractMesh;
  31622. /**
  31623. * Updates the AbstractMesh indices array
  31624. * @param indices defines the data source
  31625. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31626. * @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)
  31627. * @returns the current mesh
  31628. */
  31629. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31630. /**
  31631. * Creates new normals data for the mesh
  31632. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31633. * @returns the current mesh
  31634. */
  31635. createNormals(updatable: boolean): AbstractMesh;
  31636. /**
  31637. * Align the mesh with a normal
  31638. * @param normal defines the normal to use
  31639. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31640. * @returns the current mesh
  31641. */
  31642. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31643. /** @hidden */
  31644. _checkOcclusionQuery(): boolean;
  31645. /**
  31646. * Disables the mesh edge rendering mode
  31647. * @returns the currentAbstractMesh
  31648. */
  31649. disableEdgesRendering(): AbstractMesh;
  31650. /**
  31651. * Enables the edge rendering mode on the mesh.
  31652. * This mode makes the mesh edges visible
  31653. * @param epsilon defines the maximal distance between two angles to detect a face
  31654. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31655. * @returns the currentAbstractMesh
  31656. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31657. */
  31658. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31659. }
  31660. }
  31661. declare module BABYLON {
  31662. /**
  31663. * Interface used to define ActionEvent
  31664. */
  31665. export interface IActionEvent {
  31666. /** The mesh or sprite that triggered the action */
  31667. source: any;
  31668. /** The X mouse cursor position at the time of the event */
  31669. pointerX: number;
  31670. /** The Y mouse cursor position at the time of the event */
  31671. pointerY: number;
  31672. /** The mesh that is currently pointed at (can be null) */
  31673. meshUnderPointer: Nullable<AbstractMesh>;
  31674. /** the original (browser) event that triggered the ActionEvent */
  31675. sourceEvent?: any;
  31676. /** additional data for the event */
  31677. additionalData?: any;
  31678. }
  31679. /**
  31680. * ActionEvent is the event being sent when an action is triggered.
  31681. */
  31682. export class ActionEvent implements IActionEvent {
  31683. /** The mesh or sprite that triggered the action */
  31684. source: any;
  31685. /** The X mouse cursor position at the time of the event */
  31686. pointerX: number;
  31687. /** The Y mouse cursor position at the time of the event */
  31688. pointerY: number;
  31689. /** The mesh that is currently pointed at (can be null) */
  31690. meshUnderPointer: Nullable<AbstractMesh>;
  31691. /** the original (browser) event that triggered the ActionEvent */
  31692. sourceEvent?: any;
  31693. /** additional data for the event */
  31694. additionalData?: any;
  31695. /**
  31696. * Creates a new ActionEvent
  31697. * @param source The mesh or sprite that triggered the action
  31698. * @param pointerX The X mouse cursor position at the time of the event
  31699. * @param pointerY The Y mouse cursor position at the time of the event
  31700. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31701. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31702. * @param additionalData additional data for the event
  31703. */
  31704. constructor(
  31705. /** The mesh or sprite that triggered the action */
  31706. source: any,
  31707. /** The X mouse cursor position at the time of the event */
  31708. pointerX: number,
  31709. /** The Y mouse cursor position at the time of the event */
  31710. pointerY: number,
  31711. /** The mesh that is currently pointed at (can be null) */
  31712. meshUnderPointer: Nullable<AbstractMesh>,
  31713. /** the original (browser) event that triggered the ActionEvent */
  31714. sourceEvent?: any,
  31715. /** additional data for the event */
  31716. additionalData?: any);
  31717. /**
  31718. * Helper function to auto-create an ActionEvent from a source mesh.
  31719. * @param source The source mesh that triggered the event
  31720. * @param evt The original (browser) event
  31721. * @param additionalData additional data for the event
  31722. * @returns the new ActionEvent
  31723. */
  31724. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31725. /**
  31726. * Helper function to auto-create an ActionEvent from a source sprite
  31727. * @param source The source sprite that triggered the event
  31728. * @param scene Scene associated with the sprite
  31729. * @param evt The original (browser) event
  31730. * @param additionalData additional data for the event
  31731. * @returns the new ActionEvent
  31732. */
  31733. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31734. /**
  31735. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31736. * @param scene the scene where the event occurred
  31737. * @param evt The original (browser) event
  31738. * @returns the new ActionEvent
  31739. */
  31740. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31741. /**
  31742. * Helper function to auto-create an ActionEvent from a primitive
  31743. * @param prim defines the target primitive
  31744. * @param pointerPos defines the pointer position
  31745. * @param evt The original (browser) event
  31746. * @param additionalData additional data for the event
  31747. * @returns the new ActionEvent
  31748. */
  31749. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31750. }
  31751. }
  31752. declare module BABYLON {
  31753. /**
  31754. * Abstract class used to decouple action Manager from scene and meshes.
  31755. * Do not instantiate.
  31756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31757. */
  31758. export abstract class AbstractActionManager implements IDisposable {
  31759. /** Gets the list of active triggers */
  31760. static Triggers: {
  31761. [key: string]: number;
  31762. };
  31763. /** Gets the cursor to use when hovering items */
  31764. hoverCursor: string;
  31765. /** Gets the list of actions */
  31766. actions: IAction[];
  31767. /**
  31768. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31769. */
  31770. isRecursive: boolean;
  31771. /**
  31772. * Releases all associated resources
  31773. */
  31774. abstract dispose(): void;
  31775. /**
  31776. * Does this action manager has pointer triggers
  31777. */
  31778. abstract get hasPointerTriggers(): boolean;
  31779. /**
  31780. * Does this action manager has pick triggers
  31781. */
  31782. abstract get hasPickTriggers(): boolean;
  31783. /**
  31784. * Process a specific trigger
  31785. * @param trigger defines the trigger to process
  31786. * @param evt defines the event details to be processed
  31787. */
  31788. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31789. /**
  31790. * Does this action manager handles actions of any of the given triggers
  31791. * @param triggers defines the triggers to be tested
  31792. * @return a boolean indicating whether one (or more) of the triggers is handled
  31793. */
  31794. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31795. /**
  31796. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31797. * speed.
  31798. * @param triggerA defines the trigger to be tested
  31799. * @param triggerB defines the trigger to be tested
  31800. * @return a boolean indicating whether one (or more) of the triggers is handled
  31801. */
  31802. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31803. /**
  31804. * Does this action manager handles actions of a given trigger
  31805. * @param trigger defines the trigger to be tested
  31806. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31807. * @return whether the trigger is handled
  31808. */
  31809. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31810. /**
  31811. * Serialize this manager to a JSON object
  31812. * @param name defines the property name to store this manager
  31813. * @returns a JSON representation of this manager
  31814. */
  31815. abstract serialize(name: string): any;
  31816. /**
  31817. * Registers an action to this action manager
  31818. * @param action defines the action to be registered
  31819. * @return the action amended (prepared) after registration
  31820. */
  31821. abstract registerAction(action: IAction): Nullable<IAction>;
  31822. /**
  31823. * Unregisters an action to this action manager
  31824. * @param action defines the action to be unregistered
  31825. * @return a boolean indicating whether the action has been unregistered
  31826. */
  31827. abstract unregisterAction(action: IAction): Boolean;
  31828. /**
  31829. * Does exist one action manager with at least one trigger
  31830. **/
  31831. static get HasTriggers(): boolean;
  31832. /**
  31833. * Does exist one action manager with at least one pick trigger
  31834. **/
  31835. static get HasPickTriggers(): boolean;
  31836. /**
  31837. * Does exist one action manager that handles actions of a given trigger
  31838. * @param trigger defines the trigger to be tested
  31839. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  31840. **/
  31841. static HasSpecificTrigger(trigger: number): boolean;
  31842. }
  31843. }
  31844. declare module BABYLON {
  31845. /**
  31846. * Defines how a node can be built from a string name.
  31847. */
  31848. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  31849. /**
  31850. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  31851. */
  31852. export class Node implements IBehaviorAware<Node> {
  31853. /** @hidden */
  31854. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  31855. private static _NodeConstructors;
  31856. /**
  31857. * Add a new node constructor
  31858. * @param type defines the type name of the node to construct
  31859. * @param constructorFunc defines the constructor function
  31860. */
  31861. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  31862. /**
  31863. * Returns a node constructor based on type name
  31864. * @param type defines the type name
  31865. * @param name defines the new node name
  31866. * @param scene defines the hosting scene
  31867. * @param options defines optional options to transmit to constructors
  31868. * @returns the new constructor or null
  31869. */
  31870. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  31871. /**
  31872. * Gets or sets the name of the node
  31873. */
  31874. name: string;
  31875. /**
  31876. * Gets or sets the id of the node
  31877. */
  31878. id: string;
  31879. /**
  31880. * Gets or sets the unique id of the node
  31881. */
  31882. uniqueId: number;
  31883. /**
  31884. * Gets or sets a string used to store user defined state for the node
  31885. */
  31886. state: string;
  31887. /**
  31888. * Gets or sets an object used to store user defined information for the node
  31889. */
  31890. metadata: any;
  31891. /**
  31892. * For internal use only. Please do not use.
  31893. */
  31894. reservedDataStore: any;
  31895. /**
  31896. * List of inspectable custom properties (used by the Inspector)
  31897. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  31898. */
  31899. inspectableCustomProperties: IInspectable[];
  31900. private _doNotSerialize;
  31901. /**
  31902. * Gets or sets a boolean used to define if the node must be serialized
  31903. */
  31904. get doNotSerialize(): boolean;
  31905. set doNotSerialize(value: boolean);
  31906. /** @hidden */
  31907. _isDisposed: boolean;
  31908. /**
  31909. * Gets a list of Animations associated with the node
  31910. */
  31911. animations: Animation[];
  31912. protected _ranges: {
  31913. [name: string]: Nullable<AnimationRange>;
  31914. };
  31915. /**
  31916. * Callback raised when the node is ready to be used
  31917. */
  31918. onReady: Nullable<(node: Node) => void>;
  31919. private _isEnabled;
  31920. private _isParentEnabled;
  31921. private _isReady;
  31922. /** @hidden */
  31923. _currentRenderId: number;
  31924. private _parentUpdateId;
  31925. /** @hidden */
  31926. _childUpdateId: number;
  31927. /** @hidden */
  31928. _waitingParentId: Nullable<string>;
  31929. /** @hidden */
  31930. _scene: Scene;
  31931. /** @hidden */
  31932. _cache: any;
  31933. private _parentNode;
  31934. private _children;
  31935. /** @hidden */
  31936. _worldMatrix: Matrix;
  31937. /** @hidden */
  31938. _worldMatrixDeterminant: number;
  31939. /** @hidden */
  31940. _worldMatrixDeterminantIsDirty: boolean;
  31941. /** @hidden */
  31942. private _sceneRootNodesIndex;
  31943. /**
  31944. * Gets a boolean indicating if the node has been disposed
  31945. * @returns true if the node was disposed
  31946. */
  31947. isDisposed(): boolean;
  31948. /**
  31949. * Gets or sets the parent of the node (without keeping the current position in the scene)
  31950. * @see https://doc.babylonjs.com/how_to/parenting
  31951. */
  31952. set parent(parent: Nullable<Node>);
  31953. get parent(): Nullable<Node>;
  31954. /** @hidden */
  31955. _addToSceneRootNodes(): void;
  31956. /** @hidden */
  31957. _removeFromSceneRootNodes(): void;
  31958. private _animationPropertiesOverride;
  31959. /**
  31960. * Gets or sets the animation properties override
  31961. */
  31962. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31963. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31964. /**
  31965. * Gets a string idenfifying the name of the class
  31966. * @returns "Node" string
  31967. */
  31968. getClassName(): string;
  31969. /** @hidden */
  31970. readonly _isNode: boolean;
  31971. /**
  31972. * An event triggered when the mesh is disposed
  31973. */
  31974. onDisposeObservable: Observable<Node>;
  31975. private _onDisposeObserver;
  31976. /**
  31977. * Sets a callback that will be raised when the node will be disposed
  31978. */
  31979. set onDispose(callback: () => void);
  31980. /**
  31981. * Creates a new Node
  31982. * @param name the name and id to be given to this node
  31983. * @param scene the scene this node will be added to
  31984. */
  31985. constructor(name: string, scene?: Nullable<Scene>);
  31986. /**
  31987. * Gets the scene of the node
  31988. * @returns a scene
  31989. */
  31990. getScene(): Scene;
  31991. /**
  31992. * Gets the engine of the node
  31993. * @returns a Engine
  31994. */
  31995. getEngine(): Engine;
  31996. private _behaviors;
  31997. /**
  31998. * Attach a behavior to the node
  31999. * @see http://doc.babylonjs.com/features/behaviour
  32000. * @param behavior defines the behavior to attach
  32001. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32002. * @returns the current Node
  32003. */
  32004. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32005. /**
  32006. * Remove an attached behavior
  32007. * @see http://doc.babylonjs.com/features/behaviour
  32008. * @param behavior defines the behavior to attach
  32009. * @returns the current Node
  32010. */
  32011. removeBehavior(behavior: Behavior<Node>): Node;
  32012. /**
  32013. * Gets the list of attached behaviors
  32014. * @see http://doc.babylonjs.com/features/behaviour
  32015. */
  32016. get behaviors(): Behavior<Node>[];
  32017. /**
  32018. * Gets an attached behavior by name
  32019. * @param name defines the name of the behavior to look for
  32020. * @see http://doc.babylonjs.com/features/behaviour
  32021. * @returns null if behavior was not found else the requested behavior
  32022. */
  32023. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32024. /**
  32025. * Returns the latest update of the World matrix
  32026. * @returns a Matrix
  32027. */
  32028. getWorldMatrix(): Matrix;
  32029. /** @hidden */
  32030. _getWorldMatrixDeterminant(): number;
  32031. /**
  32032. * Returns directly the latest state of the mesh World matrix.
  32033. * A Matrix is returned.
  32034. */
  32035. get worldMatrixFromCache(): Matrix;
  32036. /** @hidden */
  32037. _initCache(): void;
  32038. /** @hidden */
  32039. updateCache(force?: boolean): void;
  32040. /** @hidden */
  32041. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32042. /** @hidden */
  32043. _updateCache(ignoreParentClass?: boolean): void;
  32044. /** @hidden */
  32045. _isSynchronized(): boolean;
  32046. /** @hidden */
  32047. _markSyncedWithParent(): void;
  32048. /** @hidden */
  32049. isSynchronizedWithParent(): boolean;
  32050. /** @hidden */
  32051. isSynchronized(): boolean;
  32052. /**
  32053. * Is this node ready to be used/rendered
  32054. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32055. * @return true if the node is ready
  32056. */
  32057. isReady(completeCheck?: boolean): boolean;
  32058. /**
  32059. * Is this node enabled?
  32060. * 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
  32061. * @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
  32062. * @return whether this node (and its parent) is enabled
  32063. */
  32064. isEnabled(checkAncestors?: boolean): boolean;
  32065. /** @hidden */
  32066. protected _syncParentEnabledState(): void;
  32067. /**
  32068. * Set the enabled state of this node
  32069. * @param value defines the new enabled state
  32070. */
  32071. setEnabled(value: boolean): void;
  32072. /**
  32073. * Is this node a descendant of the given node?
  32074. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32075. * @param ancestor defines the parent node to inspect
  32076. * @returns a boolean indicating if this node is a descendant of the given node
  32077. */
  32078. isDescendantOf(ancestor: Node): boolean;
  32079. /** @hidden */
  32080. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32081. /**
  32082. * Will return all nodes that have this node as ascendant
  32083. * @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
  32084. * @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
  32085. * @return all children nodes of all types
  32086. */
  32087. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32088. /**
  32089. * Get all child-meshes of this node
  32090. * @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)
  32091. * @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
  32092. * @returns an array of AbstractMesh
  32093. */
  32094. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32095. /**
  32096. * Get all direct children of this node
  32097. * @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
  32098. * @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)
  32099. * @returns an array of Node
  32100. */
  32101. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32102. /** @hidden */
  32103. _setReady(state: boolean): void;
  32104. /**
  32105. * Get an animation by name
  32106. * @param name defines the name of the animation to look for
  32107. * @returns null if not found else the requested animation
  32108. */
  32109. getAnimationByName(name: string): Nullable<Animation>;
  32110. /**
  32111. * Creates an animation range for this node
  32112. * @param name defines the name of the range
  32113. * @param from defines the starting key
  32114. * @param to defines the end key
  32115. */
  32116. createAnimationRange(name: string, from: number, to: number): void;
  32117. /**
  32118. * Delete a specific animation range
  32119. * @param name defines the name of the range to delete
  32120. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32121. */
  32122. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32123. /**
  32124. * Get an animation range by name
  32125. * @param name defines the name of the animation range to look for
  32126. * @returns null if not found else the requested animation range
  32127. */
  32128. getAnimationRange(name: string): Nullable<AnimationRange>;
  32129. /**
  32130. * Gets the list of all animation ranges defined on this node
  32131. * @returns an array
  32132. */
  32133. getAnimationRanges(): Nullable<AnimationRange>[];
  32134. /**
  32135. * Will start the animation sequence
  32136. * @param name defines the range frames for animation sequence
  32137. * @param loop defines if the animation should loop (false by default)
  32138. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32139. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32140. * @returns the object created for this animation. If range does not exist, it will return null
  32141. */
  32142. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32143. /**
  32144. * Serialize animation ranges into a JSON compatible object
  32145. * @returns serialization object
  32146. */
  32147. serializeAnimationRanges(): any;
  32148. /**
  32149. * Computes the world matrix of the node
  32150. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32151. * @returns the world matrix
  32152. */
  32153. computeWorldMatrix(force?: boolean): Matrix;
  32154. /**
  32155. * Releases resources associated with this node.
  32156. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32157. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32158. */
  32159. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32160. /**
  32161. * Parse animation range data from a serialization object and store them into a given node
  32162. * @param node defines where to store the animation ranges
  32163. * @param parsedNode defines the serialization object to read data from
  32164. * @param scene defines the hosting scene
  32165. */
  32166. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32167. /**
  32168. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32169. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32170. * @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
  32171. * @returns the new bounding vectors
  32172. */
  32173. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32174. min: Vector3;
  32175. max: Vector3;
  32176. };
  32177. }
  32178. }
  32179. declare module BABYLON {
  32180. /**
  32181. * @hidden
  32182. */
  32183. export class _IAnimationState {
  32184. key: number;
  32185. repeatCount: number;
  32186. workValue?: any;
  32187. loopMode?: number;
  32188. offsetValue?: any;
  32189. highLimitValue?: any;
  32190. }
  32191. /**
  32192. * Class used to store any kind of animation
  32193. */
  32194. export class Animation {
  32195. /**Name of the animation */
  32196. name: string;
  32197. /**Property to animate */
  32198. targetProperty: string;
  32199. /**The frames per second of the animation */
  32200. framePerSecond: number;
  32201. /**The data type of the animation */
  32202. dataType: number;
  32203. /**The loop mode of the animation */
  32204. loopMode?: number | undefined;
  32205. /**Specifies if blending should be enabled */
  32206. enableBlending?: boolean | undefined;
  32207. /**
  32208. * Use matrix interpolation instead of using direct key value when animating matrices
  32209. */
  32210. static AllowMatricesInterpolation: boolean;
  32211. /**
  32212. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32213. */
  32214. static AllowMatrixDecomposeForInterpolation: boolean;
  32215. /**
  32216. * Stores the key frames of the animation
  32217. */
  32218. private _keys;
  32219. /**
  32220. * Stores the easing function of the animation
  32221. */
  32222. private _easingFunction;
  32223. /**
  32224. * @hidden Internal use only
  32225. */
  32226. _runtimeAnimations: RuntimeAnimation[];
  32227. /**
  32228. * The set of event that will be linked to this animation
  32229. */
  32230. private _events;
  32231. /**
  32232. * Stores an array of target property paths
  32233. */
  32234. targetPropertyPath: string[];
  32235. /**
  32236. * Stores the blending speed of the animation
  32237. */
  32238. blendingSpeed: number;
  32239. /**
  32240. * Stores the animation ranges for the animation
  32241. */
  32242. private _ranges;
  32243. /**
  32244. * @hidden Internal use
  32245. */
  32246. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32247. /**
  32248. * Sets up an animation
  32249. * @param property The property to animate
  32250. * @param animationType The animation type to apply
  32251. * @param framePerSecond The frames per second of the animation
  32252. * @param easingFunction The easing function used in the animation
  32253. * @returns The created animation
  32254. */
  32255. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32256. /**
  32257. * Create and start an animation on a node
  32258. * @param name defines the name of the global animation that will be run on all nodes
  32259. * @param node defines the root node where the animation will take place
  32260. * @param targetProperty defines property to animate
  32261. * @param framePerSecond defines the number of frame per second yo use
  32262. * @param totalFrame defines the number of frames in total
  32263. * @param from defines the initial value
  32264. * @param to defines the final value
  32265. * @param loopMode defines which loop mode you want to use (off by default)
  32266. * @param easingFunction defines the easing function to use (linear by default)
  32267. * @param onAnimationEnd defines the callback to call when animation end
  32268. * @returns the animatable created for this animation
  32269. */
  32270. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32271. /**
  32272. * Create and start an animation on a node and its descendants
  32273. * @param name defines the name of the global animation that will be run on all nodes
  32274. * @param node defines the root node where the animation will take place
  32275. * @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
  32276. * @param targetProperty defines property to animate
  32277. * @param framePerSecond defines the number of frame per second to use
  32278. * @param totalFrame defines the number of frames in total
  32279. * @param from defines the initial value
  32280. * @param to defines the final value
  32281. * @param loopMode defines which loop mode you want to use (off by default)
  32282. * @param easingFunction defines the easing function to use (linear by default)
  32283. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32284. * @returns the list of animatables created for all nodes
  32285. * @example https://www.babylonjs-playground.com/#MH0VLI
  32286. */
  32287. 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[]>;
  32288. /**
  32289. * Creates a new animation, merges it with the existing animations and starts it
  32290. * @param name Name of the animation
  32291. * @param node Node which contains the scene that begins the animations
  32292. * @param targetProperty Specifies which property to animate
  32293. * @param framePerSecond The frames per second of the animation
  32294. * @param totalFrame The total number of frames
  32295. * @param from The frame at the beginning of the animation
  32296. * @param to The frame at the end of the animation
  32297. * @param loopMode Specifies the loop mode of the animation
  32298. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32299. * @param onAnimationEnd Callback to run once the animation is complete
  32300. * @returns Nullable animation
  32301. */
  32302. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32303. /**
  32304. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32305. * @param sourceAnimation defines the Animation containing keyframes to convert
  32306. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32307. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32308. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32309. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32310. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32311. */
  32312. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32313. /**
  32314. * Transition property of an host to the target Value
  32315. * @param property The property to transition
  32316. * @param targetValue The target Value of the property
  32317. * @param host The object where the property to animate belongs
  32318. * @param scene Scene used to run the animation
  32319. * @param frameRate Framerate (in frame/s) to use
  32320. * @param transition The transition type we want to use
  32321. * @param duration The duration of the animation, in milliseconds
  32322. * @param onAnimationEnd Callback trigger at the end of the animation
  32323. * @returns Nullable animation
  32324. */
  32325. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32326. /**
  32327. * Return the array of runtime animations currently using this animation
  32328. */
  32329. get runtimeAnimations(): RuntimeAnimation[];
  32330. /**
  32331. * Specifies if any of the runtime animations are currently running
  32332. */
  32333. get hasRunningRuntimeAnimations(): boolean;
  32334. /**
  32335. * Initializes the animation
  32336. * @param name Name of the animation
  32337. * @param targetProperty Property to animate
  32338. * @param framePerSecond The frames per second of the animation
  32339. * @param dataType The data type of the animation
  32340. * @param loopMode The loop mode of the animation
  32341. * @param enableBlending Specifies if blending should be enabled
  32342. */
  32343. constructor(
  32344. /**Name of the animation */
  32345. name: string,
  32346. /**Property to animate */
  32347. targetProperty: string,
  32348. /**The frames per second of the animation */
  32349. framePerSecond: number,
  32350. /**The data type of the animation */
  32351. dataType: number,
  32352. /**The loop mode of the animation */
  32353. loopMode?: number | undefined,
  32354. /**Specifies if blending should be enabled */
  32355. enableBlending?: boolean | undefined);
  32356. /**
  32357. * Converts the animation to a string
  32358. * @param fullDetails support for multiple levels of logging within scene loading
  32359. * @returns String form of the animation
  32360. */
  32361. toString(fullDetails?: boolean): string;
  32362. /**
  32363. * Add an event to this animation
  32364. * @param event Event to add
  32365. */
  32366. addEvent(event: AnimationEvent): void;
  32367. /**
  32368. * Remove all events found at the given frame
  32369. * @param frame The frame to remove events from
  32370. */
  32371. removeEvents(frame: number): void;
  32372. /**
  32373. * Retrieves all the events from the animation
  32374. * @returns Events from the animation
  32375. */
  32376. getEvents(): AnimationEvent[];
  32377. /**
  32378. * Creates an animation range
  32379. * @param name Name of the animation range
  32380. * @param from Starting frame of the animation range
  32381. * @param to Ending frame of the animation
  32382. */
  32383. createRange(name: string, from: number, to: number): void;
  32384. /**
  32385. * Deletes an animation range by name
  32386. * @param name Name of the animation range to delete
  32387. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32388. */
  32389. deleteRange(name: string, deleteFrames?: boolean): void;
  32390. /**
  32391. * Gets the animation range by name, or null if not defined
  32392. * @param name Name of the animation range
  32393. * @returns Nullable animation range
  32394. */
  32395. getRange(name: string): Nullable<AnimationRange>;
  32396. /**
  32397. * Gets the key frames from the animation
  32398. * @returns The key frames of the animation
  32399. */
  32400. getKeys(): Array<IAnimationKey>;
  32401. /**
  32402. * Gets the highest frame rate of the animation
  32403. * @returns Highest frame rate of the animation
  32404. */
  32405. getHighestFrame(): number;
  32406. /**
  32407. * Gets the easing function of the animation
  32408. * @returns Easing function of the animation
  32409. */
  32410. getEasingFunction(): IEasingFunction;
  32411. /**
  32412. * Sets the easing function of the animation
  32413. * @param easingFunction A custom mathematical formula for animation
  32414. */
  32415. setEasingFunction(easingFunction: EasingFunction): void;
  32416. /**
  32417. * Interpolates a scalar linearly
  32418. * @param startValue Start value of the animation curve
  32419. * @param endValue End value of the animation curve
  32420. * @param gradient Scalar amount to interpolate
  32421. * @returns Interpolated scalar value
  32422. */
  32423. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32424. /**
  32425. * Interpolates a scalar cubically
  32426. * @param startValue Start value of the animation curve
  32427. * @param outTangent End tangent of the animation
  32428. * @param endValue End value of the animation curve
  32429. * @param inTangent Start tangent of the animation curve
  32430. * @param gradient Scalar amount to interpolate
  32431. * @returns Interpolated scalar value
  32432. */
  32433. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32434. /**
  32435. * Interpolates a quaternion using a spherical linear interpolation
  32436. * @param startValue Start value of the animation curve
  32437. * @param endValue End value of the animation curve
  32438. * @param gradient Scalar amount to interpolate
  32439. * @returns Interpolated quaternion value
  32440. */
  32441. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32442. /**
  32443. * Interpolates a quaternion cubically
  32444. * @param startValue Start value of the animation curve
  32445. * @param outTangent End tangent of the animation curve
  32446. * @param endValue End value of the animation curve
  32447. * @param inTangent Start tangent of the animation curve
  32448. * @param gradient Scalar amount to interpolate
  32449. * @returns Interpolated quaternion value
  32450. */
  32451. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32452. /**
  32453. * Interpolates a Vector3 linearl
  32454. * @param startValue Start value of the animation curve
  32455. * @param endValue End value of the animation curve
  32456. * @param gradient Scalar amount to interpolate
  32457. * @returns Interpolated scalar value
  32458. */
  32459. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32460. /**
  32461. * Interpolates a Vector3 cubically
  32462. * @param startValue Start value of the animation curve
  32463. * @param outTangent End tangent of the animation
  32464. * @param endValue End value of the animation curve
  32465. * @param inTangent Start tangent of the animation curve
  32466. * @param gradient Scalar amount to interpolate
  32467. * @returns InterpolatedVector3 value
  32468. */
  32469. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32470. /**
  32471. * Interpolates a Vector2 linearly
  32472. * @param startValue Start value of the animation curve
  32473. * @param endValue End value of the animation curve
  32474. * @param gradient Scalar amount to interpolate
  32475. * @returns Interpolated Vector2 value
  32476. */
  32477. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32478. /**
  32479. * Interpolates a Vector2 cubically
  32480. * @param startValue Start value of the animation curve
  32481. * @param outTangent End tangent of the animation
  32482. * @param endValue End value of the animation curve
  32483. * @param inTangent Start tangent of the animation curve
  32484. * @param gradient Scalar amount to interpolate
  32485. * @returns Interpolated Vector2 value
  32486. */
  32487. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32488. /**
  32489. * Interpolates a size linearly
  32490. * @param startValue Start value of the animation curve
  32491. * @param endValue End value of the animation curve
  32492. * @param gradient Scalar amount to interpolate
  32493. * @returns Interpolated Size value
  32494. */
  32495. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32496. /**
  32497. * Interpolates a Color3 linearly
  32498. * @param startValue Start value of the animation curve
  32499. * @param endValue End value of the animation curve
  32500. * @param gradient Scalar amount to interpolate
  32501. * @returns Interpolated Color3 value
  32502. */
  32503. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32504. /**
  32505. * Interpolates a Color4 linearly
  32506. * @param startValue Start value of the animation curve
  32507. * @param endValue End value of the animation curve
  32508. * @param gradient Scalar amount to interpolate
  32509. * @returns Interpolated Color3 value
  32510. */
  32511. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32512. /**
  32513. * @hidden Internal use only
  32514. */
  32515. _getKeyValue(value: any): any;
  32516. /**
  32517. * @hidden Internal use only
  32518. */
  32519. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32520. /**
  32521. * Defines the function to use to interpolate matrices
  32522. * @param startValue defines the start matrix
  32523. * @param endValue defines the end matrix
  32524. * @param gradient defines the gradient between both matrices
  32525. * @param result defines an optional target matrix where to store the interpolation
  32526. * @returns the interpolated matrix
  32527. */
  32528. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32529. /**
  32530. * Makes a copy of the animation
  32531. * @returns Cloned animation
  32532. */
  32533. clone(): Animation;
  32534. /**
  32535. * Sets the key frames of the animation
  32536. * @param values The animation key frames to set
  32537. */
  32538. setKeys(values: Array<IAnimationKey>): void;
  32539. /**
  32540. * Serializes the animation to an object
  32541. * @returns Serialized object
  32542. */
  32543. serialize(): any;
  32544. /**
  32545. * Float animation type
  32546. */
  32547. static readonly ANIMATIONTYPE_FLOAT: number;
  32548. /**
  32549. * Vector3 animation type
  32550. */
  32551. static readonly ANIMATIONTYPE_VECTOR3: number;
  32552. /**
  32553. * Quaternion animation type
  32554. */
  32555. static readonly ANIMATIONTYPE_QUATERNION: number;
  32556. /**
  32557. * Matrix animation type
  32558. */
  32559. static readonly ANIMATIONTYPE_MATRIX: number;
  32560. /**
  32561. * Color3 animation type
  32562. */
  32563. static readonly ANIMATIONTYPE_COLOR3: number;
  32564. /**
  32565. * Color3 animation type
  32566. */
  32567. static readonly ANIMATIONTYPE_COLOR4: number;
  32568. /**
  32569. * Vector2 animation type
  32570. */
  32571. static readonly ANIMATIONTYPE_VECTOR2: number;
  32572. /**
  32573. * Size animation type
  32574. */
  32575. static readonly ANIMATIONTYPE_SIZE: number;
  32576. /**
  32577. * Relative Loop Mode
  32578. */
  32579. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32580. /**
  32581. * Cycle Loop Mode
  32582. */
  32583. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32584. /**
  32585. * Constant Loop Mode
  32586. */
  32587. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32588. /** @hidden */
  32589. static _UniversalLerp(left: any, right: any, amount: number): any;
  32590. /**
  32591. * Parses an animation object and creates an animation
  32592. * @param parsedAnimation Parsed animation object
  32593. * @returns Animation object
  32594. */
  32595. static Parse(parsedAnimation: any): Animation;
  32596. /**
  32597. * Appends the serialized animations from the source animations
  32598. * @param source Source containing the animations
  32599. * @param destination Target to store the animations
  32600. */
  32601. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32602. }
  32603. }
  32604. declare module BABYLON {
  32605. /**
  32606. * Interface containing an array of animations
  32607. */
  32608. export interface IAnimatable {
  32609. /**
  32610. * Array of animations
  32611. */
  32612. animations: Nullable<Array<Animation>>;
  32613. }
  32614. }
  32615. declare module BABYLON {
  32616. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32617. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32618. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32619. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32620. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32621. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32622. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32623. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32624. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32625. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32626. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32627. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32628. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32629. /**
  32630. * Decorator used to define property that can be serialized as reference to a camera
  32631. * @param sourceName defines the name of the property to decorate
  32632. */
  32633. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32634. /**
  32635. * Class used to help serialization objects
  32636. */
  32637. export class SerializationHelper {
  32638. /** @hidden */
  32639. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32640. /** @hidden */
  32641. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32642. /** @hidden */
  32643. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32644. /** @hidden */
  32645. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32646. /**
  32647. * Appends the serialized animations from the source animations
  32648. * @param source Source containing the animations
  32649. * @param destination Target to store the animations
  32650. */
  32651. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32652. /**
  32653. * Static function used to serialized a specific entity
  32654. * @param entity defines the entity to serialize
  32655. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32656. * @returns a JSON compatible object representing the serialization of the entity
  32657. */
  32658. static Serialize<T>(entity: T, serializationObject?: any): any;
  32659. /**
  32660. * Creates a new entity from a serialization data object
  32661. * @param creationFunction defines a function used to instanciated the new entity
  32662. * @param source defines the source serialization data
  32663. * @param scene defines the hosting scene
  32664. * @param rootUrl defines the root url for resources
  32665. * @returns a new entity
  32666. */
  32667. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32668. /**
  32669. * Clones an object
  32670. * @param creationFunction defines the function used to instanciate the new object
  32671. * @param source defines the source object
  32672. * @returns the cloned object
  32673. */
  32674. static Clone<T>(creationFunction: () => T, source: T): T;
  32675. /**
  32676. * Instanciates a new object based on a source one (some data will be shared between both object)
  32677. * @param creationFunction defines the function used to instanciate the new object
  32678. * @param source defines the source object
  32679. * @returns the new object
  32680. */
  32681. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32682. }
  32683. }
  32684. declare module BABYLON {
  32685. /**
  32686. * Base class of all the textures in babylon.
  32687. * It groups all the common properties the materials, post process, lights... might need
  32688. * in order to make a correct use of the texture.
  32689. */
  32690. export class BaseTexture implements IAnimatable {
  32691. /**
  32692. * Default anisotropic filtering level for the application.
  32693. * It is set to 4 as a good tradeoff between perf and quality.
  32694. */
  32695. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32696. /**
  32697. * Gets or sets the unique id of the texture
  32698. */
  32699. uniqueId: number;
  32700. /**
  32701. * Define the name of the texture.
  32702. */
  32703. name: string;
  32704. /**
  32705. * Gets or sets an object used to store user defined information.
  32706. */
  32707. metadata: any;
  32708. /**
  32709. * For internal use only. Please do not use.
  32710. */
  32711. reservedDataStore: any;
  32712. private _hasAlpha;
  32713. /**
  32714. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32715. */
  32716. set hasAlpha(value: boolean);
  32717. get hasAlpha(): boolean;
  32718. /**
  32719. * Defines if the alpha value should be determined via the rgb values.
  32720. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32721. */
  32722. getAlphaFromRGB: boolean;
  32723. /**
  32724. * Intensity or strength of the texture.
  32725. * It is commonly used by materials to fine tune the intensity of the texture
  32726. */
  32727. level: number;
  32728. /**
  32729. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32730. * This is part of the texture as textures usually maps to one uv set.
  32731. */
  32732. coordinatesIndex: number;
  32733. private _coordinatesMode;
  32734. /**
  32735. * How a texture is mapped.
  32736. *
  32737. * | Value | Type | Description |
  32738. * | ----- | ----------------------------------- | ----------- |
  32739. * | 0 | EXPLICIT_MODE | |
  32740. * | 1 | SPHERICAL_MODE | |
  32741. * | 2 | PLANAR_MODE | |
  32742. * | 3 | CUBIC_MODE | |
  32743. * | 4 | PROJECTION_MODE | |
  32744. * | 5 | SKYBOX_MODE | |
  32745. * | 6 | INVCUBIC_MODE | |
  32746. * | 7 | EQUIRECTANGULAR_MODE | |
  32747. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32748. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32749. */
  32750. set coordinatesMode(value: number);
  32751. get coordinatesMode(): number;
  32752. /**
  32753. * | Value | Type | Description |
  32754. * | ----- | ------------------ | ----------- |
  32755. * | 0 | CLAMP_ADDRESSMODE | |
  32756. * | 1 | WRAP_ADDRESSMODE | |
  32757. * | 2 | MIRROR_ADDRESSMODE | |
  32758. */
  32759. wrapU: number;
  32760. /**
  32761. * | Value | Type | Description |
  32762. * | ----- | ------------------ | ----------- |
  32763. * | 0 | CLAMP_ADDRESSMODE | |
  32764. * | 1 | WRAP_ADDRESSMODE | |
  32765. * | 2 | MIRROR_ADDRESSMODE | |
  32766. */
  32767. wrapV: number;
  32768. /**
  32769. * | Value | Type | Description |
  32770. * | ----- | ------------------ | ----------- |
  32771. * | 0 | CLAMP_ADDRESSMODE | |
  32772. * | 1 | WRAP_ADDRESSMODE | |
  32773. * | 2 | MIRROR_ADDRESSMODE | |
  32774. */
  32775. wrapR: number;
  32776. /**
  32777. * With compliant hardware and browser (supporting anisotropic filtering)
  32778. * this defines the level of anisotropic filtering in the texture.
  32779. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32780. */
  32781. anisotropicFilteringLevel: number;
  32782. /**
  32783. * Define if the texture is a cube texture or if false a 2d texture.
  32784. */
  32785. get isCube(): boolean;
  32786. set isCube(value: boolean);
  32787. /**
  32788. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32789. */
  32790. get is3D(): boolean;
  32791. set is3D(value: boolean);
  32792. /**
  32793. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32794. */
  32795. get is2DArray(): boolean;
  32796. set is2DArray(value: boolean);
  32797. /**
  32798. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  32799. * HDR texture are usually stored in linear space.
  32800. * This only impacts the PBR and Background materials
  32801. */
  32802. gammaSpace: boolean;
  32803. /**
  32804. * Gets or sets whether or not the texture contains RGBD data.
  32805. */
  32806. get isRGBD(): boolean;
  32807. set isRGBD(value: boolean);
  32808. /**
  32809. * Is Z inverted in the texture (useful in a cube texture).
  32810. */
  32811. invertZ: boolean;
  32812. /**
  32813. * Are mip maps generated for this texture or not.
  32814. */
  32815. get noMipmap(): boolean;
  32816. /**
  32817. * @hidden
  32818. */
  32819. lodLevelInAlpha: boolean;
  32820. /**
  32821. * With prefiltered texture, defined the offset used during the prefiltering steps.
  32822. */
  32823. get lodGenerationOffset(): number;
  32824. set lodGenerationOffset(value: number);
  32825. /**
  32826. * With prefiltered texture, defined the scale used during the prefiltering steps.
  32827. */
  32828. get lodGenerationScale(): number;
  32829. set lodGenerationScale(value: number);
  32830. /**
  32831. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  32832. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  32833. * average roughness values.
  32834. */
  32835. get linearSpecularLOD(): boolean;
  32836. set linearSpecularLOD(value: boolean);
  32837. /**
  32838. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  32839. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  32840. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  32841. */
  32842. get irradianceTexture(): Nullable<BaseTexture>;
  32843. set irradianceTexture(value: Nullable<BaseTexture>);
  32844. /**
  32845. * Define if the texture is a render target.
  32846. */
  32847. isRenderTarget: boolean;
  32848. /**
  32849. * Define the unique id of the texture in the scene.
  32850. */
  32851. get uid(): string;
  32852. /** @hidden */
  32853. _prefiltered: boolean;
  32854. /**
  32855. * Return a string representation of the texture.
  32856. * @returns the texture as a string
  32857. */
  32858. toString(): string;
  32859. /**
  32860. * Get the class name of the texture.
  32861. * @returns "BaseTexture"
  32862. */
  32863. getClassName(): string;
  32864. /**
  32865. * Define the list of animation attached to the texture.
  32866. */
  32867. animations: Animation[];
  32868. /**
  32869. * An event triggered when the texture is disposed.
  32870. */
  32871. onDisposeObservable: Observable<BaseTexture>;
  32872. private _onDisposeObserver;
  32873. /**
  32874. * Callback triggered when the texture has been disposed.
  32875. * Kept for back compatibility, you can use the onDisposeObservable instead.
  32876. */
  32877. set onDispose(callback: () => void);
  32878. /**
  32879. * Define the current state of the loading sequence when in delayed load mode.
  32880. */
  32881. delayLoadState: number;
  32882. private _scene;
  32883. private _engine;
  32884. /** @hidden */
  32885. _texture: Nullable<InternalTexture>;
  32886. private _uid;
  32887. /**
  32888. * Define if the texture is preventinga material to render or not.
  32889. * If not and the texture is not ready, the engine will use a default black texture instead.
  32890. */
  32891. get isBlocking(): boolean;
  32892. /**
  32893. * Instantiates a new BaseTexture.
  32894. * Base class of all the textures in babylon.
  32895. * It groups all the common properties the materials, post process, lights... might need
  32896. * in order to make a correct use of the texture.
  32897. * @param sceneOrEngine Define the scene or engine the texture blongs to
  32898. */
  32899. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  32900. /**
  32901. * Get the scene the texture belongs to.
  32902. * @returns the scene or null if undefined
  32903. */
  32904. getScene(): Nullable<Scene>;
  32905. /** @hidden */
  32906. protected _getEngine(): Nullable<ThinEngine>;
  32907. /**
  32908. * Get the texture transform matrix used to offset tile the texture for istance.
  32909. * @returns the transformation matrix
  32910. */
  32911. getTextureMatrix(): Matrix;
  32912. /**
  32913. * Get the texture reflection matrix used to rotate/transform the reflection.
  32914. * @returns the reflection matrix
  32915. */
  32916. getReflectionTextureMatrix(): Matrix;
  32917. /**
  32918. * Get the underlying lower level texture from Babylon.
  32919. * @returns the insternal texture
  32920. */
  32921. getInternalTexture(): Nullable<InternalTexture>;
  32922. /**
  32923. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  32924. * @returns true if ready or not blocking
  32925. */
  32926. isReadyOrNotBlocking(): boolean;
  32927. /**
  32928. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  32929. * @returns true if fully ready
  32930. */
  32931. isReady(): boolean;
  32932. private _cachedSize;
  32933. /**
  32934. * Get the size of the texture.
  32935. * @returns the texture size.
  32936. */
  32937. getSize(): ISize;
  32938. /**
  32939. * Get the base size of the texture.
  32940. * It can be different from the size if the texture has been resized for POT for instance
  32941. * @returns the base size
  32942. */
  32943. getBaseSize(): ISize;
  32944. /**
  32945. * Update the sampling mode of the texture.
  32946. * Default is Trilinear mode.
  32947. *
  32948. * | Value | Type | Description |
  32949. * | ----- | ------------------ | ----------- |
  32950. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  32951. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  32952. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  32953. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  32954. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  32955. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  32956. * | 7 | NEAREST_LINEAR | |
  32957. * | 8 | NEAREST_NEAREST | |
  32958. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  32959. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  32960. * | 11 | LINEAR_LINEAR | |
  32961. * | 12 | LINEAR_NEAREST | |
  32962. *
  32963. * > _mag_: magnification filter (close to the viewer)
  32964. * > _min_: minification filter (far from the viewer)
  32965. * > _mip_: filter used between mip map levels
  32966. *@param samplingMode Define the new sampling mode of the texture
  32967. */
  32968. updateSamplingMode(samplingMode: number): void;
  32969. /**
  32970. * Scales the texture if is `canRescale()`
  32971. * @param ratio the resize factor we want to use to rescale
  32972. */
  32973. scale(ratio: number): void;
  32974. /**
  32975. * Get if the texture can rescale.
  32976. */
  32977. get canRescale(): boolean;
  32978. /** @hidden */
  32979. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  32980. /** @hidden */
  32981. _rebuild(): void;
  32982. /**
  32983. * Triggers the load sequence in delayed load mode.
  32984. */
  32985. delayLoad(): void;
  32986. /**
  32987. * Clones the texture.
  32988. * @returns the cloned texture
  32989. */
  32990. clone(): Nullable<BaseTexture>;
  32991. /**
  32992. * Get the texture underlying type (INT, FLOAT...)
  32993. */
  32994. get textureType(): number;
  32995. /**
  32996. * Get the texture underlying format (RGB, RGBA...)
  32997. */
  32998. get textureFormat(): number;
  32999. /**
  33000. * Indicates that textures need to be re-calculated for all materials
  33001. */
  33002. protected _markAllSubMeshesAsTexturesDirty(): void;
  33003. /**
  33004. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33005. * This will returns an RGBA array buffer containing either in values (0-255) or
  33006. * float values (0-1) depending of the underlying buffer type.
  33007. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33008. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33009. * @param buffer defines a user defined buffer to fill with data (can be null)
  33010. * @returns The Array buffer containing the pixels data.
  33011. */
  33012. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33013. /**
  33014. * Release and destroy the underlying lower level texture aka internalTexture.
  33015. */
  33016. releaseInternalTexture(): void;
  33017. /** @hidden */
  33018. get _lodTextureHigh(): Nullable<BaseTexture>;
  33019. /** @hidden */
  33020. get _lodTextureMid(): Nullable<BaseTexture>;
  33021. /** @hidden */
  33022. get _lodTextureLow(): Nullable<BaseTexture>;
  33023. /**
  33024. * Dispose the texture and release its associated resources.
  33025. */
  33026. dispose(): void;
  33027. /**
  33028. * Serialize the texture into a JSON representation that can be parsed later on.
  33029. * @returns the JSON representation of the texture
  33030. */
  33031. serialize(): any;
  33032. /**
  33033. * Helper function to be called back once a list of texture contains only ready textures.
  33034. * @param textures Define the list of textures to wait for
  33035. * @param callback Define the callback triggered once the entire list will be ready
  33036. */
  33037. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33038. private static _isScene;
  33039. }
  33040. }
  33041. declare module BABYLON {
  33042. /**
  33043. * Options to be used when creating an effect.
  33044. */
  33045. export interface IEffectCreationOptions {
  33046. /**
  33047. * Atrributes that will be used in the shader.
  33048. */
  33049. attributes: string[];
  33050. /**
  33051. * Uniform varible names that will be set in the shader.
  33052. */
  33053. uniformsNames: string[];
  33054. /**
  33055. * Uniform buffer variable names that will be set in the shader.
  33056. */
  33057. uniformBuffersNames: string[];
  33058. /**
  33059. * Sampler texture variable names that will be set in the shader.
  33060. */
  33061. samplers: string[];
  33062. /**
  33063. * Define statements that will be set in the shader.
  33064. */
  33065. defines: any;
  33066. /**
  33067. * Possible fallbacks for this effect to improve performance when needed.
  33068. */
  33069. fallbacks: Nullable<IEffectFallbacks>;
  33070. /**
  33071. * Callback that will be called when the shader is compiled.
  33072. */
  33073. onCompiled: Nullable<(effect: Effect) => void>;
  33074. /**
  33075. * Callback that will be called if an error occurs during shader compilation.
  33076. */
  33077. onError: Nullable<(effect: Effect, errors: string) => void>;
  33078. /**
  33079. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33080. */
  33081. indexParameters?: any;
  33082. /**
  33083. * Max number of lights that can be used in the shader.
  33084. */
  33085. maxSimultaneousLights?: number;
  33086. /**
  33087. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33088. */
  33089. transformFeedbackVaryings?: Nullable<string[]>;
  33090. /**
  33091. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  33092. */
  33093. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33094. }
  33095. /**
  33096. * Effect containing vertex and fragment shader that can be executed on an object.
  33097. */
  33098. export class Effect implements IDisposable {
  33099. /**
  33100. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33101. */
  33102. static ShadersRepository: string;
  33103. /**
  33104. * Enable logging of the shader code when a compilation error occurs
  33105. */
  33106. static LogShaderCodeOnCompilationError: boolean;
  33107. /**
  33108. * Name of the effect.
  33109. */
  33110. name: any;
  33111. /**
  33112. * String container all the define statements that should be set on the shader.
  33113. */
  33114. defines: string;
  33115. /**
  33116. * Callback that will be called when the shader is compiled.
  33117. */
  33118. onCompiled: Nullable<(effect: Effect) => void>;
  33119. /**
  33120. * Callback that will be called if an error occurs during shader compilation.
  33121. */
  33122. onError: Nullable<(effect: Effect, errors: string) => void>;
  33123. /**
  33124. * Callback that will be called when effect is bound.
  33125. */
  33126. onBind: Nullable<(effect: Effect) => void>;
  33127. /**
  33128. * Unique ID of the effect.
  33129. */
  33130. uniqueId: number;
  33131. /**
  33132. * Observable that will be called when the shader is compiled.
  33133. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33134. */
  33135. onCompileObservable: Observable<Effect>;
  33136. /**
  33137. * Observable that will be called if an error occurs during shader compilation.
  33138. */
  33139. onErrorObservable: Observable<Effect>;
  33140. /** @hidden */
  33141. _onBindObservable: Nullable<Observable<Effect>>;
  33142. /**
  33143. * @hidden
  33144. * Specifies if the effect was previously ready
  33145. */
  33146. _wasPreviouslyReady: boolean;
  33147. /**
  33148. * Observable that will be called when effect is bound.
  33149. */
  33150. get onBindObservable(): Observable<Effect>;
  33151. /** @hidden */
  33152. _bonesComputationForcedToCPU: boolean;
  33153. private static _uniqueIdSeed;
  33154. private _engine;
  33155. private _uniformBuffersNames;
  33156. private _uniformBuffersNamesList;
  33157. private _uniformsNames;
  33158. private _samplerList;
  33159. private _samplers;
  33160. private _isReady;
  33161. private _compilationError;
  33162. private _allFallbacksProcessed;
  33163. private _attributesNames;
  33164. private _attributes;
  33165. private _attributeLocationByName;
  33166. private _uniforms;
  33167. /**
  33168. * Key for the effect.
  33169. * @hidden
  33170. */
  33171. _key: string;
  33172. private _indexParameters;
  33173. private _fallbacks;
  33174. private _vertexSourceCode;
  33175. private _fragmentSourceCode;
  33176. private _vertexSourceCodeOverride;
  33177. private _fragmentSourceCodeOverride;
  33178. private _transformFeedbackVaryings;
  33179. /**
  33180. * Compiled shader to webGL program.
  33181. * @hidden
  33182. */
  33183. _pipelineContext: Nullable<IPipelineContext>;
  33184. private _valueCache;
  33185. private static _baseCache;
  33186. /**
  33187. * Instantiates an effect.
  33188. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33189. * @param baseName Name of the effect.
  33190. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33191. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33192. * @param samplers List of sampler variables that will be passed to the shader.
  33193. * @param engine Engine to be used to render the effect
  33194. * @param defines Define statements to be added to the shader.
  33195. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33196. * @param onCompiled Callback that will be called when the shader is compiled.
  33197. * @param onError Callback that will be called if an error occurs during shader compilation.
  33198. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33199. */
  33200. 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);
  33201. private _useFinalCode;
  33202. /**
  33203. * Unique key for this effect
  33204. */
  33205. get key(): string;
  33206. /**
  33207. * If the effect has been compiled and prepared.
  33208. * @returns if the effect is compiled and prepared.
  33209. */
  33210. isReady(): boolean;
  33211. private _isReadyInternal;
  33212. /**
  33213. * The engine the effect was initialized with.
  33214. * @returns the engine.
  33215. */
  33216. getEngine(): Engine;
  33217. /**
  33218. * The pipeline context for this effect
  33219. * @returns the associated pipeline context
  33220. */
  33221. getPipelineContext(): Nullable<IPipelineContext>;
  33222. /**
  33223. * The set of names of attribute variables for the shader.
  33224. * @returns An array of attribute names.
  33225. */
  33226. getAttributesNames(): string[];
  33227. /**
  33228. * Returns the attribute at the given index.
  33229. * @param index The index of the attribute.
  33230. * @returns The location of the attribute.
  33231. */
  33232. getAttributeLocation(index: number): number;
  33233. /**
  33234. * Returns the attribute based on the name of the variable.
  33235. * @param name of the attribute to look up.
  33236. * @returns the attribute location.
  33237. */
  33238. getAttributeLocationByName(name: string): number;
  33239. /**
  33240. * The number of attributes.
  33241. * @returns the numnber of attributes.
  33242. */
  33243. getAttributesCount(): number;
  33244. /**
  33245. * Gets the index of a uniform variable.
  33246. * @param uniformName of the uniform to look up.
  33247. * @returns the index.
  33248. */
  33249. getUniformIndex(uniformName: string): number;
  33250. /**
  33251. * Returns the attribute based on the name of the variable.
  33252. * @param uniformName of the uniform to look up.
  33253. * @returns the location of the uniform.
  33254. */
  33255. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33256. /**
  33257. * Returns an array of sampler variable names
  33258. * @returns The array of sampler variable names.
  33259. */
  33260. getSamplers(): string[];
  33261. /**
  33262. * Returns an array of uniform variable names
  33263. * @returns The array of uniform variable names.
  33264. */
  33265. getUniformNames(): string[];
  33266. /**
  33267. * Returns an array of uniform buffer variable names
  33268. * @returns The array of uniform buffer variable names.
  33269. */
  33270. getUniformBuffersNames(): string[];
  33271. /**
  33272. * Returns the index parameters used to create the effect
  33273. * @returns The index parameters object
  33274. */
  33275. getIndexParameters(): any;
  33276. /**
  33277. * The error from the last compilation.
  33278. * @returns the error string.
  33279. */
  33280. getCompilationError(): string;
  33281. /**
  33282. * Gets a boolean indicating that all fallbacks were used during compilation
  33283. * @returns true if all fallbacks were used
  33284. */
  33285. allFallbacksProcessed(): boolean;
  33286. /**
  33287. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33288. * @param func The callback to be used.
  33289. */
  33290. executeWhenCompiled(func: (effect: Effect) => void): void;
  33291. private _checkIsReady;
  33292. private _loadShader;
  33293. /**
  33294. * Gets the vertex shader source code of this effect
  33295. */
  33296. get vertexSourceCode(): string;
  33297. /**
  33298. * Gets the fragment shader source code of this effect
  33299. */
  33300. get fragmentSourceCode(): string;
  33301. /**
  33302. * Recompiles the webGL program
  33303. * @param vertexSourceCode The source code for the vertex shader.
  33304. * @param fragmentSourceCode The source code for the fragment shader.
  33305. * @param onCompiled Callback called when completed.
  33306. * @param onError Callback called on error.
  33307. * @hidden
  33308. */
  33309. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33310. /**
  33311. * Prepares the effect
  33312. * @hidden
  33313. */
  33314. _prepareEffect(): void;
  33315. private _getShaderCodeAndErrorLine;
  33316. private _processCompilationErrors;
  33317. /**
  33318. * Checks if the effect is supported. (Must be called after compilation)
  33319. */
  33320. get isSupported(): boolean;
  33321. /**
  33322. * Binds a texture to the engine to be used as output of the shader.
  33323. * @param channel Name of the output variable.
  33324. * @param texture Texture to bind.
  33325. * @hidden
  33326. */
  33327. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33328. /**
  33329. * Sets a texture on the engine to be used in the shader.
  33330. * @param channel Name of the sampler variable.
  33331. * @param texture Texture to set.
  33332. */
  33333. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33334. /**
  33335. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33336. * @param channel Name of the sampler variable.
  33337. * @param texture Texture to set.
  33338. */
  33339. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33340. /**
  33341. * Sets an array of textures on the engine to be used in the shader.
  33342. * @param channel Name of the variable.
  33343. * @param textures Textures to set.
  33344. */
  33345. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33346. /**
  33347. * 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)
  33348. * @param channel Name of the sampler variable.
  33349. * @param postProcess Post process to get the input texture from.
  33350. */
  33351. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33352. /**
  33353. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33354. * 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)
  33355. * @param channel Name of the sampler variable.
  33356. * @param postProcess Post process to get the output texture from.
  33357. */
  33358. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33359. /** @hidden */
  33360. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33361. /** @hidden */
  33362. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33363. /** @hidden */
  33364. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33365. /** @hidden */
  33366. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33367. /**
  33368. * Binds a buffer to a uniform.
  33369. * @param buffer Buffer to bind.
  33370. * @param name Name of the uniform variable to bind to.
  33371. */
  33372. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33373. /**
  33374. * Binds block to a uniform.
  33375. * @param blockName Name of the block to bind.
  33376. * @param index Index to bind.
  33377. */
  33378. bindUniformBlock(blockName: string, index: number): void;
  33379. /**
  33380. * Sets an interger value on a uniform variable.
  33381. * @param uniformName Name of the variable.
  33382. * @param value Value to be set.
  33383. * @returns this effect.
  33384. */
  33385. setInt(uniformName: string, value: number): Effect;
  33386. /**
  33387. * Sets an int array on a uniform variable.
  33388. * @param uniformName Name of the variable.
  33389. * @param array array to be set.
  33390. * @returns this effect.
  33391. */
  33392. setIntArray(uniformName: string, array: Int32Array): Effect;
  33393. /**
  33394. * 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)
  33395. * @param uniformName Name of the variable.
  33396. * @param array array to be set.
  33397. * @returns this effect.
  33398. */
  33399. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33400. /**
  33401. * 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)
  33402. * @param uniformName Name of the variable.
  33403. * @param array array to be set.
  33404. * @returns this effect.
  33405. */
  33406. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33407. /**
  33408. * 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)
  33409. * @param uniformName Name of the variable.
  33410. * @param array array to be set.
  33411. * @returns this effect.
  33412. */
  33413. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33414. /**
  33415. * Sets an float array on a uniform variable.
  33416. * @param uniformName Name of the variable.
  33417. * @param array array to be set.
  33418. * @returns this effect.
  33419. */
  33420. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33421. /**
  33422. * 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)
  33423. * @param uniformName Name of the variable.
  33424. * @param array array to be set.
  33425. * @returns this effect.
  33426. */
  33427. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33428. /**
  33429. * 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)
  33430. * @param uniformName Name of the variable.
  33431. * @param array array to be set.
  33432. * @returns this effect.
  33433. */
  33434. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33435. /**
  33436. * 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)
  33437. * @param uniformName Name of the variable.
  33438. * @param array array to be set.
  33439. * @returns this effect.
  33440. */
  33441. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33442. /**
  33443. * Sets an array on a uniform variable.
  33444. * @param uniformName Name of the variable.
  33445. * @param array array to be set.
  33446. * @returns this effect.
  33447. */
  33448. setArray(uniformName: string, array: number[]): Effect;
  33449. /**
  33450. * 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)
  33451. * @param uniformName Name of the variable.
  33452. * @param array array to be set.
  33453. * @returns this effect.
  33454. */
  33455. setArray2(uniformName: string, array: number[]): Effect;
  33456. /**
  33457. * 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)
  33458. * @param uniformName Name of the variable.
  33459. * @param array array to be set.
  33460. * @returns this effect.
  33461. */
  33462. setArray3(uniformName: string, array: number[]): Effect;
  33463. /**
  33464. * 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)
  33465. * @param uniformName Name of the variable.
  33466. * @param array array to be set.
  33467. * @returns this effect.
  33468. */
  33469. setArray4(uniformName: string, array: number[]): Effect;
  33470. /**
  33471. * Sets matrices on a uniform variable.
  33472. * @param uniformName Name of the variable.
  33473. * @param matrices matrices to be set.
  33474. * @returns this effect.
  33475. */
  33476. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33477. /**
  33478. * Sets matrix on a uniform variable.
  33479. * @param uniformName Name of the variable.
  33480. * @param matrix matrix to be set.
  33481. * @returns this effect.
  33482. */
  33483. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33484. /**
  33485. * 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)
  33486. * @param uniformName Name of the variable.
  33487. * @param matrix matrix to be set.
  33488. * @returns this effect.
  33489. */
  33490. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33491. /**
  33492. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33493. * @param uniformName Name of the variable.
  33494. * @param matrix matrix to be set.
  33495. * @returns this effect.
  33496. */
  33497. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33498. /**
  33499. * Sets a float on a uniform variable.
  33500. * @param uniformName Name of the variable.
  33501. * @param value value to be set.
  33502. * @returns this effect.
  33503. */
  33504. setFloat(uniformName: string, value: number): Effect;
  33505. /**
  33506. * Sets a boolean on a uniform variable.
  33507. * @param uniformName Name of the variable.
  33508. * @param bool value to be set.
  33509. * @returns this effect.
  33510. */
  33511. setBool(uniformName: string, bool: boolean): Effect;
  33512. /**
  33513. * Sets a Vector2 on a uniform variable.
  33514. * @param uniformName Name of the variable.
  33515. * @param vector2 vector2 to be set.
  33516. * @returns this effect.
  33517. */
  33518. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33519. /**
  33520. * Sets a float2 on a uniform variable.
  33521. * @param uniformName Name of the variable.
  33522. * @param x First float in float2.
  33523. * @param y Second float in float2.
  33524. * @returns this effect.
  33525. */
  33526. setFloat2(uniformName: string, x: number, y: number): Effect;
  33527. /**
  33528. * Sets a Vector3 on a uniform variable.
  33529. * @param uniformName Name of the variable.
  33530. * @param vector3 Value to be set.
  33531. * @returns this effect.
  33532. */
  33533. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33534. /**
  33535. * Sets a float3 on a uniform variable.
  33536. * @param uniformName Name of the variable.
  33537. * @param x First float in float3.
  33538. * @param y Second float in float3.
  33539. * @param z Third float in float3.
  33540. * @returns this effect.
  33541. */
  33542. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33543. /**
  33544. * Sets a Vector4 on a uniform variable.
  33545. * @param uniformName Name of the variable.
  33546. * @param vector4 Value to be set.
  33547. * @returns this effect.
  33548. */
  33549. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33550. /**
  33551. * Sets a float4 on a uniform variable.
  33552. * @param uniformName Name of the variable.
  33553. * @param x First float in float4.
  33554. * @param y Second float in float4.
  33555. * @param z Third float in float4.
  33556. * @param w Fourth float in float4.
  33557. * @returns this effect.
  33558. */
  33559. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33560. /**
  33561. * Sets a Color3 on a uniform variable.
  33562. * @param uniformName Name of the variable.
  33563. * @param color3 Value to be set.
  33564. * @returns this effect.
  33565. */
  33566. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33567. /**
  33568. * Sets a Color4 on a uniform variable.
  33569. * @param uniformName Name of the variable.
  33570. * @param color3 Value to be set.
  33571. * @param alpha Alpha value to be set.
  33572. * @returns this effect.
  33573. */
  33574. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33575. /**
  33576. * Sets a Color4 on a uniform variable
  33577. * @param uniformName defines the name of the variable
  33578. * @param color4 defines the value to be set
  33579. * @returns this effect.
  33580. */
  33581. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33582. /** Release all associated resources */
  33583. dispose(): void;
  33584. /**
  33585. * This function will add a new shader to the shader store
  33586. * @param name the name of the shader
  33587. * @param pixelShader optional pixel shader content
  33588. * @param vertexShader optional vertex shader content
  33589. */
  33590. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33591. /**
  33592. * Store of each shader (The can be looked up using effect.key)
  33593. */
  33594. static ShadersStore: {
  33595. [key: string]: string;
  33596. };
  33597. /**
  33598. * Store of each included file for a shader (The can be looked up using effect.key)
  33599. */
  33600. static IncludesShadersStore: {
  33601. [key: string]: string;
  33602. };
  33603. /**
  33604. * Resets the cache of effects.
  33605. */
  33606. static ResetCache(): void;
  33607. }
  33608. }
  33609. declare module BABYLON {
  33610. /**
  33611. * Interface used to describe the capabilities of the engine relatively to the current browser
  33612. */
  33613. export interface EngineCapabilities {
  33614. /** Maximum textures units per fragment shader */
  33615. maxTexturesImageUnits: number;
  33616. /** Maximum texture units per vertex shader */
  33617. maxVertexTextureImageUnits: number;
  33618. /** Maximum textures units in the entire pipeline */
  33619. maxCombinedTexturesImageUnits: number;
  33620. /** Maximum texture size */
  33621. maxTextureSize: number;
  33622. /** Maximum texture samples */
  33623. maxSamples?: number;
  33624. /** Maximum cube texture size */
  33625. maxCubemapTextureSize: number;
  33626. /** Maximum render texture size */
  33627. maxRenderTextureSize: number;
  33628. /** Maximum number of vertex attributes */
  33629. maxVertexAttribs: number;
  33630. /** Maximum number of varyings */
  33631. maxVaryingVectors: number;
  33632. /** Maximum number of uniforms per vertex shader */
  33633. maxVertexUniformVectors: number;
  33634. /** Maximum number of uniforms per fragment shader */
  33635. maxFragmentUniformVectors: number;
  33636. /** Defines if standard derivates (dx/dy) are supported */
  33637. standardDerivatives: boolean;
  33638. /** Defines if s3tc texture compression is supported */
  33639. s3tc?: WEBGL_compressed_texture_s3tc;
  33640. /** Defines if pvrtc texture compression is supported */
  33641. pvrtc: any;
  33642. /** Defines if etc1 texture compression is supported */
  33643. etc1: any;
  33644. /** Defines if etc2 texture compression is supported */
  33645. etc2: any;
  33646. /** Defines if astc texture compression is supported */
  33647. astc: any;
  33648. /** Defines if float textures are supported */
  33649. textureFloat: boolean;
  33650. /** Defines if vertex array objects are supported */
  33651. vertexArrayObject: boolean;
  33652. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33653. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33654. /** Gets the maximum level of anisotropy supported */
  33655. maxAnisotropy: number;
  33656. /** Defines if instancing is supported */
  33657. instancedArrays: boolean;
  33658. /** Defines if 32 bits indices are supported */
  33659. uintIndices: boolean;
  33660. /** Defines if high precision shaders are supported */
  33661. highPrecisionShaderSupported: boolean;
  33662. /** Defines if depth reading in the fragment shader is supported */
  33663. fragmentDepthSupported: boolean;
  33664. /** Defines if float texture linear filtering is supported*/
  33665. textureFloatLinearFiltering: boolean;
  33666. /** Defines if rendering to float textures is supported */
  33667. textureFloatRender: boolean;
  33668. /** Defines if half float textures are supported*/
  33669. textureHalfFloat: boolean;
  33670. /** Defines if half float texture linear filtering is supported*/
  33671. textureHalfFloatLinearFiltering: boolean;
  33672. /** Defines if rendering to half float textures is supported */
  33673. textureHalfFloatRender: boolean;
  33674. /** Defines if textureLOD shader command is supported */
  33675. textureLOD: boolean;
  33676. /** Defines if draw buffers extension is supported */
  33677. drawBuffersExtension: boolean;
  33678. /** Defines if depth textures are supported */
  33679. depthTextureExtension: boolean;
  33680. /** Defines if float color buffer are supported */
  33681. colorBufferFloat: boolean;
  33682. /** Gets disjoint timer query extension (null if not supported) */
  33683. timerQuery?: EXT_disjoint_timer_query;
  33684. /** Defines if timestamp can be used with timer query */
  33685. canUseTimestampForTimerQuery: boolean;
  33686. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33687. multiview?: any;
  33688. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33689. oculusMultiview?: any;
  33690. /** Function used to let the system compiles shaders in background */
  33691. parallelShaderCompile?: {
  33692. COMPLETION_STATUS_KHR: number;
  33693. };
  33694. /** Max number of texture samples for MSAA */
  33695. maxMSAASamples: number;
  33696. /** Defines if the blend min max extension is supported */
  33697. blendMinMax: boolean;
  33698. }
  33699. }
  33700. declare module BABYLON {
  33701. /**
  33702. * @hidden
  33703. **/
  33704. export class DepthCullingState {
  33705. private _isDepthTestDirty;
  33706. private _isDepthMaskDirty;
  33707. private _isDepthFuncDirty;
  33708. private _isCullFaceDirty;
  33709. private _isCullDirty;
  33710. private _isZOffsetDirty;
  33711. private _isFrontFaceDirty;
  33712. private _depthTest;
  33713. private _depthMask;
  33714. private _depthFunc;
  33715. private _cull;
  33716. private _cullFace;
  33717. private _zOffset;
  33718. private _frontFace;
  33719. /**
  33720. * Initializes the state.
  33721. */
  33722. constructor();
  33723. get isDirty(): boolean;
  33724. get zOffset(): number;
  33725. set zOffset(value: number);
  33726. get cullFace(): Nullable<number>;
  33727. set cullFace(value: Nullable<number>);
  33728. get cull(): Nullable<boolean>;
  33729. set cull(value: Nullable<boolean>);
  33730. get depthFunc(): Nullable<number>;
  33731. set depthFunc(value: Nullable<number>);
  33732. get depthMask(): boolean;
  33733. set depthMask(value: boolean);
  33734. get depthTest(): boolean;
  33735. set depthTest(value: boolean);
  33736. get frontFace(): Nullable<number>;
  33737. set frontFace(value: Nullable<number>);
  33738. reset(): void;
  33739. apply(gl: WebGLRenderingContext): void;
  33740. }
  33741. }
  33742. declare module BABYLON {
  33743. /**
  33744. * @hidden
  33745. **/
  33746. export class StencilState {
  33747. /** 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 */
  33748. static readonly ALWAYS: number;
  33749. /** Passed to stencilOperation to specify that stencil value must be kept */
  33750. static readonly KEEP: number;
  33751. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33752. static readonly REPLACE: number;
  33753. private _isStencilTestDirty;
  33754. private _isStencilMaskDirty;
  33755. private _isStencilFuncDirty;
  33756. private _isStencilOpDirty;
  33757. private _stencilTest;
  33758. private _stencilMask;
  33759. private _stencilFunc;
  33760. private _stencilFuncRef;
  33761. private _stencilFuncMask;
  33762. private _stencilOpStencilFail;
  33763. private _stencilOpDepthFail;
  33764. private _stencilOpStencilDepthPass;
  33765. get isDirty(): boolean;
  33766. get stencilFunc(): number;
  33767. set stencilFunc(value: number);
  33768. get stencilFuncRef(): number;
  33769. set stencilFuncRef(value: number);
  33770. get stencilFuncMask(): number;
  33771. set stencilFuncMask(value: number);
  33772. get stencilOpStencilFail(): number;
  33773. set stencilOpStencilFail(value: number);
  33774. get stencilOpDepthFail(): number;
  33775. set stencilOpDepthFail(value: number);
  33776. get stencilOpStencilDepthPass(): number;
  33777. set stencilOpStencilDepthPass(value: number);
  33778. get stencilMask(): number;
  33779. set stencilMask(value: number);
  33780. get stencilTest(): boolean;
  33781. set stencilTest(value: boolean);
  33782. constructor();
  33783. reset(): void;
  33784. apply(gl: WebGLRenderingContext): void;
  33785. }
  33786. }
  33787. declare module BABYLON {
  33788. /**
  33789. * @hidden
  33790. **/
  33791. export class AlphaState {
  33792. private _isAlphaBlendDirty;
  33793. private _isBlendFunctionParametersDirty;
  33794. private _isBlendEquationParametersDirty;
  33795. private _isBlendConstantsDirty;
  33796. private _alphaBlend;
  33797. private _blendFunctionParameters;
  33798. private _blendEquationParameters;
  33799. private _blendConstants;
  33800. /**
  33801. * Initializes the state.
  33802. */
  33803. constructor();
  33804. get isDirty(): boolean;
  33805. get alphaBlend(): boolean;
  33806. set alphaBlend(value: boolean);
  33807. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33808. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33809. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33810. reset(): void;
  33811. apply(gl: WebGLRenderingContext): void;
  33812. }
  33813. }
  33814. declare module BABYLON {
  33815. /** @hidden */
  33816. export class WebGL2ShaderProcessor implements IShaderProcessor {
  33817. attributeProcessor(attribute: string): string;
  33818. varyingProcessor(varying: string, isFragment: boolean): string;
  33819. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  33820. }
  33821. }
  33822. declare module BABYLON {
  33823. /**
  33824. * Interface for attribute information associated with buffer instanciation
  33825. */
  33826. export interface InstancingAttributeInfo {
  33827. /**
  33828. * Name of the GLSL attribute
  33829. * if attribute index is not specified, this is used to retrieve the index from the effect
  33830. */
  33831. attributeName: string;
  33832. /**
  33833. * Index/offset of the attribute in the vertex shader
  33834. * if not specified, this will be computes from the name.
  33835. */
  33836. index?: number;
  33837. /**
  33838. * size of the attribute, 1, 2, 3 or 4
  33839. */
  33840. attributeSize: number;
  33841. /**
  33842. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  33843. */
  33844. offset: number;
  33845. /**
  33846. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  33847. * default to 1
  33848. */
  33849. divisor?: number;
  33850. /**
  33851. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  33852. * default is FLOAT
  33853. */
  33854. attributeType?: number;
  33855. /**
  33856. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  33857. */
  33858. normalized?: boolean;
  33859. }
  33860. }
  33861. declare module BABYLON {
  33862. interface ThinEngine {
  33863. /**
  33864. * Update a video texture
  33865. * @param texture defines the texture to update
  33866. * @param video defines the video element to use
  33867. * @param invertY defines if data must be stored with Y axis inverted
  33868. */
  33869. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  33870. }
  33871. }
  33872. declare module BABYLON {
  33873. /**
  33874. * Settings for finer control over video usage
  33875. */
  33876. export interface VideoTextureSettings {
  33877. /**
  33878. * Applies `autoplay` to video, if specified
  33879. */
  33880. autoPlay?: boolean;
  33881. /**
  33882. * Applies `loop` to video, if specified
  33883. */
  33884. loop?: boolean;
  33885. /**
  33886. * Automatically updates internal texture from video at every frame in the render loop
  33887. */
  33888. autoUpdateTexture: boolean;
  33889. /**
  33890. * Image src displayed during the video loading or until the user interacts with the video.
  33891. */
  33892. poster?: string;
  33893. }
  33894. /**
  33895. * If you want to display a video in your scene, this is the special texture for that.
  33896. * This special texture works similar to other textures, with the exception of a few parameters.
  33897. * @see https://doc.babylonjs.com/how_to/video_texture
  33898. */
  33899. export class VideoTexture extends Texture {
  33900. /**
  33901. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33902. */
  33903. readonly autoUpdateTexture: boolean;
  33904. /**
  33905. * The video instance used by the texture internally
  33906. */
  33907. readonly video: HTMLVideoElement;
  33908. private _onUserActionRequestedObservable;
  33909. /**
  33910. * Event triggerd when a dom action is required by the user to play the video.
  33911. * This happens due to recent changes in browser policies preventing video to auto start.
  33912. */
  33913. get onUserActionRequestedObservable(): Observable<Texture>;
  33914. private _generateMipMaps;
  33915. private _stillImageCaptured;
  33916. private _displayingPosterTexture;
  33917. private _settings;
  33918. private _createInternalTextureOnEvent;
  33919. private _frameId;
  33920. private _currentSrc;
  33921. /**
  33922. * Creates a video texture.
  33923. * If you want to display a video in your scene, this is the special texture for that.
  33924. * This special texture works similar to other textures, with the exception of a few parameters.
  33925. * @see https://doc.babylonjs.com/how_to/video_texture
  33926. * @param name optional name, will detect from video source, if not defined
  33927. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  33928. * @param scene is obviously the current scene.
  33929. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33930. * @param invertY is false by default but can be used to invert video on Y axis
  33931. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33932. * @param settings allows finer control over video usage
  33933. */
  33934. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  33935. private _getName;
  33936. private _getVideo;
  33937. private _createInternalTexture;
  33938. private reset;
  33939. /**
  33940. * @hidden Internal method to initiate `update`.
  33941. */
  33942. _rebuild(): void;
  33943. /**
  33944. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  33945. */
  33946. update(): void;
  33947. /**
  33948. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  33949. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  33950. */
  33951. updateTexture(isVisible: boolean): void;
  33952. protected _updateInternalTexture: () => void;
  33953. /**
  33954. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  33955. * @param url New url.
  33956. */
  33957. updateURL(url: string): void;
  33958. /**
  33959. * Clones the texture.
  33960. * @returns the cloned texture
  33961. */
  33962. clone(): VideoTexture;
  33963. /**
  33964. * Dispose the texture and release its associated resources.
  33965. */
  33966. dispose(): void;
  33967. /**
  33968. * Creates a video texture straight from a stream.
  33969. * @param scene Define the scene the texture should be created in
  33970. * @param stream Define the stream the texture should be created from
  33971. * @returns The created video texture as a promise
  33972. */
  33973. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  33974. /**
  33975. * Creates a video texture straight from your WebCam video feed.
  33976. * @param scene Define the scene the texture should be created in
  33977. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33978. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33979. * @returns The created video texture as a promise
  33980. */
  33981. static CreateFromWebCamAsync(scene: Scene, constraints: {
  33982. minWidth: number;
  33983. maxWidth: number;
  33984. minHeight: number;
  33985. maxHeight: number;
  33986. deviceId: string;
  33987. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  33988. /**
  33989. * Creates a video texture straight from your WebCam video feed.
  33990. * @param scene Define the scene the texture should be created in
  33991. * @param onReady Define a callback to triggered once the texture will be ready
  33992. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33993. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33994. */
  33995. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  33996. minWidth: number;
  33997. maxWidth: number;
  33998. minHeight: number;
  33999. maxHeight: number;
  34000. deviceId: string;
  34001. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34002. }
  34003. }
  34004. declare module BABYLON {
  34005. /**
  34006. * Defines the interface used by objects working like Scene
  34007. * @hidden
  34008. */
  34009. export interface ISceneLike {
  34010. _addPendingData(data: any): void;
  34011. _removePendingData(data: any): void;
  34012. offlineProvider: IOfflineProvider;
  34013. }
  34014. /** Interface defining initialization parameters for Engine class */
  34015. export interface EngineOptions extends WebGLContextAttributes {
  34016. /**
  34017. * Defines if the engine should no exceed a specified device ratio
  34018. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34019. */
  34020. limitDeviceRatio?: number;
  34021. /**
  34022. * Defines if webvr should be enabled automatically
  34023. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34024. */
  34025. autoEnableWebVR?: boolean;
  34026. /**
  34027. * Defines if webgl2 should be turned off even if supported
  34028. * @see http://doc.babylonjs.com/features/webgl2
  34029. */
  34030. disableWebGL2Support?: boolean;
  34031. /**
  34032. * Defines if webaudio should be initialized as well
  34033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34034. */
  34035. audioEngine?: boolean;
  34036. /**
  34037. * Defines if animations should run using a deterministic lock step
  34038. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34039. */
  34040. deterministicLockstep?: boolean;
  34041. /** Defines the maximum steps to use with deterministic lock step mode */
  34042. lockstepMaxSteps?: number;
  34043. /** Defines the seconds between each deterministic lock step */
  34044. timeStep?: number;
  34045. /**
  34046. * Defines that engine should ignore context lost events
  34047. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34048. */
  34049. doNotHandleContextLost?: boolean;
  34050. /**
  34051. * Defines that engine should ignore modifying touch action attribute and style
  34052. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34053. */
  34054. doNotHandleTouchAction?: boolean;
  34055. /**
  34056. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34057. */
  34058. useHighPrecisionFloats?: boolean;
  34059. }
  34060. /**
  34061. * The base engine class (root of all engines)
  34062. */
  34063. export class ThinEngine {
  34064. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34065. static ExceptionList: ({
  34066. key: string;
  34067. capture: string;
  34068. captureConstraint: number;
  34069. targets: string[];
  34070. } | {
  34071. key: string;
  34072. capture: null;
  34073. captureConstraint: null;
  34074. targets: string[];
  34075. })[];
  34076. /** @hidden */
  34077. static _TextureLoaders: IInternalTextureLoader[];
  34078. /**
  34079. * Returns the current npm package of the sdk
  34080. */
  34081. static get NpmPackage(): string;
  34082. /**
  34083. * Returns the current version of the framework
  34084. */
  34085. static get Version(): string;
  34086. /**
  34087. * Returns a string describing the current engine
  34088. */
  34089. get description(): string;
  34090. /**
  34091. * Gets or sets the epsilon value used by collision engine
  34092. */
  34093. static CollisionsEpsilon: number;
  34094. /**
  34095. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34096. */
  34097. static get ShadersRepository(): string;
  34098. static set ShadersRepository(value: string);
  34099. /** @hidden */
  34100. _shaderProcessor: IShaderProcessor;
  34101. /**
  34102. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34103. */
  34104. forcePOTTextures: boolean;
  34105. /**
  34106. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34107. */
  34108. isFullscreen: boolean;
  34109. /**
  34110. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34111. */
  34112. cullBackFaces: boolean;
  34113. /**
  34114. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34115. */
  34116. renderEvenInBackground: boolean;
  34117. /**
  34118. * Gets or sets a boolean indicating that cache can be kept between frames
  34119. */
  34120. preventCacheWipeBetweenFrames: boolean;
  34121. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34122. validateShaderPrograms: boolean;
  34123. /**
  34124. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34125. * This can provide greater z depth for distant objects.
  34126. */
  34127. useReverseDepthBuffer: boolean;
  34128. /**
  34129. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34130. */
  34131. disableUniformBuffers: boolean;
  34132. /** @hidden */
  34133. _uniformBuffers: UniformBuffer[];
  34134. /**
  34135. * Gets a boolean indicating that the engine supports uniform buffers
  34136. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34137. */
  34138. get supportsUniformBuffers(): boolean;
  34139. /** @hidden */
  34140. _gl: WebGLRenderingContext;
  34141. /** @hidden */
  34142. _webGLVersion: number;
  34143. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34144. protected _windowIsBackground: boolean;
  34145. protected _creationOptions: EngineOptions;
  34146. protected _highPrecisionShadersAllowed: boolean;
  34147. /** @hidden */
  34148. get _shouldUseHighPrecisionShader(): boolean;
  34149. /**
  34150. * Gets a boolean indicating that only power of 2 textures are supported
  34151. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34152. */
  34153. get needPOTTextures(): boolean;
  34154. /** @hidden */
  34155. _badOS: boolean;
  34156. /** @hidden */
  34157. _badDesktopOS: boolean;
  34158. private _hardwareScalingLevel;
  34159. /** @hidden */
  34160. _caps: EngineCapabilities;
  34161. private _isStencilEnable;
  34162. private _glVersion;
  34163. private _glRenderer;
  34164. private _glVendor;
  34165. /** @hidden */
  34166. _videoTextureSupported: boolean;
  34167. protected _renderingQueueLaunched: boolean;
  34168. protected _activeRenderLoops: (() => void)[];
  34169. /**
  34170. * Observable signaled when a context lost event is raised
  34171. */
  34172. onContextLostObservable: Observable<ThinEngine>;
  34173. /**
  34174. * Observable signaled when a context restored event is raised
  34175. */
  34176. onContextRestoredObservable: Observable<ThinEngine>;
  34177. private _onContextLost;
  34178. private _onContextRestored;
  34179. protected _contextWasLost: boolean;
  34180. /** @hidden */
  34181. _doNotHandleContextLost: boolean;
  34182. /**
  34183. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34184. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34185. */
  34186. get doNotHandleContextLost(): boolean;
  34187. set doNotHandleContextLost(value: boolean);
  34188. /**
  34189. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34190. */
  34191. disableVertexArrayObjects: boolean;
  34192. /** @hidden */
  34193. protected _colorWrite: boolean;
  34194. /** @hidden */
  34195. protected _colorWriteChanged: boolean;
  34196. /** @hidden */
  34197. protected _depthCullingState: DepthCullingState;
  34198. /** @hidden */
  34199. protected _stencilState: StencilState;
  34200. /** @hidden */
  34201. _alphaState: AlphaState;
  34202. /** @hidden */
  34203. _alphaMode: number;
  34204. /** @hidden */
  34205. _alphaEquation: number;
  34206. /** @hidden */
  34207. _internalTexturesCache: InternalTexture[];
  34208. /** @hidden */
  34209. protected _activeChannel: number;
  34210. private _currentTextureChannel;
  34211. /** @hidden */
  34212. protected _boundTexturesCache: {
  34213. [key: string]: Nullable<InternalTexture>;
  34214. };
  34215. /** @hidden */
  34216. protected _currentEffect: Nullable<Effect>;
  34217. /** @hidden */
  34218. protected _currentProgram: Nullable<WebGLProgram>;
  34219. private _compiledEffects;
  34220. private _vertexAttribArraysEnabled;
  34221. /** @hidden */
  34222. protected _cachedViewport: Nullable<IViewportLike>;
  34223. private _cachedVertexArrayObject;
  34224. /** @hidden */
  34225. protected _cachedVertexBuffers: any;
  34226. /** @hidden */
  34227. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34228. /** @hidden */
  34229. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34230. /** @hidden */
  34231. _currentRenderTarget: Nullable<InternalTexture>;
  34232. private _uintIndicesCurrentlySet;
  34233. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34234. /** @hidden */
  34235. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34236. /** @hidden */
  34237. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34238. private _currentBufferPointers;
  34239. private _currentInstanceLocations;
  34240. private _currentInstanceBuffers;
  34241. private _textureUnits;
  34242. /** @hidden */
  34243. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34244. /** @hidden */
  34245. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34246. /** @hidden */
  34247. _boundRenderFunction: any;
  34248. private _vaoRecordInProgress;
  34249. private _mustWipeVertexAttributes;
  34250. private _emptyTexture;
  34251. private _emptyCubeTexture;
  34252. private _emptyTexture3D;
  34253. private _emptyTexture2DArray;
  34254. /** @hidden */
  34255. _frameHandler: number;
  34256. private _nextFreeTextureSlots;
  34257. private _maxSimultaneousTextures;
  34258. private _activeRequests;
  34259. /** @hidden */
  34260. _transformTextureUrl: Nullable<(url: string) => string>;
  34261. protected get _supportsHardwareTextureRescaling(): boolean;
  34262. private _framebufferDimensionsObject;
  34263. /**
  34264. * sets the object from which width and height will be taken from when getting render width and height
  34265. * Will fallback to the gl object
  34266. * @param dimensions the framebuffer width and height that will be used.
  34267. */
  34268. set framebufferDimensionsObject(dimensions: Nullable<{
  34269. framebufferWidth: number;
  34270. framebufferHeight: number;
  34271. }>);
  34272. /**
  34273. * Gets the current viewport
  34274. */
  34275. get currentViewport(): Nullable<IViewportLike>;
  34276. /**
  34277. * Gets the default empty texture
  34278. */
  34279. get emptyTexture(): InternalTexture;
  34280. /**
  34281. * Gets the default empty 3D texture
  34282. */
  34283. get emptyTexture3D(): InternalTexture;
  34284. /**
  34285. * Gets the default empty 2D array texture
  34286. */
  34287. get emptyTexture2DArray(): InternalTexture;
  34288. /**
  34289. * Gets the default empty cube texture
  34290. */
  34291. get emptyCubeTexture(): InternalTexture;
  34292. /**
  34293. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34294. */
  34295. readonly premultipliedAlpha: boolean;
  34296. /**
  34297. * Observable event triggered before each texture is initialized
  34298. */
  34299. onBeforeTextureInitObservable: Observable<Texture>;
  34300. /**
  34301. * Creates a new engine
  34302. * @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
  34303. * @param antialias defines enable antialiasing (default: false)
  34304. * @param options defines further options to be sent to the getContext() function
  34305. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34306. */
  34307. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34308. private _rebuildInternalTextures;
  34309. private _rebuildEffects;
  34310. /**
  34311. * Gets a boolean indicating if all created effects are ready
  34312. * @returns true if all effects are ready
  34313. */
  34314. areAllEffectsReady(): boolean;
  34315. protected _rebuildBuffers(): void;
  34316. protected _initGLContext(): void;
  34317. /**
  34318. * Gets version of the current webGL context
  34319. */
  34320. get webGLVersion(): number;
  34321. /**
  34322. * Gets a string idenfifying the name of the class
  34323. * @returns "Engine" string
  34324. */
  34325. getClassName(): string;
  34326. /**
  34327. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34328. */
  34329. get isStencilEnable(): boolean;
  34330. /** @hidden */
  34331. _prepareWorkingCanvas(): void;
  34332. /**
  34333. * Reset the texture cache to empty state
  34334. */
  34335. resetTextureCache(): void;
  34336. /**
  34337. * Gets an object containing information about the current webGL context
  34338. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34339. */
  34340. getGlInfo(): {
  34341. vendor: string;
  34342. renderer: string;
  34343. version: string;
  34344. };
  34345. /**
  34346. * Defines the hardware scaling level.
  34347. * By default the hardware scaling level is computed from the window device ratio.
  34348. * 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.
  34349. * @param level defines the level to use
  34350. */
  34351. setHardwareScalingLevel(level: number): void;
  34352. /**
  34353. * Gets the current hardware scaling level.
  34354. * By default the hardware scaling level is computed from the window device ratio.
  34355. * 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.
  34356. * @returns a number indicating the current hardware scaling level
  34357. */
  34358. getHardwareScalingLevel(): number;
  34359. /**
  34360. * Gets the list of loaded textures
  34361. * @returns an array containing all loaded textures
  34362. */
  34363. getLoadedTexturesCache(): InternalTexture[];
  34364. /**
  34365. * Gets the object containing all engine capabilities
  34366. * @returns the EngineCapabilities object
  34367. */
  34368. getCaps(): EngineCapabilities;
  34369. /**
  34370. * stop executing a render loop function and remove it from the execution array
  34371. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34372. */
  34373. stopRenderLoop(renderFunction?: () => void): void;
  34374. /** @hidden */
  34375. _renderLoop(): void;
  34376. /**
  34377. * Gets the HTML canvas attached with the current webGL context
  34378. * @returns a HTML canvas
  34379. */
  34380. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34381. /**
  34382. * Gets host window
  34383. * @returns the host window object
  34384. */
  34385. getHostWindow(): Nullable<Window>;
  34386. /**
  34387. * Gets the current render width
  34388. * @param useScreen defines if screen size must be used (or the current render target if any)
  34389. * @returns a number defining the current render width
  34390. */
  34391. getRenderWidth(useScreen?: boolean): number;
  34392. /**
  34393. * Gets the current render height
  34394. * @param useScreen defines if screen size must be used (or the current render target if any)
  34395. * @returns a number defining the current render height
  34396. */
  34397. getRenderHeight(useScreen?: boolean): number;
  34398. /**
  34399. * Can be used to override the current requestAnimationFrame requester.
  34400. * @hidden
  34401. */
  34402. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34403. /**
  34404. * Register and execute a render loop. The engine can have more than one render function
  34405. * @param renderFunction defines the function to continuously execute
  34406. */
  34407. runRenderLoop(renderFunction: () => void): void;
  34408. /**
  34409. * Clear the current render buffer or the current render target (if any is set up)
  34410. * @param color defines the color to use
  34411. * @param backBuffer defines if the back buffer must be cleared
  34412. * @param depth defines if the depth buffer must be cleared
  34413. * @param stencil defines if the stencil buffer must be cleared
  34414. */
  34415. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34416. private _viewportCached;
  34417. /** @hidden */
  34418. _viewport(x: number, y: number, width: number, height: number): void;
  34419. /**
  34420. * Set the WebGL's viewport
  34421. * @param viewport defines the viewport element to be used
  34422. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34423. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34424. */
  34425. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34426. /**
  34427. * Begin a new frame
  34428. */
  34429. beginFrame(): void;
  34430. /**
  34431. * Enf the current frame
  34432. */
  34433. endFrame(): void;
  34434. /**
  34435. * Resize the view according to the canvas' size
  34436. */
  34437. resize(): void;
  34438. /**
  34439. * Force a specific size of the canvas
  34440. * @param width defines the new canvas' width
  34441. * @param height defines the new canvas' height
  34442. */
  34443. setSize(width: number, height: number): void;
  34444. /**
  34445. * Binds the frame buffer to the specified texture.
  34446. * @param texture The texture to render to or null for the default canvas
  34447. * @param faceIndex The face of the texture to render to in case of cube texture
  34448. * @param requiredWidth The width of the target to render to
  34449. * @param requiredHeight The height of the target to render to
  34450. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34451. * @param lodLevel defines the lod level to bind to the frame buffer
  34452. * @param layer defines the 2d array index to bind to frame buffer to
  34453. */
  34454. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34455. /** @hidden */
  34456. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34457. /**
  34458. * Unbind the current render target texture from the webGL context
  34459. * @param texture defines the render target texture to unbind
  34460. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34461. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34462. */
  34463. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34464. /**
  34465. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34466. */
  34467. flushFramebuffer(): void;
  34468. /**
  34469. * Unbind the current render target and bind the default framebuffer
  34470. */
  34471. restoreDefaultFramebuffer(): void;
  34472. /** @hidden */
  34473. protected _resetVertexBufferBinding(): void;
  34474. /**
  34475. * Creates a vertex buffer
  34476. * @param data the data for the vertex buffer
  34477. * @returns the new WebGL static buffer
  34478. */
  34479. createVertexBuffer(data: DataArray): DataBuffer;
  34480. private _createVertexBuffer;
  34481. /**
  34482. * Creates a dynamic vertex buffer
  34483. * @param data the data for the dynamic vertex buffer
  34484. * @returns the new WebGL dynamic buffer
  34485. */
  34486. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34487. protected _resetIndexBufferBinding(): void;
  34488. /**
  34489. * Creates a new index buffer
  34490. * @param indices defines the content of the index buffer
  34491. * @param updatable defines if the index buffer must be updatable
  34492. * @returns a new webGL buffer
  34493. */
  34494. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34495. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34496. /**
  34497. * Bind a webGL buffer to the webGL context
  34498. * @param buffer defines the buffer to bind
  34499. */
  34500. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34501. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34502. private bindBuffer;
  34503. /**
  34504. * update the bound buffer with the given data
  34505. * @param data defines the data to update
  34506. */
  34507. updateArrayBuffer(data: Float32Array): void;
  34508. private _vertexAttribPointer;
  34509. /** @hidden */
  34510. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34511. private _bindVertexBuffersAttributes;
  34512. /**
  34513. * Records a vertex array object
  34514. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34515. * @param vertexBuffers defines the list of vertex buffers to store
  34516. * @param indexBuffer defines the index buffer to store
  34517. * @param effect defines the effect to store
  34518. * @returns the new vertex array object
  34519. */
  34520. recordVertexArrayObject(vertexBuffers: {
  34521. [key: string]: VertexBuffer;
  34522. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34523. /**
  34524. * Bind a specific vertex array object
  34525. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34526. * @param vertexArrayObject defines the vertex array object to bind
  34527. * @param indexBuffer defines the index buffer to bind
  34528. */
  34529. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34530. /**
  34531. * Bind webGl buffers directly to the webGL context
  34532. * @param vertexBuffer defines the vertex buffer to bind
  34533. * @param indexBuffer defines the index buffer to bind
  34534. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34535. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34536. * @param effect defines the effect associated with the vertex buffer
  34537. */
  34538. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34539. private _unbindVertexArrayObject;
  34540. /**
  34541. * Bind a list of vertex buffers to the webGL context
  34542. * @param vertexBuffers defines the list of vertex buffers to bind
  34543. * @param indexBuffer defines the index buffer to bind
  34544. * @param effect defines the effect associated with the vertex buffers
  34545. */
  34546. bindBuffers(vertexBuffers: {
  34547. [key: string]: Nullable<VertexBuffer>;
  34548. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34549. /**
  34550. * Unbind all instance attributes
  34551. */
  34552. unbindInstanceAttributes(): void;
  34553. /**
  34554. * Release and free the memory of a vertex array object
  34555. * @param vao defines the vertex array object to delete
  34556. */
  34557. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34558. /** @hidden */
  34559. _releaseBuffer(buffer: DataBuffer): boolean;
  34560. protected _deleteBuffer(buffer: DataBuffer): void;
  34561. /**
  34562. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34563. * @param instancesBuffer defines the webGL buffer to update and bind
  34564. * @param data defines the data to store in the buffer
  34565. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34566. */
  34567. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34568. /**
  34569. * Bind the content of a webGL buffer used with instantiation
  34570. * @param instancesBuffer defines the webGL buffer to bind
  34571. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34572. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34573. */
  34574. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34575. /**
  34576. * Disable the instance attribute corresponding to the name in parameter
  34577. * @param name defines the name of the attribute to disable
  34578. */
  34579. disableInstanceAttributeByName(name: string): void;
  34580. /**
  34581. * Disable the instance attribute corresponding to the location in parameter
  34582. * @param attributeLocation defines the attribute location of the attribute to disable
  34583. */
  34584. disableInstanceAttribute(attributeLocation: number): void;
  34585. /**
  34586. * Disable the attribute corresponding to the location in parameter
  34587. * @param attributeLocation defines the attribute location of the attribute to disable
  34588. */
  34589. disableAttributeByIndex(attributeLocation: number): void;
  34590. /**
  34591. * Send a draw order
  34592. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34593. * @param indexStart defines the starting index
  34594. * @param indexCount defines the number of index to draw
  34595. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34596. */
  34597. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34598. /**
  34599. * Draw a list of points
  34600. * @param verticesStart defines the index of first vertex to draw
  34601. * @param verticesCount defines the count of vertices to draw
  34602. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34603. */
  34604. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34605. /**
  34606. * Draw a list of unindexed primitives
  34607. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34608. * @param verticesStart defines the index of first vertex to draw
  34609. * @param verticesCount defines the count of vertices to draw
  34610. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34611. */
  34612. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34613. /**
  34614. * Draw a list of indexed primitives
  34615. * @param fillMode defines the primitive to use
  34616. * @param indexStart defines the starting index
  34617. * @param indexCount defines the number of index to draw
  34618. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34619. */
  34620. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34621. /**
  34622. * Draw a list of unindexed primitives
  34623. * @param fillMode defines the primitive to use
  34624. * @param verticesStart defines the index of first vertex to draw
  34625. * @param verticesCount defines the count of vertices to draw
  34626. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34627. */
  34628. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34629. private _drawMode;
  34630. /** @hidden */
  34631. protected _reportDrawCall(): void;
  34632. /** @hidden */
  34633. _releaseEffect(effect: Effect): void;
  34634. /** @hidden */
  34635. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34636. /**
  34637. * Create a new effect (used to store vertex/fragment shaders)
  34638. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34639. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34640. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34641. * @param samplers defines an array of string used to represent textures
  34642. * @param defines defines the string containing the defines to use to compile the shaders
  34643. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34644. * @param onCompiled defines a function to call when the effect creation is successful
  34645. * @param onError defines a function to call when the effect creation has failed
  34646. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34647. * @returns the new Effect
  34648. */
  34649. 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;
  34650. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34651. private _compileShader;
  34652. private _compileRawShader;
  34653. /** @hidden */
  34654. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34655. /**
  34656. * Directly creates a webGL program
  34657. * @param pipelineContext defines the pipeline context to attach to
  34658. * @param vertexCode defines the vertex shader code to use
  34659. * @param fragmentCode defines the fragment shader code to use
  34660. * @param context defines the webGL context to use (if not set, the current one will be used)
  34661. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34662. * @returns the new webGL program
  34663. */
  34664. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34665. /**
  34666. * Creates a webGL program
  34667. * @param pipelineContext defines the pipeline context to attach to
  34668. * @param vertexCode defines the vertex shader code to use
  34669. * @param fragmentCode defines the fragment shader code to use
  34670. * @param defines defines the string containing the defines to use to compile the shaders
  34671. * @param context defines the webGL context to use (if not set, the current one will be used)
  34672. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34673. * @returns the new webGL program
  34674. */
  34675. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34676. /**
  34677. * Creates a new pipeline context
  34678. * @returns the new pipeline
  34679. */
  34680. createPipelineContext(): IPipelineContext;
  34681. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34682. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34683. /** @hidden */
  34684. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34685. /** @hidden */
  34686. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34687. /** @hidden */
  34688. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34689. /**
  34690. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34691. * @param pipelineContext defines the pipeline context to use
  34692. * @param uniformsNames defines the list of uniform names
  34693. * @returns an array of webGL uniform locations
  34694. */
  34695. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34696. /**
  34697. * Gets the lsit of active attributes for a given webGL program
  34698. * @param pipelineContext defines the pipeline context to use
  34699. * @param attributesNames defines the list of attribute names to get
  34700. * @returns an array of indices indicating the offset of each attribute
  34701. */
  34702. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34703. /**
  34704. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34705. * @param effect defines the effect to activate
  34706. */
  34707. enableEffect(effect: Nullable<Effect>): void;
  34708. /**
  34709. * Set the value of an uniform to a number (int)
  34710. * @param uniform defines the webGL uniform location where to store the value
  34711. * @param value defines the int number to store
  34712. */
  34713. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34714. /**
  34715. * Set the value of an uniform to an array of int32
  34716. * @param uniform defines the webGL uniform location where to store the value
  34717. * @param array defines the array of int32 to store
  34718. */
  34719. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34720. /**
  34721. * Set the value of an uniform to an array of int32 (stored as vec2)
  34722. * @param uniform defines the webGL uniform location where to store the value
  34723. * @param array defines the array of int32 to store
  34724. */
  34725. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34726. /**
  34727. * Set the value of an uniform to an array of int32 (stored as vec3)
  34728. * @param uniform defines the webGL uniform location where to store the value
  34729. * @param array defines the array of int32 to store
  34730. */
  34731. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34732. /**
  34733. * Set the value of an uniform to an array of int32 (stored as vec4)
  34734. * @param uniform defines the webGL uniform location where to store the value
  34735. * @param array defines the array of int32 to store
  34736. */
  34737. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34738. /**
  34739. * Set the value of an uniform to an array of number
  34740. * @param uniform defines the webGL uniform location where to store the value
  34741. * @param array defines the array of number to store
  34742. */
  34743. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34744. /**
  34745. * Set the value of an uniform to an array of number (stored as vec2)
  34746. * @param uniform defines the webGL uniform location where to store the value
  34747. * @param array defines the array of number to store
  34748. */
  34749. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34750. /**
  34751. * Set the value of an uniform to an array of number (stored as vec3)
  34752. * @param uniform defines the webGL uniform location where to store the value
  34753. * @param array defines the array of number to store
  34754. */
  34755. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34756. /**
  34757. * Set the value of an uniform to an array of number (stored as vec4)
  34758. * @param uniform defines the webGL uniform location where to store the value
  34759. * @param array defines the array of number to store
  34760. */
  34761. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34762. /**
  34763. * Set the value of an uniform to an array of float32 (stored as matrices)
  34764. * @param uniform defines the webGL uniform location where to store the value
  34765. * @param matrices defines the array of float32 to store
  34766. */
  34767. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  34768. /**
  34769. * Set the value of an uniform to a matrix (3x3)
  34770. * @param uniform defines the webGL uniform location where to store the value
  34771. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  34772. */
  34773. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34774. /**
  34775. * Set the value of an uniform to a matrix (2x2)
  34776. * @param uniform defines the webGL uniform location where to store the value
  34777. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  34778. */
  34779. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34780. /**
  34781. * Set the value of an uniform to a number (float)
  34782. * @param uniform defines the webGL uniform location where to store the value
  34783. * @param value defines the float number to store
  34784. */
  34785. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34786. /**
  34787. * Set the value of an uniform to a vec2
  34788. * @param uniform defines the webGL uniform location where to store the value
  34789. * @param x defines the 1st component of the value
  34790. * @param y defines the 2nd component of the value
  34791. */
  34792. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  34793. /**
  34794. * Set the value of an uniform to a vec3
  34795. * @param uniform defines the webGL uniform location where to store the value
  34796. * @param x defines the 1st component of the value
  34797. * @param y defines the 2nd component of the value
  34798. * @param z defines the 3rd component of the value
  34799. */
  34800. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  34801. /**
  34802. * Set the value of an uniform to a vec4
  34803. * @param uniform defines the webGL uniform location where to store the value
  34804. * @param x defines the 1st component of the value
  34805. * @param y defines the 2nd component of the value
  34806. * @param z defines the 3rd component of the value
  34807. * @param w defines the 4th component of the value
  34808. */
  34809. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  34810. /**
  34811. * Apply all cached states (depth, culling, stencil and alpha)
  34812. */
  34813. applyStates(): void;
  34814. /**
  34815. * Enable or disable color writing
  34816. * @param enable defines the state to set
  34817. */
  34818. setColorWrite(enable: boolean): void;
  34819. /**
  34820. * Gets a boolean indicating if color writing is enabled
  34821. * @returns the current color writing state
  34822. */
  34823. getColorWrite(): boolean;
  34824. /**
  34825. * Gets the depth culling state manager
  34826. */
  34827. get depthCullingState(): DepthCullingState;
  34828. /**
  34829. * Gets the alpha state manager
  34830. */
  34831. get alphaState(): AlphaState;
  34832. /**
  34833. * Gets the stencil state manager
  34834. */
  34835. get stencilState(): StencilState;
  34836. /**
  34837. * Clears the list of texture accessible through engine.
  34838. * This can help preventing texture load conflict due to name collision.
  34839. */
  34840. clearInternalTexturesCache(): void;
  34841. /**
  34842. * Force the entire cache to be cleared
  34843. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  34844. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  34845. */
  34846. wipeCaches(bruteForce?: boolean): void;
  34847. /** @hidden */
  34848. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  34849. min: number;
  34850. mag: number;
  34851. };
  34852. /** @hidden */
  34853. _createTexture(): WebGLTexture;
  34854. /**
  34855. * Usually called from Texture.ts.
  34856. * Passed information to create a WebGLTexture
  34857. * @param url defines a value which contains one of the following:
  34858. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  34859. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  34860. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  34861. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  34862. * @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)
  34863. * @param scene needed for loading to the correct scene
  34864. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  34865. * @param onLoad optional callback to be called upon successful completion
  34866. * @param onError optional callback to be called upon failure
  34867. * @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
  34868. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  34869. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  34870. * @param forcedExtension defines the extension to use to pick the right loader
  34871. * @param mimeType defines an optional mime type
  34872. * @returns a InternalTexture for assignment back into BABYLON.Texture
  34873. */
  34874. 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;
  34875. /**
  34876. * Loads an image as an HTMLImageElement.
  34877. * @param input url string, ArrayBuffer, or Blob to load
  34878. * @param onLoad callback called when the image successfully loads
  34879. * @param onError callback called when the image fails to load
  34880. * @param offlineProvider offline provider for caching
  34881. * @param mimeType optional mime type
  34882. * @returns the HTMLImageElement of the loaded image
  34883. * @hidden
  34884. */
  34885. 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>;
  34886. /**
  34887. * @hidden
  34888. */
  34889. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34890. private _unpackFlipYCached;
  34891. /**
  34892. * In case you are sharing the context with other applications, it might
  34893. * be interested to not cache the unpack flip y state to ensure a consistent
  34894. * value would be set.
  34895. */
  34896. enableUnpackFlipYCached: boolean;
  34897. /** @hidden */
  34898. _unpackFlipY(value: boolean): void;
  34899. /** @hidden */
  34900. _getUnpackAlignement(): number;
  34901. private _getTextureTarget;
  34902. /**
  34903. * Update the sampling mode of a given texture
  34904. * @param samplingMode defines the required sampling mode
  34905. * @param texture defines the texture to update
  34906. * @param generateMipMaps defines whether to generate mipmaps for the texture
  34907. */
  34908. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  34909. /**
  34910. * Update the sampling mode of a given texture
  34911. * @param texture defines the texture to update
  34912. * @param wrapU defines the texture wrap mode of the u coordinates
  34913. * @param wrapV defines the texture wrap mode of the v coordinates
  34914. * @param wrapR defines the texture wrap mode of the r coordinates
  34915. */
  34916. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  34917. /** @hidden */
  34918. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  34919. width: number;
  34920. height: number;
  34921. layers?: number;
  34922. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  34923. /** @hidden */
  34924. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34925. /** @hidden */
  34926. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  34927. /**
  34928. * Update a portion of an internal texture
  34929. * @param texture defines the texture to update
  34930. * @param imageData defines the data to store into the texture
  34931. * @param xOffset defines the x coordinates of the update rectangle
  34932. * @param yOffset defines the y coordinates of the update rectangle
  34933. * @param width defines the width of the update rectangle
  34934. * @param height defines the height of the update rectangle
  34935. * @param faceIndex defines the face index if texture is a cube (0 by default)
  34936. * @param lod defines the lod level to update (0 by default)
  34937. */
  34938. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  34939. /** @hidden */
  34940. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34941. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  34942. private _prepareWebGLTexture;
  34943. /** @hidden */
  34944. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  34945. private _getDepthStencilBuffer;
  34946. /** @hidden */
  34947. _releaseFramebufferObjects(texture: InternalTexture): void;
  34948. /** @hidden */
  34949. _releaseTexture(texture: InternalTexture): void;
  34950. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  34951. protected _setProgram(program: WebGLProgram): void;
  34952. protected _boundUniforms: {
  34953. [key: number]: WebGLUniformLocation;
  34954. };
  34955. /**
  34956. * Binds an effect to the webGL context
  34957. * @param effect defines the effect to bind
  34958. */
  34959. bindSamplers(effect: Effect): void;
  34960. private _activateCurrentTexture;
  34961. /** @hidden */
  34962. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  34963. /** @hidden */
  34964. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  34965. /**
  34966. * Unbind all textures from the webGL context
  34967. */
  34968. unbindAllTextures(): void;
  34969. /**
  34970. * Sets a texture to the according uniform.
  34971. * @param channel The texture channel
  34972. * @param uniform The uniform to set
  34973. * @param texture The texture to apply
  34974. */
  34975. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  34976. private _bindSamplerUniformToChannel;
  34977. private _getTextureWrapMode;
  34978. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  34979. /**
  34980. * Sets an array of texture to the webGL context
  34981. * @param channel defines the channel where the texture array must be set
  34982. * @param uniform defines the associated uniform location
  34983. * @param textures defines the array of textures to bind
  34984. */
  34985. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  34986. /** @hidden */
  34987. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  34988. private _setTextureParameterFloat;
  34989. private _setTextureParameterInteger;
  34990. /**
  34991. * Unbind all vertex attributes from the webGL context
  34992. */
  34993. unbindAllAttributes(): void;
  34994. /**
  34995. * 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
  34996. */
  34997. releaseEffects(): void;
  34998. /**
  34999. * Dispose and release all associated resources
  35000. */
  35001. dispose(): void;
  35002. /**
  35003. * Attach a new callback raised when context lost event is fired
  35004. * @param callback defines the callback to call
  35005. */
  35006. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35007. /**
  35008. * Attach a new callback raised when context restored event is fired
  35009. * @param callback defines the callback to call
  35010. */
  35011. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35012. /**
  35013. * Get the current error code of the webGL context
  35014. * @returns the error code
  35015. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35016. */
  35017. getError(): number;
  35018. private _canRenderToFloatFramebuffer;
  35019. private _canRenderToHalfFloatFramebuffer;
  35020. private _canRenderToFramebuffer;
  35021. /** @hidden */
  35022. _getWebGLTextureType(type: number): number;
  35023. /** @hidden */
  35024. _getInternalFormat(format: number): number;
  35025. /** @hidden */
  35026. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35027. /** @hidden */
  35028. _getRGBAMultiSampleBufferFormat(type: number): number;
  35029. /** @hidden */
  35030. _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;
  35031. /**
  35032. * Loads a file from a url
  35033. * @param url url to load
  35034. * @param onSuccess callback called when the file successfully loads
  35035. * @param onProgress callback called while file is loading (if the server supports this mode)
  35036. * @param offlineProvider defines the offline provider for caching
  35037. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35038. * @param onError callback called when the file fails to load
  35039. * @returns a file request object
  35040. * @hidden
  35041. */
  35042. 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;
  35043. /**
  35044. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35045. * @param x defines the x coordinate of the rectangle where pixels must be read
  35046. * @param y defines the y coordinate of the rectangle where pixels must be read
  35047. * @param width defines the width of the rectangle where pixels must be read
  35048. * @param height defines the height of the rectangle where pixels must be read
  35049. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35050. * @returns a Uint8Array containing RGBA colors
  35051. */
  35052. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35053. private static _isSupported;
  35054. /**
  35055. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35056. * @returns true if the engine can be created
  35057. * @ignorenaming
  35058. */
  35059. static isSupported(): boolean;
  35060. /**
  35061. * Find the next highest power of two.
  35062. * @param x Number to start search from.
  35063. * @return Next highest power of two.
  35064. */
  35065. static CeilingPOT(x: number): number;
  35066. /**
  35067. * Find the next lowest power of two.
  35068. * @param x Number to start search from.
  35069. * @return Next lowest power of two.
  35070. */
  35071. static FloorPOT(x: number): number;
  35072. /**
  35073. * Find the nearest power of two.
  35074. * @param x Number to start search from.
  35075. * @return Next nearest power of two.
  35076. */
  35077. static NearestPOT(x: number): number;
  35078. /**
  35079. * Get the closest exponent of two
  35080. * @param value defines the value to approximate
  35081. * @param max defines the maximum value to return
  35082. * @param mode defines how to define the closest value
  35083. * @returns closest exponent of two of the given value
  35084. */
  35085. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35086. /**
  35087. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35088. * @param func - the function to be called
  35089. * @param requester - the object that will request the next frame. Falls back to window.
  35090. * @returns frame number
  35091. */
  35092. static QueueNewFrame(func: () => void, requester?: any): number;
  35093. /**
  35094. * Gets host document
  35095. * @returns the host document object
  35096. */
  35097. getHostDocument(): Nullable<Document>;
  35098. }
  35099. }
  35100. declare module BABYLON {
  35101. /**
  35102. * Class representing spherical harmonics coefficients to the 3rd degree
  35103. */
  35104. export class SphericalHarmonics {
  35105. /**
  35106. * Defines whether or not the harmonics have been prescaled for rendering.
  35107. */
  35108. preScaled: boolean;
  35109. /**
  35110. * The l0,0 coefficients of the spherical harmonics
  35111. */
  35112. l00: Vector3;
  35113. /**
  35114. * The l1,-1 coefficients of the spherical harmonics
  35115. */
  35116. l1_1: Vector3;
  35117. /**
  35118. * The l1,0 coefficients of the spherical harmonics
  35119. */
  35120. l10: Vector3;
  35121. /**
  35122. * The l1,1 coefficients of the spherical harmonics
  35123. */
  35124. l11: Vector3;
  35125. /**
  35126. * The l2,-2 coefficients of the spherical harmonics
  35127. */
  35128. l2_2: Vector3;
  35129. /**
  35130. * The l2,-1 coefficients of the spherical harmonics
  35131. */
  35132. l2_1: Vector3;
  35133. /**
  35134. * The l2,0 coefficients of the spherical harmonics
  35135. */
  35136. l20: Vector3;
  35137. /**
  35138. * The l2,1 coefficients of the spherical harmonics
  35139. */
  35140. l21: Vector3;
  35141. /**
  35142. * The l2,2 coefficients of the spherical harmonics
  35143. */
  35144. l22: Vector3;
  35145. /**
  35146. * Adds a light to the spherical harmonics
  35147. * @param direction the direction of the light
  35148. * @param color the color of the light
  35149. * @param deltaSolidAngle the delta solid angle of the light
  35150. */
  35151. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35152. /**
  35153. * Scales the spherical harmonics by the given amount
  35154. * @param scale the amount to scale
  35155. */
  35156. scaleInPlace(scale: number): void;
  35157. /**
  35158. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35159. *
  35160. * ```
  35161. * E_lm = A_l * L_lm
  35162. * ```
  35163. *
  35164. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35165. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35166. * the scaling factors are given in equation 9.
  35167. */
  35168. convertIncidentRadianceToIrradiance(): void;
  35169. /**
  35170. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35171. *
  35172. * ```
  35173. * L = (1/pi) * E * rho
  35174. * ```
  35175. *
  35176. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35177. */
  35178. convertIrradianceToLambertianRadiance(): void;
  35179. /**
  35180. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35181. * required operations at run time.
  35182. *
  35183. * This is simply done by scaling back the SH with Ylm constants parameter.
  35184. * The trigonometric part being applied by the shader at run time.
  35185. */
  35186. preScaleForRendering(): void;
  35187. /**
  35188. * Constructs a spherical harmonics from an array.
  35189. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35190. * @returns the spherical harmonics
  35191. */
  35192. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35193. /**
  35194. * Gets the spherical harmonics from polynomial
  35195. * @param polynomial the spherical polynomial
  35196. * @returns the spherical harmonics
  35197. */
  35198. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35199. }
  35200. /**
  35201. * Class representing spherical polynomial coefficients to the 3rd degree
  35202. */
  35203. export class SphericalPolynomial {
  35204. private _harmonics;
  35205. /**
  35206. * The spherical harmonics used to create the polynomials.
  35207. */
  35208. get preScaledHarmonics(): SphericalHarmonics;
  35209. /**
  35210. * The x coefficients of the spherical polynomial
  35211. */
  35212. x: Vector3;
  35213. /**
  35214. * The y coefficients of the spherical polynomial
  35215. */
  35216. y: Vector3;
  35217. /**
  35218. * The z coefficients of the spherical polynomial
  35219. */
  35220. z: Vector3;
  35221. /**
  35222. * The xx coefficients of the spherical polynomial
  35223. */
  35224. xx: Vector3;
  35225. /**
  35226. * The yy coefficients of the spherical polynomial
  35227. */
  35228. yy: Vector3;
  35229. /**
  35230. * The zz coefficients of the spherical polynomial
  35231. */
  35232. zz: Vector3;
  35233. /**
  35234. * The xy coefficients of the spherical polynomial
  35235. */
  35236. xy: Vector3;
  35237. /**
  35238. * The yz coefficients of the spherical polynomial
  35239. */
  35240. yz: Vector3;
  35241. /**
  35242. * The zx coefficients of the spherical polynomial
  35243. */
  35244. zx: Vector3;
  35245. /**
  35246. * Adds an ambient color to the spherical polynomial
  35247. * @param color the color to add
  35248. */
  35249. addAmbient(color: Color3): void;
  35250. /**
  35251. * Scales the spherical polynomial by the given amount
  35252. * @param scale the amount to scale
  35253. */
  35254. scaleInPlace(scale: number): void;
  35255. /**
  35256. * Gets the spherical polynomial from harmonics
  35257. * @param harmonics the spherical harmonics
  35258. * @returns the spherical polynomial
  35259. */
  35260. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35261. /**
  35262. * Constructs a spherical polynomial from an array.
  35263. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35264. * @returns the spherical polynomial
  35265. */
  35266. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35267. }
  35268. }
  35269. declare module BABYLON {
  35270. /**
  35271. * Defines the source of the internal texture
  35272. */
  35273. export enum InternalTextureSource {
  35274. /**
  35275. * The source of the texture data is unknown
  35276. */
  35277. Unknown = 0,
  35278. /**
  35279. * Texture data comes from an URL
  35280. */
  35281. Url = 1,
  35282. /**
  35283. * Texture data is only used for temporary storage
  35284. */
  35285. Temp = 2,
  35286. /**
  35287. * Texture data comes from raw data (ArrayBuffer)
  35288. */
  35289. Raw = 3,
  35290. /**
  35291. * Texture content is dynamic (video or dynamic texture)
  35292. */
  35293. Dynamic = 4,
  35294. /**
  35295. * Texture content is generated by rendering to it
  35296. */
  35297. RenderTarget = 5,
  35298. /**
  35299. * Texture content is part of a multi render target process
  35300. */
  35301. MultiRenderTarget = 6,
  35302. /**
  35303. * Texture data comes from a cube data file
  35304. */
  35305. Cube = 7,
  35306. /**
  35307. * Texture data comes from a raw cube data
  35308. */
  35309. CubeRaw = 8,
  35310. /**
  35311. * Texture data come from a prefiltered cube data file
  35312. */
  35313. CubePrefiltered = 9,
  35314. /**
  35315. * Texture content is raw 3D data
  35316. */
  35317. Raw3D = 10,
  35318. /**
  35319. * Texture content is raw 2D array data
  35320. */
  35321. Raw2DArray = 11,
  35322. /**
  35323. * Texture content is a depth texture
  35324. */
  35325. Depth = 12,
  35326. /**
  35327. * Texture data comes from a raw cube data encoded with RGBD
  35328. */
  35329. CubeRawRGBD = 13
  35330. }
  35331. /**
  35332. * Class used to store data associated with WebGL texture data for the engine
  35333. * This class should not be used directly
  35334. */
  35335. export class InternalTexture {
  35336. /** @hidden */
  35337. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35338. /**
  35339. * Defines if the texture is ready
  35340. */
  35341. isReady: boolean;
  35342. /**
  35343. * Defines if the texture is a cube texture
  35344. */
  35345. isCube: boolean;
  35346. /**
  35347. * Defines if the texture contains 3D data
  35348. */
  35349. is3D: boolean;
  35350. /**
  35351. * Defines if the texture contains 2D array data
  35352. */
  35353. is2DArray: boolean;
  35354. /**
  35355. * Defines if the texture contains multiview data
  35356. */
  35357. isMultiview: boolean;
  35358. /**
  35359. * Gets the URL used to load this texture
  35360. */
  35361. url: string;
  35362. /**
  35363. * Gets the sampling mode of the texture
  35364. */
  35365. samplingMode: number;
  35366. /**
  35367. * Gets a boolean indicating if the texture needs mipmaps generation
  35368. */
  35369. generateMipMaps: boolean;
  35370. /**
  35371. * Gets the number of samples used by the texture (WebGL2+ only)
  35372. */
  35373. samples: number;
  35374. /**
  35375. * Gets the type of the texture (int, float...)
  35376. */
  35377. type: number;
  35378. /**
  35379. * Gets the format of the texture (RGB, RGBA...)
  35380. */
  35381. format: number;
  35382. /**
  35383. * Observable called when the texture is loaded
  35384. */
  35385. onLoadedObservable: Observable<InternalTexture>;
  35386. /**
  35387. * Gets the width of the texture
  35388. */
  35389. width: number;
  35390. /**
  35391. * Gets the height of the texture
  35392. */
  35393. height: number;
  35394. /**
  35395. * Gets the depth of the texture
  35396. */
  35397. depth: number;
  35398. /**
  35399. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35400. */
  35401. baseWidth: number;
  35402. /**
  35403. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35404. */
  35405. baseHeight: number;
  35406. /**
  35407. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35408. */
  35409. baseDepth: number;
  35410. /**
  35411. * Gets a boolean indicating if the texture is inverted on Y axis
  35412. */
  35413. invertY: boolean;
  35414. /** @hidden */
  35415. _invertVScale: boolean;
  35416. /** @hidden */
  35417. _associatedChannel: number;
  35418. /** @hidden */
  35419. _source: InternalTextureSource;
  35420. /** @hidden */
  35421. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35422. /** @hidden */
  35423. _bufferView: Nullable<ArrayBufferView>;
  35424. /** @hidden */
  35425. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35426. /** @hidden */
  35427. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35428. /** @hidden */
  35429. _size: number;
  35430. /** @hidden */
  35431. _extension: string;
  35432. /** @hidden */
  35433. _files: Nullable<string[]>;
  35434. /** @hidden */
  35435. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35436. /** @hidden */
  35437. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35438. /** @hidden */
  35439. _framebuffer: Nullable<WebGLFramebuffer>;
  35440. /** @hidden */
  35441. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35442. /** @hidden */
  35443. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35444. /** @hidden */
  35445. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35446. /** @hidden */
  35447. _attachments: Nullable<number[]>;
  35448. /** @hidden */
  35449. _cachedCoordinatesMode: Nullable<number>;
  35450. /** @hidden */
  35451. _cachedWrapU: Nullable<number>;
  35452. /** @hidden */
  35453. _cachedWrapV: Nullable<number>;
  35454. /** @hidden */
  35455. _cachedWrapR: Nullable<number>;
  35456. /** @hidden */
  35457. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35458. /** @hidden */
  35459. _isDisabled: boolean;
  35460. /** @hidden */
  35461. _compression: Nullable<string>;
  35462. /** @hidden */
  35463. _generateStencilBuffer: boolean;
  35464. /** @hidden */
  35465. _generateDepthBuffer: boolean;
  35466. /** @hidden */
  35467. _comparisonFunction: number;
  35468. /** @hidden */
  35469. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35470. /** @hidden */
  35471. _lodGenerationScale: number;
  35472. /** @hidden */
  35473. _lodGenerationOffset: number;
  35474. /** @hidden */
  35475. _depthStencilTexture: Nullable<InternalTexture>;
  35476. /** @hidden */
  35477. _colorTextureArray: Nullable<WebGLTexture>;
  35478. /** @hidden */
  35479. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35480. /** @hidden */
  35481. _lodTextureHigh: Nullable<BaseTexture>;
  35482. /** @hidden */
  35483. _lodTextureMid: Nullable<BaseTexture>;
  35484. /** @hidden */
  35485. _lodTextureLow: Nullable<BaseTexture>;
  35486. /** @hidden */
  35487. _isRGBD: boolean;
  35488. /** @hidden */
  35489. _linearSpecularLOD: boolean;
  35490. /** @hidden */
  35491. _irradianceTexture: Nullable<BaseTexture>;
  35492. /** @hidden */
  35493. _webGLTexture: Nullable<WebGLTexture>;
  35494. /** @hidden */
  35495. _references: number;
  35496. private _engine;
  35497. /**
  35498. * Gets the Engine the texture belongs to.
  35499. * @returns The babylon engine
  35500. */
  35501. getEngine(): ThinEngine;
  35502. /**
  35503. * Gets the data source type of the texture
  35504. */
  35505. get source(): InternalTextureSource;
  35506. /**
  35507. * Creates a new InternalTexture
  35508. * @param engine defines the engine to use
  35509. * @param source defines the type of data that will be used
  35510. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35511. */
  35512. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35513. /**
  35514. * Increments the number of references (ie. the number of Texture that point to it)
  35515. */
  35516. incrementReferences(): void;
  35517. /**
  35518. * Change the size of the texture (not the size of the content)
  35519. * @param width defines the new width
  35520. * @param height defines the new height
  35521. * @param depth defines the new depth (1 by default)
  35522. */
  35523. updateSize(width: int, height: int, depth?: int): void;
  35524. /** @hidden */
  35525. _rebuild(): void;
  35526. /** @hidden */
  35527. _swapAndDie(target: InternalTexture): void;
  35528. /**
  35529. * Dispose the current allocated resources
  35530. */
  35531. dispose(): void;
  35532. }
  35533. }
  35534. declare module BABYLON {
  35535. /**
  35536. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35538. */
  35539. export class Analyser {
  35540. /**
  35541. * Gets or sets the smoothing
  35542. * @ignorenaming
  35543. */
  35544. SMOOTHING: number;
  35545. /**
  35546. * Gets or sets the FFT table size
  35547. * @ignorenaming
  35548. */
  35549. FFT_SIZE: number;
  35550. /**
  35551. * Gets or sets the bar graph amplitude
  35552. * @ignorenaming
  35553. */
  35554. BARGRAPHAMPLITUDE: number;
  35555. /**
  35556. * Gets or sets the position of the debug canvas
  35557. * @ignorenaming
  35558. */
  35559. DEBUGCANVASPOS: {
  35560. x: number;
  35561. y: number;
  35562. };
  35563. /**
  35564. * Gets or sets the debug canvas size
  35565. * @ignorenaming
  35566. */
  35567. DEBUGCANVASSIZE: {
  35568. width: number;
  35569. height: number;
  35570. };
  35571. private _byteFreqs;
  35572. private _byteTime;
  35573. private _floatFreqs;
  35574. private _webAudioAnalyser;
  35575. private _debugCanvas;
  35576. private _debugCanvasContext;
  35577. private _scene;
  35578. private _registerFunc;
  35579. private _audioEngine;
  35580. /**
  35581. * Creates a new analyser
  35582. * @param scene defines hosting scene
  35583. */
  35584. constructor(scene: Scene);
  35585. /**
  35586. * Get the number of data values you will have to play with for the visualization
  35587. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35588. * @returns a number
  35589. */
  35590. getFrequencyBinCount(): number;
  35591. /**
  35592. * Gets the current frequency data as a byte array
  35593. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35594. * @returns a Uint8Array
  35595. */
  35596. getByteFrequencyData(): Uint8Array;
  35597. /**
  35598. * Gets the current waveform as a byte array
  35599. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35600. * @returns a Uint8Array
  35601. */
  35602. getByteTimeDomainData(): Uint8Array;
  35603. /**
  35604. * Gets the current frequency data as a float array
  35605. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35606. * @returns a Float32Array
  35607. */
  35608. getFloatFrequencyData(): Float32Array;
  35609. /**
  35610. * Renders the debug canvas
  35611. */
  35612. drawDebugCanvas(): void;
  35613. /**
  35614. * Stops rendering the debug canvas and removes it
  35615. */
  35616. stopDebugCanvas(): void;
  35617. /**
  35618. * Connects two audio nodes
  35619. * @param inputAudioNode defines first node to connect
  35620. * @param outputAudioNode defines second node to connect
  35621. */
  35622. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35623. /**
  35624. * Releases all associated resources
  35625. */
  35626. dispose(): void;
  35627. }
  35628. }
  35629. declare module BABYLON {
  35630. /**
  35631. * This represents an audio engine and it is responsible
  35632. * to play, synchronize and analyse sounds throughout the application.
  35633. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35634. */
  35635. export interface IAudioEngine extends IDisposable {
  35636. /**
  35637. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35638. */
  35639. readonly canUseWebAudio: boolean;
  35640. /**
  35641. * Gets the current AudioContext if available.
  35642. */
  35643. readonly audioContext: Nullable<AudioContext>;
  35644. /**
  35645. * The master gain node defines the global audio volume of your audio engine.
  35646. */
  35647. readonly masterGain: GainNode;
  35648. /**
  35649. * Gets whether or not mp3 are supported by your browser.
  35650. */
  35651. readonly isMP3supported: boolean;
  35652. /**
  35653. * Gets whether or not ogg are supported by your browser.
  35654. */
  35655. readonly isOGGsupported: boolean;
  35656. /**
  35657. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35658. * @ignoreNaming
  35659. */
  35660. WarnedWebAudioUnsupported: boolean;
  35661. /**
  35662. * Defines if the audio engine relies on a custom unlocked button.
  35663. * In this case, the embedded button will not be displayed.
  35664. */
  35665. useCustomUnlockedButton: boolean;
  35666. /**
  35667. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35668. */
  35669. readonly unlocked: boolean;
  35670. /**
  35671. * Event raised when audio has been unlocked on the browser.
  35672. */
  35673. onAudioUnlockedObservable: Observable<AudioEngine>;
  35674. /**
  35675. * Event raised when audio has been locked on the browser.
  35676. */
  35677. onAudioLockedObservable: Observable<AudioEngine>;
  35678. /**
  35679. * Flags the audio engine in Locked state.
  35680. * This happens due to new browser policies preventing audio to autoplay.
  35681. */
  35682. lock(): void;
  35683. /**
  35684. * Unlocks the audio engine once a user action has been done on the dom.
  35685. * This is helpful to resume play once browser policies have been satisfied.
  35686. */
  35687. unlock(): void;
  35688. /**
  35689. * Gets the global volume sets on the master gain.
  35690. * @returns the global volume if set or -1 otherwise
  35691. */
  35692. getGlobalVolume(): number;
  35693. /**
  35694. * Sets the global volume of your experience (sets on the master gain).
  35695. * @param newVolume Defines the new global volume of the application
  35696. */
  35697. setGlobalVolume(newVolume: number): void;
  35698. /**
  35699. * Connect the audio engine to an audio analyser allowing some amazing
  35700. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35702. * @param analyser The analyser to connect to the engine
  35703. */
  35704. connectToAnalyser(analyser: Analyser): void;
  35705. }
  35706. /**
  35707. * This represents the default audio engine used in babylon.
  35708. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35710. */
  35711. export class AudioEngine implements IAudioEngine {
  35712. private _audioContext;
  35713. private _audioContextInitialized;
  35714. private _muteButton;
  35715. private _hostElement;
  35716. /**
  35717. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35718. */
  35719. canUseWebAudio: boolean;
  35720. /**
  35721. * The master gain node defines the global audio volume of your audio engine.
  35722. */
  35723. masterGain: GainNode;
  35724. /**
  35725. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35726. * @ignoreNaming
  35727. */
  35728. WarnedWebAudioUnsupported: boolean;
  35729. /**
  35730. * Gets whether or not mp3 are supported by your browser.
  35731. */
  35732. isMP3supported: boolean;
  35733. /**
  35734. * Gets whether or not ogg are supported by your browser.
  35735. */
  35736. isOGGsupported: boolean;
  35737. /**
  35738. * Gets whether audio has been unlocked on the device.
  35739. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35740. * a user interaction has happened.
  35741. */
  35742. unlocked: boolean;
  35743. /**
  35744. * Defines if the audio engine relies on a custom unlocked button.
  35745. * In this case, the embedded button will not be displayed.
  35746. */
  35747. useCustomUnlockedButton: boolean;
  35748. /**
  35749. * Event raised when audio has been unlocked on the browser.
  35750. */
  35751. onAudioUnlockedObservable: Observable<AudioEngine>;
  35752. /**
  35753. * Event raised when audio has been locked on the browser.
  35754. */
  35755. onAudioLockedObservable: Observable<AudioEngine>;
  35756. /**
  35757. * Gets the current AudioContext if available.
  35758. */
  35759. get audioContext(): Nullable<AudioContext>;
  35760. private _connectedAnalyser;
  35761. /**
  35762. * Instantiates a new audio engine.
  35763. *
  35764. * There should be only one per page as some browsers restrict the number
  35765. * of audio contexts you can create.
  35766. * @param hostElement defines the host element where to display the mute icon if necessary
  35767. */
  35768. constructor(hostElement?: Nullable<HTMLElement>);
  35769. /**
  35770. * Flags the audio engine in Locked state.
  35771. * This happens due to new browser policies preventing audio to autoplay.
  35772. */
  35773. lock(): void;
  35774. /**
  35775. * Unlocks the audio engine once a user action has been done on the dom.
  35776. * This is helpful to resume play once browser policies have been satisfied.
  35777. */
  35778. unlock(): void;
  35779. private _resumeAudioContext;
  35780. private _initializeAudioContext;
  35781. private _tryToRun;
  35782. private _triggerRunningState;
  35783. private _triggerSuspendedState;
  35784. private _displayMuteButton;
  35785. private _moveButtonToTopLeft;
  35786. private _onResize;
  35787. private _hideMuteButton;
  35788. /**
  35789. * Destroy and release the resources associated with the audio ccontext.
  35790. */
  35791. dispose(): void;
  35792. /**
  35793. * Gets the global volume sets on the master gain.
  35794. * @returns the global volume if set or -1 otherwise
  35795. */
  35796. getGlobalVolume(): number;
  35797. /**
  35798. * Sets the global volume of your experience (sets on the master gain).
  35799. * @param newVolume Defines the new global volume of the application
  35800. */
  35801. setGlobalVolume(newVolume: number): void;
  35802. /**
  35803. * Connect the audio engine to an audio analyser allowing some amazing
  35804. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35805. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35806. * @param analyser The analyser to connect to the engine
  35807. */
  35808. connectToAnalyser(analyser: Analyser): void;
  35809. }
  35810. }
  35811. declare module BABYLON {
  35812. /**
  35813. * Interface used to present a loading screen while loading a scene
  35814. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35815. */
  35816. export interface ILoadingScreen {
  35817. /**
  35818. * Function called to display the loading screen
  35819. */
  35820. displayLoadingUI: () => void;
  35821. /**
  35822. * Function called to hide the loading screen
  35823. */
  35824. hideLoadingUI: () => void;
  35825. /**
  35826. * Gets or sets the color to use for the background
  35827. */
  35828. loadingUIBackgroundColor: string;
  35829. /**
  35830. * Gets or sets the text to display while loading
  35831. */
  35832. loadingUIText: string;
  35833. }
  35834. /**
  35835. * Class used for the default loading screen
  35836. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35837. */
  35838. export class DefaultLoadingScreen implements ILoadingScreen {
  35839. private _renderingCanvas;
  35840. private _loadingText;
  35841. private _loadingDivBackgroundColor;
  35842. private _loadingDiv;
  35843. private _loadingTextDiv;
  35844. /** Gets or sets the logo url to use for the default loading screen */
  35845. static DefaultLogoUrl: string;
  35846. /** Gets or sets the spinner url to use for the default loading screen */
  35847. static DefaultSpinnerUrl: string;
  35848. /**
  35849. * Creates a new default loading screen
  35850. * @param _renderingCanvas defines the canvas used to render the scene
  35851. * @param _loadingText defines the default text to display
  35852. * @param _loadingDivBackgroundColor defines the default background color
  35853. */
  35854. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  35855. /**
  35856. * Function called to display the loading screen
  35857. */
  35858. displayLoadingUI(): void;
  35859. /**
  35860. * Function called to hide the loading screen
  35861. */
  35862. hideLoadingUI(): void;
  35863. /**
  35864. * Gets or sets the text to display while loading
  35865. */
  35866. set loadingUIText(text: string);
  35867. get loadingUIText(): string;
  35868. /**
  35869. * Gets or sets the color to use for the background
  35870. */
  35871. get loadingUIBackgroundColor(): string;
  35872. set loadingUIBackgroundColor(color: string);
  35873. private _resizeLoadingUI;
  35874. }
  35875. }
  35876. declare module BABYLON {
  35877. /**
  35878. * Interface for any object that can request an animation frame
  35879. */
  35880. export interface ICustomAnimationFrameRequester {
  35881. /**
  35882. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  35883. */
  35884. renderFunction?: Function;
  35885. /**
  35886. * Called to request the next frame to render to
  35887. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  35888. */
  35889. requestAnimationFrame: Function;
  35890. /**
  35891. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  35892. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  35893. */
  35894. requestID?: number;
  35895. }
  35896. }
  35897. declare module BABYLON {
  35898. /**
  35899. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  35900. */
  35901. export class PerformanceMonitor {
  35902. private _enabled;
  35903. private _rollingFrameTime;
  35904. private _lastFrameTimeMs;
  35905. /**
  35906. * constructor
  35907. * @param frameSampleSize The number of samples required to saturate the sliding window
  35908. */
  35909. constructor(frameSampleSize?: number);
  35910. /**
  35911. * Samples current frame
  35912. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  35913. */
  35914. sampleFrame(timeMs?: number): void;
  35915. /**
  35916. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35917. */
  35918. get averageFrameTime(): number;
  35919. /**
  35920. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35921. */
  35922. get averageFrameTimeVariance(): number;
  35923. /**
  35924. * Returns the frame time of the most recent frame
  35925. */
  35926. get instantaneousFrameTime(): number;
  35927. /**
  35928. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  35929. */
  35930. get averageFPS(): number;
  35931. /**
  35932. * Returns the average framerate in frames per second using the most recent frame time
  35933. */
  35934. get instantaneousFPS(): number;
  35935. /**
  35936. * Returns true if enough samples have been taken to completely fill the sliding window
  35937. */
  35938. get isSaturated(): boolean;
  35939. /**
  35940. * Enables contributions to the sliding window sample set
  35941. */
  35942. enable(): void;
  35943. /**
  35944. * Disables contributions to the sliding window sample set
  35945. * Samples will not be interpolated over the disabled period
  35946. */
  35947. disable(): void;
  35948. /**
  35949. * Returns true if sampling is enabled
  35950. */
  35951. get isEnabled(): boolean;
  35952. /**
  35953. * Resets performance monitor
  35954. */
  35955. reset(): void;
  35956. }
  35957. /**
  35958. * RollingAverage
  35959. *
  35960. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  35961. */
  35962. export class RollingAverage {
  35963. /**
  35964. * Current average
  35965. */
  35966. average: number;
  35967. /**
  35968. * Current variance
  35969. */
  35970. variance: number;
  35971. protected _samples: Array<number>;
  35972. protected _sampleCount: number;
  35973. protected _pos: number;
  35974. protected _m2: number;
  35975. /**
  35976. * constructor
  35977. * @param length The number of samples required to saturate the sliding window
  35978. */
  35979. constructor(length: number);
  35980. /**
  35981. * Adds a sample to the sample set
  35982. * @param v The sample value
  35983. */
  35984. add(v: number): void;
  35985. /**
  35986. * Returns previously added values or null if outside of history or outside the sliding window domain
  35987. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  35988. * @return Value previously recorded with add() or null if outside of range
  35989. */
  35990. history(i: number): number;
  35991. /**
  35992. * Returns true if enough samples have been taken to completely fill the sliding window
  35993. * @return true if sample-set saturated
  35994. */
  35995. isSaturated(): boolean;
  35996. /**
  35997. * Resets the rolling average (equivalent to 0 samples taken so far)
  35998. */
  35999. reset(): void;
  36000. /**
  36001. * Wraps a value around the sample range boundaries
  36002. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36003. * @return Wrapped position in sample range
  36004. */
  36005. protected _wrapPosition(i: number): number;
  36006. }
  36007. }
  36008. declare module BABYLON {
  36009. /**
  36010. * This class is used to track a performance counter which is number based.
  36011. * The user has access to many properties which give statistics of different nature.
  36012. *
  36013. * The implementer can track two kinds of Performance Counter: time and count.
  36014. * 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.
  36015. * 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.
  36016. */
  36017. export class PerfCounter {
  36018. /**
  36019. * Gets or sets a global boolean to turn on and off all the counters
  36020. */
  36021. static Enabled: boolean;
  36022. /**
  36023. * Returns the smallest value ever
  36024. */
  36025. get min(): number;
  36026. /**
  36027. * Returns the biggest value ever
  36028. */
  36029. get max(): number;
  36030. /**
  36031. * Returns the average value since the performance counter is running
  36032. */
  36033. get average(): number;
  36034. /**
  36035. * Returns the average value of the last second the counter was monitored
  36036. */
  36037. get lastSecAverage(): number;
  36038. /**
  36039. * Returns the current value
  36040. */
  36041. get current(): number;
  36042. /**
  36043. * Gets the accumulated total
  36044. */
  36045. get total(): number;
  36046. /**
  36047. * Gets the total value count
  36048. */
  36049. get count(): number;
  36050. /**
  36051. * Creates a new counter
  36052. */
  36053. constructor();
  36054. /**
  36055. * Call this method to start monitoring a new frame.
  36056. * 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.
  36057. */
  36058. fetchNewFrame(): void;
  36059. /**
  36060. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36061. * @param newCount the count value to add to the monitored count
  36062. * @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.
  36063. */
  36064. addCount(newCount: number, fetchResult: boolean): void;
  36065. /**
  36066. * Start monitoring this performance counter
  36067. */
  36068. beginMonitoring(): void;
  36069. /**
  36070. * Compute the time lapsed since the previous beginMonitoring() call.
  36071. * @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
  36072. */
  36073. endMonitoring(newFrame?: boolean): void;
  36074. private _fetchResult;
  36075. private _startMonitoringTime;
  36076. private _min;
  36077. private _max;
  36078. private _average;
  36079. private _current;
  36080. private _totalValueCount;
  36081. private _totalAccumulated;
  36082. private _lastSecAverage;
  36083. private _lastSecAccumulated;
  36084. private _lastSecTime;
  36085. private _lastSecValueCount;
  36086. }
  36087. }
  36088. declare module BABYLON {
  36089. interface ThinEngine {
  36090. /**
  36091. * Sets alpha constants used by some alpha blending modes
  36092. * @param r defines the red component
  36093. * @param g defines the green component
  36094. * @param b defines the blue component
  36095. * @param a defines the alpha component
  36096. */
  36097. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36098. /**
  36099. * Sets the current alpha mode
  36100. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36101. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36102. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36103. */
  36104. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36105. /**
  36106. * Gets the current alpha mode
  36107. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36108. * @returns the current alpha mode
  36109. */
  36110. getAlphaMode(): number;
  36111. /**
  36112. * Sets the current alpha equation
  36113. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36114. */
  36115. setAlphaEquation(equation: number): void;
  36116. /**
  36117. * Gets the current alpha equation.
  36118. * @returns the current alpha equation
  36119. */
  36120. getAlphaEquation(): number;
  36121. }
  36122. }
  36123. declare module BABYLON {
  36124. interface ThinEngine {
  36125. /** @hidden */
  36126. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36127. }
  36128. }
  36129. declare module BABYLON {
  36130. /**
  36131. * Defines the interface used by display changed events
  36132. */
  36133. export interface IDisplayChangedEventArgs {
  36134. /** Gets the vrDisplay object (if any) */
  36135. vrDisplay: Nullable<any>;
  36136. /** Gets a boolean indicating if webVR is supported */
  36137. vrSupported: boolean;
  36138. }
  36139. /**
  36140. * Defines the interface used by objects containing a viewport (like a camera)
  36141. */
  36142. interface IViewportOwnerLike {
  36143. /**
  36144. * Gets or sets the viewport
  36145. */
  36146. viewport: IViewportLike;
  36147. }
  36148. /**
  36149. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36150. */
  36151. export class Engine extends ThinEngine {
  36152. /** Defines that alpha blending is disabled */
  36153. static readonly ALPHA_DISABLE: number;
  36154. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36155. static readonly ALPHA_ADD: number;
  36156. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36157. static readonly ALPHA_COMBINE: number;
  36158. /** Defines that alpha blending to DEST - SRC * DEST */
  36159. static readonly ALPHA_SUBTRACT: number;
  36160. /** Defines that alpha blending to SRC * DEST */
  36161. static readonly ALPHA_MULTIPLY: number;
  36162. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36163. static readonly ALPHA_MAXIMIZED: number;
  36164. /** Defines that alpha blending to SRC + DEST */
  36165. static readonly ALPHA_ONEONE: number;
  36166. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36167. static readonly ALPHA_PREMULTIPLIED: number;
  36168. /**
  36169. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36170. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36171. */
  36172. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36173. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36174. static readonly ALPHA_INTERPOLATE: number;
  36175. /**
  36176. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36177. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36178. */
  36179. static readonly ALPHA_SCREENMODE: number;
  36180. /** Defines that the ressource is not delayed*/
  36181. static readonly DELAYLOADSTATE_NONE: number;
  36182. /** Defines that the ressource was successfully delay loaded */
  36183. static readonly DELAYLOADSTATE_LOADED: number;
  36184. /** Defines that the ressource is currently delay loading */
  36185. static readonly DELAYLOADSTATE_LOADING: number;
  36186. /** Defines that the ressource is delayed and has not started loading */
  36187. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36188. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36189. static readonly NEVER: number;
  36190. /** 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 */
  36191. static readonly ALWAYS: number;
  36192. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36193. static readonly LESS: number;
  36194. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36195. static readonly EQUAL: number;
  36196. /** 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 */
  36197. static readonly LEQUAL: number;
  36198. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36199. static readonly GREATER: number;
  36200. /** 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 */
  36201. static readonly GEQUAL: number;
  36202. /** 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 */
  36203. static readonly NOTEQUAL: number;
  36204. /** Passed to stencilOperation to specify that stencil value must be kept */
  36205. static readonly KEEP: number;
  36206. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36207. static readonly REPLACE: number;
  36208. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36209. static readonly INCR: number;
  36210. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36211. static readonly DECR: number;
  36212. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36213. static readonly INVERT: number;
  36214. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36215. static readonly INCR_WRAP: number;
  36216. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36217. static readonly DECR_WRAP: number;
  36218. /** Texture is not repeating outside of 0..1 UVs */
  36219. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36220. /** Texture is repeating outside of 0..1 UVs */
  36221. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36222. /** Texture is repeating and mirrored */
  36223. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36224. /** ALPHA */
  36225. static readonly TEXTUREFORMAT_ALPHA: number;
  36226. /** LUMINANCE */
  36227. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36228. /** LUMINANCE_ALPHA */
  36229. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36230. /** RGB */
  36231. static readonly TEXTUREFORMAT_RGB: number;
  36232. /** RGBA */
  36233. static readonly TEXTUREFORMAT_RGBA: number;
  36234. /** RED */
  36235. static readonly TEXTUREFORMAT_RED: number;
  36236. /** RED (2nd reference) */
  36237. static readonly TEXTUREFORMAT_R: number;
  36238. /** RG */
  36239. static readonly TEXTUREFORMAT_RG: number;
  36240. /** RED_INTEGER */
  36241. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36242. /** RED_INTEGER (2nd reference) */
  36243. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36244. /** RG_INTEGER */
  36245. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36246. /** RGB_INTEGER */
  36247. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36248. /** RGBA_INTEGER */
  36249. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36250. /** UNSIGNED_BYTE */
  36251. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36252. /** UNSIGNED_BYTE (2nd reference) */
  36253. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36254. /** FLOAT */
  36255. static readonly TEXTURETYPE_FLOAT: number;
  36256. /** HALF_FLOAT */
  36257. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36258. /** BYTE */
  36259. static readonly TEXTURETYPE_BYTE: number;
  36260. /** SHORT */
  36261. static readonly TEXTURETYPE_SHORT: number;
  36262. /** UNSIGNED_SHORT */
  36263. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36264. /** INT */
  36265. static readonly TEXTURETYPE_INT: number;
  36266. /** UNSIGNED_INT */
  36267. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36268. /** UNSIGNED_SHORT_4_4_4_4 */
  36269. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36270. /** UNSIGNED_SHORT_5_5_5_1 */
  36271. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36272. /** UNSIGNED_SHORT_5_6_5 */
  36273. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36274. /** UNSIGNED_INT_2_10_10_10_REV */
  36275. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36276. /** UNSIGNED_INT_24_8 */
  36277. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36278. /** UNSIGNED_INT_10F_11F_11F_REV */
  36279. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36280. /** UNSIGNED_INT_5_9_9_9_REV */
  36281. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36282. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36283. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36284. /** nearest is mag = nearest and min = nearest and mip = linear */
  36285. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36286. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36287. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36288. /** Trilinear is mag = linear and min = linear and mip = linear */
  36289. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36290. /** nearest is mag = nearest and min = nearest and mip = linear */
  36291. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36292. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36293. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36294. /** Trilinear is mag = linear and min = linear and mip = linear */
  36295. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36296. /** mag = nearest and min = nearest and mip = nearest */
  36297. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36298. /** mag = nearest and min = linear and mip = nearest */
  36299. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36300. /** mag = nearest and min = linear and mip = linear */
  36301. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36302. /** mag = nearest and min = linear and mip = none */
  36303. static readonly TEXTURE_NEAREST_LINEAR: number;
  36304. /** mag = nearest and min = nearest and mip = none */
  36305. static readonly TEXTURE_NEAREST_NEAREST: number;
  36306. /** mag = linear and min = nearest and mip = nearest */
  36307. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36308. /** mag = linear and min = nearest and mip = linear */
  36309. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36310. /** mag = linear and min = linear and mip = none */
  36311. static readonly TEXTURE_LINEAR_LINEAR: number;
  36312. /** mag = linear and min = nearest and mip = none */
  36313. static readonly TEXTURE_LINEAR_NEAREST: number;
  36314. /** Explicit coordinates mode */
  36315. static readonly TEXTURE_EXPLICIT_MODE: number;
  36316. /** Spherical coordinates mode */
  36317. static readonly TEXTURE_SPHERICAL_MODE: number;
  36318. /** Planar coordinates mode */
  36319. static readonly TEXTURE_PLANAR_MODE: number;
  36320. /** Cubic coordinates mode */
  36321. static readonly TEXTURE_CUBIC_MODE: number;
  36322. /** Projection coordinates mode */
  36323. static readonly TEXTURE_PROJECTION_MODE: number;
  36324. /** Skybox coordinates mode */
  36325. static readonly TEXTURE_SKYBOX_MODE: number;
  36326. /** Inverse Cubic coordinates mode */
  36327. static readonly TEXTURE_INVCUBIC_MODE: number;
  36328. /** Equirectangular coordinates mode */
  36329. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36330. /** Equirectangular Fixed coordinates mode */
  36331. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36332. /** Equirectangular Fixed Mirrored coordinates mode */
  36333. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36334. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36335. static readonly SCALEMODE_FLOOR: number;
  36336. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36337. static readonly SCALEMODE_NEAREST: number;
  36338. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36339. static readonly SCALEMODE_CEILING: number;
  36340. /**
  36341. * Returns the current npm package of the sdk
  36342. */
  36343. static get NpmPackage(): string;
  36344. /**
  36345. * Returns the current version of the framework
  36346. */
  36347. static get Version(): string;
  36348. /** Gets the list of created engines */
  36349. static get Instances(): Engine[];
  36350. /**
  36351. * Gets the latest created engine
  36352. */
  36353. static get LastCreatedEngine(): Nullable<Engine>;
  36354. /**
  36355. * Gets the latest created scene
  36356. */
  36357. static get LastCreatedScene(): Nullable<Scene>;
  36358. /**
  36359. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36360. * @param flag defines which part of the materials must be marked as dirty
  36361. * @param predicate defines a predicate used to filter which materials should be affected
  36362. */
  36363. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36364. /**
  36365. * Method called to create the default loading screen.
  36366. * This can be overriden in your own app.
  36367. * @param canvas The rendering canvas element
  36368. * @returns The loading screen
  36369. */
  36370. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36371. /**
  36372. * Method called to create the default rescale post process on each engine.
  36373. */
  36374. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36375. /**
  36376. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36377. **/
  36378. enableOfflineSupport: boolean;
  36379. /**
  36380. * 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)
  36381. **/
  36382. disableManifestCheck: boolean;
  36383. /**
  36384. * Gets the list of created scenes
  36385. */
  36386. scenes: Scene[];
  36387. /**
  36388. * Event raised when a new scene is created
  36389. */
  36390. onNewSceneAddedObservable: Observable<Scene>;
  36391. /**
  36392. * Gets the list of created postprocesses
  36393. */
  36394. postProcesses: PostProcess[];
  36395. /**
  36396. * Gets a boolean indicating if the pointer is currently locked
  36397. */
  36398. isPointerLock: boolean;
  36399. /**
  36400. * Observable event triggered each time the rendering canvas is resized
  36401. */
  36402. onResizeObservable: Observable<Engine>;
  36403. /**
  36404. * Observable event triggered each time the canvas loses focus
  36405. */
  36406. onCanvasBlurObservable: Observable<Engine>;
  36407. /**
  36408. * Observable event triggered each time the canvas gains focus
  36409. */
  36410. onCanvasFocusObservable: Observable<Engine>;
  36411. /**
  36412. * Observable event triggered each time the canvas receives pointerout event
  36413. */
  36414. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36415. /**
  36416. * Observable raised when the engine begins a new frame
  36417. */
  36418. onBeginFrameObservable: Observable<Engine>;
  36419. /**
  36420. * If set, will be used to request the next animation frame for the render loop
  36421. */
  36422. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36423. /**
  36424. * Observable raised when the engine ends the current frame
  36425. */
  36426. onEndFrameObservable: Observable<Engine>;
  36427. /**
  36428. * Observable raised when the engine is about to compile a shader
  36429. */
  36430. onBeforeShaderCompilationObservable: Observable<Engine>;
  36431. /**
  36432. * Observable raised when the engine has jsut compiled a shader
  36433. */
  36434. onAfterShaderCompilationObservable: Observable<Engine>;
  36435. /**
  36436. * Gets the audio engine
  36437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36438. * @ignorenaming
  36439. */
  36440. static audioEngine: IAudioEngine;
  36441. /**
  36442. * Default AudioEngine factory responsible of creating the Audio Engine.
  36443. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36444. */
  36445. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36446. /**
  36447. * Default offline support factory responsible of creating a tool used to store data locally.
  36448. * By default, this will create a Database object if the workload has been embedded.
  36449. */
  36450. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36451. private _loadingScreen;
  36452. private _pointerLockRequested;
  36453. private _rescalePostProcess;
  36454. private _deterministicLockstep;
  36455. private _lockstepMaxSteps;
  36456. private _timeStep;
  36457. protected get _supportsHardwareTextureRescaling(): boolean;
  36458. private _fps;
  36459. private _deltaTime;
  36460. /** @hidden */
  36461. _drawCalls: PerfCounter;
  36462. /** 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 */
  36463. canvasTabIndex: number;
  36464. /**
  36465. * Turn this value on if you want to pause FPS computation when in background
  36466. */
  36467. disablePerformanceMonitorInBackground: boolean;
  36468. private _performanceMonitor;
  36469. /**
  36470. * Gets the performance monitor attached to this engine
  36471. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36472. */
  36473. get performanceMonitor(): PerformanceMonitor;
  36474. private _onFocus;
  36475. private _onBlur;
  36476. private _onCanvasPointerOut;
  36477. private _onCanvasBlur;
  36478. private _onCanvasFocus;
  36479. private _onFullscreenChange;
  36480. private _onPointerLockChange;
  36481. /**
  36482. * Gets the HTML element used to attach event listeners
  36483. * @returns a HTML element
  36484. */
  36485. getInputElement(): Nullable<HTMLElement>;
  36486. /**
  36487. * Creates a new engine
  36488. * @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
  36489. * @param antialias defines enable antialiasing (default: false)
  36490. * @param options defines further options to be sent to the getContext() function
  36491. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36492. */
  36493. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36494. /**
  36495. * Gets current aspect ratio
  36496. * @param viewportOwner defines the camera to use to get the aspect ratio
  36497. * @param useScreen defines if screen size must be used (or the current render target if any)
  36498. * @returns a number defining the aspect ratio
  36499. */
  36500. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36501. /**
  36502. * Gets current screen aspect ratio
  36503. * @returns a number defining the aspect ratio
  36504. */
  36505. getScreenAspectRatio(): number;
  36506. /**
  36507. * Gets the client rect of the HTML canvas attached with the current webGL context
  36508. * @returns a client rectanglee
  36509. */
  36510. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36511. /**
  36512. * Gets the client rect of the HTML element used for events
  36513. * @returns a client rectanglee
  36514. */
  36515. getInputElementClientRect(): Nullable<ClientRect>;
  36516. /**
  36517. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36518. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36519. * @returns true if engine is in deterministic lock step mode
  36520. */
  36521. isDeterministicLockStep(): boolean;
  36522. /**
  36523. * Gets the max steps when engine is running in deterministic lock step
  36524. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36525. * @returns the max steps
  36526. */
  36527. getLockstepMaxSteps(): number;
  36528. /**
  36529. * Returns the time in ms between steps when using deterministic lock step.
  36530. * @returns time step in (ms)
  36531. */
  36532. getTimeStep(): number;
  36533. /**
  36534. * Force the mipmap generation for the given render target texture
  36535. * @param texture defines the render target texture to use
  36536. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36537. */
  36538. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36539. /** States */
  36540. /**
  36541. * Set various states to the webGL context
  36542. * @param culling defines backface culling state
  36543. * @param zOffset defines the value to apply to zOffset (0 by default)
  36544. * @param force defines if states must be applied even if cache is up to date
  36545. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36546. */
  36547. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36548. /**
  36549. * Set the z offset to apply to current rendering
  36550. * @param value defines the offset to apply
  36551. */
  36552. setZOffset(value: number): void;
  36553. /**
  36554. * Gets the current value of the zOffset
  36555. * @returns the current zOffset state
  36556. */
  36557. getZOffset(): number;
  36558. /**
  36559. * Enable or disable depth buffering
  36560. * @param enable defines the state to set
  36561. */
  36562. setDepthBuffer(enable: boolean): void;
  36563. /**
  36564. * Gets a boolean indicating if depth writing is enabled
  36565. * @returns the current depth writing state
  36566. */
  36567. getDepthWrite(): boolean;
  36568. /**
  36569. * Enable or disable depth writing
  36570. * @param enable defines the state to set
  36571. */
  36572. setDepthWrite(enable: boolean): void;
  36573. /**
  36574. * Gets a boolean indicating if stencil buffer is enabled
  36575. * @returns the current stencil buffer state
  36576. */
  36577. getStencilBuffer(): boolean;
  36578. /**
  36579. * Enable or disable the stencil buffer
  36580. * @param enable defines if the stencil buffer must be enabled or disabled
  36581. */
  36582. setStencilBuffer(enable: boolean): void;
  36583. /**
  36584. * Gets the current stencil mask
  36585. * @returns a number defining the new stencil mask to use
  36586. */
  36587. getStencilMask(): number;
  36588. /**
  36589. * Sets the current stencil mask
  36590. * @param mask defines the new stencil mask to use
  36591. */
  36592. setStencilMask(mask: number): void;
  36593. /**
  36594. * Gets the current stencil function
  36595. * @returns a number defining the stencil function to use
  36596. */
  36597. getStencilFunction(): number;
  36598. /**
  36599. * Gets the current stencil reference value
  36600. * @returns a number defining the stencil reference value to use
  36601. */
  36602. getStencilFunctionReference(): number;
  36603. /**
  36604. * Gets the current stencil mask
  36605. * @returns a number defining the stencil mask to use
  36606. */
  36607. getStencilFunctionMask(): number;
  36608. /**
  36609. * Sets the current stencil function
  36610. * @param stencilFunc defines the new stencil function to use
  36611. */
  36612. setStencilFunction(stencilFunc: number): void;
  36613. /**
  36614. * Sets the current stencil reference
  36615. * @param reference defines the new stencil reference to use
  36616. */
  36617. setStencilFunctionReference(reference: number): void;
  36618. /**
  36619. * Sets the current stencil mask
  36620. * @param mask defines the new stencil mask to use
  36621. */
  36622. setStencilFunctionMask(mask: number): void;
  36623. /**
  36624. * Gets the current stencil operation when stencil fails
  36625. * @returns a number defining stencil operation to use when stencil fails
  36626. */
  36627. getStencilOperationFail(): number;
  36628. /**
  36629. * Gets the current stencil operation when depth fails
  36630. * @returns a number defining stencil operation to use when depth fails
  36631. */
  36632. getStencilOperationDepthFail(): number;
  36633. /**
  36634. * Gets the current stencil operation when stencil passes
  36635. * @returns a number defining stencil operation to use when stencil passes
  36636. */
  36637. getStencilOperationPass(): number;
  36638. /**
  36639. * Sets the stencil operation to use when stencil fails
  36640. * @param operation defines the stencil operation to use when stencil fails
  36641. */
  36642. setStencilOperationFail(operation: number): void;
  36643. /**
  36644. * Sets the stencil operation to use when depth fails
  36645. * @param operation defines the stencil operation to use when depth fails
  36646. */
  36647. setStencilOperationDepthFail(operation: number): void;
  36648. /**
  36649. * Sets the stencil operation to use when stencil passes
  36650. * @param operation defines the stencil operation to use when stencil passes
  36651. */
  36652. setStencilOperationPass(operation: number): void;
  36653. /**
  36654. * Sets a boolean indicating if the dithering state is enabled or disabled
  36655. * @param value defines the dithering state
  36656. */
  36657. setDitheringState(value: boolean): void;
  36658. /**
  36659. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36660. * @param value defines the rasterizer state
  36661. */
  36662. setRasterizerState(value: boolean): void;
  36663. /**
  36664. * Gets the current depth function
  36665. * @returns a number defining the depth function
  36666. */
  36667. getDepthFunction(): Nullable<number>;
  36668. /**
  36669. * Sets the current depth function
  36670. * @param depthFunc defines the function to use
  36671. */
  36672. setDepthFunction(depthFunc: number): void;
  36673. /**
  36674. * Sets the current depth function to GREATER
  36675. */
  36676. setDepthFunctionToGreater(): void;
  36677. /**
  36678. * Sets the current depth function to GEQUAL
  36679. */
  36680. setDepthFunctionToGreaterOrEqual(): void;
  36681. /**
  36682. * Sets the current depth function to LESS
  36683. */
  36684. setDepthFunctionToLess(): void;
  36685. /**
  36686. * Sets the current depth function to LEQUAL
  36687. */
  36688. setDepthFunctionToLessOrEqual(): void;
  36689. private _cachedStencilBuffer;
  36690. private _cachedStencilFunction;
  36691. private _cachedStencilMask;
  36692. private _cachedStencilOperationPass;
  36693. private _cachedStencilOperationFail;
  36694. private _cachedStencilOperationDepthFail;
  36695. private _cachedStencilReference;
  36696. /**
  36697. * Caches the the state of the stencil buffer
  36698. */
  36699. cacheStencilState(): void;
  36700. /**
  36701. * Restores the state of the stencil buffer
  36702. */
  36703. restoreStencilState(): void;
  36704. /**
  36705. * Directly set the WebGL Viewport
  36706. * @param x defines the x coordinate of the viewport (in screen space)
  36707. * @param y defines the y coordinate of the viewport (in screen space)
  36708. * @param width defines the width of the viewport (in screen space)
  36709. * @param height defines the height of the viewport (in screen space)
  36710. * @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
  36711. */
  36712. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36713. /**
  36714. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36715. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36716. * @param y defines the y-coordinate of the corner of the clear rectangle
  36717. * @param width defines the width of the clear rectangle
  36718. * @param height defines the height of the clear rectangle
  36719. * @param clearColor defines the clear color
  36720. */
  36721. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36722. /**
  36723. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36724. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36725. * @param y defines the y-coordinate of the corner of the clear rectangle
  36726. * @param width defines the width of the clear rectangle
  36727. * @param height defines the height of the clear rectangle
  36728. */
  36729. enableScissor(x: number, y: number, width: number, height: number): void;
  36730. /**
  36731. * Disable previously set scissor test rectangle
  36732. */
  36733. disableScissor(): void;
  36734. protected _reportDrawCall(): void;
  36735. /**
  36736. * Initializes a webVR display and starts listening to display change events
  36737. * The onVRDisplayChangedObservable will be notified upon these changes
  36738. * @returns The onVRDisplayChangedObservable
  36739. */
  36740. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36741. /** @hidden */
  36742. _prepareVRComponent(): void;
  36743. /** @hidden */
  36744. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36745. /** @hidden */
  36746. _submitVRFrame(): void;
  36747. /**
  36748. * Call this function to leave webVR mode
  36749. * Will do nothing if webVR is not supported or if there is no webVR device
  36750. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36751. */
  36752. disableVR(): void;
  36753. /**
  36754. * Gets a boolean indicating that the system is in VR mode and is presenting
  36755. * @returns true if VR mode is engaged
  36756. */
  36757. isVRPresenting(): boolean;
  36758. /** @hidden */
  36759. _requestVRFrame(): void;
  36760. /** @hidden */
  36761. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36762. /**
  36763. * Gets the source code of the vertex shader associated with a specific webGL program
  36764. * @param program defines the program to use
  36765. * @returns a string containing the source code of the vertex shader associated with the program
  36766. */
  36767. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  36768. /**
  36769. * Gets the source code of the fragment shader associated with a specific webGL program
  36770. * @param program defines the program to use
  36771. * @returns a string containing the source code of the fragment shader associated with the program
  36772. */
  36773. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  36774. /**
  36775. * Sets a depth stencil texture from a render target to the according uniform.
  36776. * @param channel The texture channel
  36777. * @param uniform The uniform to set
  36778. * @param texture The render target texture containing the depth stencil texture to apply
  36779. */
  36780. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  36781. /**
  36782. * Sets a texture to the webGL context from a postprocess
  36783. * @param channel defines the channel to use
  36784. * @param postProcess defines the source postprocess
  36785. */
  36786. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  36787. /**
  36788. * Binds the output of the passed in post process to the texture channel specified
  36789. * @param channel The channel the texture should be bound to
  36790. * @param postProcess The post process which's output should be bound
  36791. */
  36792. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  36793. protected _rebuildBuffers(): void;
  36794. /** @hidden */
  36795. _renderFrame(): void;
  36796. _renderLoop(): void;
  36797. /** @hidden */
  36798. _renderViews(): boolean;
  36799. /**
  36800. * Toggle full screen mode
  36801. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36802. */
  36803. switchFullscreen(requestPointerLock: boolean): void;
  36804. /**
  36805. * Enters full screen mode
  36806. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36807. */
  36808. enterFullscreen(requestPointerLock: boolean): void;
  36809. /**
  36810. * Exits full screen mode
  36811. */
  36812. exitFullscreen(): void;
  36813. /**
  36814. * Enters Pointerlock mode
  36815. */
  36816. enterPointerlock(): void;
  36817. /**
  36818. * Exits Pointerlock mode
  36819. */
  36820. exitPointerlock(): void;
  36821. /**
  36822. * Begin a new frame
  36823. */
  36824. beginFrame(): void;
  36825. /**
  36826. * Enf the current frame
  36827. */
  36828. endFrame(): void;
  36829. resize(): void;
  36830. /**
  36831. * Force a specific size of the canvas
  36832. * @param width defines the new canvas' width
  36833. * @param height defines the new canvas' height
  36834. */
  36835. setSize(width: number, height: number): void;
  36836. /**
  36837. * Updates a dynamic vertex buffer.
  36838. * @param vertexBuffer the vertex buffer to update
  36839. * @param data the data used to update the vertex buffer
  36840. * @param byteOffset the byte offset of the data
  36841. * @param byteLength the byte length of the data
  36842. */
  36843. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  36844. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36845. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36846. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36847. _releaseTexture(texture: InternalTexture): void;
  36848. /**
  36849. * @hidden
  36850. * Rescales a texture
  36851. * @param source input texutre
  36852. * @param destination destination texture
  36853. * @param scene scene to use to render the resize
  36854. * @param internalFormat format to use when resizing
  36855. * @param onComplete callback to be called when resize has completed
  36856. */
  36857. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36858. /**
  36859. * Gets the current framerate
  36860. * @returns a number representing the framerate
  36861. */
  36862. getFps(): number;
  36863. /**
  36864. * Gets the time spent between current and previous frame
  36865. * @returns a number representing the delta time in ms
  36866. */
  36867. getDeltaTime(): number;
  36868. private _measureFps;
  36869. /** @hidden */
  36870. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  36871. /**
  36872. * Update a dynamic index buffer
  36873. * @param indexBuffer defines the target index buffer
  36874. * @param indices defines the data to update
  36875. * @param offset defines the offset in the target index buffer where update should start
  36876. */
  36877. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  36878. /**
  36879. * Updates the sample count of a render target texture
  36880. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  36881. * @param texture defines the texture to update
  36882. * @param samples defines the sample count to set
  36883. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  36884. */
  36885. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  36886. /**
  36887. * Updates a depth texture Comparison Mode and Function.
  36888. * If the comparison Function is equal to 0, the mode will be set to none.
  36889. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  36890. * @param texture The texture to set the comparison function for
  36891. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  36892. */
  36893. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  36894. /**
  36895. * Creates a webGL buffer to use with instanciation
  36896. * @param capacity defines the size of the buffer
  36897. * @returns the webGL buffer
  36898. */
  36899. createInstancesBuffer(capacity: number): DataBuffer;
  36900. /**
  36901. * Delete a webGL buffer used with instanciation
  36902. * @param buffer defines the webGL buffer to delete
  36903. */
  36904. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  36905. private _clientWaitAsync;
  36906. /** @hidden */
  36907. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  36908. dispose(): void;
  36909. private _disableTouchAction;
  36910. /**
  36911. * Display the loading screen
  36912. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36913. */
  36914. displayLoadingUI(): void;
  36915. /**
  36916. * Hide the loading screen
  36917. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36918. */
  36919. hideLoadingUI(): void;
  36920. /**
  36921. * Gets the current loading screen object
  36922. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36923. */
  36924. get loadingScreen(): ILoadingScreen;
  36925. /**
  36926. * Sets the current loading screen object
  36927. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36928. */
  36929. set loadingScreen(loadingScreen: ILoadingScreen);
  36930. /**
  36931. * Sets the current loading screen text
  36932. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36933. */
  36934. set loadingUIText(text: string);
  36935. /**
  36936. * Sets the current loading screen background color
  36937. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36938. */
  36939. set loadingUIBackgroundColor(color: string);
  36940. /** Pointerlock and fullscreen */
  36941. /**
  36942. * Ask the browser to promote the current element to pointerlock mode
  36943. * @param element defines the DOM element to promote
  36944. */
  36945. static _RequestPointerlock(element: HTMLElement): void;
  36946. /**
  36947. * Asks the browser to exit pointerlock mode
  36948. */
  36949. static _ExitPointerlock(): void;
  36950. /**
  36951. * Ask the browser to promote the current element to fullscreen rendering mode
  36952. * @param element defines the DOM element to promote
  36953. */
  36954. static _RequestFullscreen(element: HTMLElement): void;
  36955. /**
  36956. * Asks the browser to exit fullscreen mode
  36957. */
  36958. static _ExitFullscreen(): void;
  36959. }
  36960. }
  36961. declare module BABYLON {
  36962. /**
  36963. * The engine store class is responsible to hold all the instances of Engine and Scene created
  36964. * during the life time of the application.
  36965. */
  36966. export class EngineStore {
  36967. /** Gets the list of created engines */
  36968. static Instances: Engine[];
  36969. /** @hidden */
  36970. static _LastCreatedScene: Nullable<Scene>;
  36971. /**
  36972. * Gets the latest created engine
  36973. */
  36974. static get LastCreatedEngine(): Nullable<Engine>;
  36975. /**
  36976. * Gets the latest created scene
  36977. */
  36978. static get LastCreatedScene(): Nullable<Scene>;
  36979. /**
  36980. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  36981. * @ignorenaming
  36982. */
  36983. static UseFallbackTexture: boolean;
  36984. /**
  36985. * Texture content used if a texture cannot loaded
  36986. * @ignorenaming
  36987. */
  36988. static FallbackTexture: string;
  36989. }
  36990. }
  36991. declare module BABYLON {
  36992. /**
  36993. * Helper class that provides a small promise polyfill
  36994. */
  36995. export class PromisePolyfill {
  36996. /**
  36997. * Static function used to check if the polyfill is required
  36998. * If this is the case then the function will inject the polyfill to window.Promise
  36999. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37000. */
  37001. static Apply(force?: boolean): void;
  37002. }
  37003. }
  37004. declare module BABYLON {
  37005. /**
  37006. * Interface for screenshot methods with describe argument called `size` as object with options
  37007. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37008. */
  37009. export interface IScreenshotSize {
  37010. /**
  37011. * number in pixels for canvas height
  37012. */
  37013. height?: number;
  37014. /**
  37015. * multiplier allowing render at a higher or lower resolution
  37016. * If value is defined then height and width will be ignored and taken from camera
  37017. */
  37018. precision?: number;
  37019. /**
  37020. * number in pixels for canvas width
  37021. */
  37022. width?: number;
  37023. }
  37024. }
  37025. declare module BABYLON {
  37026. interface IColor4Like {
  37027. r: float;
  37028. g: float;
  37029. b: float;
  37030. a: float;
  37031. }
  37032. /**
  37033. * Class containing a set of static utilities functions
  37034. */
  37035. export class Tools {
  37036. /**
  37037. * Gets or sets the base URL to use to load assets
  37038. */
  37039. static get BaseUrl(): string;
  37040. static set BaseUrl(value: string);
  37041. /**
  37042. * Enable/Disable Custom HTTP Request Headers globally.
  37043. * default = false
  37044. * @see CustomRequestHeaders
  37045. */
  37046. static UseCustomRequestHeaders: boolean;
  37047. /**
  37048. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37049. * i.e. when loading files, where the server/service expects an Authorization header
  37050. */
  37051. static CustomRequestHeaders: {
  37052. [key: string]: string;
  37053. };
  37054. /**
  37055. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37056. */
  37057. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37058. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37059. /**
  37060. * Default behaviour for cors in the application.
  37061. * It can be a string if the expected behavior is identical in the entire app.
  37062. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37063. */
  37064. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37065. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37066. /**
  37067. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37068. * @ignorenaming
  37069. */
  37070. static get UseFallbackTexture(): boolean;
  37071. static set UseFallbackTexture(value: boolean);
  37072. /**
  37073. * Use this object to register external classes like custom textures or material
  37074. * to allow the laoders to instantiate them
  37075. */
  37076. static get RegisteredExternalClasses(): {
  37077. [key: string]: Object;
  37078. };
  37079. static set RegisteredExternalClasses(classes: {
  37080. [key: string]: Object;
  37081. });
  37082. /**
  37083. * Texture content used if a texture cannot loaded
  37084. * @ignorenaming
  37085. */
  37086. static get fallbackTexture(): string;
  37087. static set fallbackTexture(value: string);
  37088. /**
  37089. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37090. * @param u defines the coordinate on X axis
  37091. * @param v defines the coordinate on Y axis
  37092. * @param width defines the width of the source data
  37093. * @param height defines the height of the source data
  37094. * @param pixels defines the source byte array
  37095. * @param color defines the output color
  37096. */
  37097. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37098. /**
  37099. * Interpolates between a and b via alpha
  37100. * @param a The lower value (returned when alpha = 0)
  37101. * @param b The upper value (returned when alpha = 1)
  37102. * @param alpha The interpolation-factor
  37103. * @return The mixed value
  37104. */
  37105. static Mix(a: number, b: number, alpha: number): number;
  37106. /**
  37107. * Tries to instantiate a new object from a given class name
  37108. * @param className defines the class name to instantiate
  37109. * @returns the new object or null if the system was not able to do the instantiation
  37110. */
  37111. static Instantiate(className: string): any;
  37112. /**
  37113. * Provides a slice function that will work even on IE
  37114. * @param data defines the array to slice
  37115. * @param start defines the start of the data (optional)
  37116. * @param end defines the end of the data (optional)
  37117. * @returns the new sliced array
  37118. */
  37119. static Slice<T>(data: T, start?: number, end?: number): T;
  37120. /**
  37121. * Polyfill for setImmediate
  37122. * @param action defines the action to execute after the current execution block
  37123. */
  37124. static SetImmediate(action: () => void): void;
  37125. /**
  37126. * Function indicating if a number is an exponent of 2
  37127. * @param value defines the value to test
  37128. * @returns true if the value is an exponent of 2
  37129. */
  37130. static IsExponentOfTwo(value: number): boolean;
  37131. private static _tmpFloatArray;
  37132. /**
  37133. * Returns the nearest 32-bit single precision float representation of a Number
  37134. * @param value A Number. If the parameter is of a different type, it will get converted
  37135. * to a number or to NaN if it cannot be converted
  37136. * @returns number
  37137. */
  37138. static FloatRound(value: number): number;
  37139. /**
  37140. * Extracts the filename from a path
  37141. * @param path defines the path to use
  37142. * @returns the filename
  37143. */
  37144. static GetFilename(path: string): string;
  37145. /**
  37146. * Extracts the "folder" part of a path (everything before the filename).
  37147. * @param uri The URI to extract the info from
  37148. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37149. * @returns The "folder" part of the path
  37150. */
  37151. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37152. /**
  37153. * Extracts text content from a DOM element hierarchy
  37154. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37155. */
  37156. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37157. /**
  37158. * Convert an angle in radians to degrees
  37159. * @param angle defines the angle to convert
  37160. * @returns the angle in degrees
  37161. */
  37162. static ToDegrees(angle: number): number;
  37163. /**
  37164. * Convert an angle in degrees to radians
  37165. * @param angle defines the angle to convert
  37166. * @returns the angle in radians
  37167. */
  37168. static ToRadians(angle: number): number;
  37169. /**
  37170. * Returns an array if obj is not an array
  37171. * @param obj defines the object to evaluate as an array
  37172. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37173. * @returns either obj directly if obj is an array or a new array containing obj
  37174. */
  37175. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37176. /**
  37177. * Gets the pointer prefix to use
  37178. * @param engine defines the engine we are finding the prefix for
  37179. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37180. */
  37181. static GetPointerPrefix(engine: Engine): string;
  37182. /**
  37183. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37184. * @param url define the url we are trying
  37185. * @param element define the dom element where to configure the cors policy
  37186. */
  37187. static SetCorsBehavior(url: string | string[], element: {
  37188. crossOrigin: string | null;
  37189. }): void;
  37190. /**
  37191. * Removes unwanted characters from an url
  37192. * @param url defines the url to clean
  37193. * @returns the cleaned url
  37194. */
  37195. static CleanUrl(url: string): string;
  37196. /**
  37197. * Gets or sets a function used to pre-process url before using them to load assets
  37198. */
  37199. static get PreprocessUrl(): (url: string) => string;
  37200. static set PreprocessUrl(processor: (url: string) => string);
  37201. /**
  37202. * Loads an image as an HTMLImageElement.
  37203. * @param input url string, ArrayBuffer, or Blob to load
  37204. * @param onLoad callback called when the image successfully loads
  37205. * @param onError callback called when the image fails to load
  37206. * @param offlineProvider offline provider for caching
  37207. * @param mimeType optional mime type
  37208. * @returns the HTMLImageElement of the loaded image
  37209. */
  37210. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37211. /**
  37212. * Loads a file from a url
  37213. * @param url url string, ArrayBuffer, or Blob to load
  37214. * @param onSuccess callback called when the file successfully loads
  37215. * @param onProgress callback called while file is loading (if the server supports this mode)
  37216. * @param offlineProvider defines the offline provider for caching
  37217. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37218. * @param onError callback called when the file fails to load
  37219. * @returns a file request object
  37220. */
  37221. 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;
  37222. /**
  37223. * Loads a file from a url
  37224. * @param url the file url to load
  37225. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37226. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37227. */
  37228. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37229. /**
  37230. * Load a script (identified by an url). When the url returns, the
  37231. * content of this file is added into a new script element, attached to the DOM (body element)
  37232. * @param scriptUrl defines the url of the script to laod
  37233. * @param onSuccess defines the callback called when the script is loaded
  37234. * @param onError defines the callback to call if an error occurs
  37235. * @param scriptId defines the id of the script element
  37236. */
  37237. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37238. /**
  37239. * Load an asynchronous script (identified by an url). When the url returns, the
  37240. * content of this file is added into a new script element, attached to the DOM (body element)
  37241. * @param scriptUrl defines the url of the script to laod
  37242. * @param scriptId defines the id of the script element
  37243. * @returns a promise request object
  37244. */
  37245. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37246. /**
  37247. * Loads a file from a blob
  37248. * @param fileToLoad defines the blob to use
  37249. * @param callback defines the callback to call when data is loaded
  37250. * @param progressCallback defines the callback to call during loading process
  37251. * @returns a file request object
  37252. */
  37253. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37254. /**
  37255. * Reads a file from a File object
  37256. * @param file defines the file to load
  37257. * @param onSuccess defines the callback to call when data is loaded
  37258. * @param onProgress defines the callback to call during loading process
  37259. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37260. * @param onError defines the callback to call when an error occurs
  37261. * @returns a file request object
  37262. */
  37263. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37264. /**
  37265. * Creates a data url from a given string content
  37266. * @param content defines the content to convert
  37267. * @returns the new data url link
  37268. */
  37269. static FileAsURL(content: string): string;
  37270. /**
  37271. * Format the given number to a specific decimal format
  37272. * @param value defines the number to format
  37273. * @param decimals defines the number of decimals to use
  37274. * @returns the formatted string
  37275. */
  37276. static Format(value: number, decimals?: number): string;
  37277. /**
  37278. * Tries to copy an object by duplicating every property
  37279. * @param source defines the source object
  37280. * @param destination defines the target object
  37281. * @param doNotCopyList defines a list of properties to avoid
  37282. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37283. */
  37284. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37285. /**
  37286. * Gets a boolean indicating if the given object has no own property
  37287. * @param obj defines the object to test
  37288. * @returns true if object has no own property
  37289. */
  37290. static IsEmpty(obj: any): boolean;
  37291. /**
  37292. * Function used to register events at window level
  37293. * @param windowElement defines the Window object to use
  37294. * @param events defines the events to register
  37295. */
  37296. static RegisterTopRootEvents(windowElement: Window, events: {
  37297. name: string;
  37298. handler: Nullable<(e: FocusEvent) => any>;
  37299. }[]): void;
  37300. /**
  37301. * Function used to unregister events from window level
  37302. * @param windowElement defines the Window object to use
  37303. * @param events defines the events to unregister
  37304. */
  37305. static UnregisterTopRootEvents(windowElement: Window, events: {
  37306. name: string;
  37307. handler: Nullable<(e: FocusEvent) => any>;
  37308. }[]): void;
  37309. /**
  37310. * @ignore
  37311. */
  37312. static _ScreenshotCanvas: HTMLCanvasElement;
  37313. /**
  37314. * Dumps the current bound framebuffer
  37315. * @param width defines the rendering width
  37316. * @param height defines the rendering height
  37317. * @param engine defines the hosting engine
  37318. * @param successCallback defines the callback triggered once the data are available
  37319. * @param mimeType defines the mime type of the result
  37320. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37321. */
  37322. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37323. /**
  37324. * Converts the canvas data to blob.
  37325. * This acts as a polyfill for browsers not supporting the to blob function.
  37326. * @param canvas Defines the canvas to extract the data from
  37327. * @param successCallback Defines the callback triggered once the data are available
  37328. * @param mimeType Defines the mime type of the result
  37329. */
  37330. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37331. /**
  37332. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37333. * @param successCallback defines the callback triggered once the data are available
  37334. * @param mimeType defines the mime type of the result
  37335. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37336. */
  37337. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37338. /**
  37339. * Downloads a blob in the browser
  37340. * @param blob defines the blob to download
  37341. * @param fileName defines the name of the downloaded file
  37342. */
  37343. static Download(blob: Blob, fileName: string): void;
  37344. /**
  37345. * Captures a screenshot of the current rendering
  37346. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37347. * @param engine defines the rendering engine
  37348. * @param camera defines the source camera
  37349. * @param size This parameter can be set to a single number or to an object with the
  37350. * following (optional) properties: precision, width, height. If a single number is passed,
  37351. * it will be used for both width and height. If an object is passed, the screenshot size
  37352. * will be derived from the parameters. The precision property is a multiplier allowing
  37353. * rendering at a higher or lower resolution
  37354. * @param successCallback defines the callback receives a single parameter which contains the
  37355. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37356. * src parameter of an <img> to display it
  37357. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37358. * Check your browser for supported MIME types
  37359. */
  37360. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37361. /**
  37362. * Captures a screenshot of the current rendering
  37363. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37364. * @param engine defines the rendering engine
  37365. * @param camera defines the source camera
  37366. * @param size This parameter can be set to a single number or to an object with the
  37367. * following (optional) properties: precision, width, height. If a single number is passed,
  37368. * it will be used for both width and height. If an object is passed, the screenshot size
  37369. * will be derived from the parameters. The precision property is a multiplier allowing
  37370. * rendering at a higher or lower resolution
  37371. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37372. * Check your browser for supported MIME types
  37373. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37374. * to the src parameter of an <img> to display it
  37375. */
  37376. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37377. /**
  37378. * Generates an image screenshot from the specified camera.
  37379. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37380. * @param engine The engine to use for rendering
  37381. * @param camera The camera to use for rendering
  37382. * @param size This parameter can be set to a single number or to an object with the
  37383. * following (optional) properties: precision, width, height. If a single number is passed,
  37384. * it will be used for both width and height. If an object is passed, the screenshot size
  37385. * will be derived from the parameters. The precision property is a multiplier allowing
  37386. * rendering at a higher or lower resolution
  37387. * @param successCallback The callback receives a single parameter which contains the
  37388. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37389. * src parameter of an <img> to display it
  37390. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37391. * Check your browser for supported MIME types
  37392. * @param samples Texture samples (default: 1)
  37393. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37394. * @param fileName A name for for the downloaded file.
  37395. */
  37396. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37397. /**
  37398. * Generates an image screenshot from the specified camera.
  37399. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37400. * @param engine The engine to use for rendering
  37401. * @param camera The camera to use for rendering
  37402. * @param size This parameter can be set to a single number or to an object with the
  37403. * following (optional) properties: precision, width, height. If a single number is passed,
  37404. * it will be used for both width and height. If an object is passed, the screenshot size
  37405. * will be derived from the parameters. The precision property is a multiplier allowing
  37406. * rendering at a higher or lower resolution
  37407. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37408. * Check your browser for supported MIME types
  37409. * @param samples Texture samples (default: 1)
  37410. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37411. * @param fileName A name for for the downloaded file.
  37412. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37413. * to the src parameter of an <img> to display it
  37414. */
  37415. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37416. /**
  37417. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37418. * Be aware Math.random() could cause collisions, but:
  37419. * "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"
  37420. * @returns a pseudo random id
  37421. */
  37422. static RandomId(): string;
  37423. /**
  37424. * Test if the given uri is a base64 string
  37425. * @param uri The uri to test
  37426. * @return True if the uri is a base64 string or false otherwise
  37427. */
  37428. static IsBase64(uri: string): boolean;
  37429. /**
  37430. * Decode the given base64 uri.
  37431. * @param uri The uri to decode
  37432. * @return The decoded base64 data.
  37433. */
  37434. static DecodeBase64(uri: string): ArrayBuffer;
  37435. /**
  37436. * Gets the absolute url.
  37437. * @param url the input url
  37438. * @return the absolute url
  37439. */
  37440. static GetAbsoluteUrl(url: string): string;
  37441. /**
  37442. * No log
  37443. */
  37444. static readonly NoneLogLevel: number;
  37445. /**
  37446. * Only message logs
  37447. */
  37448. static readonly MessageLogLevel: number;
  37449. /**
  37450. * Only warning logs
  37451. */
  37452. static readonly WarningLogLevel: number;
  37453. /**
  37454. * Only error logs
  37455. */
  37456. static readonly ErrorLogLevel: number;
  37457. /**
  37458. * All logs
  37459. */
  37460. static readonly AllLogLevel: number;
  37461. /**
  37462. * Gets a value indicating the number of loading errors
  37463. * @ignorenaming
  37464. */
  37465. static get errorsCount(): number;
  37466. /**
  37467. * Callback called when a new log is added
  37468. */
  37469. static OnNewCacheEntry: (entry: string) => void;
  37470. /**
  37471. * Log a message to the console
  37472. * @param message defines the message to log
  37473. */
  37474. static Log(message: string): void;
  37475. /**
  37476. * Write a warning message to the console
  37477. * @param message defines the message to log
  37478. */
  37479. static Warn(message: string): void;
  37480. /**
  37481. * Write an error message to the console
  37482. * @param message defines the message to log
  37483. */
  37484. static Error(message: string): void;
  37485. /**
  37486. * Gets current log cache (list of logs)
  37487. */
  37488. static get LogCache(): string;
  37489. /**
  37490. * Clears the log cache
  37491. */
  37492. static ClearLogCache(): void;
  37493. /**
  37494. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37495. */
  37496. static set LogLevels(level: number);
  37497. /**
  37498. * Checks if the window object exists
  37499. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37500. */
  37501. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37502. /**
  37503. * No performance log
  37504. */
  37505. static readonly PerformanceNoneLogLevel: number;
  37506. /**
  37507. * Use user marks to log performance
  37508. */
  37509. static readonly PerformanceUserMarkLogLevel: number;
  37510. /**
  37511. * Log performance to the console
  37512. */
  37513. static readonly PerformanceConsoleLogLevel: number;
  37514. private static _performance;
  37515. /**
  37516. * Sets the current performance log level
  37517. */
  37518. static set PerformanceLogLevel(level: number);
  37519. private static _StartPerformanceCounterDisabled;
  37520. private static _EndPerformanceCounterDisabled;
  37521. private static _StartUserMark;
  37522. private static _EndUserMark;
  37523. private static _StartPerformanceConsole;
  37524. private static _EndPerformanceConsole;
  37525. /**
  37526. * Starts a performance counter
  37527. */
  37528. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37529. /**
  37530. * Ends a specific performance coutner
  37531. */
  37532. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37533. /**
  37534. * Gets either window.performance.now() if supported or Date.now() else
  37535. */
  37536. static get Now(): number;
  37537. /**
  37538. * This method will return the name of the class used to create the instance of the given object.
  37539. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37540. * @param object the object to get the class name from
  37541. * @param isType defines if the object is actually a type
  37542. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37543. */
  37544. static GetClassName(object: any, isType?: boolean): string;
  37545. /**
  37546. * Gets the first element of an array satisfying a given predicate
  37547. * @param array defines the array to browse
  37548. * @param predicate defines the predicate to use
  37549. * @returns null if not found or the element
  37550. */
  37551. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37552. /**
  37553. * This method will return the name of the full name of the class, including its owning module (if any).
  37554. * 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).
  37555. * @param object the object to get the class name from
  37556. * @param isType defines if the object is actually a type
  37557. * @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.
  37558. * @ignorenaming
  37559. */
  37560. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37561. /**
  37562. * Returns a promise that resolves after the given amount of time.
  37563. * @param delay Number of milliseconds to delay
  37564. * @returns Promise that resolves after the given amount of time
  37565. */
  37566. static DelayAsync(delay: number): Promise<void>;
  37567. /**
  37568. * Utility function to detect if the current user agent is Safari
  37569. * @returns whether or not the current user agent is safari
  37570. */
  37571. static IsSafari(): boolean;
  37572. }
  37573. /**
  37574. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37575. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37576. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37577. * @param name The name of the class, case should be preserved
  37578. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37579. */
  37580. export function className(name: string, module?: string): (target: Object) => void;
  37581. /**
  37582. * An implementation of a loop for asynchronous functions.
  37583. */
  37584. export class AsyncLoop {
  37585. /**
  37586. * Defines the number of iterations for the loop
  37587. */
  37588. iterations: number;
  37589. /**
  37590. * Defines the current index of the loop.
  37591. */
  37592. index: number;
  37593. private _done;
  37594. private _fn;
  37595. private _successCallback;
  37596. /**
  37597. * Constructor.
  37598. * @param iterations the number of iterations.
  37599. * @param func the function to run each iteration
  37600. * @param successCallback the callback that will be called upon succesful execution
  37601. * @param offset starting offset.
  37602. */
  37603. constructor(
  37604. /**
  37605. * Defines the number of iterations for the loop
  37606. */
  37607. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37608. /**
  37609. * Execute the next iteration. Must be called after the last iteration was finished.
  37610. */
  37611. executeNext(): void;
  37612. /**
  37613. * Break the loop and run the success callback.
  37614. */
  37615. breakLoop(): void;
  37616. /**
  37617. * Create and run an async loop.
  37618. * @param iterations the number of iterations.
  37619. * @param fn the function to run each iteration
  37620. * @param successCallback the callback that will be called upon succesful execution
  37621. * @param offset starting offset.
  37622. * @returns the created async loop object
  37623. */
  37624. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37625. /**
  37626. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37627. * @param iterations total number of iterations
  37628. * @param syncedIterations number of synchronous iterations in each async iteration.
  37629. * @param fn the function to call each iteration.
  37630. * @param callback a success call back that will be called when iterating stops.
  37631. * @param breakFunction a break condition (optional)
  37632. * @param timeout timeout settings for the setTimeout function. default - 0.
  37633. * @returns the created async loop object
  37634. */
  37635. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37636. }
  37637. }
  37638. declare module BABYLON {
  37639. /**
  37640. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37641. * The underlying implementation relies on an associative array to ensure the best performances.
  37642. * The value can be anything including 'null' but except 'undefined'
  37643. */
  37644. export class StringDictionary<T> {
  37645. /**
  37646. * This will clear this dictionary and copy the content from the 'source' one.
  37647. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37648. * @param source the dictionary to take the content from and copy to this dictionary
  37649. */
  37650. copyFrom(source: StringDictionary<T>): void;
  37651. /**
  37652. * Get a value based from its key
  37653. * @param key the given key to get the matching value from
  37654. * @return the value if found, otherwise undefined is returned
  37655. */
  37656. get(key: string): T | undefined;
  37657. /**
  37658. * Get a value from its key or add it if it doesn't exist.
  37659. * This method will ensure you that a given key/data will be present in the dictionary.
  37660. * @param key the given key to get the matching value from
  37661. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37662. * The factory will only be invoked if there's no data for the given key.
  37663. * @return the value corresponding to the key.
  37664. */
  37665. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37666. /**
  37667. * Get a value from its key if present in the dictionary otherwise add it
  37668. * @param key the key to get the value from
  37669. * @param val if there's no such key/value pair in the dictionary add it with this value
  37670. * @return the value corresponding to the key
  37671. */
  37672. getOrAdd(key: string, val: T): T;
  37673. /**
  37674. * Check if there's a given key in the dictionary
  37675. * @param key the key to check for
  37676. * @return true if the key is present, false otherwise
  37677. */
  37678. contains(key: string): boolean;
  37679. /**
  37680. * Add a new key and its corresponding value
  37681. * @param key the key to add
  37682. * @param value the value corresponding to the key
  37683. * @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
  37684. */
  37685. add(key: string, value: T): boolean;
  37686. /**
  37687. * Update a specific value associated to a key
  37688. * @param key defines the key to use
  37689. * @param value defines the value to store
  37690. * @returns true if the value was updated (or false if the key was not found)
  37691. */
  37692. set(key: string, value: T): boolean;
  37693. /**
  37694. * Get the element of the given key and remove it from the dictionary
  37695. * @param key defines the key to search
  37696. * @returns the value associated with the key or null if not found
  37697. */
  37698. getAndRemove(key: string): Nullable<T>;
  37699. /**
  37700. * Remove a key/value from the dictionary.
  37701. * @param key the key to remove
  37702. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37703. */
  37704. remove(key: string): boolean;
  37705. /**
  37706. * Clear the whole content of the dictionary
  37707. */
  37708. clear(): void;
  37709. /**
  37710. * Gets the current count
  37711. */
  37712. get count(): number;
  37713. /**
  37714. * Execute a callback on each key/val of the dictionary.
  37715. * Note that you can remove any element in this dictionary in the callback implementation
  37716. * @param callback the callback to execute on a given key/value pair
  37717. */
  37718. forEach(callback: (key: string, val: T) => void): void;
  37719. /**
  37720. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37721. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37722. * Note that you can remove any element in this dictionary in the callback implementation
  37723. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37724. * @returns the first item
  37725. */
  37726. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37727. private _count;
  37728. private _data;
  37729. }
  37730. }
  37731. declare module BABYLON {
  37732. /** @hidden */
  37733. export interface ICollisionCoordinator {
  37734. createCollider(): Collider;
  37735. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37736. init(scene: Scene): void;
  37737. }
  37738. /** @hidden */
  37739. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37740. private _scene;
  37741. private _scaledPosition;
  37742. private _scaledVelocity;
  37743. private _finalPosition;
  37744. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37745. createCollider(): Collider;
  37746. init(scene: Scene): void;
  37747. private _collideWithWorld;
  37748. }
  37749. }
  37750. declare module BABYLON {
  37751. /**
  37752. * Class used to manage all inputs for the scene.
  37753. */
  37754. export class InputManager {
  37755. /** The distance in pixel that you have to move to prevent some events */
  37756. static DragMovementThreshold: number;
  37757. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37758. static LongPressDelay: number;
  37759. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37760. static DoubleClickDelay: number;
  37761. /** If you need to check double click without raising a single click at first click, enable this flag */
  37762. static ExclusiveDoubleClickMode: boolean;
  37763. private _wheelEventName;
  37764. private _onPointerMove;
  37765. private _onPointerDown;
  37766. private _onPointerUp;
  37767. private _initClickEvent;
  37768. private _initActionManager;
  37769. private _delayedSimpleClick;
  37770. private _delayedSimpleClickTimeout;
  37771. private _previousDelayedSimpleClickTimeout;
  37772. private _meshPickProceed;
  37773. private _previousButtonPressed;
  37774. private _currentPickResult;
  37775. private _previousPickResult;
  37776. private _totalPointersPressed;
  37777. private _doubleClickOccured;
  37778. private _pointerOverMesh;
  37779. private _pickedDownMesh;
  37780. private _pickedUpMesh;
  37781. private _pointerX;
  37782. private _pointerY;
  37783. private _unTranslatedPointerX;
  37784. private _unTranslatedPointerY;
  37785. private _startingPointerPosition;
  37786. private _previousStartingPointerPosition;
  37787. private _startingPointerTime;
  37788. private _previousStartingPointerTime;
  37789. private _pointerCaptures;
  37790. private _onKeyDown;
  37791. private _onKeyUp;
  37792. private _onCanvasFocusObserver;
  37793. private _onCanvasBlurObserver;
  37794. private _scene;
  37795. /**
  37796. * Creates a new InputManager
  37797. * @param scene defines the hosting scene
  37798. */
  37799. constructor(scene: Scene);
  37800. /**
  37801. * Gets the mesh that is currently under the pointer
  37802. */
  37803. get meshUnderPointer(): Nullable<AbstractMesh>;
  37804. /**
  37805. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  37806. */
  37807. get unTranslatedPointer(): Vector2;
  37808. /**
  37809. * Gets or sets the current on-screen X position of the pointer
  37810. */
  37811. get pointerX(): number;
  37812. set pointerX(value: number);
  37813. /**
  37814. * Gets or sets the current on-screen Y position of the pointer
  37815. */
  37816. get pointerY(): number;
  37817. set pointerY(value: number);
  37818. private _updatePointerPosition;
  37819. private _processPointerMove;
  37820. private _setRayOnPointerInfo;
  37821. private _checkPrePointerObservable;
  37822. /**
  37823. * Use this method to simulate a pointer move on a mesh
  37824. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37825. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37826. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37827. */
  37828. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37829. /**
  37830. * Use this method to simulate a pointer down on a mesh
  37831. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37832. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37833. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37834. */
  37835. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37836. private _processPointerDown;
  37837. /** @hidden */
  37838. _isPointerSwiping(): boolean;
  37839. /**
  37840. * Use this method to simulate a pointer up on a mesh
  37841. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37842. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37843. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37844. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37845. */
  37846. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  37847. private _processPointerUp;
  37848. /**
  37849. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37850. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37851. * @returns true if the pointer was captured
  37852. */
  37853. isPointerCaptured(pointerId?: number): boolean;
  37854. /**
  37855. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37856. * @param attachUp defines if you want to attach events to pointerup
  37857. * @param attachDown defines if you want to attach events to pointerdown
  37858. * @param attachMove defines if you want to attach events to pointermove
  37859. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  37860. */
  37861. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  37862. /**
  37863. * Detaches all event handlers
  37864. */
  37865. detachControl(): void;
  37866. /**
  37867. * Force the value of meshUnderPointer
  37868. * @param mesh defines the mesh to use
  37869. */
  37870. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37871. /**
  37872. * Gets the mesh under the pointer
  37873. * @returns a Mesh or null if no mesh is under the pointer
  37874. */
  37875. getPointerOverMesh(): Nullable<AbstractMesh>;
  37876. }
  37877. }
  37878. declare module BABYLON {
  37879. /**
  37880. * This class defines the direct association between an animation and a target
  37881. */
  37882. export class TargetedAnimation {
  37883. /**
  37884. * Animation to perform
  37885. */
  37886. animation: Animation;
  37887. /**
  37888. * Target to animate
  37889. */
  37890. target: any;
  37891. /**
  37892. * Serialize the object
  37893. * @returns the JSON object representing the current entity
  37894. */
  37895. serialize(): any;
  37896. }
  37897. /**
  37898. * Use this class to create coordinated animations on multiple targets
  37899. */
  37900. export class AnimationGroup implements IDisposable {
  37901. /** The name of the animation group */
  37902. name: string;
  37903. private _scene;
  37904. private _targetedAnimations;
  37905. private _animatables;
  37906. private _from;
  37907. private _to;
  37908. private _isStarted;
  37909. private _isPaused;
  37910. private _speedRatio;
  37911. private _loopAnimation;
  37912. private _isAdditive;
  37913. /**
  37914. * Gets or sets the unique id of the node
  37915. */
  37916. uniqueId: number;
  37917. /**
  37918. * This observable will notify when one animation have ended
  37919. */
  37920. onAnimationEndObservable: Observable<TargetedAnimation>;
  37921. /**
  37922. * Observer raised when one animation loops
  37923. */
  37924. onAnimationLoopObservable: Observable<TargetedAnimation>;
  37925. /**
  37926. * Observer raised when all animations have looped
  37927. */
  37928. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  37929. /**
  37930. * This observable will notify when all animations have ended.
  37931. */
  37932. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  37933. /**
  37934. * This observable will notify when all animations have paused.
  37935. */
  37936. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  37937. /**
  37938. * This observable will notify when all animations are playing.
  37939. */
  37940. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  37941. /**
  37942. * Gets the first frame
  37943. */
  37944. get from(): number;
  37945. /**
  37946. * Gets the last frame
  37947. */
  37948. get to(): number;
  37949. /**
  37950. * Define if the animations are started
  37951. */
  37952. get isStarted(): boolean;
  37953. /**
  37954. * Gets a value indicating that the current group is playing
  37955. */
  37956. get isPlaying(): boolean;
  37957. /**
  37958. * Gets or sets the speed ratio to use for all animations
  37959. */
  37960. get speedRatio(): number;
  37961. /**
  37962. * Gets or sets the speed ratio to use for all animations
  37963. */
  37964. set speedRatio(value: number);
  37965. /**
  37966. * Gets or sets if all animations should loop or not
  37967. */
  37968. get loopAnimation(): boolean;
  37969. set loopAnimation(value: boolean);
  37970. /**
  37971. * Gets or sets if all animations should be evaluated additively
  37972. */
  37973. get isAdditive(): boolean;
  37974. set isAdditive(value: boolean);
  37975. /**
  37976. * Gets the targeted animations for this animation group
  37977. */
  37978. get targetedAnimations(): Array<TargetedAnimation>;
  37979. /**
  37980. * returning the list of animatables controlled by this animation group.
  37981. */
  37982. get animatables(): Array<Animatable>;
  37983. /**
  37984. * Instantiates a new Animation Group.
  37985. * This helps managing several animations at once.
  37986. * @see http://doc.babylonjs.com/how_to/group
  37987. * @param name Defines the name of the group
  37988. * @param scene Defines the scene the group belongs to
  37989. */
  37990. constructor(
  37991. /** The name of the animation group */
  37992. name: string, scene?: Nullable<Scene>);
  37993. /**
  37994. * Add an animation (with its target) in the group
  37995. * @param animation defines the animation we want to add
  37996. * @param target defines the target of the animation
  37997. * @returns the TargetedAnimation object
  37998. */
  37999. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38000. /**
  38001. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38002. * It can add constant keys at begin or end
  38003. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38004. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38005. * @returns the animation group
  38006. */
  38007. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38008. private _animationLoopCount;
  38009. private _animationLoopFlags;
  38010. private _processLoop;
  38011. /**
  38012. * Start all animations on given targets
  38013. * @param loop defines if animations must loop
  38014. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38015. * @param from defines the from key (optional)
  38016. * @param to defines the to key (optional)
  38017. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38018. * @returns the current animation group
  38019. */
  38020. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38021. /**
  38022. * Pause all animations
  38023. * @returns the animation group
  38024. */
  38025. pause(): AnimationGroup;
  38026. /**
  38027. * Play all animations to initial state
  38028. * This function will start() the animations if they were not started or will restart() them if they were paused
  38029. * @param loop defines if animations must loop
  38030. * @returns the animation group
  38031. */
  38032. play(loop?: boolean): AnimationGroup;
  38033. /**
  38034. * Reset all animations to initial state
  38035. * @returns the animation group
  38036. */
  38037. reset(): AnimationGroup;
  38038. /**
  38039. * Restart animations from key 0
  38040. * @returns the animation group
  38041. */
  38042. restart(): AnimationGroup;
  38043. /**
  38044. * Stop all animations
  38045. * @returns the animation group
  38046. */
  38047. stop(): AnimationGroup;
  38048. /**
  38049. * Set animation weight for all animatables
  38050. * @param weight defines the weight to use
  38051. * @return the animationGroup
  38052. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38053. */
  38054. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38055. /**
  38056. * Synchronize and normalize all animatables with a source animatable
  38057. * @param root defines the root animatable to synchronize with
  38058. * @return the animationGroup
  38059. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38060. */
  38061. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38062. /**
  38063. * Goes to a specific frame in this animation group
  38064. * @param frame the frame number to go to
  38065. * @return the animationGroup
  38066. */
  38067. goToFrame(frame: number): AnimationGroup;
  38068. /**
  38069. * Dispose all associated resources
  38070. */
  38071. dispose(): void;
  38072. private _checkAnimationGroupEnded;
  38073. /**
  38074. * Clone the current animation group and returns a copy
  38075. * @param newName defines the name of the new group
  38076. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38077. * @returns the new aniamtion group
  38078. */
  38079. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38080. /**
  38081. * Serializes the animationGroup to an object
  38082. * @returns Serialized object
  38083. */
  38084. serialize(): any;
  38085. /**
  38086. * Returns a new AnimationGroup object parsed from the source provided.
  38087. * @param parsedAnimationGroup defines the source
  38088. * @param scene defines the scene that will receive the animationGroup
  38089. * @returns a new AnimationGroup
  38090. */
  38091. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38092. /**
  38093. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38094. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38095. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38096. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38097. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38098. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38099. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38100. */
  38101. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38102. /**
  38103. * Returns the string "AnimationGroup"
  38104. * @returns "AnimationGroup"
  38105. */
  38106. getClassName(): string;
  38107. /**
  38108. * Creates a detailled string about the object
  38109. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38110. * @returns a string representing the object
  38111. */
  38112. toString(fullDetails?: boolean): string;
  38113. }
  38114. }
  38115. declare module BABYLON {
  38116. /**
  38117. * Define an interface for all classes that will hold resources
  38118. */
  38119. export interface IDisposable {
  38120. /**
  38121. * Releases all held resources
  38122. */
  38123. dispose(): void;
  38124. }
  38125. /** Interface defining initialization parameters for Scene class */
  38126. export interface SceneOptions {
  38127. /**
  38128. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38129. * It will improve performance when the number of geometries becomes important.
  38130. */
  38131. useGeometryUniqueIdsMap?: boolean;
  38132. /**
  38133. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38134. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38135. */
  38136. useMaterialMeshMap?: boolean;
  38137. /**
  38138. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38139. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38140. */
  38141. useClonedMeshMap?: boolean;
  38142. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38143. virtual?: boolean;
  38144. }
  38145. /**
  38146. * Represents a scene to be rendered by the engine.
  38147. * @see http://doc.babylonjs.com/features/scene
  38148. */
  38149. export class Scene extends AbstractScene implements IAnimatable {
  38150. /** The fog is deactivated */
  38151. static readonly FOGMODE_NONE: number;
  38152. /** The fog density is following an exponential function */
  38153. static readonly FOGMODE_EXP: number;
  38154. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38155. static readonly FOGMODE_EXP2: number;
  38156. /** The fog density is following a linear function. */
  38157. static readonly FOGMODE_LINEAR: number;
  38158. /**
  38159. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38160. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38161. */
  38162. static MinDeltaTime: number;
  38163. /**
  38164. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38165. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38166. */
  38167. static MaxDeltaTime: number;
  38168. /**
  38169. * Factory used to create the default material.
  38170. * @param name The name of the material to create
  38171. * @param scene The scene to create the material for
  38172. * @returns The default material
  38173. */
  38174. static DefaultMaterialFactory(scene: Scene): Material;
  38175. /**
  38176. * Factory used to create the a collision coordinator.
  38177. * @returns The collision coordinator
  38178. */
  38179. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38180. /** @hidden */
  38181. _inputManager: InputManager;
  38182. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38183. cameraToUseForPointers: Nullable<Camera>;
  38184. /** @hidden */
  38185. readonly _isScene: boolean;
  38186. /** @hidden */
  38187. _blockEntityCollection: boolean;
  38188. /**
  38189. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38190. */
  38191. autoClear: boolean;
  38192. /**
  38193. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38194. */
  38195. autoClearDepthAndStencil: boolean;
  38196. /**
  38197. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38198. */
  38199. clearColor: Color4;
  38200. /**
  38201. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38202. */
  38203. ambientColor: Color3;
  38204. /**
  38205. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38206. * It should only be one of the following (if not the default embedded one):
  38207. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38208. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38209. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38210. * The material properties need to be setup according to the type of texture in use.
  38211. */
  38212. environmentBRDFTexture: BaseTexture;
  38213. /** @hidden */
  38214. protected _environmentTexture: Nullable<BaseTexture>;
  38215. /**
  38216. * Texture used in all pbr material as the reflection texture.
  38217. * As in the majority of the scene they are the same (exception for multi room and so on),
  38218. * this is easier to reference from here than from all the materials.
  38219. */
  38220. get environmentTexture(): Nullable<BaseTexture>;
  38221. /**
  38222. * Texture used in all pbr material as the reflection texture.
  38223. * As in the majority of the scene they are the same (exception for multi room and so on),
  38224. * this is easier to set here than in all the materials.
  38225. */
  38226. set environmentTexture(value: Nullable<BaseTexture>);
  38227. /** @hidden */
  38228. protected _environmentIntensity: number;
  38229. /**
  38230. * Intensity of the environment in all pbr material.
  38231. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38232. * As in the majority of the scene they are the same (exception for multi room and so on),
  38233. * this is easier to reference from here than from all the materials.
  38234. */
  38235. get environmentIntensity(): number;
  38236. /**
  38237. * Intensity of the environment in all pbr material.
  38238. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38239. * As in the majority of the scene they are the same (exception for multi room and so on),
  38240. * this is easier to set here than in all the materials.
  38241. */
  38242. set environmentIntensity(value: number);
  38243. /** @hidden */
  38244. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38245. /**
  38246. * Default image processing configuration used either in the rendering
  38247. * Forward main pass or through the imageProcessingPostProcess if present.
  38248. * As in the majority of the scene they are the same (exception for multi camera),
  38249. * this is easier to reference from here than from all the materials and post process.
  38250. *
  38251. * No setter as we it is a shared configuration, you can set the values instead.
  38252. */
  38253. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38254. private _forceWireframe;
  38255. /**
  38256. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38257. */
  38258. set forceWireframe(value: boolean);
  38259. get forceWireframe(): boolean;
  38260. private _skipFrustumClipping;
  38261. /**
  38262. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38263. */
  38264. set skipFrustumClipping(value: boolean);
  38265. get skipFrustumClipping(): boolean;
  38266. private _forcePointsCloud;
  38267. /**
  38268. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38269. */
  38270. set forcePointsCloud(value: boolean);
  38271. get forcePointsCloud(): boolean;
  38272. /**
  38273. * Gets or sets the active clipplane 1
  38274. */
  38275. clipPlane: Nullable<Plane>;
  38276. /**
  38277. * Gets or sets the active clipplane 2
  38278. */
  38279. clipPlane2: Nullable<Plane>;
  38280. /**
  38281. * Gets or sets the active clipplane 3
  38282. */
  38283. clipPlane3: Nullable<Plane>;
  38284. /**
  38285. * Gets or sets the active clipplane 4
  38286. */
  38287. clipPlane4: Nullable<Plane>;
  38288. /**
  38289. * Gets or sets the active clipplane 5
  38290. */
  38291. clipPlane5: Nullable<Plane>;
  38292. /**
  38293. * Gets or sets the active clipplane 6
  38294. */
  38295. clipPlane6: Nullable<Plane>;
  38296. /**
  38297. * Gets or sets a boolean indicating if animations are enabled
  38298. */
  38299. animationsEnabled: boolean;
  38300. private _animationPropertiesOverride;
  38301. /**
  38302. * Gets or sets the animation properties override
  38303. */
  38304. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38305. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38306. /**
  38307. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38308. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38309. */
  38310. useConstantAnimationDeltaTime: boolean;
  38311. /**
  38312. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38313. * Please note that it requires to run a ray cast through the scene on every frame
  38314. */
  38315. constantlyUpdateMeshUnderPointer: boolean;
  38316. /**
  38317. * Defines the HTML cursor to use when hovering over interactive elements
  38318. */
  38319. hoverCursor: string;
  38320. /**
  38321. * Defines the HTML default cursor to use (empty by default)
  38322. */
  38323. defaultCursor: string;
  38324. /**
  38325. * Defines whether cursors are handled by the scene.
  38326. */
  38327. doNotHandleCursors: boolean;
  38328. /**
  38329. * This is used to call preventDefault() on pointer down
  38330. * in order to block unwanted artifacts like system double clicks
  38331. */
  38332. preventDefaultOnPointerDown: boolean;
  38333. /**
  38334. * This is used to call preventDefault() on pointer up
  38335. * in order to block unwanted artifacts like system double clicks
  38336. */
  38337. preventDefaultOnPointerUp: boolean;
  38338. /**
  38339. * Gets or sets user defined metadata
  38340. */
  38341. metadata: any;
  38342. /**
  38343. * For internal use only. Please do not use.
  38344. */
  38345. reservedDataStore: any;
  38346. /**
  38347. * Gets the name of the plugin used to load this scene (null by default)
  38348. */
  38349. loadingPluginName: string;
  38350. /**
  38351. * Use this array to add regular expressions used to disable offline support for specific urls
  38352. */
  38353. disableOfflineSupportExceptionRules: RegExp[];
  38354. /**
  38355. * An event triggered when the scene is disposed.
  38356. */
  38357. onDisposeObservable: Observable<Scene>;
  38358. private _onDisposeObserver;
  38359. /** Sets a function to be executed when this scene is disposed. */
  38360. set onDispose(callback: () => void);
  38361. /**
  38362. * An event triggered before rendering the scene (right after animations and physics)
  38363. */
  38364. onBeforeRenderObservable: Observable<Scene>;
  38365. private _onBeforeRenderObserver;
  38366. /** Sets a function to be executed before rendering this scene */
  38367. set beforeRender(callback: Nullable<() => void>);
  38368. /**
  38369. * An event triggered after rendering the scene
  38370. */
  38371. onAfterRenderObservable: Observable<Scene>;
  38372. /**
  38373. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38374. */
  38375. onAfterRenderCameraObservable: Observable<Camera>;
  38376. private _onAfterRenderObserver;
  38377. /** Sets a function to be executed after rendering this scene */
  38378. set afterRender(callback: Nullable<() => void>);
  38379. /**
  38380. * An event triggered before animating the scene
  38381. */
  38382. onBeforeAnimationsObservable: Observable<Scene>;
  38383. /**
  38384. * An event triggered after animations processing
  38385. */
  38386. onAfterAnimationsObservable: Observable<Scene>;
  38387. /**
  38388. * An event triggered before draw calls are ready to be sent
  38389. */
  38390. onBeforeDrawPhaseObservable: Observable<Scene>;
  38391. /**
  38392. * An event triggered after draw calls have been sent
  38393. */
  38394. onAfterDrawPhaseObservable: Observable<Scene>;
  38395. /**
  38396. * An event triggered when the scene is ready
  38397. */
  38398. onReadyObservable: Observable<Scene>;
  38399. /**
  38400. * An event triggered before rendering a camera
  38401. */
  38402. onBeforeCameraRenderObservable: Observable<Camera>;
  38403. private _onBeforeCameraRenderObserver;
  38404. /** Sets a function to be executed before rendering a camera*/
  38405. set beforeCameraRender(callback: () => void);
  38406. /**
  38407. * An event triggered after rendering a camera
  38408. */
  38409. onAfterCameraRenderObservable: Observable<Camera>;
  38410. private _onAfterCameraRenderObserver;
  38411. /** Sets a function to be executed after rendering a camera*/
  38412. set afterCameraRender(callback: () => void);
  38413. /**
  38414. * An event triggered when active meshes evaluation is about to start
  38415. */
  38416. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38417. /**
  38418. * An event triggered when active meshes evaluation is done
  38419. */
  38420. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38421. /**
  38422. * An event triggered when particles rendering is about to start
  38423. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38424. */
  38425. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38426. /**
  38427. * An event triggered when particles rendering is done
  38428. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38429. */
  38430. onAfterParticlesRenderingObservable: Observable<Scene>;
  38431. /**
  38432. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38433. */
  38434. onDataLoadedObservable: Observable<Scene>;
  38435. /**
  38436. * An event triggered when a camera is created
  38437. */
  38438. onNewCameraAddedObservable: Observable<Camera>;
  38439. /**
  38440. * An event triggered when a camera is removed
  38441. */
  38442. onCameraRemovedObservable: Observable<Camera>;
  38443. /**
  38444. * An event triggered when a light is created
  38445. */
  38446. onNewLightAddedObservable: Observable<Light>;
  38447. /**
  38448. * An event triggered when a light is removed
  38449. */
  38450. onLightRemovedObservable: Observable<Light>;
  38451. /**
  38452. * An event triggered when a geometry is created
  38453. */
  38454. onNewGeometryAddedObservable: Observable<Geometry>;
  38455. /**
  38456. * An event triggered when a geometry is removed
  38457. */
  38458. onGeometryRemovedObservable: Observable<Geometry>;
  38459. /**
  38460. * An event triggered when a transform node is created
  38461. */
  38462. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38463. /**
  38464. * An event triggered when a transform node is removed
  38465. */
  38466. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38467. /**
  38468. * An event triggered when a mesh is created
  38469. */
  38470. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38471. /**
  38472. * An event triggered when a mesh is removed
  38473. */
  38474. onMeshRemovedObservable: Observable<AbstractMesh>;
  38475. /**
  38476. * An event triggered when a skeleton is created
  38477. */
  38478. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38479. /**
  38480. * An event triggered when a skeleton is removed
  38481. */
  38482. onSkeletonRemovedObservable: Observable<Skeleton>;
  38483. /**
  38484. * An event triggered when a material is created
  38485. */
  38486. onNewMaterialAddedObservable: Observable<Material>;
  38487. /**
  38488. * An event triggered when a material is removed
  38489. */
  38490. onMaterialRemovedObservable: Observable<Material>;
  38491. /**
  38492. * An event triggered when a texture is created
  38493. */
  38494. onNewTextureAddedObservable: Observable<BaseTexture>;
  38495. /**
  38496. * An event triggered when a texture is removed
  38497. */
  38498. onTextureRemovedObservable: Observable<BaseTexture>;
  38499. /**
  38500. * An event triggered when render targets are about to be rendered
  38501. * Can happen multiple times per frame.
  38502. */
  38503. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38504. /**
  38505. * An event triggered when render targets were rendered.
  38506. * Can happen multiple times per frame.
  38507. */
  38508. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38509. /**
  38510. * An event triggered before calculating deterministic simulation step
  38511. */
  38512. onBeforeStepObservable: Observable<Scene>;
  38513. /**
  38514. * An event triggered after calculating deterministic simulation step
  38515. */
  38516. onAfterStepObservable: Observable<Scene>;
  38517. /**
  38518. * An event triggered when the activeCamera property is updated
  38519. */
  38520. onActiveCameraChanged: Observable<Scene>;
  38521. /**
  38522. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38523. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38524. * 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)
  38525. */
  38526. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38527. /**
  38528. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38529. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38530. * 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)
  38531. */
  38532. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38533. /**
  38534. * This Observable will when a mesh has been imported into the scene.
  38535. */
  38536. onMeshImportedObservable: Observable<AbstractMesh>;
  38537. /**
  38538. * This Observable will when an animation file has been imported into the scene.
  38539. */
  38540. onAnimationFileImportedObservable: Observable<Scene>;
  38541. /**
  38542. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38543. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38544. */
  38545. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38546. /** @hidden */
  38547. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38548. /**
  38549. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38550. */
  38551. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38552. /**
  38553. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38554. */
  38555. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38556. /**
  38557. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38558. */
  38559. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38560. /** Callback called when a pointer move is detected */
  38561. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38562. /** Callback called when a pointer down is detected */
  38563. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38564. /** Callback called when a pointer up is detected */
  38565. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38566. /** Callback called when a pointer pick is detected */
  38567. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38568. /**
  38569. * 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).
  38570. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38571. */
  38572. onPrePointerObservable: Observable<PointerInfoPre>;
  38573. /**
  38574. * Observable event triggered each time an input event is received from the rendering canvas
  38575. */
  38576. onPointerObservable: Observable<PointerInfo>;
  38577. /**
  38578. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38579. */
  38580. get unTranslatedPointer(): Vector2;
  38581. /**
  38582. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38583. */
  38584. static get DragMovementThreshold(): number;
  38585. static set DragMovementThreshold(value: number);
  38586. /**
  38587. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38588. */
  38589. static get LongPressDelay(): number;
  38590. static set LongPressDelay(value: number);
  38591. /**
  38592. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38593. */
  38594. static get DoubleClickDelay(): number;
  38595. static set DoubleClickDelay(value: number);
  38596. /** If you need to check double click without raising a single click at first click, enable this flag */
  38597. static get ExclusiveDoubleClickMode(): boolean;
  38598. static set ExclusiveDoubleClickMode(value: boolean);
  38599. /** @hidden */
  38600. _mirroredCameraPosition: Nullable<Vector3>;
  38601. /**
  38602. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38603. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38604. */
  38605. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38606. /**
  38607. * Observable event triggered each time an keyboard event is received from the hosting window
  38608. */
  38609. onKeyboardObservable: Observable<KeyboardInfo>;
  38610. private _useRightHandedSystem;
  38611. /**
  38612. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38613. */
  38614. set useRightHandedSystem(value: boolean);
  38615. get useRightHandedSystem(): boolean;
  38616. private _timeAccumulator;
  38617. private _currentStepId;
  38618. private _currentInternalStep;
  38619. /**
  38620. * Sets the step Id used by deterministic lock step
  38621. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38622. * @param newStepId defines the step Id
  38623. */
  38624. setStepId(newStepId: number): void;
  38625. /**
  38626. * Gets the step Id used by deterministic lock step
  38627. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38628. * @returns the step Id
  38629. */
  38630. getStepId(): number;
  38631. /**
  38632. * Gets the internal step used by deterministic lock step
  38633. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38634. * @returns the internal step
  38635. */
  38636. getInternalStep(): number;
  38637. private _fogEnabled;
  38638. /**
  38639. * Gets or sets a boolean indicating if fog is enabled on this scene
  38640. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38641. * (Default is true)
  38642. */
  38643. set fogEnabled(value: boolean);
  38644. get fogEnabled(): boolean;
  38645. private _fogMode;
  38646. /**
  38647. * Gets or sets the fog mode to use
  38648. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38649. * | mode | value |
  38650. * | --- | --- |
  38651. * | FOGMODE_NONE | 0 |
  38652. * | FOGMODE_EXP | 1 |
  38653. * | FOGMODE_EXP2 | 2 |
  38654. * | FOGMODE_LINEAR | 3 |
  38655. */
  38656. set fogMode(value: number);
  38657. get fogMode(): number;
  38658. /**
  38659. * Gets or sets the fog color to use
  38660. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38661. * (Default is Color3(0.2, 0.2, 0.3))
  38662. */
  38663. fogColor: Color3;
  38664. /**
  38665. * Gets or sets the fog density to use
  38666. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38667. * (Default is 0.1)
  38668. */
  38669. fogDensity: number;
  38670. /**
  38671. * Gets or sets the fog start distance to use
  38672. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38673. * (Default is 0)
  38674. */
  38675. fogStart: number;
  38676. /**
  38677. * Gets or sets the fog end distance to use
  38678. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38679. * (Default is 1000)
  38680. */
  38681. fogEnd: number;
  38682. private _shadowsEnabled;
  38683. /**
  38684. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38685. */
  38686. set shadowsEnabled(value: boolean);
  38687. get shadowsEnabled(): boolean;
  38688. private _lightsEnabled;
  38689. /**
  38690. * Gets or sets a boolean indicating if lights are enabled on this scene
  38691. */
  38692. set lightsEnabled(value: boolean);
  38693. get lightsEnabled(): boolean;
  38694. /** All of the active cameras added to this scene. */
  38695. activeCameras: Camera[];
  38696. /** @hidden */
  38697. _activeCamera: Nullable<Camera>;
  38698. /** Gets or sets the current active camera */
  38699. get activeCamera(): Nullable<Camera>;
  38700. set activeCamera(value: Nullable<Camera>);
  38701. private _defaultMaterial;
  38702. /** The default material used on meshes when no material is affected */
  38703. get defaultMaterial(): Material;
  38704. /** The default material used on meshes when no material is affected */
  38705. set defaultMaterial(value: Material);
  38706. private _texturesEnabled;
  38707. /**
  38708. * Gets or sets a boolean indicating if textures are enabled on this scene
  38709. */
  38710. set texturesEnabled(value: boolean);
  38711. get texturesEnabled(): boolean;
  38712. /**
  38713. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38714. */
  38715. physicsEnabled: boolean;
  38716. /**
  38717. * Gets or sets a boolean indicating if particles are enabled on this scene
  38718. */
  38719. particlesEnabled: boolean;
  38720. /**
  38721. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38722. */
  38723. spritesEnabled: boolean;
  38724. private _skeletonsEnabled;
  38725. /**
  38726. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38727. */
  38728. set skeletonsEnabled(value: boolean);
  38729. get skeletonsEnabled(): boolean;
  38730. /**
  38731. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38732. */
  38733. lensFlaresEnabled: boolean;
  38734. /**
  38735. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38736. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38737. */
  38738. collisionsEnabled: boolean;
  38739. private _collisionCoordinator;
  38740. /** @hidden */
  38741. get collisionCoordinator(): ICollisionCoordinator;
  38742. /**
  38743. * Defines the gravity applied to this scene (used only for collisions)
  38744. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38745. */
  38746. gravity: Vector3;
  38747. /**
  38748. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38749. */
  38750. postProcessesEnabled: boolean;
  38751. /**
  38752. * The list of postprocesses added to the scene
  38753. */
  38754. postProcesses: PostProcess[];
  38755. /**
  38756. * Gets the current postprocess manager
  38757. */
  38758. postProcessManager: PostProcessManager;
  38759. /**
  38760. * Gets or sets a boolean indicating if render targets are enabled on this scene
  38761. */
  38762. renderTargetsEnabled: boolean;
  38763. /**
  38764. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  38765. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  38766. */
  38767. dumpNextRenderTargets: boolean;
  38768. /**
  38769. * The list of user defined render targets added to the scene
  38770. */
  38771. customRenderTargets: RenderTargetTexture[];
  38772. /**
  38773. * Defines if texture loading must be delayed
  38774. * If true, textures will only be loaded when they need to be rendered
  38775. */
  38776. useDelayedTextureLoading: boolean;
  38777. /**
  38778. * Gets the list of meshes imported to the scene through SceneLoader
  38779. */
  38780. importedMeshesFiles: String[];
  38781. /**
  38782. * Gets or sets a boolean indicating if probes are enabled on this scene
  38783. */
  38784. probesEnabled: boolean;
  38785. /**
  38786. * Gets or sets the current offline provider to use to store scene data
  38787. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  38788. */
  38789. offlineProvider: IOfflineProvider;
  38790. /**
  38791. * Gets or sets the action manager associated with the scene
  38792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38793. */
  38794. actionManager: AbstractActionManager;
  38795. private _meshesForIntersections;
  38796. /**
  38797. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  38798. */
  38799. proceduralTexturesEnabled: boolean;
  38800. private _engine;
  38801. private _totalVertices;
  38802. /** @hidden */
  38803. _activeIndices: PerfCounter;
  38804. /** @hidden */
  38805. _activeParticles: PerfCounter;
  38806. /** @hidden */
  38807. _activeBones: PerfCounter;
  38808. private _animationRatio;
  38809. /** @hidden */
  38810. _animationTimeLast: number;
  38811. /** @hidden */
  38812. _animationTime: number;
  38813. /**
  38814. * Gets or sets a general scale for animation speed
  38815. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  38816. */
  38817. animationTimeScale: number;
  38818. /** @hidden */
  38819. _cachedMaterial: Nullable<Material>;
  38820. /** @hidden */
  38821. _cachedEffect: Nullable<Effect>;
  38822. /** @hidden */
  38823. _cachedVisibility: Nullable<number>;
  38824. private _renderId;
  38825. private _frameId;
  38826. private _executeWhenReadyTimeoutId;
  38827. private _intermediateRendering;
  38828. private _viewUpdateFlag;
  38829. private _projectionUpdateFlag;
  38830. /** @hidden */
  38831. _toBeDisposed: Nullable<IDisposable>[];
  38832. private _activeRequests;
  38833. /** @hidden */
  38834. _pendingData: any[];
  38835. private _isDisposed;
  38836. /**
  38837. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  38838. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  38839. */
  38840. dispatchAllSubMeshesOfActiveMeshes: boolean;
  38841. private _activeMeshes;
  38842. private _processedMaterials;
  38843. private _renderTargets;
  38844. /** @hidden */
  38845. _activeParticleSystems: SmartArray<IParticleSystem>;
  38846. private _activeSkeletons;
  38847. private _softwareSkinnedMeshes;
  38848. private _renderingManager;
  38849. /** @hidden */
  38850. _activeAnimatables: Animatable[];
  38851. private _transformMatrix;
  38852. private _sceneUbo;
  38853. /** @hidden */
  38854. _viewMatrix: Matrix;
  38855. private _projectionMatrix;
  38856. /** @hidden */
  38857. _forcedViewPosition: Nullable<Vector3>;
  38858. /** @hidden */
  38859. _frustumPlanes: Plane[];
  38860. /**
  38861. * Gets the list of frustum planes (built from the active camera)
  38862. */
  38863. get frustumPlanes(): Plane[];
  38864. /**
  38865. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  38866. * This is useful if there are more lights that the maximum simulteanous authorized
  38867. */
  38868. requireLightSorting: boolean;
  38869. /** @hidden */
  38870. readonly useMaterialMeshMap: boolean;
  38871. /** @hidden */
  38872. readonly useClonedMeshMap: boolean;
  38873. private _externalData;
  38874. private _uid;
  38875. /**
  38876. * @hidden
  38877. * Backing store of defined scene components.
  38878. */
  38879. _components: ISceneComponent[];
  38880. /**
  38881. * @hidden
  38882. * Backing store of defined scene components.
  38883. */
  38884. _serializableComponents: ISceneSerializableComponent[];
  38885. /**
  38886. * List of components to register on the next registration step.
  38887. */
  38888. private _transientComponents;
  38889. /**
  38890. * Registers the transient components if needed.
  38891. */
  38892. private _registerTransientComponents;
  38893. /**
  38894. * @hidden
  38895. * Add a component to the scene.
  38896. * Note that the ccomponent could be registered on th next frame if this is called after
  38897. * the register component stage.
  38898. * @param component Defines the component to add to the scene
  38899. */
  38900. _addComponent(component: ISceneComponent): void;
  38901. /**
  38902. * @hidden
  38903. * Gets a component from the scene.
  38904. * @param name defines the name of the component to retrieve
  38905. * @returns the component or null if not present
  38906. */
  38907. _getComponent(name: string): Nullable<ISceneComponent>;
  38908. /**
  38909. * @hidden
  38910. * Defines the actions happening before camera updates.
  38911. */
  38912. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  38913. /**
  38914. * @hidden
  38915. * Defines the actions happening before clear the canvas.
  38916. */
  38917. _beforeClearStage: Stage<SimpleStageAction>;
  38918. /**
  38919. * @hidden
  38920. * Defines the actions when collecting render targets for the frame.
  38921. */
  38922. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38923. /**
  38924. * @hidden
  38925. * Defines the actions happening for one camera in the frame.
  38926. */
  38927. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38928. /**
  38929. * @hidden
  38930. * Defines the actions happening during the per mesh ready checks.
  38931. */
  38932. _isReadyForMeshStage: Stage<MeshStageAction>;
  38933. /**
  38934. * @hidden
  38935. * Defines the actions happening before evaluate active mesh checks.
  38936. */
  38937. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  38938. /**
  38939. * @hidden
  38940. * Defines the actions happening during the evaluate sub mesh checks.
  38941. */
  38942. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  38943. /**
  38944. * @hidden
  38945. * Defines the actions happening during the active mesh stage.
  38946. */
  38947. _activeMeshStage: Stage<ActiveMeshStageAction>;
  38948. /**
  38949. * @hidden
  38950. * Defines the actions happening during the per camera render target step.
  38951. */
  38952. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  38953. /**
  38954. * @hidden
  38955. * Defines the actions happening just before the active camera is drawing.
  38956. */
  38957. _beforeCameraDrawStage: Stage<CameraStageAction>;
  38958. /**
  38959. * @hidden
  38960. * Defines the actions happening just before a render target is drawing.
  38961. */
  38962. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38963. /**
  38964. * @hidden
  38965. * Defines the actions happening just before a rendering group is drawing.
  38966. */
  38967. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38968. /**
  38969. * @hidden
  38970. * Defines the actions happening just before a mesh is drawing.
  38971. */
  38972. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38973. /**
  38974. * @hidden
  38975. * Defines the actions happening just after a mesh has been drawn.
  38976. */
  38977. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38978. /**
  38979. * @hidden
  38980. * Defines the actions happening just after a rendering group has been drawn.
  38981. */
  38982. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38983. /**
  38984. * @hidden
  38985. * Defines the actions happening just after the active camera has been drawn.
  38986. */
  38987. _afterCameraDrawStage: Stage<CameraStageAction>;
  38988. /**
  38989. * @hidden
  38990. * Defines the actions happening just after a render target has been drawn.
  38991. */
  38992. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38993. /**
  38994. * @hidden
  38995. * Defines the actions happening just after rendering all cameras and computing intersections.
  38996. */
  38997. _afterRenderStage: Stage<SimpleStageAction>;
  38998. /**
  38999. * @hidden
  39000. * Defines the actions happening when a pointer move event happens.
  39001. */
  39002. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39003. /**
  39004. * @hidden
  39005. * Defines the actions happening when a pointer down event happens.
  39006. */
  39007. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39008. /**
  39009. * @hidden
  39010. * Defines the actions happening when a pointer up event happens.
  39011. */
  39012. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39013. /**
  39014. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39015. */
  39016. private geometriesByUniqueId;
  39017. /**
  39018. * Creates a new Scene
  39019. * @param engine defines the engine to use to render this scene
  39020. * @param options defines the scene options
  39021. */
  39022. constructor(engine: Engine, options?: SceneOptions);
  39023. /**
  39024. * Gets a string idenfifying the name of the class
  39025. * @returns "Scene" string
  39026. */
  39027. getClassName(): string;
  39028. private _defaultMeshCandidates;
  39029. /**
  39030. * @hidden
  39031. */
  39032. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39033. private _defaultSubMeshCandidates;
  39034. /**
  39035. * @hidden
  39036. */
  39037. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39038. /**
  39039. * Sets the default candidate providers for the scene.
  39040. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39041. * and getCollidingSubMeshCandidates to their default function
  39042. */
  39043. setDefaultCandidateProviders(): void;
  39044. /**
  39045. * Gets the mesh that is currently under the pointer
  39046. */
  39047. get meshUnderPointer(): Nullable<AbstractMesh>;
  39048. /**
  39049. * Gets or sets the current on-screen X position of the pointer
  39050. */
  39051. get pointerX(): number;
  39052. set pointerX(value: number);
  39053. /**
  39054. * Gets or sets the current on-screen Y position of the pointer
  39055. */
  39056. get pointerY(): number;
  39057. set pointerY(value: number);
  39058. /**
  39059. * Gets the cached material (ie. the latest rendered one)
  39060. * @returns the cached material
  39061. */
  39062. getCachedMaterial(): Nullable<Material>;
  39063. /**
  39064. * Gets the cached effect (ie. the latest rendered one)
  39065. * @returns the cached effect
  39066. */
  39067. getCachedEffect(): Nullable<Effect>;
  39068. /**
  39069. * Gets the cached visibility state (ie. the latest rendered one)
  39070. * @returns the cached visibility state
  39071. */
  39072. getCachedVisibility(): Nullable<number>;
  39073. /**
  39074. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39075. * @param material defines the current material
  39076. * @param effect defines the current effect
  39077. * @param visibility defines the current visibility state
  39078. * @returns true if one parameter is not cached
  39079. */
  39080. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39081. /**
  39082. * Gets the engine associated with the scene
  39083. * @returns an Engine
  39084. */
  39085. getEngine(): Engine;
  39086. /**
  39087. * Gets the total number of vertices rendered per frame
  39088. * @returns the total number of vertices rendered per frame
  39089. */
  39090. getTotalVertices(): number;
  39091. /**
  39092. * Gets the performance counter for total vertices
  39093. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39094. */
  39095. get totalVerticesPerfCounter(): PerfCounter;
  39096. /**
  39097. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39098. * @returns the total number of active indices rendered per frame
  39099. */
  39100. getActiveIndices(): number;
  39101. /**
  39102. * Gets the performance counter for active indices
  39103. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39104. */
  39105. get totalActiveIndicesPerfCounter(): PerfCounter;
  39106. /**
  39107. * Gets the total number of active particles rendered per frame
  39108. * @returns the total number of active particles rendered per frame
  39109. */
  39110. getActiveParticles(): number;
  39111. /**
  39112. * Gets the performance counter for active particles
  39113. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39114. */
  39115. get activeParticlesPerfCounter(): PerfCounter;
  39116. /**
  39117. * Gets the total number of active bones rendered per frame
  39118. * @returns the total number of active bones rendered per frame
  39119. */
  39120. getActiveBones(): number;
  39121. /**
  39122. * Gets the performance counter for active bones
  39123. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39124. */
  39125. get activeBonesPerfCounter(): PerfCounter;
  39126. /**
  39127. * Gets the array of active meshes
  39128. * @returns an array of AbstractMesh
  39129. */
  39130. getActiveMeshes(): SmartArray<AbstractMesh>;
  39131. /**
  39132. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39133. * @returns a number
  39134. */
  39135. getAnimationRatio(): number;
  39136. /**
  39137. * Gets an unique Id for the current render phase
  39138. * @returns a number
  39139. */
  39140. getRenderId(): number;
  39141. /**
  39142. * Gets an unique Id for the current frame
  39143. * @returns a number
  39144. */
  39145. getFrameId(): number;
  39146. /** Call this function if you want to manually increment the render Id*/
  39147. incrementRenderId(): void;
  39148. private _createUbo;
  39149. /**
  39150. * Use this method to simulate a pointer move on a mesh
  39151. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39152. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39153. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39154. * @returns the current scene
  39155. */
  39156. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39157. /**
  39158. * Use this method to simulate a pointer down on a mesh
  39159. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39160. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39161. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39162. * @returns the current scene
  39163. */
  39164. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39165. /**
  39166. * Use this method to simulate a pointer up on a mesh
  39167. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39168. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39169. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39170. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39171. * @returns the current scene
  39172. */
  39173. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39174. /**
  39175. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39176. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39177. * @returns true if the pointer was captured
  39178. */
  39179. isPointerCaptured(pointerId?: number): boolean;
  39180. /**
  39181. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39182. * @param attachUp defines if you want to attach events to pointerup
  39183. * @param attachDown defines if you want to attach events to pointerdown
  39184. * @param attachMove defines if you want to attach events to pointermove
  39185. */
  39186. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39187. /** Detaches all event handlers*/
  39188. detachControl(): void;
  39189. /**
  39190. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39191. * Delay loaded resources are not taking in account
  39192. * @return true if all required resources are ready
  39193. */
  39194. isReady(): boolean;
  39195. /** Resets all cached information relative to material (including effect and visibility) */
  39196. resetCachedMaterial(): void;
  39197. /**
  39198. * Registers a function to be called before every frame render
  39199. * @param func defines the function to register
  39200. */
  39201. registerBeforeRender(func: () => void): void;
  39202. /**
  39203. * Unregisters a function called before every frame render
  39204. * @param func defines the function to unregister
  39205. */
  39206. unregisterBeforeRender(func: () => void): void;
  39207. /**
  39208. * Registers a function to be called after every frame render
  39209. * @param func defines the function to register
  39210. */
  39211. registerAfterRender(func: () => void): void;
  39212. /**
  39213. * Unregisters a function called after every frame render
  39214. * @param func defines the function to unregister
  39215. */
  39216. unregisterAfterRender(func: () => void): void;
  39217. private _executeOnceBeforeRender;
  39218. /**
  39219. * The provided function will run before render once and will be disposed afterwards.
  39220. * A timeout delay can be provided so that the function will be executed in N ms.
  39221. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39222. * @param func The function to be executed.
  39223. * @param timeout optional delay in ms
  39224. */
  39225. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39226. /** @hidden */
  39227. _addPendingData(data: any): void;
  39228. /** @hidden */
  39229. _removePendingData(data: any): void;
  39230. /**
  39231. * Returns the number of items waiting to be loaded
  39232. * @returns the number of items waiting to be loaded
  39233. */
  39234. getWaitingItemsCount(): number;
  39235. /**
  39236. * Returns a boolean indicating if the scene is still loading data
  39237. */
  39238. get isLoading(): boolean;
  39239. /**
  39240. * Registers a function to be executed when the scene is ready
  39241. * @param {Function} func - the function to be executed
  39242. */
  39243. executeWhenReady(func: () => void): void;
  39244. /**
  39245. * Returns a promise that resolves when the scene is ready
  39246. * @returns A promise that resolves when the scene is ready
  39247. */
  39248. whenReadyAsync(): Promise<void>;
  39249. /** @hidden */
  39250. _checkIsReady(): void;
  39251. /**
  39252. * Gets all animatable attached to the scene
  39253. */
  39254. get animatables(): Animatable[];
  39255. /**
  39256. * Resets the last animation time frame.
  39257. * Useful to override when animations start running when loading a scene for the first time.
  39258. */
  39259. resetLastAnimationTimeFrame(): void;
  39260. /**
  39261. * Gets the current view matrix
  39262. * @returns a Matrix
  39263. */
  39264. getViewMatrix(): Matrix;
  39265. /**
  39266. * Gets the current projection matrix
  39267. * @returns a Matrix
  39268. */
  39269. getProjectionMatrix(): Matrix;
  39270. /**
  39271. * Gets the current transform matrix
  39272. * @returns a Matrix made of View * Projection
  39273. */
  39274. getTransformMatrix(): Matrix;
  39275. /**
  39276. * Sets the current transform matrix
  39277. * @param viewL defines the View matrix to use
  39278. * @param projectionL defines the Projection matrix to use
  39279. * @param viewR defines the right View matrix to use (if provided)
  39280. * @param projectionR defines the right Projection matrix to use (if provided)
  39281. */
  39282. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39283. /**
  39284. * Gets the uniform buffer used to store scene data
  39285. * @returns a UniformBuffer
  39286. */
  39287. getSceneUniformBuffer(): UniformBuffer;
  39288. /**
  39289. * Gets an unique (relatively to the current scene) Id
  39290. * @returns an unique number for the scene
  39291. */
  39292. getUniqueId(): number;
  39293. /**
  39294. * Add a mesh to the list of scene's meshes
  39295. * @param newMesh defines the mesh to add
  39296. * @param recursive if all child meshes should also be added to the scene
  39297. */
  39298. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39299. /**
  39300. * Remove a mesh for the list of scene's meshes
  39301. * @param toRemove defines the mesh to remove
  39302. * @param recursive if all child meshes should also be removed from the scene
  39303. * @returns the index where the mesh was in the mesh list
  39304. */
  39305. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39306. /**
  39307. * Add a transform node to the list of scene's transform nodes
  39308. * @param newTransformNode defines the transform node to add
  39309. */
  39310. addTransformNode(newTransformNode: TransformNode): void;
  39311. /**
  39312. * Remove a transform node for the list of scene's transform nodes
  39313. * @param toRemove defines the transform node to remove
  39314. * @returns the index where the transform node was in the transform node list
  39315. */
  39316. removeTransformNode(toRemove: TransformNode): number;
  39317. /**
  39318. * Remove a skeleton for the list of scene's skeletons
  39319. * @param toRemove defines the skeleton to remove
  39320. * @returns the index where the skeleton was in the skeleton list
  39321. */
  39322. removeSkeleton(toRemove: Skeleton): number;
  39323. /**
  39324. * Remove a morph target for the list of scene's morph targets
  39325. * @param toRemove defines the morph target to remove
  39326. * @returns the index where the morph target was in the morph target list
  39327. */
  39328. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39329. /**
  39330. * Remove a light for the list of scene's lights
  39331. * @param toRemove defines the light to remove
  39332. * @returns the index where the light was in the light list
  39333. */
  39334. removeLight(toRemove: Light): number;
  39335. /**
  39336. * Remove a camera for the list of scene's cameras
  39337. * @param toRemove defines the camera to remove
  39338. * @returns the index where the camera was in the camera list
  39339. */
  39340. removeCamera(toRemove: Camera): number;
  39341. /**
  39342. * Remove a particle system for the list of scene's particle systems
  39343. * @param toRemove defines the particle system to remove
  39344. * @returns the index where the particle system was in the particle system list
  39345. */
  39346. removeParticleSystem(toRemove: IParticleSystem): number;
  39347. /**
  39348. * Remove a animation for the list of scene's animations
  39349. * @param toRemove defines the animation to remove
  39350. * @returns the index where the animation was in the animation list
  39351. */
  39352. removeAnimation(toRemove: Animation): number;
  39353. /**
  39354. * Will stop the animation of the given target
  39355. * @param target - the target
  39356. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39357. * @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)
  39358. */
  39359. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39360. /**
  39361. * Removes the given animation group from this scene.
  39362. * @param toRemove The animation group to remove
  39363. * @returns The index of the removed animation group
  39364. */
  39365. removeAnimationGroup(toRemove: AnimationGroup): number;
  39366. /**
  39367. * Removes the given multi-material from this scene.
  39368. * @param toRemove The multi-material to remove
  39369. * @returns The index of the removed multi-material
  39370. */
  39371. removeMultiMaterial(toRemove: MultiMaterial): number;
  39372. /**
  39373. * Removes the given material from this scene.
  39374. * @param toRemove The material to remove
  39375. * @returns The index of the removed material
  39376. */
  39377. removeMaterial(toRemove: Material): number;
  39378. /**
  39379. * Removes the given action manager from this scene.
  39380. * @param toRemove The action manager to remove
  39381. * @returns The index of the removed action manager
  39382. */
  39383. removeActionManager(toRemove: AbstractActionManager): number;
  39384. /**
  39385. * Removes the given texture from this scene.
  39386. * @param toRemove The texture to remove
  39387. * @returns The index of the removed texture
  39388. */
  39389. removeTexture(toRemove: BaseTexture): number;
  39390. /**
  39391. * Adds the given light to this scene
  39392. * @param newLight The light to add
  39393. */
  39394. addLight(newLight: Light): void;
  39395. /**
  39396. * Sorts the list list based on light priorities
  39397. */
  39398. sortLightsByPriority(): void;
  39399. /**
  39400. * Adds the given camera to this scene
  39401. * @param newCamera The camera to add
  39402. */
  39403. addCamera(newCamera: Camera): void;
  39404. /**
  39405. * Adds the given skeleton to this scene
  39406. * @param newSkeleton The skeleton to add
  39407. */
  39408. addSkeleton(newSkeleton: Skeleton): void;
  39409. /**
  39410. * Adds the given particle system to this scene
  39411. * @param newParticleSystem The particle system to add
  39412. */
  39413. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39414. /**
  39415. * Adds the given animation to this scene
  39416. * @param newAnimation The animation to add
  39417. */
  39418. addAnimation(newAnimation: Animation): void;
  39419. /**
  39420. * Adds the given animation group to this scene.
  39421. * @param newAnimationGroup The animation group to add
  39422. */
  39423. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39424. /**
  39425. * Adds the given multi-material to this scene
  39426. * @param newMultiMaterial The multi-material to add
  39427. */
  39428. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39429. /**
  39430. * Adds the given material to this scene
  39431. * @param newMaterial The material to add
  39432. */
  39433. addMaterial(newMaterial: Material): void;
  39434. /**
  39435. * Adds the given morph target to this scene
  39436. * @param newMorphTargetManager The morph target to add
  39437. */
  39438. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39439. /**
  39440. * Adds the given geometry to this scene
  39441. * @param newGeometry The geometry to add
  39442. */
  39443. addGeometry(newGeometry: Geometry): void;
  39444. /**
  39445. * Adds the given action manager to this scene
  39446. * @param newActionManager The action manager to add
  39447. */
  39448. addActionManager(newActionManager: AbstractActionManager): void;
  39449. /**
  39450. * Adds the given texture to this scene.
  39451. * @param newTexture The texture to add
  39452. */
  39453. addTexture(newTexture: BaseTexture): void;
  39454. /**
  39455. * Switch active camera
  39456. * @param newCamera defines the new active camera
  39457. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39458. */
  39459. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39460. /**
  39461. * sets the active camera of the scene using its ID
  39462. * @param id defines the camera's ID
  39463. * @return the new active camera or null if none found.
  39464. */
  39465. setActiveCameraByID(id: string): Nullable<Camera>;
  39466. /**
  39467. * sets the active camera of the scene using its name
  39468. * @param name defines the camera's name
  39469. * @returns the new active camera or null if none found.
  39470. */
  39471. setActiveCameraByName(name: string): Nullable<Camera>;
  39472. /**
  39473. * get an animation group using its name
  39474. * @param name defines the material's name
  39475. * @return the animation group or null if none found.
  39476. */
  39477. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39478. /**
  39479. * Get a material using its unique id
  39480. * @param uniqueId defines the material's unique id
  39481. * @return the material or null if none found.
  39482. */
  39483. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39484. /**
  39485. * get a material using its id
  39486. * @param id defines the material's ID
  39487. * @return the material or null if none found.
  39488. */
  39489. getMaterialByID(id: string): Nullable<Material>;
  39490. /**
  39491. * Gets a the last added material using a given id
  39492. * @param id defines the material's ID
  39493. * @return the last material with the given id or null if none found.
  39494. */
  39495. getLastMaterialByID(id: string): Nullable<Material>;
  39496. /**
  39497. * Gets a material using its name
  39498. * @param name defines the material's name
  39499. * @return the material or null if none found.
  39500. */
  39501. getMaterialByName(name: string): Nullable<Material>;
  39502. /**
  39503. * Get a texture using its unique id
  39504. * @param uniqueId defines the texture's unique id
  39505. * @return the texture or null if none found.
  39506. */
  39507. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39508. /**
  39509. * Gets a camera using its id
  39510. * @param id defines the id to look for
  39511. * @returns the camera or null if not found
  39512. */
  39513. getCameraByID(id: string): Nullable<Camera>;
  39514. /**
  39515. * Gets a camera using its unique id
  39516. * @param uniqueId defines the unique id to look for
  39517. * @returns the camera or null if not found
  39518. */
  39519. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39520. /**
  39521. * Gets a camera using its name
  39522. * @param name defines the camera's name
  39523. * @return the camera or null if none found.
  39524. */
  39525. getCameraByName(name: string): Nullable<Camera>;
  39526. /**
  39527. * Gets a bone using its id
  39528. * @param id defines the bone's id
  39529. * @return the bone or null if not found
  39530. */
  39531. getBoneByID(id: string): Nullable<Bone>;
  39532. /**
  39533. * Gets a bone using its id
  39534. * @param name defines the bone's name
  39535. * @return the bone or null if not found
  39536. */
  39537. getBoneByName(name: string): Nullable<Bone>;
  39538. /**
  39539. * Gets a light node using its name
  39540. * @param name defines the the light's name
  39541. * @return the light or null if none found.
  39542. */
  39543. getLightByName(name: string): Nullable<Light>;
  39544. /**
  39545. * Gets a light node using its id
  39546. * @param id defines the light's id
  39547. * @return the light or null if none found.
  39548. */
  39549. getLightByID(id: string): Nullable<Light>;
  39550. /**
  39551. * Gets a light node using its scene-generated unique ID
  39552. * @param uniqueId defines the light's unique id
  39553. * @return the light or null if none found.
  39554. */
  39555. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39556. /**
  39557. * Gets a particle system by id
  39558. * @param id defines the particle system id
  39559. * @return the corresponding system or null if none found
  39560. */
  39561. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39562. /**
  39563. * Gets a geometry using its ID
  39564. * @param id defines the geometry's id
  39565. * @return the geometry or null if none found.
  39566. */
  39567. getGeometryByID(id: string): Nullable<Geometry>;
  39568. private _getGeometryByUniqueID;
  39569. /**
  39570. * Add a new geometry to this scene
  39571. * @param geometry defines the geometry to be added to the scene.
  39572. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39573. * @return a boolean defining if the geometry was added or not
  39574. */
  39575. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39576. /**
  39577. * Removes an existing geometry
  39578. * @param geometry defines the geometry to be removed from the scene
  39579. * @return a boolean defining if the geometry was removed or not
  39580. */
  39581. removeGeometry(geometry: Geometry): boolean;
  39582. /**
  39583. * Gets the list of geometries attached to the scene
  39584. * @returns an array of Geometry
  39585. */
  39586. getGeometries(): Geometry[];
  39587. /**
  39588. * Gets the first added mesh found of a given ID
  39589. * @param id defines the id to search for
  39590. * @return the mesh found or null if not found at all
  39591. */
  39592. getMeshByID(id: string): Nullable<AbstractMesh>;
  39593. /**
  39594. * Gets a list of meshes using their id
  39595. * @param id defines the id to search for
  39596. * @returns a list of meshes
  39597. */
  39598. getMeshesByID(id: string): Array<AbstractMesh>;
  39599. /**
  39600. * Gets the first added transform node found of a given ID
  39601. * @param id defines the id to search for
  39602. * @return the found transform node or null if not found at all.
  39603. */
  39604. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39605. /**
  39606. * Gets a transform node with its auto-generated unique id
  39607. * @param uniqueId efines the unique id to search for
  39608. * @return the found transform node or null if not found at all.
  39609. */
  39610. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39611. /**
  39612. * Gets a list of transform nodes using their id
  39613. * @param id defines the id to search for
  39614. * @returns a list of transform nodes
  39615. */
  39616. getTransformNodesByID(id: string): Array<TransformNode>;
  39617. /**
  39618. * Gets a mesh with its auto-generated unique id
  39619. * @param uniqueId defines the unique id to search for
  39620. * @return the found mesh or null if not found at all.
  39621. */
  39622. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39623. /**
  39624. * Gets a the last added mesh using a given id
  39625. * @param id defines the id to search for
  39626. * @return the found mesh or null if not found at all.
  39627. */
  39628. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39629. /**
  39630. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39631. * @param id defines the id to search for
  39632. * @return the found node or null if not found at all
  39633. */
  39634. getLastEntryByID(id: string): Nullable<Node>;
  39635. /**
  39636. * Gets a node (Mesh, Camera, Light) using a given id
  39637. * @param id defines the id to search for
  39638. * @return the found node or null if not found at all
  39639. */
  39640. getNodeByID(id: string): Nullable<Node>;
  39641. /**
  39642. * Gets a node (Mesh, Camera, Light) using a given name
  39643. * @param name defines the name to search for
  39644. * @return the found node or null if not found at all.
  39645. */
  39646. getNodeByName(name: string): Nullable<Node>;
  39647. /**
  39648. * Gets a mesh using a given name
  39649. * @param name defines the name to search for
  39650. * @return the found mesh or null if not found at all.
  39651. */
  39652. getMeshByName(name: string): Nullable<AbstractMesh>;
  39653. /**
  39654. * Gets a transform node using a given name
  39655. * @param name defines the name to search for
  39656. * @return the found transform node or null if not found at all.
  39657. */
  39658. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39659. /**
  39660. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39661. * @param id defines the id to search for
  39662. * @return the found skeleton or null if not found at all.
  39663. */
  39664. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39665. /**
  39666. * Gets a skeleton using a given auto generated unique id
  39667. * @param uniqueId defines the unique id to search for
  39668. * @return the found skeleton or null if not found at all.
  39669. */
  39670. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39671. /**
  39672. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39673. * @param id defines the id to search for
  39674. * @return the found skeleton or null if not found at all.
  39675. */
  39676. getSkeletonById(id: string): Nullable<Skeleton>;
  39677. /**
  39678. * Gets a skeleton using a given name
  39679. * @param name defines the name to search for
  39680. * @return the found skeleton or null if not found at all.
  39681. */
  39682. getSkeletonByName(name: string): Nullable<Skeleton>;
  39683. /**
  39684. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39685. * @param id defines the id to search for
  39686. * @return the found morph target manager or null if not found at all.
  39687. */
  39688. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39689. /**
  39690. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39691. * @param id defines the id to search for
  39692. * @return the found morph target or null if not found at all.
  39693. */
  39694. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39695. /**
  39696. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39697. * @param name defines the name to search for
  39698. * @return the found morph target or null if not found at all.
  39699. */
  39700. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39701. /**
  39702. * Gets a boolean indicating if the given mesh is active
  39703. * @param mesh defines the mesh to look for
  39704. * @returns true if the mesh is in the active list
  39705. */
  39706. isActiveMesh(mesh: AbstractMesh): boolean;
  39707. /**
  39708. * Return a unique id as a string which can serve as an identifier for the scene
  39709. */
  39710. get uid(): string;
  39711. /**
  39712. * Add an externaly attached data from its key.
  39713. * This method call will fail and return false, if such key already exists.
  39714. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39715. * @param key the unique key that identifies the data
  39716. * @param data the data object to associate to the key for this Engine instance
  39717. * @return true if no such key were already present and the data was added successfully, false otherwise
  39718. */
  39719. addExternalData<T>(key: string, data: T): boolean;
  39720. /**
  39721. * Get an externaly attached data from its key
  39722. * @param key the unique key that identifies the data
  39723. * @return the associated data, if present (can be null), or undefined if not present
  39724. */
  39725. getExternalData<T>(key: string): Nullable<T>;
  39726. /**
  39727. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39728. * @param key the unique key that identifies the data
  39729. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39730. * @return the associated data, can be null if the factory returned null.
  39731. */
  39732. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39733. /**
  39734. * Remove an externaly attached data from the Engine instance
  39735. * @param key the unique key that identifies the data
  39736. * @return true if the data was successfully removed, false if it doesn't exist
  39737. */
  39738. removeExternalData(key: string): boolean;
  39739. private _evaluateSubMesh;
  39740. /**
  39741. * Clear the processed materials smart array preventing retention point in material dispose.
  39742. */
  39743. freeProcessedMaterials(): void;
  39744. private _preventFreeActiveMeshesAndRenderingGroups;
  39745. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39746. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39747. * when disposing several meshes in a row or a hierarchy of meshes.
  39748. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39749. */
  39750. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39751. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39752. /**
  39753. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39754. */
  39755. freeActiveMeshes(): void;
  39756. /**
  39757. * Clear the info related to rendering groups preventing retention points during dispose.
  39758. */
  39759. freeRenderingGroups(): void;
  39760. /** @hidden */
  39761. _isInIntermediateRendering(): boolean;
  39762. /**
  39763. * Lambda returning the list of potentially active meshes.
  39764. */
  39765. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  39766. /**
  39767. * Lambda returning the list of potentially active sub meshes.
  39768. */
  39769. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  39770. /**
  39771. * Lambda returning the list of potentially intersecting sub meshes.
  39772. */
  39773. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  39774. /**
  39775. * Lambda returning the list of potentially colliding sub meshes.
  39776. */
  39777. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  39778. private _activeMeshesFrozen;
  39779. private _skipEvaluateActiveMeshesCompletely;
  39780. /**
  39781. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  39782. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  39783. * @returns the current scene
  39784. */
  39785. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  39786. /**
  39787. * Use this function to restart evaluating active meshes on every frame
  39788. * @returns the current scene
  39789. */
  39790. unfreezeActiveMeshes(): Scene;
  39791. private _evaluateActiveMeshes;
  39792. private _activeMesh;
  39793. /**
  39794. * Update the transform matrix to update from the current active camera
  39795. * @param force defines a boolean used to force the update even if cache is up to date
  39796. */
  39797. updateTransformMatrix(force?: boolean): void;
  39798. private _bindFrameBuffer;
  39799. /** @hidden */
  39800. _allowPostProcessClearColor: boolean;
  39801. /** @hidden */
  39802. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  39803. private _processSubCameras;
  39804. private _checkIntersections;
  39805. /** @hidden */
  39806. _advancePhysicsEngineStep(step: number): void;
  39807. /**
  39808. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  39809. */
  39810. getDeterministicFrameTime: () => number;
  39811. /** @hidden */
  39812. _animate(): void;
  39813. /** Execute all animations (for a frame) */
  39814. animate(): void;
  39815. /**
  39816. * Render the scene
  39817. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  39818. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  39819. */
  39820. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  39821. /**
  39822. * Freeze all materials
  39823. * A frozen material will not be updatable but should be faster to render
  39824. */
  39825. freezeMaterials(): void;
  39826. /**
  39827. * Unfreeze all materials
  39828. * A frozen material will not be updatable but should be faster to render
  39829. */
  39830. unfreezeMaterials(): void;
  39831. /**
  39832. * Releases all held ressources
  39833. */
  39834. dispose(): void;
  39835. /**
  39836. * Gets if the scene is already disposed
  39837. */
  39838. get isDisposed(): boolean;
  39839. /**
  39840. * Call this function to reduce memory footprint of the scene.
  39841. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  39842. */
  39843. clearCachedVertexData(): void;
  39844. /**
  39845. * This function will remove the local cached buffer data from texture.
  39846. * It will save memory but will prevent the texture from being rebuilt
  39847. */
  39848. cleanCachedTextureBuffer(): void;
  39849. /**
  39850. * Get the world extend vectors with an optional filter
  39851. *
  39852. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  39853. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  39854. */
  39855. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  39856. min: Vector3;
  39857. max: Vector3;
  39858. };
  39859. /**
  39860. * Creates a ray that can be used to pick in the scene
  39861. * @param x defines the x coordinate of the origin (on-screen)
  39862. * @param y defines the y coordinate of the origin (on-screen)
  39863. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39864. * @param camera defines the camera to use for the picking
  39865. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39866. * @returns a Ray
  39867. */
  39868. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  39869. /**
  39870. * Creates a ray that can be used to pick in the scene
  39871. * @param x defines the x coordinate of the origin (on-screen)
  39872. * @param y defines the y coordinate of the origin (on-screen)
  39873. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39874. * @param result defines the ray where to store the picking ray
  39875. * @param camera defines the camera to use for the picking
  39876. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39877. * @returns the current scene
  39878. */
  39879. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  39880. /**
  39881. * Creates a ray that can be used to pick in the scene
  39882. * @param x defines the x coordinate of the origin (on-screen)
  39883. * @param y defines the y coordinate of the origin (on-screen)
  39884. * @param camera defines the camera to use for the picking
  39885. * @returns a Ray
  39886. */
  39887. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  39888. /**
  39889. * Creates a ray that can be used to pick in the scene
  39890. * @param x defines the x coordinate of the origin (on-screen)
  39891. * @param y defines the y coordinate of the origin (on-screen)
  39892. * @param result defines the ray where to store the picking ray
  39893. * @param camera defines the camera to use for the picking
  39894. * @returns the current scene
  39895. */
  39896. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  39897. /** Launch a ray to try to pick a mesh in the scene
  39898. * @param x position on screen
  39899. * @param y position on screen
  39900. * @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
  39901. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39902. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39903. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39904. * @returns a PickingInfo
  39905. */
  39906. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39907. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  39908. * @param x position on screen
  39909. * @param y position on screen
  39910. * @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
  39911. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39912. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39913. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  39914. */
  39915. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  39916. /** Use the given ray to pick a mesh in the scene
  39917. * @param ray The ray to use to pick meshes
  39918. * @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
  39919. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39920. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39921. * @returns a PickingInfo
  39922. */
  39923. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39924. /**
  39925. * Launch a ray to try to pick a mesh in the scene
  39926. * @param x X position on screen
  39927. * @param y Y position on screen
  39928. * @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
  39929. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39930. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39931. * @returns an array of PickingInfo
  39932. */
  39933. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39934. /**
  39935. * Launch a ray to try to pick a mesh in the scene
  39936. * @param ray Ray to use
  39937. * @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
  39938. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39939. * @returns an array of PickingInfo
  39940. */
  39941. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39942. /**
  39943. * Force the value of meshUnderPointer
  39944. * @param mesh defines the mesh to use
  39945. */
  39946. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39947. /**
  39948. * Gets the mesh under the pointer
  39949. * @returns a Mesh or null if no mesh is under the pointer
  39950. */
  39951. getPointerOverMesh(): Nullable<AbstractMesh>;
  39952. /** @hidden */
  39953. _rebuildGeometries(): void;
  39954. /** @hidden */
  39955. _rebuildTextures(): void;
  39956. private _getByTags;
  39957. /**
  39958. * Get a list of meshes by tags
  39959. * @param tagsQuery defines the tags query to use
  39960. * @param forEach defines a predicate used to filter results
  39961. * @returns an array of Mesh
  39962. */
  39963. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  39964. /**
  39965. * Get a list of cameras by tags
  39966. * @param tagsQuery defines the tags query to use
  39967. * @param forEach defines a predicate used to filter results
  39968. * @returns an array of Camera
  39969. */
  39970. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  39971. /**
  39972. * Get a list of lights by tags
  39973. * @param tagsQuery defines the tags query to use
  39974. * @param forEach defines a predicate used to filter results
  39975. * @returns an array of Light
  39976. */
  39977. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  39978. /**
  39979. * Get a list of materials by tags
  39980. * @param tagsQuery defines the tags query to use
  39981. * @param forEach defines a predicate used to filter results
  39982. * @returns an array of Material
  39983. */
  39984. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  39985. /**
  39986. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  39987. * This allowed control for front to back rendering or reversly depending of the special needs.
  39988. *
  39989. * @param renderingGroupId The rendering group id corresponding to its index
  39990. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39991. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39992. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39993. */
  39994. 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;
  39995. /**
  39996. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39997. *
  39998. * @param renderingGroupId The rendering group id corresponding to its index
  39999. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40000. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40001. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40002. */
  40003. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40004. /**
  40005. * Gets the current auto clear configuration for one rendering group of the rendering
  40006. * manager.
  40007. * @param index the rendering group index to get the information for
  40008. * @returns The auto clear setup for the requested rendering group
  40009. */
  40010. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40011. private _blockMaterialDirtyMechanism;
  40012. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40013. get blockMaterialDirtyMechanism(): boolean;
  40014. set blockMaterialDirtyMechanism(value: boolean);
  40015. /**
  40016. * Will flag all materials as dirty to trigger new shader compilation
  40017. * @param flag defines the flag used to specify which material part must be marked as dirty
  40018. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40019. */
  40020. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40021. /** @hidden */
  40022. _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;
  40023. /** @hidden */
  40024. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40025. /** @hidden */
  40026. _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;
  40027. /** @hidden */
  40028. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40029. /** @hidden */
  40030. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40031. /** @hidden */
  40032. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40033. }
  40034. }
  40035. declare module BABYLON {
  40036. /**
  40037. * Set of assets to keep when moving a scene into an asset container.
  40038. */
  40039. export class KeepAssets extends AbstractScene {
  40040. }
  40041. /**
  40042. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40043. */
  40044. export class InstantiatedEntries {
  40045. /**
  40046. * List of new root nodes (eg. nodes with no parent)
  40047. */
  40048. rootNodes: TransformNode[];
  40049. /**
  40050. * List of new skeletons
  40051. */
  40052. skeletons: Skeleton[];
  40053. /**
  40054. * List of new animation groups
  40055. */
  40056. animationGroups: AnimationGroup[];
  40057. }
  40058. /**
  40059. * Container with a set of assets that can be added or removed from a scene.
  40060. */
  40061. export class AssetContainer extends AbstractScene {
  40062. private _wasAddedToScene;
  40063. /**
  40064. * The scene the AssetContainer belongs to.
  40065. */
  40066. scene: Scene;
  40067. /**
  40068. * Instantiates an AssetContainer.
  40069. * @param scene The scene the AssetContainer belongs to.
  40070. */
  40071. constructor(scene: Scene);
  40072. /**
  40073. * Instantiate or clone all meshes and add the new ones to the scene.
  40074. * Skeletons and animation groups will all be cloned
  40075. * @param nameFunction defines an optional function used to get new names for clones
  40076. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40077. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40078. */
  40079. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40080. /**
  40081. * Adds all the assets from the container to the scene.
  40082. */
  40083. addAllToScene(): void;
  40084. /**
  40085. * Removes all the assets in the container from the scene
  40086. */
  40087. removeAllFromScene(): void;
  40088. /**
  40089. * Disposes all the assets in the container
  40090. */
  40091. dispose(): void;
  40092. private _moveAssets;
  40093. /**
  40094. * Removes all the assets contained in the scene and adds them to the container.
  40095. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40096. */
  40097. moveAllFromScene(keepAssets?: KeepAssets): void;
  40098. /**
  40099. * 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.
  40100. * @returns the root mesh
  40101. */
  40102. createRootMesh(): Mesh;
  40103. /**
  40104. * Merge animations (direct and animation groups) from this asset container into a scene
  40105. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40106. * @param animatables set of animatables to retarget to a node from the scene
  40107. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40108. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40109. */
  40110. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40111. }
  40112. }
  40113. declare module BABYLON {
  40114. /**
  40115. * Defines how the parser contract is defined.
  40116. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40117. */
  40118. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40119. /**
  40120. * Defines how the individual parser contract is defined.
  40121. * These parser can parse an individual asset
  40122. */
  40123. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40124. /**
  40125. * Base class of the scene acting as a container for the different elements composing a scene.
  40126. * This class is dynamically extended by the different components of the scene increasing
  40127. * flexibility and reducing coupling
  40128. */
  40129. export abstract class AbstractScene {
  40130. /**
  40131. * Stores the list of available parsers in the application.
  40132. */
  40133. private static _BabylonFileParsers;
  40134. /**
  40135. * Stores the list of available individual parsers in the application.
  40136. */
  40137. private static _IndividualBabylonFileParsers;
  40138. /**
  40139. * Adds a parser in the list of available ones
  40140. * @param name Defines the name of the parser
  40141. * @param parser Defines the parser to add
  40142. */
  40143. static AddParser(name: string, parser: BabylonFileParser): void;
  40144. /**
  40145. * Gets a general parser from the list of avaialble ones
  40146. * @param name Defines the name of the parser
  40147. * @returns the requested parser or null
  40148. */
  40149. static GetParser(name: string): Nullable<BabylonFileParser>;
  40150. /**
  40151. * Adds n individual parser in the list of available ones
  40152. * @param name Defines the name of the parser
  40153. * @param parser Defines the parser to add
  40154. */
  40155. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40156. /**
  40157. * Gets an individual parser from the list of avaialble ones
  40158. * @param name Defines the name of the parser
  40159. * @returns the requested parser or null
  40160. */
  40161. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40162. /**
  40163. * Parser json data and populate both a scene and its associated container object
  40164. * @param jsonData Defines the data to parse
  40165. * @param scene Defines the scene to parse the data for
  40166. * @param container Defines the container attached to the parsing sequence
  40167. * @param rootUrl Defines the root url of the data
  40168. */
  40169. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40170. /**
  40171. * Gets the list of root nodes (ie. nodes with no parent)
  40172. */
  40173. rootNodes: Node[];
  40174. /** All of the cameras added to this scene
  40175. * @see http://doc.babylonjs.com/babylon101/cameras
  40176. */
  40177. cameras: Camera[];
  40178. /**
  40179. * All of the lights added to this scene
  40180. * @see http://doc.babylonjs.com/babylon101/lights
  40181. */
  40182. lights: Light[];
  40183. /**
  40184. * All of the (abstract) meshes added to this scene
  40185. */
  40186. meshes: AbstractMesh[];
  40187. /**
  40188. * The list of skeletons added to the scene
  40189. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40190. */
  40191. skeletons: Skeleton[];
  40192. /**
  40193. * All of the particle systems added to this scene
  40194. * @see http://doc.babylonjs.com/babylon101/particles
  40195. */
  40196. particleSystems: IParticleSystem[];
  40197. /**
  40198. * Gets a list of Animations associated with the scene
  40199. */
  40200. animations: Animation[];
  40201. /**
  40202. * All of the animation groups added to this scene
  40203. * @see http://doc.babylonjs.com/how_to/group
  40204. */
  40205. animationGroups: AnimationGroup[];
  40206. /**
  40207. * All of the multi-materials added to this scene
  40208. * @see http://doc.babylonjs.com/how_to/multi_materials
  40209. */
  40210. multiMaterials: MultiMaterial[];
  40211. /**
  40212. * All of the materials added to this scene
  40213. * In the context of a Scene, it is not supposed to be modified manually.
  40214. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40215. * Note also that the order of the Material within the array is not significant and might change.
  40216. * @see http://doc.babylonjs.com/babylon101/materials
  40217. */
  40218. materials: Material[];
  40219. /**
  40220. * The list of morph target managers added to the scene
  40221. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40222. */
  40223. morphTargetManagers: MorphTargetManager[];
  40224. /**
  40225. * The list of geometries used in the scene.
  40226. */
  40227. geometries: Geometry[];
  40228. /**
  40229. * All of the tranform nodes added to this scene
  40230. * In the context of a Scene, it is not supposed to be modified manually.
  40231. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40232. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40233. * @see http://doc.babylonjs.com/how_to/transformnode
  40234. */
  40235. transformNodes: TransformNode[];
  40236. /**
  40237. * ActionManagers available on the scene.
  40238. */
  40239. actionManagers: AbstractActionManager[];
  40240. /**
  40241. * Textures to keep.
  40242. */
  40243. textures: BaseTexture[];
  40244. /**
  40245. * Environment texture for the scene
  40246. */
  40247. environmentTexture: Nullable<BaseTexture>;
  40248. /**
  40249. * @returns all meshes, lights, cameras, transformNodes and bones
  40250. */
  40251. getNodes(): Array<Node>;
  40252. }
  40253. }
  40254. declare module BABYLON {
  40255. /**
  40256. * Interface used to define options for Sound class
  40257. */
  40258. export interface ISoundOptions {
  40259. /**
  40260. * Does the sound autoplay once loaded.
  40261. */
  40262. autoplay?: boolean;
  40263. /**
  40264. * Does the sound loop after it finishes playing once.
  40265. */
  40266. loop?: boolean;
  40267. /**
  40268. * Sound's volume
  40269. */
  40270. volume?: number;
  40271. /**
  40272. * Is it a spatial sound?
  40273. */
  40274. spatialSound?: boolean;
  40275. /**
  40276. * Maximum distance to hear that sound
  40277. */
  40278. maxDistance?: number;
  40279. /**
  40280. * Uses user defined attenuation function
  40281. */
  40282. useCustomAttenuation?: boolean;
  40283. /**
  40284. * Define the roll off factor of spatial sounds.
  40285. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40286. */
  40287. rolloffFactor?: number;
  40288. /**
  40289. * Define the reference distance the sound should be heard perfectly.
  40290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40291. */
  40292. refDistance?: number;
  40293. /**
  40294. * Define the distance attenuation model the sound will follow.
  40295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40296. */
  40297. distanceModel?: string;
  40298. /**
  40299. * Defines the playback speed (1 by default)
  40300. */
  40301. playbackRate?: number;
  40302. /**
  40303. * Defines if the sound is from a streaming source
  40304. */
  40305. streaming?: boolean;
  40306. /**
  40307. * Defines an optional length (in seconds) inside the sound file
  40308. */
  40309. length?: number;
  40310. /**
  40311. * Defines an optional offset (in seconds) inside the sound file
  40312. */
  40313. offset?: number;
  40314. /**
  40315. * If true, URLs will not be required to state the audio file codec to use.
  40316. */
  40317. skipCodecCheck?: boolean;
  40318. }
  40319. /**
  40320. * Defines a sound that can be played in the application.
  40321. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40322. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40323. */
  40324. export class Sound {
  40325. /**
  40326. * The name of the sound in the scene.
  40327. */
  40328. name: string;
  40329. /**
  40330. * Does the sound autoplay once loaded.
  40331. */
  40332. autoplay: boolean;
  40333. /**
  40334. * Does the sound loop after it finishes playing once.
  40335. */
  40336. loop: boolean;
  40337. /**
  40338. * Does the sound use a custom attenuation curve to simulate the falloff
  40339. * happening when the source gets further away from the camera.
  40340. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40341. */
  40342. useCustomAttenuation: boolean;
  40343. /**
  40344. * The sound track id this sound belongs to.
  40345. */
  40346. soundTrackId: number;
  40347. /**
  40348. * Is this sound currently played.
  40349. */
  40350. isPlaying: boolean;
  40351. /**
  40352. * Is this sound currently paused.
  40353. */
  40354. isPaused: boolean;
  40355. /**
  40356. * Does this sound enables spatial sound.
  40357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40358. */
  40359. spatialSound: boolean;
  40360. /**
  40361. * Define the reference distance the sound should be heard perfectly.
  40362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40363. */
  40364. refDistance: number;
  40365. /**
  40366. * Define the roll off factor of spatial sounds.
  40367. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40368. */
  40369. rolloffFactor: number;
  40370. /**
  40371. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40372. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40373. */
  40374. maxDistance: number;
  40375. /**
  40376. * Define the distance attenuation model the sound will follow.
  40377. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40378. */
  40379. distanceModel: string;
  40380. /**
  40381. * @hidden
  40382. * Back Compat
  40383. **/
  40384. onended: () => any;
  40385. /**
  40386. * Gets or sets an object used to store user defined information for the sound.
  40387. */
  40388. metadata: any;
  40389. /**
  40390. * Observable event when the current playing sound finishes.
  40391. */
  40392. onEndedObservable: Observable<Sound>;
  40393. private _panningModel;
  40394. private _playbackRate;
  40395. private _streaming;
  40396. private _startTime;
  40397. private _startOffset;
  40398. private _position;
  40399. /** @hidden */
  40400. _positionInEmitterSpace: boolean;
  40401. private _localDirection;
  40402. private _volume;
  40403. private _isReadyToPlay;
  40404. private _isDirectional;
  40405. private _readyToPlayCallback;
  40406. private _audioBuffer;
  40407. private _soundSource;
  40408. private _streamingSource;
  40409. private _soundPanner;
  40410. private _soundGain;
  40411. private _inputAudioNode;
  40412. private _outputAudioNode;
  40413. private _coneInnerAngle;
  40414. private _coneOuterAngle;
  40415. private _coneOuterGain;
  40416. private _scene;
  40417. private _connectedTransformNode;
  40418. private _customAttenuationFunction;
  40419. private _registerFunc;
  40420. private _isOutputConnected;
  40421. private _htmlAudioElement;
  40422. private _urlType;
  40423. private _length?;
  40424. private _offset?;
  40425. /** @hidden */
  40426. static _SceneComponentInitialization: (scene: Scene) => void;
  40427. /**
  40428. * Create a sound and attach it to a scene
  40429. * @param name Name of your sound
  40430. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40431. * @param scene defines the scene the sound belongs to
  40432. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40433. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40434. */
  40435. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40436. /**
  40437. * Release the sound and its associated resources
  40438. */
  40439. dispose(): void;
  40440. /**
  40441. * Gets if the sounds is ready to be played or not.
  40442. * @returns true if ready, otherwise false
  40443. */
  40444. isReady(): boolean;
  40445. private _soundLoaded;
  40446. /**
  40447. * Sets the data of the sound from an audiobuffer
  40448. * @param audioBuffer The audioBuffer containing the data
  40449. */
  40450. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40451. /**
  40452. * Updates the current sounds options such as maxdistance, loop...
  40453. * @param options A JSON object containing values named as the object properties
  40454. */
  40455. updateOptions(options: ISoundOptions): void;
  40456. private _createSpatialParameters;
  40457. private _updateSpatialParameters;
  40458. /**
  40459. * Switch the panning model to HRTF:
  40460. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40462. */
  40463. switchPanningModelToHRTF(): void;
  40464. /**
  40465. * Switch the panning model to Equal Power:
  40466. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40468. */
  40469. switchPanningModelToEqualPower(): void;
  40470. private _switchPanningModel;
  40471. /**
  40472. * Connect this sound to a sound track audio node like gain...
  40473. * @param soundTrackAudioNode the sound track audio node to connect to
  40474. */
  40475. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40476. /**
  40477. * Transform this sound into a directional source
  40478. * @param coneInnerAngle Size of the inner cone in degree
  40479. * @param coneOuterAngle Size of the outer cone in degree
  40480. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40481. */
  40482. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40483. /**
  40484. * Gets or sets the inner angle for the directional cone.
  40485. */
  40486. get directionalConeInnerAngle(): number;
  40487. /**
  40488. * Gets or sets the inner angle for the directional cone.
  40489. */
  40490. set directionalConeInnerAngle(value: number);
  40491. /**
  40492. * Gets or sets the outer angle for the directional cone.
  40493. */
  40494. get directionalConeOuterAngle(): number;
  40495. /**
  40496. * Gets or sets the outer angle for the directional cone.
  40497. */
  40498. set directionalConeOuterAngle(value: number);
  40499. /**
  40500. * Sets the position of the emitter if spatial sound is enabled
  40501. * @param newPosition Defines the new posisiton
  40502. */
  40503. setPosition(newPosition: Vector3): void;
  40504. /**
  40505. * Sets the local direction of the emitter if spatial sound is enabled
  40506. * @param newLocalDirection Defines the new local direction
  40507. */
  40508. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40509. private _updateDirection;
  40510. /** @hidden */
  40511. updateDistanceFromListener(): void;
  40512. /**
  40513. * Sets a new custom attenuation function for the sound.
  40514. * @param callback Defines the function used for the attenuation
  40515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40516. */
  40517. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40518. /**
  40519. * Play the sound
  40520. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40521. * @param offset (optional) Start the sound at a specific time in seconds
  40522. * @param length (optional) Sound duration (in seconds)
  40523. */
  40524. play(time?: number, offset?: number, length?: number): void;
  40525. private _onended;
  40526. /**
  40527. * Stop the sound
  40528. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40529. */
  40530. stop(time?: number): void;
  40531. /**
  40532. * Put the sound in pause
  40533. */
  40534. pause(): void;
  40535. /**
  40536. * Sets a dedicated volume for this sounds
  40537. * @param newVolume Define the new volume of the sound
  40538. * @param time Define time for gradual change to new volume
  40539. */
  40540. setVolume(newVolume: number, time?: number): void;
  40541. /**
  40542. * Set the sound play back rate
  40543. * @param newPlaybackRate Define the playback rate the sound should be played at
  40544. */
  40545. setPlaybackRate(newPlaybackRate: number): void;
  40546. /**
  40547. * Gets the volume of the sound.
  40548. * @returns the volume of the sound
  40549. */
  40550. getVolume(): number;
  40551. /**
  40552. * Attach the sound to a dedicated mesh
  40553. * @param transformNode The transform node to connect the sound with
  40554. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40555. */
  40556. attachToMesh(transformNode: TransformNode): void;
  40557. /**
  40558. * Detach the sound from the previously attached mesh
  40559. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40560. */
  40561. detachFromMesh(): void;
  40562. private _onRegisterAfterWorldMatrixUpdate;
  40563. /**
  40564. * Clone the current sound in the scene.
  40565. * @returns the new sound clone
  40566. */
  40567. clone(): Nullable<Sound>;
  40568. /**
  40569. * Gets the current underlying audio buffer containing the data
  40570. * @returns the audio buffer
  40571. */
  40572. getAudioBuffer(): Nullable<AudioBuffer>;
  40573. /**
  40574. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40575. * @returns the source node
  40576. */
  40577. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40578. /**
  40579. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40580. * @returns the gain node
  40581. */
  40582. getSoundGain(): Nullable<GainNode>;
  40583. /**
  40584. * Serializes the Sound in a JSON representation
  40585. * @returns the JSON representation of the sound
  40586. */
  40587. serialize(): any;
  40588. /**
  40589. * Parse a JSON representation of a sound to innstantiate in a given scene
  40590. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40591. * @param scene Define the scene the new parsed sound should be created in
  40592. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40593. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40594. * @returns the newly parsed sound
  40595. */
  40596. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40597. }
  40598. }
  40599. declare module BABYLON {
  40600. /**
  40601. * This defines an action helpful to play a defined sound on a triggered action.
  40602. */
  40603. export class PlaySoundAction extends Action {
  40604. private _sound;
  40605. /**
  40606. * Instantiate the action
  40607. * @param triggerOptions defines the trigger options
  40608. * @param sound defines the sound to play
  40609. * @param condition defines the trigger related conditions
  40610. */
  40611. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40612. /** @hidden */
  40613. _prepare(): void;
  40614. /**
  40615. * Execute the action and play the sound.
  40616. */
  40617. execute(): void;
  40618. /**
  40619. * Serializes the actions and its related information.
  40620. * @param parent defines the object to serialize in
  40621. * @returns the serialized object
  40622. */
  40623. serialize(parent: any): any;
  40624. }
  40625. /**
  40626. * This defines an action helpful to stop a defined sound on a triggered action.
  40627. */
  40628. export class StopSoundAction extends Action {
  40629. private _sound;
  40630. /**
  40631. * Instantiate the action
  40632. * @param triggerOptions defines the trigger options
  40633. * @param sound defines the sound to stop
  40634. * @param condition defines the trigger related conditions
  40635. */
  40636. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40637. /** @hidden */
  40638. _prepare(): void;
  40639. /**
  40640. * Execute the action and stop the sound.
  40641. */
  40642. execute(): void;
  40643. /**
  40644. * Serializes the actions and its related information.
  40645. * @param parent defines the object to serialize in
  40646. * @returns the serialized object
  40647. */
  40648. serialize(parent: any): any;
  40649. }
  40650. }
  40651. declare module BABYLON {
  40652. /**
  40653. * This defines an action responsible to change the value of a property
  40654. * by interpolating between its current value and the newly set one once triggered.
  40655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40656. */
  40657. export class InterpolateValueAction extends Action {
  40658. /**
  40659. * Defines the path of the property where the value should be interpolated
  40660. */
  40661. propertyPath: string;
  40662. /**
  40663. * Defines the target value at the end of the interpolation.
  40664. */
  40665. value: any;
  40666. /**
  40667. * Defines the time it will take for the property to interpolate to the value.
  40668. */
  40669. duration: number;
  40670. /**
  40671. * Defines if the other scene animations should be stopped when the action has been triggered
  40672. */
  40673. stopOtherAnimations?: boolean;
  40674. /**
  40675. * Defines a callback raised once the interpolation animation has been done.
  40676. */
  40677. onInterpolationDone?: () => void;
  40678. /**
  40679. * Observable triggered once the interpolation animation has been done.
  40680. */
  40681. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40682. private _target;
  40683. private _effectiveTarget;
  40684. private _property;
  40685. /**
  40686. * Instantiate the action
  40687. * @param triggerOptions defines the trigger options
  40688. * @param target defines the object containing the value to interpolate
  40689. * @param propertyPath defines the path to the property in the target object
  40690. * @param value defines the target value at the end of the interpolation
  40691. * @param duration deines the time it will take for the property to interpolate to the value.
  40692. * @param condition defines the trigger related conditions
  40693. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40694. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40695. */
  40696. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40697. /** @hidden */
  40698. _prepare(): void;
  40699. /**
  40700. * Execute the action starts the value interpolation.
  40701. */
  40702. execute(): void;
  40703. /**
  40704. * Serializes the actions and its related information.
  40705. * @param parent defines the object to serialize in
  40706. * @returns the serialized object
  40707. */
  40708. serialize(parent: any): any;
  40709. }
  40710. }
  40711. declare module BABYLON {
  40712. /**
  40713. * Options allowed during the creation of a sound track.
  40714. */
  40715. export interface ISoundTrackOptions {
  40716. /**
  40717. * The volume the sound track should take during creation
  40718. */
  40719. volume?: number;
  40720. /**
  40721. * Define if the sound track is the main sound track of the scene
  40722. */
  40723. mainTrack?: boolean;
  40724. }
  40725. /**
  40726. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40727. * It will be also used in a future release to apply effects on a specific track.
  40728. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40729. */
  40730. export class SoundTrack {
  40731. /**
  40732. * The unique identifier of the sound track in the scene.
  40733. */
  40734. id: number;
  40735. /**
  40736. * The list of sounds included in the sound track.
  40737. */
  40738. soundCollection: Array<Sound>;
  40739. private _outputAudioNode;
  40740. private _scene;
  40741. private _connectedAnalyser;
  40742. private _options;
  40743. private _isInitialized;
  40744. /**
  40745. * Creates a new sound track.
  40746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40747. * @param scene Define the scene the sound track belongs to
  40748. * @param options
  40749. */
  40750. constructor(scene: Scene, options?: ISoundTrackOptions);
  40751. private _initializeSoundTrackAudioGraph;
  40752. /**
  40753. * Release the sound track and its associated resources
  40754. */
  40755. dispose(): void;
  40756. /**
  40757. * Adds a sound to this sound track
  40758. * @param sound define the cound to add
  40759. * @ignoreNaming
  40760. */
  40761. AddSound(sound: Sound): void;
  40762. /**
  40763. * Removes a sound to this sound track
  40764. * @param sound define the cound to remove
  40765. * @ignoreNaming
  40766. */
  40767. RemoveSound(sound: Sound): void;
  40768. /**
  40769. * Set a global volume for the full sound track.
  40770. * @param newVolume Define the new volume of the sound track
  40771. */
  40772. setVolume(newVolume: number): void;
  40773. /**
  40774. * Switch the panning model to HRTF:
  40775. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40777. */
  40778. switchPanningModelToHRTF(): void;
  40779. /**
  40780. * Switch the panning model to Equal Power:
  40781. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40782. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40783. */
  40784. switchPanningModelToEqualPower(): void;
  40785. /**
  40786. * Connect the sound track to an audio analyser allowing some amazing
  40787. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40788. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40789. * @param analyser The analyser to connect to the engine
  40790. */
  40791. connectToAnalyser(analyser: Analyser): void;
  40792. }
  40793. }
  40794. declare module BABYLON {
  40795. interface AbstractScene {
  40796. /**
  40797. * The list of sounds used in the scene.
  40798. */
  40799. sounds: Nullable<Array<Sound>>;
  40800. }
  40801. interface Scene {
  40802. /**
  40803. * @hidden
  40804. * Backing field
  40805. */
  40806. _mainSoundTrack: SoundTrack;
  40807. /**
  40808. * The main sound track played by the scene.
  40809. * It cotains your primary collection of sounds.
  40810. */
  40811. mainSoundTrack: SoundTrack;
  40812. /**
  40813. * The list of sound tracks added to the scene
  40814. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40815. */
  40816. soundTracks: Nullable<Array<SoundTrack>>;
  40817. /**
  40818. * Gets a sound using a given name
  40819. * @param name defines the name to search for
  40820. * @return the found sound or null if not found at all.
  40821. */
  40822. getSoundByName(name: string): Nullable<Sound>;
  40823. /**
  40824. * Gets or sets if audio support is enabled
  40825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40826. */
  40827. audioEnabled: boolean;
  40828. /**
  40829. * Gets or sets if audio will be output to headphones
  40830. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40831. */
  40832. headphone: boolean;
  40833. /**
  40834. * Gets or sets custom audio listener position provider
  40835. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40836. */
  40837. audioListenerPositionProvider: Nullable<() => Vector3>;
  40838. /**
  40839. * Gets or sets a refresh rate when using 3D audio positioning
  40840. */
  40841. audioPositioningRefreshRate: number;
  40842. }
  40843. /**
  40844. * Defines the sound scene component responsible to manage any sounds
  40845. * in a given scene.
  40846. */
  40847. export class AudioSceneComponent implements ISceneSerializableComponent {
  40848. /**
  40849. * The component name helpfull to identify the component in the list of scene components.
  40850. */
  40851. readonly name: string;
  40852. /**
  40853. * The scene the component belongs to.
  40854. */
  40855. scene: Scene;
  40856. private _audioEnabled;
  40857. /**
  40858. * Gets whether audio is enabled or not.
  40859. * Please use related enable/disable method to switch state.
  40860. */
  40861. get audioEnabled(): boolean;
  40862. private _headphone;
  40863. /**
  40864. * Gets whether audio is outputing to headphone or not.
  40865. * Please use the according Switch methods to change output.
  40866. */
  40867. get headphone(): boolean;
  40868. /**
  40869. * Gets or sets a refresh rate when using 3D audio positioning
  40870. */
  40871. audioPositioningRefreshRate: number;
  40872. private _audioListenerPositionProvider;
  40873. /**
  40874. * Gets the current audio listener position provider
  40875. */
  40876. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  40877. /**
  40878. * Sets a custom listener position for all sounds in the scene
  40879. * By default, this is the position of the first active camera
  40880. */
  40881. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  40882. /**
  40883. * Creates a new instance of the component for the given scene
  40884. * @param scene Defines the scene to register the component in
  40885. */
  40886. constructor(scene: Scene);
  40887. /**
  40888. * Registers the component in a given scene
  40889. */
  40890. register(): void;
  40891. /**
  40892. * Rebuilds the elements related to this component in case of
  40893. * context lost for instance.
  40894. */
  40895. rebuild(): void;
  40896. /**
  40897. * Serializes the component data to the specified json object
  40898. * @param serializationObject The object to serialize to
  40899. */
  40900. serialize(serializationObject: any): void;
  40901. /**
  40902. * Adds all the elements from the container to the scene
  40903. * @param container the container holding the elements
  40904. */
  40905. addFromContainer(container: AbstractScene): void;
  40906. /**
  40907. * Removes all the elements in the container from the scene
  40908. * @param container contains the elements to remove
  40909. * @param dispose if the removed element should be disposed (default: false)
  40910. */
  40911. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  40912. /**
  40913. * Disposes the component and the associated ressources.
  40914. */
  40915. dispose(): void;
  40916. /**
  40917. * Disables audio in the associated scene.
  40918. */
  40919. disableAudio(): void;
  40920. /**
  40921. * Enables audio in the associated scene.
  40922. */
  40923. enableAudio(): void;
  40924. /**
  40925. * Switch audio to headphone output.
  40926. */
  40927. switchAudioModeForHeadphones(): void;
  40928. /**
  40929. * Switch audio to normal speakers.
  40930. */
  40931. switchAudioModeForNormalSpeakers(): void;
  40932. private _cachedCameraDirection;
  40933. private _cachedCameraPosition;
  40934. private _lastCheck;
  40935. private _afterRender;
  40936. }
  40937. }
  40938. declare module BABYLON {
  40939. /**
  40940. * Wraps one or more Sound objects and selects one with random weight for playback.
  40941. */
  40942. export class WeightedSound {
  40943. /** When true a Sound will be selected and played when the current playing Sound completes. */
  40944. loop: boolean;
  40945. private _coneInnerAngle;
  40946. private _coneOuterAngle;
  40947. private _volume;
  40948. /** A Sound is currently playing. */
  40949. isPlaying: boolean;
  40950. /** A Sound is currently paused. */
  40951. isPaused: boolean;
  40952. private _sounds;
  40953. private _weights;
  40954. private _currentIndex?;
  40955. /**
  40956. * Creates a new WeightedSound from the list of sounds given.
  40957. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  40958. * @param sounds Array of Sounds that will be selected from.
  40959. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  40960. */
  40961. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  40962. /**
  40963. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  40964. */
  40965. get directionalConeInnerAngle(): number;
  40966. /**
  40967. * The size of cone in degress for a directional sound in which there will be no attenuation.
  40968. */
  40969. set directionalConeInnerAngle(value: number);
  40970. /**
  40971. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40972. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40973. */
  40974. get directionalConeOuterAngle(): number;
  40975. /**
  40976. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40977. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40978. */
  40979. set directionalConeOuterAngle(value: number);
  40980. /**
  40981. * Playback volume.
  40982. */
  40983. get volume(): number;
  40984. /**
  40985. * Playback volume.
  40986. */
  40987. set volume(value: number);
  40988. private _onended;
  40989. /**
  40990. * Suspend playback
  40991. */
  40992. pause(): void;
  40993. /**
  40994. * Stop playback
  40995. */
  40996. stop(): void;
  40997. /**
  40998. * Start playback.
  40999. * @param startOffset Position the clip head at a specific time in seconds.
  41000. */
  41001. play(startOffset?: number): void;
  41002. }
  41003. }
  41004. declare module BABYLON {
  41005. /**
  41006. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41007. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41008. */
  41009. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41010. /**
  41011. * Gets the name of the behavior.
  41012. */
  41013. get name(): string;
  41014. /**
  41015. * The easing function used by animations
  41016. */
  41017. static EasingFunction: BackEase;
  41018. /**
  41019. * The easing mode used by animations
  41020. */
  41021. static EasingMode: number;
  41022. /**
  41023. * The duration of the animation, in milliseconds
  41024. */
  41025. transitionDuration: number;
  41026. /**
  41027. * Length of the distance animated by the transition when lower radius is reached
  41028. */
  41029. lowerRadiusTransitionRange: number;
  41030. /**
  41031. * Length of the distance animated by the transition when upper radius is reached
  41032. */
  41033. upperRadiusTransitionRange: number;
  41034. private _autoTransitionRange;
  41035. /**
  41036. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41037. */
  41038. get autoTransitionRange(): boolean;
  41039. /**
  41040. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41041. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41042. */
  41043. set autoTransitionRange(value: boolean);
  41044. private _attachedCamera;
  41045. private _onAfterCheckInputsObserver;
  41046. private _onMeshTargetChangedObserver;
  41047. /**
  41048. * Initializes the behavior.
  41049. */
  41050. init(): void;
  41051. /**
  41052. * Attaches the behavior to its arc rotate camera.
  41053. * @param camera Defines the camera to attach the behavior to
  41054. */
  41055. attach(camera: ArcRotateCamera): void;
  41056. /**
  41057. * Detaches the behavior from its current arc rotate camera.
  41058. */
  41059. detach(): void;
  41060. private _radiusIsAnimating;
  41061. private _radiusBounceTransition;
  41062. private _animatables;
  41063. private _cachedWheelPrecision;
  41064. /**
  41065. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41066. * @param radiusLimit The limit to check against.
  41067. * @return Bool to indicate if at limit.
  41068. */
  41069. private _isRadiusAtLimit;
  41070. /**
  41071. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41072. * @param radiusDelta The delta by which to animate to. Can be negative.
  41073. */
  41074. private _applyBoundRadiusAnimation;
  41075. /**
  41076. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41077. */
  41078. protected _clearAnimationLocks(): void;
  41079. /**
  41080. * Stops and removes all animations that have been applied to the camera
  41081. */
  41082. stopAllAnimations(): void;
  41083. }
  41084. }
  41085. declare module BABYLON {
  41086. /**
  41087. * 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.
  41088. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41089. */
  41090. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41091. /**
  41092. * Gets the name of the behavior.
  41093. */
  41094. get name(): string;
  41095. private _mode;
  41096. private _radiusScale;
  41097. private _positionScale;
  41098. private _defaultElevation;
  41099. private _elevationReturnTime;
  41100. private _elevationReturnWaitTime;
  41101. private _zoomStopsAnimation;
  41102. private _framingTime;
  41103. /**
  41104. * The easing function used by animations
  41105. */
  41106. static EasingFunction: ExponentialEase;
  41107. /**
  41108. * The easing mode used by animations
  41109. */
  41110. static EasingMode: number;
  41111. /**
  41112. * Sets the current mode used by the behavior
  41113. */
  41114. set mode(mode: number);
  41115. /**
  41116. * Gets current mode used by the behavior.
  41117. */
  41118. get mode(): number;
  41119. /**
  41120. * Sets the scale applied to the radius (1 by default)
  41121. */
  41122. set radiusScale(radius: number);
  41123. /**
  41124. * Gets the scale applied to the radius
  41125. */
  41126. get radiusScale(): number;
  41127. /**
  41128. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41129. */
  41130. set positionScale(scale: number);
  41131. /**
  41132. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41133. */
  41134. get positionScale(): number;
  41135. /**
  41136. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41137. * behaviour is triggered, in radians.
  41138. */
  41139. set defaultElevation(elevation: number);
  41140. /**
  41141. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41142. * behaviour is triggered, in radians.
  41143. */
  41144. get defaultElevation(): number;
  41145. /**
  41146. * Sets the time (in milliseconds) taken to return to the default beta position.
  41147. * Negative value indicates camera should not return to default.
  41148. */
  41149. set elevationReturnTime(speed: number);
  41150. /**
  41151. * Gets the time (in milliseconds) taken to return to the default beta position.
  41152. * Negative value indicates camera should not return to default.
  41153. */
  41154. get elevationReturnTime(): number;
  41155. /**
  41156. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41157. */
  41158. set elevationReturnWaitTime(time: number);
  41159. /**
  41160. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41161. */
  41162. get elevationReturnWaitTime(): number;
  41163. /**
  41164. * Sets the flag that indicates if user zooming should stop animation.
  41165. */
  41166. set zoomStopsAnimation(flag: boolean);
  41167. /**
  41168. * Gets the flag that indicates if user zooming should stop animation.
  41169. */
  41170. get zoomStopsAnimation(): boolean;
  41171. /**
  41172. * Sets the transition time when framing the mesh, in milliseconds
  41173. */
  41174. set framingTime(time: number);
  41175. /**
  41176. * Gets the transition time when framing the mesh, in milliseconds
  41177. */
  41178. get framingTime(): number;
  41179. /**
  41180. * Define if the behavior should automatically change the configured
  41181. * camera limits and sensibilities.
  41182. */
  41183. autoCorrectCameraLimitsAndSensibility: boolean;
  41184. private _onPrePointerObservableObserver;
  41185. private _onAfterCheckInputsObserver;
  41186. private _onMeshTargetChangedObserver;
  41187. private _attachedCamera;
  41188. private _isPointerDown;
  41189. private _lastInteractionTime;
  41190. /**
  41191. * Initializes the behavior.
  41192. */
  41193. init(): void;
  41194. /**
  41195. * Attaches the behavior to its arc rotate camera.
  41196. * @param camera Defines the camera to attach the behavior to
  41197. */
  41198. attach(camera: ArcRotateCamera): void;
  41199. /**
  41200. * Detaches the behavior from its current arc rotate camera.
  41201. */
  41202. detach(): void;
  41203. private _animatables;
  41204. private _betaIsAnimating;
  41205. private _betaTransition;
  41206. private _radiusTransition;
  41207. private _vectorTransition;
  41208. /**
  41209. * Targets the given mesh and updates zoom level accordingly.
  41210. * @param mesh The mesh to target.
  41211. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41212. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41213. */
  41214. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41215. /**
  41216. * Targets the given mesh with its children and updates zoom level accordingly.
  41217. * @param mesh The mesh to target.
  41218. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41219. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41220. */
  41221. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41222. /**
  41223. * Targets the given meshes with their children and updates zoom level accordingly.
  41224. * @param meshes The mesh to target.
  41225. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41226. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41227. */
  41228. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41229. /**
  41230. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41231. * @param minimumWorld Determines the smaller position of the bounding box extend
  41232. * @param maximumWorld Determines the bigger position of the bounding box extend
  41233. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41234. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41235. */
  41236. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41237. /**
  41238. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41239. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41240. * frustum width.
  41241. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41242. * to fully enclose the mesh in the viewing frustum.
  41243. */
  41244. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41245. /**
  41246. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41247. * is automatically returned to its default position (expected to be above ground plane).
  41248. */
  41249. private _maintainCameraAboveGround;
  41250. /**
  41251. * Returns the frustum slope based on the canvas ratio and camera FOV
  41252. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41253. */
  41254. private _getFrustumSlope;
  41255. /**
  41256. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41257. */
  41258. private _clearAnimationLocks;
  41259. /**
  41260. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41261. */
  41262. private _applyUserInteraction;
  41263. /**
  41264. * Stops and removes all animations that have been applied to the camera
  41265. */
  41266. stopAllAnimations(): void;
  41267. /**
  41268. * Gets a value indicating if the user is moving the camera
  41269. */
  41270. get isUserIsMoving(): boolean;
  41271. /**
  41272. * The camera can move all the way towards the mesh.
  41273. */
  41274. static IgnoreBoundsSizeMode: number;
  41275. /**
  41276. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41277. */
  41278. static FitFrustumSidesMode: number;
  41279. }
  41280. }
  41281. declare module BABYLON {
  41282. /**
  41283. * Base class for Camera Pointer Inputs.
  41284. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41285. * for example usage.
  41286. */
  41287. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41288. /**
  41289. * Defines the camera the input is attached to.
  41290. */
  41291. abstract camera: Camera;
  41292. /**
  41293. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41294. */
  41295. protected _altKey: boolean;
  41296. protected _ctrlKey: boolean;
  41297. protected _metaKey: boolean;
  41298. protected _shiftKey: boolean;
  41299. /**
  41300. * Which mouse buttons were pressed at time of last mouse event.
  41301. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41302. */
  41303. protected _buttonsPressed: number;
  41304. /**
  41305. * Defines the buttons associated with the input to handle camera move.
  41306. */
  41307. buttons: number[];
  41308. /**
  41309. * Attach the input controls to a specific dom element to get the input from.
  41310. * @param element Defines the element the controls should be listened from
  41311. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41312. */
  41313. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41314. /**
  41315. * Detach the current controls from the specified dom element.
  41316. * @param element Defines the element to stop listening the inputs from
  41317. */
  41318. detachControl(element: Nullable<HTMLElement>): void;
  41319. /**
  41320. * Gets the class name of the current input.
  41321. * @returns the class name
  41322. */
  41323. getClassName(): string;
  41324. /**
  41325. * Get the friendly name associated with the input class.
  41326. * @returns the input friendly name
  41327. */
  41328. getSimpleName(): string;
  41329. /**
  41330. * Called on pointer POINTERDOUBLETAP event.
  41331. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41332. */
  41333. protected onDoubleTap(type: string): void;
  41334. /**
  41335. * Called on pointer POINTERMOVE event if only a single touch is active.
  41336. * Override this method to provide functionality.
  41337. */
  41338. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41339. /**
  41340. * Called on pointer POINTERMOVE event if multiple touches are active.
  41341. * Override this method to provide functionality.
  41342. */
  41343. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41344. /**
  41345. * Called on JS contextmenu event.
  41346. * Override this method to provide functionality.
  41347. */
  41348. protected onContextMenu(evt: PointerEvent): void;
  41349. /**
  41350. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41351. * press.
  41352. * Override this method to provide functionality.
  41353. */
  41354. protected onButtonDown(evt: PointerEvent): void;
  41355. /**
  41356. * Called each time a new POINTERUP event occurs. Ie, for each button
  41357. * release.
  41358. * Override this method to provide functionality.
  41359. */
  41360. protected onButtonUp(evt: PointerEvent): void;
  41361. /**
  41362. * Called when window becomes inactive.
  41363. * Override this method to provide functionality.
  41364. */
  41365. protected onLostFocus(): void;
  41366. private _pointerInput;
  41367. private _observer;
  41368. private _onLostFocus;
  41369. private pointA;
  41370. private pointB;
  41371. }
  41372. }
  41373. declare module BABYLON {
  41374. /**
  41375. * Manage the pointers inputs to control an arc rotate camera.
  41376. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41377. */
  41378. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41379. /**
  41380. * Defines the camera the input is attached to.
  41381. */
  41382. camera: ArcRotateCamera;
  41383. /**
  41384. * Gets the class name of the current input.
  41385. * @returns the class name
  41386. */
  41387. getClassName(): string;
  41388. /**
  41389. * Defines the buttons associated with the input to handle camera move.
  41390. */
  41391. buttons: number[];
  41392. /**
  41393. * Defines the pointer angular sensibility along the X axis or how fast is
  41394. * the camera rotating.
  41395. */
  41396. angularSensibilityX: number;
  41397. /**
  41398. * Defines the pointer angular sensibility along the Y axis or how fast is
  41399. * the camera rotating.
  41400. */
  41401. angularSensibilityY: number;
  41402. /**
  41403. * Defines the pointer pinch precision or how fast is the camera zooming.
  41404. */
  41405. pinchPrecision: number;
  41406. /**
  41407. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41408. * from 0.
  41409. * It defines the percentage of current camera.radius to use as delta when
  41410. * pinch zoom is used.
  41411. */
  41412. pinchDeltaPercentage: number;
  41413. /**
  41414. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41415. * that any object in the plane at the camera's target point will scale
  41416. * perfectly with finger motion.
  41417. * Overrides pinchDeltaPercentage and pinchPrecision.
  41418. */
  41419. useNaturalPinchZoom: boolean;
  41420. /**
  41421. * Defines the pointer panning sensibility or how fast is the camera moving.
  41422. */
  41423. panningSensibility: number;
  41424. /**
  41425. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41426. */
  41427. multiTouchPanning: boolean;
  41428. /**
  41429. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41430. * zoom (pinch) through multitouch.
  41431. */
  41432. multiTouchPanAndZoom: boolean;
  41433. /**
  41434. * Revers pinch action direction.
  41435. */
  41436. pinchInwards: boolean;
  41437. private _isPanClick;
  41438. private _twoFingerActivityCount;
  41439. private _isPinching;
  41440. /**
  41441. * Called on pointer POINTERMOVE event if only a single touch is active.
  41442. */
  41443. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41444. /**
  41445. * Called on pointer POINTERDOUBLETAP event.
  41446. */
  41447. protected onDoubleTap(type: string): void;
  41448. /**
  41449. * Called on pointer POINTERMOVE event if multiple touches are active.
  41450. */
  41451. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41452. /**
  41453. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41454. * press.
  41455. */
  41456. protected onButtonDown(evt: PointerEvent): void;
  41457. /**
  41458. * Called each time a new POINTERUP event occurs. Ie, for each button
  41459. * release.
  41460. */
  41461. protected onButtonUp(evt: PointerEvent): void;
  41462. /**
  41463. * Called when window becomes inactive.
  41464. */
  41465. protected onLostFocus(): void;
  41466. }
  41467. }
  41468. declare module BABYLON {
  41469. /**
  41470. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41471. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41472. */
  41473. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41474. /**
  41475. * Defines the camera the input is attached to.
  41476. */
  41477. camera: ArcRotateCamera;
  41478. /**
  41479. * Defines the list of key codes associated with the up action (increase alpha)
  41480. */
  41481. keysUp: number[];
  41482. /**
  41483. * Defines the list of key codes associated with the down action (decrease alpha)
  41484. */
  41485. keysDown: number[];
  41486. /**
  41487. * Defines the list of key codes associated with the left action (increase beta)
  41488. */
  41489. keysLeft: number[];
  41490. /**
  41491. * Defines the list of key codes associated with the right action (decrease beta)
  41492. */
  41493. keysRight: number[];
  41494. /**
  41495. * Defines the list of key codes associated with the reset action.
  41496. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41497. */
  41498. keysReset: number[];
  41499. /**
  41500. * Defines the panning sensibility of the inputs.
  41501. * (How fast is the camera panning)
  41502. */
  41503. panningSensibility: number;
  41504. /**
  41505. * Defines the zooming sensibility of the inputs.
  41506. * (How fast is the camera zooming)
  41507. */
  41508. zoomingSensibility: number;
  41509. /**
  41510. * Defines whether maintaining the alt key down switch the movement mode from
  41511. * orientation to zoom.
  41512. */
  41513. useAltToZoom: boolean;
  41514. /**
  41515. * Rotation speed of the camera
  41516. */
  41517. angularSpeed: number;
  41518. private _keys;
  41519. private _ctrlPressed;
  41520. private _altPressed;
  41521. private _onCanvasBlurObserver;
  41522. private _onKeyboardObserver;
  41523. private _engine;
  41524. private _scene;
  41525. /**
  41526. * Attach the input controls to a specific dom element to get the input from.
  41527. * @param element Defines the element the controls should be listened from
  41528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41529. */
  41530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41531. /**
  41532. * Detach the current controls from the specified dom element.
  41533. * @param element Defines the element to stop listening the inputs from
  41534. */
  41535. detachControl(element: Nullable<HTMLElement>): void;
  41536. /**
  41537. * Update the current camera state depending on the inputs that have been used this frame.
  41538. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41539. */
  41540. checkInputs(): void;
  41541. /**
  41542. * Gets the class name of the current intput.
  41543. * @returns the class name
  41544. */
  41545. getClassName(): string;
  41546. /**
  41547. * Get the friendly name associated with the input class.
  41548. * @returns the input friendly name
  41549. */
  41550. getSimpleName(): string;
  41551. }
  41552. }
  41553. declare module BABYLON {
  41554. /**
  41555. * Manage the mouse wheel inputs to control an arc rotate camera.
  41556. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41557. */
  41558. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41559. /**
  41560. * Defines the camera the input is attached to.
  41561. */
  41562. camera: ArcRotateCamera;
  41563. /**
  41564. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41565. */
  41566. wheelPrecision: number;
  41567. /**
  41568. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41569. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41570. */
  41571. wheelDeltaPercentage: number;
  41572. private _wheel;
  41573. private _observer;
  41574. private computeDeltaFromMouseWheelLegacyEvent;
  41575. /**
  41576. * Attach the input controls to a specific dom element to get the input from.
  41577. * @param element Defines the element the controls should be listened from
  41578. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41579. */
  41580. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41581. /**
  41582. * Detach the current controls from the specified dom element.
  41583. * @param element Defines the element to stop listening the inputs from
  41584. */
  41585. detachControl(element: Nullable<HTMLElement>): void;
  41586. /**
  41587. * Gets the class name of the current intput.
  41588. * @returns the class name
  41589. */
  41590. getClassName(): string;
  41591. /**
  41592. * Get the friendly name associated with the input class.
  41593. * @returns the input friendly name
  41594. */
  41595. getSimpleName(): string;
  41596. }
  41597. }
  41598. declare module BABYLON {
  41599. /**
  41600. * Default Inputs manager for the ArcRotateCamera.
  41601. * It groups all the default supported inputs for ease of use.
  41602. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41603. */
  41604. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41605. /**
  41606. * Instantiates a new ArcRotateCameraInputsManager.
  41607. * @param camera Defines the camera the inputs belong to
  41608. */
  41609. constructor(camera: ArcRotateCamera);
  41610. /**
  41611. * Add mouse wheel input support to the input manager.
  41612. * @returns the current input manager
  41613. */
  41614. addMouseWheel(): ArcRotateCameraInputsManager;
  41615. /**
  41616. * Add pointers input support to the input manager.
  41617. * @returns the current input manager
  41618. */
  41619. addPointers(): ArcRotateCameraInputsManager;
  41620. /**
  41621. * Add keyboard input support to the input manager.
  41622. * @returns the current input manager
  41623. */
  41624. addKeyboard(): ArcRotateCameraInputsManager;
  41625. }
  41626. }
  41627. declare module BABYLON {
  41628. /**
  41629. * This represents an orbital type of camera.
  41630. *
  41631. * 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.
  41632. * 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.
  41633. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41634. */
  41635. export class ArcRotateCamera extends TargetCamera {
  41636. /**
  41637. * Defines the rotation angle of the camera along the longitudinal axis.
  41638. */
  41639. alpha: number;
  41640. /**
  41641. * Defines the rotation angle of the camera along the latitudinal axis.
  41642. */
  41643. beta: number;
  41644. /**
  41645. * Defines the radius of the camera from it s target point.
  41646. */
  41647. radius: number;
  41648. protected _target: Vector3;
  41649. protected _targetHost: Nullable<AbstractMesh>;
  41650. /**
  41651. * Defines the target point of the camera.
  41652. * The camera looks towards it form the radius distance.
  41653. */
  41654. get target(): Vector3;
  41655. set target(value: Vector3);
  41656. /**
  41657. * Define the current local position of the camera in the scene
  41658. */
  41659. get position(): Vector3;
  41660. set position(newPosition: Vector3);
  41661. protected _upVector: Vector3;
  41662. protected _upToYMatrix: Matrix;
  41663. protected _YToUpMatrix: Matrix;
  41664. /**
  41665. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41666. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41667. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41668. */
  41669. set upVector(vec: Vector3);
  41670. get upVector(): Vector3;
  41671. /**
  41672. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41673. */
  41674. setMatUp(): void;
  41675. /**
  41676. * Current inertia value on the longitudinal axis.
  41677. * The bigger this number the longer it will take for the camera to stop.
  41678. */
  41679. inertialAlphaOffset: number;
  41680. /**
  41681. * Current inertia value on the latitudinal axis.
  41682. * The bigger this number the longer it will take for the camera to stop.
  41683. */
  41684. inertialBetaOffset: number;
  41685. /**
  41686. * Current inertia value on the radius axis.
  41687. * The bigger this number the longer it will take for the camera to stop.
  41688. */
  41689. inertialRadiusOffset: number;
  41690. /**
  41691. * Minimum allowed angle on the longitudinal axis.
  41692. * This can help limiting how the Camera is able to move in the scene.
  41693. */
  41694. lowerAlphaLimit: Nullable<number>;
  41695. /**
  41696. * Maximum allowed angle on the longitudinal axis.
  41697. * This can help limiting how the Camera is able to move in the scene.
  41698. */
  41699. upperAlphaLimit: Nullable<number>;
  41700. /**
  41701. * Minimum allowed angle on the latitudinal axis.
  41702. * This can help limiting how the Camera is able to move in the scene.
  41703. */
  41704. lowerBetaLimit: number;
  41705. /**
  41706. * Maximum allowed angle on the latitudinal axis.
  41707. * This can help limiting how the Camera is able to move in the scene.
  41708. */
  41709. upperBetaLimit: number;
  41710. /**
  41711. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41712. * This can help limiting how the Camera is able to move in the scene.
  41713. */
  41714. lowerRadiusLimit: Nullable<number>;
  41715. /**
  41716. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41717. * This can help limiting how the Camera is able to move in the scene.
  41718. */
  41719. upperRadiusLimit: Nullable<number>;
  41720. /**
  41721. * Defines the current inertia value used during panning of the camera along the X axis.
  41722. */
  41723. inertialPanningX: number;
  41724. /**
  41725. * Defines the current inertia value used during panning of the camera along the Y axis.
  41726. */
  41727. inertialPanningY: number;
  41728. /**
  41729. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41730. * Basically if your fingers moves away from more than this distance you will be considered
  41731. * in pinch mode.
  41732. */
  41733. pinchToPanMaxDistance: number;
  41734. /**
  41735. * Defines the maximum distance the camera can pan.
  41736. * This could help keeping the cammera always in your scene.
  41737. */
  41738. panningDistanceLimit: Nullable<number>;
  41739. /**
  41740. * Defines the target of the camera before paning.
  41741. */
  41742. panningOriginTarget: Vector3;
  41743. /**
  41744. * Defines the value of the inertia used during panning.
  41745. * 0 would mean stop inertia and one would mean no decelleration at all.
  41746. */
  41747. panningInertia: number;
  41748. /**
  41749. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41750. */
  41751. get angularSensibilityX(): number;
  41752. set angularSensibilityX(value: number);
  41753. /**
  41754. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41755. */
  41756. get angularSensibilityY(): number;
  41757. set angularSensibilityY(value: number);
  41758. /**
  41759. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  41760. */
  41761. get pinchPrecision(): number;
  41762. set pinchPrecision(value: number);
  41763. /**
  41764. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  41765. * It will be used instead of pinchDeltaPrecision if different from 0.
  41766. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41767. */
  41768. get pinchDeltaPercentage(): number;
  41769. set pinchDeltaPercentage(value: number);
  41770. /**
  41771. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  41772. * and pinch delta percentage.
  41773. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41774. * that any object in the plane at the camera's target point will scale
  41775. * perfectly with finger motion.
  41776. */
  41777. get useNaturalPinchZoom(): boolean;
  41778. set useNaturalPinchZoom(value: boolean);
  41779. /**
  41780. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  41781. */
  41782. get panningSensibility(): number;
  41783. set panningSensibility(value: number);
  41784. /**
  41785. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  41786. */
  41787. get keysUp(): number[];
  41788. set keysUp(value: number[]);
  41789. /**
  41790. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  41791. */
  41792. get keysDown(): number[];
  41793. set keysDown(value: number[]);
  41794. /**
  41795. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  41796. */
  41797. get keysLeft(): number[];
  41798. set keysLeft(value: number[]);
  41799. /**
  41800. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  41801. */
  41802. get keysRight(): number[];
  41803. set keysRight(value: number[]);
  41804. /**
  41805. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41806. */
  41807. get wheelPrecision(): number;
  41808. set wheelPrecision(value: number);
  41809. /**
  41810. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  41811. * It will be used instead of pinchDeltaPrecision if different from 0.
  41812. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41813. */
  41814. get wheelDeltaPercentage(): number;
  41815. set wheelDeltaPercentage(value: number);
  41816. /**
  41817. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  41818. */
  41819. zoomOnFactor: number;
  41820. /**
  41821. * Defines a screen offset for the camera position.
  41822. */
  41823. targetScreenOffset: Vector2;
  41824. /**
  41825. * Allows the camera to be completely reversed.
  41826. * If false the camera can not arrive upside down.
  41827. */
  41828. allowUpsideDown: boolean;
  41829. /**
  41830. * Define if double tap/click is used to restore the previously saved state of the camera.
  41831. */
  41832. useInputToRestoreState: boolean;
  41833. /** @hidden */
  41834. _viewMatrix: Matrix;
  41835. /** @hidden */
  41836. _useCtrlForPanning: boolean;
  41837. /** @hidden */
  41838. _panningMouseButton: number;
  41839. /**
  41840. * Defines the input associated to the camera.
  41841. */
  41842. inputs: ArcRotateCameraInputsManager;
  41843. /** @hidden */
  41844. _reset: () => void;
  41845. /**
  41846. * Defines the allowed panning axis.
  41847. */
  41848. panningAxis: Vector3;
  41849. protected _localDirection: Vector3;
  41850. protected _transformedDirection: Vector3;
  41851. private _bouncingBehavior;
  41852. /**
  41853. * Gets the bouncing behavior of the camera if it has been enabled.
  41854. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41855. */
  41856. get bouncingBehavior(): Nullable<BouncingBehavior>;
  41857. /**
  41858. * Defines if the bouncing behavior of the camera is enabled on the camera.
  41859. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41860. */
  41861. get useBouncingBehavior(): boolean;
  41862. set useBouncingBehavior(value: boolean);
  41863. private _framingBehavior;
  41864. /**
  41865. * Gets the framing behavior of the camera if it has been enabled.
  41866. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41867. */
  41868. get framingBehavior(): Nullable<FramingBehavior>;
  41869. /**
  41870. * Defines if the framing behavior of the camera is enabled on the camera.
  41871. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41872. */
  41873. get useFramingBehavior(): boolean;
  41874. set useFramingBehavior(value: boolean);
  41875. private _autoRotationBehavior;
  41876. /**
  41877. * Gets the auto rotation behavior of the camera if it has been enabled.
  41878. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41879. */
  41880. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  41881. /**
  41882. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  41883. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41884. */
  41885. get useAutoRotationBehavior(): boolean;
  41886. set useAutoRotationBehavior(value: boolean);
  41887. /**
  41888. * Observable triggered when the mesh target has been changed on the camera.
  41889. */
  41890. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  41891. /**
  41892. * Event raised when the camera is colliding with a mesh.
  41893. */
  41894. onCollide: (collidedMesh: AbstractMesh) => void;
  41895. /**
  41896. * Defines whether the camera should check collision with the objects oh the scene.
  41897. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  41898. */
  41899. checkCollisions: boolean;
  41900. /**
  41901. * Defines the collision radius of the camera.
  41902. * This simulates a sphere around the camera.
  41903. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41904. */
  41905. collisionRadius: Vector3;
  41906. protected _collider: Collider;
  41907. protected _previousPosition: Vector3;
  41908. protected _collisionVelocity: Vector3;
  41909. protected _newPosition: Vector3;
  41910. protected _previousAlpha: number;
  41911. protected _previousBeta: number;
  41912. protected _previousRadius: number;
  41913. protected _collisionTriggered: boolean;
  41914. protected _targetBoundingCenter: Nullable<Vector3>;
  41915. private _computationVector;
  41916. /**
  41917. * Instantiates a new ArcRotateCamera in a given scene
  41918. * @param name Defines the name of the camera
  41919. * @param alpha Defines the camera rotation along the logitudinal axis
  41920. * @param beta Defines the camera rotation along the latitudinal axis
  41921. * @param radius Defines the camera distance from its target
  41922. * @param target Defines the camera target
  41923. * @param scene Defines the scene the camera belongs to
  41924. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  41925. */
  41926. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41927. /** @hidden */
  41928. _initCache(): void;
  41929. /** @hidden */
  41930. _updateCache(ignoreParentClass?: boolean): void;
  41931. protected _getTargetPosition(): Vector3;
  41932. private _storedAlpha;
  41933. private _storedBeta;
  41934. private _storedRadius;
  41935. private _storedTarget;
  41936. private _storedTargetScreenOffset;
  41937. /**
  41938. * Stores the current state of the camera (alpha, beta, radius and target)
  41939. * @returns the camera itself
  41940. */
  41941. storeState(): Camera;
  41942. /**
  41943. * @hidden
  41944. * Restored camera state. You must call storeState() first
  41945. */
  41946. _restoreStateValues(): boolean;
  41947. /** @hidden */
  41948. _isSynchronizedViewMatrix(): boolean;
  41949. /**
  41950. * Attached controls to the current camera.
  41951. * @param element Defines the element the controls should be listened from
  41952. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41953. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  41954. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  41955. */
  41956. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  41957. /**
  41958. * Detach the current controls from the camera.
  41959. * The camera will stop reacting to inputs.
  41960. * @param element Defines the element to stop listening the inputs from
  41961. */
  41962. detachControl(element: HTMLElement): void;
  41963. /** @hidden */
  41964. _checkInputs(): void;
  41965. protected _checkLimits(): void;
  41966. /**
  41967. * Rebuilds angles (alpha, beta) and radius from the give position and target
  41968. */
  41969. rebuildAnglesAndRadius(): void;
  41970. /**
  41971. * Use a position to define the current camera related information like alpha, beta and radius
  41972. * @param position Defines the position to set the camera at
  41973. */
  41974. setPosition(position: Vector3): void;
  41975. /**
  41976. * Defines the target the camera should look at.
  41977. * This will automatically adapt alpha beta and radius to fit within the new target.
  41978. * @param target Defines the new target as a Vector or a mesh
  41979. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  41980. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  41981. */
  41982. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  41983. /** @hidden */
  41984. _getViewMatrix(): Matrix;
  41985. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  41986. /**
  41987. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  41988. * @param meshes Defines the mesh to zoom on
  41989. * @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)
  41990. */
  41991. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  41992. /**
  41993. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  41994. * The target will be changed but the radius
  41995. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  41996. * @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)
  41997. */
  41998. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  41999. min: Vector3;
  42000. max: Vector3;
  42001. distance: number;
  42002. }, doNotUpdateMaxZ?: boolean): void;
  42003. /**
  42004. * @override
  42005. * Override Camera.createRigCamera
  42006. */
  42007. createRigCamera(name: string, cameraIndex: number): Camera;
  42008. /**
  42009. * @hidden
  42010. * @override
  42011. * Override Camera._updateRigCameras
  42012. */
  42013. _updateRigCameras(): void;
  42014. /**
  42015. * Destroy the camera and release the current resources hold by it.
  42016. */
  42017. dispose(): void;
  42018. /**
  42019. * Gets the current object class name.
  42020. * @return the class name
  42021. */
  42022. getClassName(): string;
  42023. }
  42024. }
  42025. declare module BABYLON {
  42026. /**
  42027. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42028. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42029. */
  42030. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42031. /**
  42032. * Gets the name of the behavior.
  42033. */
  42034. get name(): string;
  42035. private _zoomStopsAnimation;
  42036. private _idleRotationSpeed;
  42037. private _idleRotationWaitTime;
  42038. private _idleRotationSpinupTime;
  42039. /**
  42040. * Sets the flag that indicates if user zooming should stop animation.
  42041. */
  42042. set zoomStopsAnimation(flag: boolean);
  42043. /**
  42044. * Gets the flag that indicates if user zooming should stop animation.
  42045. */
  42046. get zoomStopsAnimation(): boolean;
  42047. /**
  42048. * Sets the default speed at which the camera rotates around the model.
  42049. */
  42050. set idleRotationSpeed(speed: number);
  42051. /**
  42052. * Gets the default speed at which the camera rotates around the model.
  42053. */
  42054. get idleRotationSpeed(): number;
  42055. /**
  42056. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42057. */
  42058. set idleRotationWaitTime(time: number);
  42059. /**
  42060. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42061. */
  42062. get idleRotationWaitTime(): number;
  42063. /**
  42064. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42065. */
  42066. set idleRotationSpinupTime(time: number);
  42067. /**
  42068. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42069. */
  42070. get idleRotationSpinupTime(): number;
  42071. /**
  42072. * Gets a value indicating if the camera is currently rotating because of this behavior
  42073. */
  42074. get rotationInProgress(): boolean;
  42075. private _onPrePointerObservableObserver;
  42076. private _onAfterCheckInputsObserver;
  42077. private _attachedCamera;
  42078. private _isPointerDown;
  42079. private _lastFrameTime;
  42080. private _lastInteractionTime;
  42081. private _cameraRotationSpeed;
  42082. /**
  42083. * Initializes the behavior.
  42084. */
  42085. init(): void;
  42086. /**
  42087. * Attaches the behavior to its arc rotate camera.
  42088. * @param camera Defines the camera to attach the behavior to
  42089. */
  42090. attach(camera: ArcRotateCamera): void;
  42091. /**
  42092. * Detaches the behavior from its current arc rotate camera.
  42093. */
  42094. detach(): void;
  42095. /**
  42096. * Returns true if user is scrolling.
  42097. * @return true if user is scrolling.
  42098. */
  42099. private _userIsZooming;
  42100. private _lastFrameRadius;
  42101. private _shouldAnimationStopForInteraction;
  42102. /**
  42103. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42104. */
  42105. private _applyUserInteraction;
  42106. private _userIsMoving;
  42107. }
  42108. }
  42109. declare module BABYLON {
  42110. /**
  42111. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42112. */
  42113. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42114. private ui;
  42115. /**
  42116. * The name of the behavior
  42117. */
  42118. name: string;
  42119. /**
  42120. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42121. */
  42122. distanceAwayFromFace: number;
  42123. /**
  42124. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42125. */
  42126. distanceAwayFromBottomOfFace: number;
  42127. private _faceVectors;
  42128. private _target;
  42129. private _scene;
  42130. private _onRenderObserver;
  42131. private _tmpMatrix;
  42132. private _tmpVector;
  42133. /**
  42134. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42135. * @param ui The transform node that should be attched to the mesh
  42136. */
  42137. constructor(ui: TransformNode);
  42138. /**
  42139. * Initializes the behavior
  42140. */
  42141. init(): void;
  42142. private _closestFace;
  42143. private _zeroVector;
  42144. private _lookAtTmpMatrix;
  42145. private _lookAtToRef;
  42146. /**
  42147. * Attaches the AttachToBoxBehavior to the passed in mesh
  42148. * @param target The mesh that the specified node will be attached to
  42149. */
  42150. attach(target: Mesh): void;
  42151. /**
  42152. * Detaches the behavior from the mesh
  42153. */
  42154. detach(): void;
  42155. }
  42156. }
  42157. declare module BABYLON {
  42158. /**
  42159. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42160. */
  42161. export class FadeInOutBehavior implements Behavior<Mesh> {
  42162. /**
  42163. * Time in milliseconds to delay before fading in (Default: 0)
  42164. */
  42165. delay: number;
  42166. /**
  42167. * Time in milliseconds for the mesh to fade in (Default: 300)
  42168. */
  42169. fadeInTime: number;
  42170. private _millisecondsPerFrame;
  42171. private _hovered;
  42172. private _hoverValue;
  42173. private _ownerNode;
  42174. /**
  42175. * Instatiates the FadeInOutBehavior
  42176. */
  42177. constructor();
  42178. /**
  42179. * The name of the behavior
  42180. */
  42181. get name(): string;
  42182. /**
  42183. * Initializes the behavior
  42184. */
  42185. init(): void;
  42186. /**
  42187. * Attaches the fade behavior on the passed in mesh
  42188. * @param ownerNode The mesh that will be faded in/out once attached
  42189. */
  42190. attach(ownerNode: Mesh): void;
  42191. /**
  42192. * Detaches the behavior from the mesh
  42193. */
  42194. detach(): void;
  42195. /**
  42196. * Triggers the mesh to begin fading in or out
  42197. * @param value if the object should fade in or out (true to fade in)
  42198. */
  42199. fadeIn(value: boolean): void;
  42200. private _update;
  42201. private _setAllVisibility;
  42202. }
  42203. }
  42204. declare module BABYLON {
  42205. /**
  42206. * Class containing a set of static utilities functions for managing Pivots
  42207. * @hidden
  42208. */
  42209. export class PivotTools {
  42210. private static _PivotCached;
  42211. private static _OldPivotPoint;
  42212. private static _PivotTranslation;
  42213. private static _PivotTmpVector;
  42214. /** @hidden */
  42215. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42216. /** @hidden */
  42217. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42218. }
  42219. }
  42220. declare module BABYLON {
  42221. /**
  42222. * Class containing static functions to help procedurally build meshes
  42223. */
  42224. export class PlaneBuilder {
  42225. /**
  42226. * Creates a plane mesh
  42227. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42228. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42229. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42231. * * 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
  42232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42233. * @param name defines the name of the mesh
  42234. * @param options defines the options used to create the mesh
  42235. * @param scene defines the hosting scene
  42236. * @returns the plane mesh
  42237. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42238. */
  42239. static CreatePlane(name: string, options: {
  42240. size?: number;
  42241. width?: number;
  42242. height?: number;
  42243. sideOrientation?: number;
  42244. frontUVs?: Vector4;
  42245. backUVs?: Vector4;
  42246. updatable?: boolean;
  42247. sourcePlane?: Plane;
  42248. }, scene?: Nullable<Scene>): Mesh;
  42249. }
  42250. }
  42251. declare module BABYLON {
  42252. /**
  42253. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42254. */
  42255. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42256. private static _AnyMouseID;
  42257. /**
  42258. * Abstract mesh the behavior is set on
  42259. */
  42260. attachedNode: AbstractMesh;
  42261. private _dragPlane;
  42262. private _scene;
  42263. private _pointerObserver;
  42264. private _beforeRenderObserver;
  42265. private static _planeScene;
  42266. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42267. /**
  42268. * 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)
  42269. */
  42270. maxDragAngle: number;
  42271. /**
  42272. * @hidden
  42273. */
  42274. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42275. /**
  42276. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42277. */
  42278. currentDraggingPointerID: number;
  42279. /**
  42280. * The last position where the pointer hit the drag plane in world space
  42281. */
  42282. lastDragPosition: Vector3;
  42283. /**
  42284. * If the behavior is currently in a dragging state
  42285. */
  42286. dragging: boolean;
  42287. /**
  42288. * 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)
  42289. */
  42290. dragDeltaRatio: number;
  42291. /**
  42292. * If the drag plane orientation should be updated during the dragging (Default: true)
  42293. */
  42294. updateDragPlane: boolean;
  42295. private _debugMode;
  42296. private _moving;
  42297. /**
  42298. * Fires each time the attached mesh is dragged with the pointer
  42299. * * delta between last drag position and current drag position in world space
  42300. * * dragDistance along the drag axis
  42301. * * dragPlaneNormal normal of the current drag plane used during the drag
  42302. * * dragPlanePoint in world space where the drag intersects the drag plane
  42303. */
  42304. onDragObservable: Observable<{
  42305. delta: Vector3;
  42306. dragPlanePoint: Vector3;
  42307. dragPlaneNormal: Vector3;
  42308. dragDistance: number;
  42309. pointerId: number;
  42310. }>;
  42311. /**
  42312. * Fires each time a drag begins (eg. mouse down on mesh)
  42313. */
  42314. onDragStartObservable: Observable<{
  42315. dragPlanePoint: Vector3;
  42316. pointerId: number;
  42317. }>;
  42318. /**
  42319. * Fires each time a drag ends (eg. mouse release after drag)
  42320. */
  42321. onDragEndObservable: Observable<{
  42322. dragPlanePoint: Vector3;
  42323. pointerId: number;
  42324. }>;
  42325. /**
  42326. * If the attached mesh should be moved when dragged
  42327. */
  42328. moveAttached: boolean;
  42329. /**
  42330. * If the drag behavior will react to drag events (Default: true)
  42331. */
  42332. enabled: boolean;
  42333. /**
  42334. * If pointer events should start and release the drag (Default: true)
  42335. */
  42336. startAndReleaseDragOnPointerEvents: boolean;
  42337. /**
  42338. * If camera controls should be detached during the drag
  42339. */
  42340. detachCameraControls: boolean;
  42341. /**
  42342. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42343. */
  42344. useObjectOrientationForDragging: boolean;
  42345. private _options;
  42346. /**
  42347. * Gets the options used by the behavior
  42348. */
  42349. get options(): {
  42350. dragAxis?: Vector3;
  42351. dragPlaneNormal?: Vector3;
  42352. };
  42353. /**
  42354. * Sets the options used by the behavior
  42355. */
  42356. set options(options: {
  42357. dragAxis?: Vector3;
  42358. dragPlaneNormal?: Vector3;
  42359. });
  42360. /**
  42361. * Creates a pointer drag behavior that can be attached to a mesh
  42362. * @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)
  42363. */
  42364. constructor(options?: {
  42365. dragAxis?: Vector3;
  42366. dragPlaneNormal?: Vector3;
  42367. });
  42368. /**
  42369. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42370. */
  42371. validateDrag: (targetPosition: Vector3) => boolean;
  42372. /**
  42373. * The name of the behavior
  42374. */
  42375. get name(): string;
  42376. /**
  42377. * Initializes the behavior
  42378. */
  42379. init(): void;
  42380. private _tmpVector;
  42381. private _alternatePickedPoint;
  42382. private _worldDragAxis;
  42383. private _targetPosition;
  42384. private _attachedElement;
  42385. /**
  42386. * Attaches the drag behavior the passed in mesh
  42387. * @param ownerNode The mesh that will be dragged around once attached
  42388. * @param predicate Predicate to use for pick filtering
  42389. */
  42390. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42391. /**
  42392. * Force relase the drag action by code.
  42393. */
  42394. releaseDrag(): void;
  42395. private _startDragRay;
  42396. private _lastPointerRay;
  42397. /**
  42398. * Simulates the start of a pointer drag event on the behavior
  42399. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42400. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42401. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42402. */
  42403. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42404. private _startDrag;
  42405. private _dragDelta;
  42406. private _moveDrag;
  42407. private _pickWithRayOnDragPlane;
  42408. private _pointA;
  42409. private _pointB;
  42410. private _pointC;
  42411. private _lineA;
  42412. private _lineB;
  42413. private _localAxis;
  42414. private _lookAt;
  42415. private _updateDragPlanePosition;
  42416. /**
  42417. * Detaches the behavior from the mesh
  42418. */
  42419. detach(): void;
  42420. }
  42421. }
  42422. declare module BABYLON {
  42423. /**
  42424. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42425. */
  42426. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42427. private _dragBehaviorA;
  42428. private _dragBehaviorB;
  42429. private _startDistance;
  42430. private _initialScale;
  42431. private _targetScale;
  42432. private _ownerNode;
  42433. private _sceneRenderObserver;
  42434. /**
  42435. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42436. */
  42437. constructor();
  42438. /**
  42439. * The name of the behavior
  42440. */
  42441. get name(): string;
  42442. /**
  42443. * Initializes the behavior
  42444. */
  42445. init(): void;
  42446. private _getCurrentDistance;
  42447. /**
  42448. * Attaches the scale behavior the passed in mesh
  42449. * @param ownerNode The mesh that will be scaled around once attached
  42450. */
  42451. attach(ownerNode: Mesh): void;
  42452. /**
  42453. * Detaches the behavior from the mesh
  42454. */
  42455. detach(): void;
  42456. }
  42457. }
  42458. declare module BABYLON {
  42459. /**
  42460. * 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
  42461. */
  42462. export class SixDofDragBehavior implements Behavior<Mesh> {
  42463. private static _virtualScene;
  42464. private _ownerNode;
  42465. private _sceneRenderObserver;
  42466. private _scene;
  42467. private _targetPosition;
  42468. private _virtualOriginMesh;
  42469. private _virtualDragMesh;
  42470. private _pointerObserver;
  42471. private _moving;
  42472. private _startingOrientation;
  42473. private _attachedElement;
  42474. /**
  42475. * 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)
  42476. */
  42477. private zDragFactor;
  42478. /**
  42479. * If the object should rotate to face the drag origin
  42480. */
  42481. rotateDraggedObject: boolean;
  42482. /**
  42483. * If the behavior is currently in a dragging state
  42484. */
  42485. dragging: boolean;
  42486. /**
  42487. * 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)
  42488. */
  42489. dragDeltaRatio: number;
  42490. /**
  42491. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42492. */
  42493. currentDraggingPointerID: number;
  42494. /**
  42495. * If camera controls should be detached during the drag
  42496. */
  42497. detachCameraControls: boolean;
  42498. /**
  42499. * Fires each time a drag starts
  42500. */
  42501. onDragStartObservable: Observable<{}>;
  42502. /**
  42503. * Fires each time a drag ends (eg. mouse release after drag)
  42504. */
  42505. onDragEndObservable: Observable<{}>;
  42506. /**
  42507. * 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
  42508. */
  42509. constructor();
  42510. /**
  42511. * The name of the behavior
  42512. */
  42513. get name(): string;
  42514. /**
  42515. * Initializes the behavior
  42516. */
  42517. init(): void;
  42518. /**
  42519. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42520. */
  42521. private get _pointerCamera();
  42522. /**
  42523. * Attaches the scale behavior the passed in mesh
  42524. * @param ownerNode The mesh that will be scaled around once attached
  42525. */
  42526. attach(ownerNode: Mesh): void;
  42527. /**
  42528. * Detaches the behavior from the mesh
  42529. */
  42530. detach(): void;
  42531. }
  42532. }
  42533. declare module BABYLON {
  42534. /**
  42535. * Class used to apply inverse kinematics to bones
  42536. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42537. */
  42538. export class BoneIKController {
  42539. private static _tmpVecs;
  42540. private static _tmpQuat;
  42541. private static _tmpMats;
  42542. /**
  42543. * Gets or sets the target mesh
  42544. */
  42545. targetMesh: AbstractMesh;
  42546. /** Gets or sets the mesh used as pole */
  42547. poleTargetMesh: AbstractMesh;
  42548. /**
  42549. * Gets or sets the bone used as pole
  42550. */
  42551. poleTargetBone: Nullable<Bone>;
  42552. /**
  42553. * Gets or sets the target position
  42554. */
  42555. targetPosition: Vector3;
  42556. /**
  42557. * Gets or sets the pole target position
  42558. */
  42559. poleTargetPosition: Vector3;
  42560. /**
  42561. * Gets or sets the pole target local offset
  42562. */
  42563. poleTargetLocalOffset: Vector3;
  42564. /**
  42565. * Gets or sets the pole angle
  42566. */
  42567. poleAngle: number;
  42568. /**
  42569. * Gets or sets the mesh associated with the controller
  42570. */
  42571. mesh: AbstractMesh;
  42572. /**
  42573. * 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)
  42574. */
  42575. slerpAmount: number;
  42576. private _bone1Quat;
  42577. private _bone1Mat;
  42578. private _bone2Ang;
  42579. private _bone1;
  42580. private _bone2;
  42581. private _bone1Length;
  42582. private _bone2Length;
  42583. private _maxAngle;
  42584. private _maxReach;
  42585. private _rightHandedSystem;
  42586. private _bendAxis;
  42587. private _slerping;
  42588. private _adjustRoll;
  42589. /**
  42590. * Gets or sets maximum allowed angle
  42591. */
  42592. get maxAngle(): number;
  42593. set maxAngle(value: number);
  42594. /**
  42595. * Creates a new BoneIKController
  42596. * @param mesh defines the mesh to control
  42597. * @param bone defines the bone to control
  42598. * @param options defines options to set up the controller
  42599. */
  42600. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42601. targetMesh?: AbstractMesh;
  42602. poleTargetMesh?: AbstractMesh;
  42603. poleTargetBone?: Bone;
  42604. poleTargetLocalOffset?: Vector3;
  42605. poleAngle?: number;
  42606. bendAxis?: Vector3;
  42607. maxAngle?: number;
  42608. slerpAmount?: number;
  42609. });
  42610. private _setMaxAngle;
  42611. /**
  42612. * Force the controller to update the bones
  42613. */
  42614. update(): void;
  42615. }
  42616. }
  42617. declare module BABYLON {
  42618. /**
  42619. * Class used to make a bone look toward a point in space
  42620. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42621. */
  42622. export class BoneLookController {
  42623. private static _tmpVecs;
  42624. private static _tmpQuat;
  42625. private static _tmpMats;
  42626. /**
  42627. * The target Vector3 that the bone will look at
  42628. */
  42629. target: Vector3;
  42630. /**
  42631. * The mesh that the bone is attached to
  42632. */
  42633. mesh: AbstractMesh;
  42634. /**
  42635. * The bone that will be looking to the target
  42636. */
  42637. bone: Bone;
  42638. /**
  42639. * The up axis of the coordinate system that is used when the bone is rotated
  42640. */
  42641. upAxis: Vector3;
  42642. /**
  42643. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42644. */
  42645. upAxisSpace: Space;
  42646. /**
  42647. * Used to make an adjustment to the yaw of the bone
  42648. */
  42649. adjustYaw: number;
  42650. /**
  42651. * Used to make an adjustment to the pitch of the bone
  42652. */
  42653. adjustPitch: number;
  42654. /**
  42655. * Used to make an adjustment to the roll of the bone
  42656. */
  42657. adjustRoll: number;
  42658. /**
  42659. * 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)
  42660. */
  42661. slerpAmount: number;
  42662. private _minYaw;
  42663. private _maxYaw;
  42664. private _minPitch;
  42665. private _maxPitch;
  42666. private _minYawSin;
  42667. private _minYawCos;
  42668. private _maxYawSin;
  42669. private _maxYawCos;
  42670. private _midYawConstraint;
  42671. private _minPitchTan;
  42672. private _maxPitchTan;
  42673. private _boneQuat;
  42674. private _slerping;
  42675. private _transformYawPitch;
  42676. private _transformYawPitchInv;
  42677. private _firstFrameSkipped;
  42678. private _yawRange;
  42679. private _fowardAxis;
  42680. /**
  42681. * Gets or sets the minimum yaw angle that the bone can look to
  42682. */
  42683. get minYaw(): number;
  42684. set minYaw(value: number);
  42685. /**
  42686. * Gets or sets the maximum yaw angle that the bone can look to
  42687. */
  42688. get maxYaw(): number;
  42689. set maxYaw(value: number);
  42690. /**
  42691. * Gets or sets the minimum pitch angle that the bone can look to
  42692. */
  42693. get minPitch(): number;
  42694. set minPitch(value: number);
  42695. /**
  42696. * Gets or sets the maximum pitch angle that the bone can look to
  42697. */
  42698. get maxPitch(): number;
  42699. set maxPitch(value: number);
  42700. /**
  42701. * Create a BoneLookController
  42702. * @param mesh the mesh that the bone belongs to
  42703. * @param bone the bone that will be looking to the target
  42704. * @param target the target Vector3 to look at
  42705. * @param options optional settings:
  42706. * * maxYaw: the maximum angle the bone will yaw to
  42707. * * minYaw: the minimum angle the bone will yaw to
  42708. * * maxPitch: the maximum angle the bone will pitch to
  42709. * * minPitch: the minimum angle the bone will yaw to
  42710. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42711. * * upAxis: the up axis of the coordinate system
  42712. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42713. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42714. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42715. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42716. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42717. * * adjustRoll: used to make an adjustment to the roll of the bone
  42718. **/
  42719. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42720. maxYaw?: number;
  42721. minYaw?: number;
  42722. maxPitch?: number;
  42723. minPitch?: number;
  42724. slerpAmount?: number;
  42725. upAxis?: Vector3;
  42726. upAxisSpace?: Space;
  42727. yawAxis?: Vector3;
  42728. pitchAxis?: Vector3;
  42729. adjustYaw?: number;
  42730. adjustPitch?: number;
  42731. adjustRoll?: number;
  42732. });
  42733. /**
  42734. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42735. */
  42736. update(): void;
  42737. private _getAngleDiff;
  42738. private _getAngleBetween;
  42739. private _isAngleBetween;
  42740. }
  42741. }
  42742. declare module BABYLON {
  42743. /**
  42744. * Manage the gamepad inputs to control an arc rotate camera.
  42745. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42746. */
  42747. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42748. /**
  42749. * Defines the camera the input is attached to.
  42750. */
  42751. camera: ArcRotateCamera;
  42752. /**
  42753. * Defines the gamepad the input is gathering event from.
  42754. */
  42755. gamepad: Nullable<Gamepad>;
  42756. /**
  42757. * Defines the gamepad rotation sensiblity.
  42758. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42759. */
  42760. gamepadRotationSensibility: number;
  42761. /**
  42762. * Defines the gamepad move sensiblity.
  42763. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42764. */
  42765. gamepadMoveSensibility: number;
  42766. private _yAxisScale;
  42767. /**
  42768. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42769. */
  42770. get invertYAxis(): boolean;
  42771. set invertYAxis(value: boolean);
  42772. private _onGamepadConnectedObserver;
  42773. private _onGamepadDisconnectedObserver;
  42774. /**
  42775. * Attach the input controls to a specific dom element to get the input from.
  42776. * @param element Defines the element the controls should be listened from
  42777. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42778. */
  42779. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42780. /**
  42781. * Detach the current controls from the specified dom element.
  42782. * @param element Defines the element to stop listening the inputs from
  42783. */
  42784. detachControl(element: Nullable<HTMLElement>): void;
  42785. /**
  42786. * Update the current camera state depending on the inputs that have been used this frame.
  42787. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42788. */
  42789. checkInputs(): void;
  42790. /**
  42791. * Gets the class name of the current intput.
  42792. * @returns the class name
  42793. */
  42794. getClassName(): string;
  42795. /**
  42796. * Get the friendly name associated with the input class.
  42797. * @returns the input friendly name
  42798. */
  42799. getSimpleName(): string;
  42800. }
  42801. }
  42802. declare module BABYLON {
  42803. interface ArcRotateCameraInputsManager {
  42804. /**
  42805. * Add orientation input support to the input manager.
  42806. * @returns the current input manager
  42807. */
  42808. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  42809. }
  42810. /**
  42811. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42812. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42813. */
  42814. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42815. /**
  42816. * Defines the camera the input is attached to.
  42817. */
  42818. camera: ArcRotateCamera;
  42819. /**
  42820. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  42821. */
  42822. alphaCorrection: number;
  42823. /**
  42824. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  42825. */
  42826. gammaCorrection: number;
  42827. private _alpha;
  42828. private _gamma;
  42829. private _dirty;
  42830. private _deviceOrientationHandler;
  42831. /**
  42832. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  42833. */
  42834. constructor();
  42835. /**
  42836. * Attach the input controls to a specific dom element to get the input from.
  42837. * @param element Defines the element the controls should be listened from
  42838. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42839. */
  42840. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42841. /** @hidden */
  42842. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  42843. /**
  42844. * Update the current camera state depending on the inputs that have been used this frame.
  42845. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42846. */
  42847. checkInputs(): void;
  42848. /**
  42849. * Detach the current controls from the specified dom element.
  42850. * @param element Defines the element to stop listening the inputs from
  42851. */
  42852. detachControl(element: Nullable<HTMLElement>): void;
  42853. /**
  42854. * Gets the class name of the current intput.
  42855. * @returns the class name
  42856. */
  42857. getClassName(): string;
  42858. /**
  42859. * Get the friendly name associated with the input class.
  42860. * @returns the input friendly name
  42861. */
  42862. getSimpleName(): string;
  42863. }
  42864. }
  42865. declare module BABYLON {
  42866. /**
  42867. * Listen to mouse events to control the camera.
  42868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42869. */
  42870. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  42871. /**
  42872. * Defines the camera the input is attached to.
  42873. */
  42874. camera: FlyCamera;
  42875. /**
  42876. * Defines if touch is enabled. (Default is true.)
  42877. */
  42878. touchEnabled: boolean;
  42879. /**
  42880. * Defines the buttons associated with the input to handle camera rotation.
  42881. */
  42882. buttons: number[];
  42883. /**
  42884. * Assign buttons for Yaw control.
  42885. */
  42886. buttonsYaw: number[];
  42887. /**
  42888. * Assign buttons for Pitch control.
  42889. */
  42890. buttonsPitch: number[];
  42891. /**
  42892. * Assign buttons for Roll control.
  42893. */
  42894. buttonsRoll: number[];
  42895. /**
  42896. * Detect if any button is being pressed while mouse is moved.
  42897. * -1 = Mouse locked.
  42898. * 0 = Left button.
  42899. * 1 = Middle Button.
  42900. * 2 = Right Button.
  42901. */
  42902. activeButton: number;
  42903. /**
  42904. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42905. * Higher values reduce its sensitivity.
  42906. */
  42907. angularSensibility: number;
  42908. private _mousemoveCallback;
  42909. private _observer;
  42910. private _rollObserver;
  42911. private previousPosition;
  42912. private noPreventDefault;
  42913. private element;
  42914. /**
  42915. * Listen to mouse events to control the camera.
  42916. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42917. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42918. */
  42919. constructor(touchEnabled?: boolean);
  42920. /**
  42921. * Attach the mouse control to the HTML DOM element.
  42922. * @param element Defines the element that listens to the input events.
  42923. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  42924. */
  42925. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42926. /**
  42927. * Detach the current controls from the specified dom element.
  42928. * @param element Defines the element to stop listening the inputs from
  42929. */
  42930. detachControl(element: Nullable<HTMLElement>): void;
  42931. /**
  42932. * Gets the class name of the current input.
  42933. * @returns the class name.
  42934. */
  42935. getClassName(): string;
  42936. /**
  42937. * Get the friendly name associated with the input class.
  42938. * @returns the input's friendly name.
  42939. */
  42940. getSimpleName(): string;
  42941. private _pointerInput;
  42942. private _onMouseMove;
  42943. /**
  42944. * Rotate camera by mouse offset.
  42945. */
  42946. private rotateCamera;
  42947. }
  42948. }
  42949. declare module BABYLON {
  42950. /**
  42951. * Default Inputs manager for the FlyCamera.
  42952. * It groups all the default supported inputs for ease of use.
  42953. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42954. */
  42955. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  42956. /**
  42957. * Instantiates a new FlyCameraInputsManager.
  42958. * @param camera Defines the camera the inputs belong to.
  42959. */
  42960. constructor(camera: FlyCamera);
  42961. /**
  42962. * Add keyboard input support to the input manager.
  42963. * @returns the new FlyCameraKeyboardMoveInput().
  42964. */
  42965. addKeyboard(): FlyCameraInputsManager;
  42966. /**
  42967. * Add mouse input support to the input manager.
  42968. * @param touchEnabled Enable touch screen support.
  42969. * @returns the new FlyCameraMouseInput().
  42970. */
  42971. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  42972. }
  42973. }
  42974. declare module BABYLON {
  42975. /**
  42976. * This is a flying camera, designed for 3D movement and rotation in all directions,
  42977. * such as in a 3D Space Shooter or a Flight Simulator.
  42978. */
  42979. export class FlyCamera extends TargetCamera {
  42980. /**
  42981. * Define the collision ellipsoid of the camera.
  42982. * This is helpful for simulating a camera body, like a player's body.
  42983. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42984. */
  42985. ellipsoid: Vector3;
  42986. /**
  42987. * Define an offset for the position of the ellipsoid around the camera.
  42988. * This can be helpful if the camera is attached away from the player's body center,
  42989. * such as at its head.
  42990. */
  42991. ellipsoidOffset: Vector3;
  42992. /**
  42993. * Enable or disable collisions of the camera with the rest of the scene objects.
  42994. */
  42995. checkCollisions: boolean;
  42996. /**
  42997. * Enable or disable gravity on the camera.
  42998. */
  42999. applyGravity: boolean;
  43000. /**
  43001. * Define the current direction the camera is moving to.
  43002. */
  43003. cameraDirection: Vector3;
  43004. /**
  43005. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43006. * This overrides and empties cameraRotation.
  43007. */
  43008. rotationQuaternion: Quaternion;
  43009. /**
  43010. * Track Roll to maintain the wanted Rolling when looking around.
  43011. */
  43012. _trackRoll: number;
  43013. /**
  43014. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43015. */
  43016. rollCorrect: number;
  43017. /**
  43018. * Mimic a banked turn, Rolling the camera when Yawing.
  43019. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43020. */
  43021. bankedTurn: boolean;
  43022. /**
  43023. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43024. */
  43025. bankedTurnLimit: number;
  43026. /**
  43027. * Value of 0 disables the banked Roll.
  43028. * Value of 1 is equal to the Yaw angle in radians.
  43029. */
  43030. bankedTurnMultiplier: number;
  43031. /**
  43032. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43033. */
  43034. inputs: FlyCameraInputsManager;
  43035. /**
  43036. * Gets the input sensibility for mouse input.
  43037. * Higher values reduce sensitivity.
  43038. */
  43039. get angularSensibility(): number;
  43040. /**
  43041. * Sets the input sensibility for a mouse input.
  43042. * Higher values reduce sensitivity.
  43043. */
  43044. set angularSensibility(value: number);
  43045. /**
  43046. * Get the keys for camera movement forward.
  43047. */
  43048. get keysForward(): number[];
  43049. /**
  43050. * Set the keys for camera movement forward.
  43051. */
  43052. set keysForward(value: number[]);
  43053. /**
  43054. * Get the keys for camera movement backward.
  43055. */
  43056. get keysBackward(): number[];
  43057. set keysBackward(value: number[]);
  43058. /**
  43059. * Get the keys for camera movement up.
  43060. */
  43061. get keysUp(): number[];
  43062. /**
  43063. * Set the keys for camera movement up.
  43064. */
  43065. set keysUp(value: number[]);
  43066. /**
  43067. * Get the keys for camera movement down.
  43068. */
  43069. get keysDown(): number[];
  43070. /**
  43071. * Set the keys for camera movement down.
  43072. */
  43073. set keysDown(value: number[]);
  43074. /**
  43075. * Get the keys for camera movement left.
  43076. */
  43077. get keysLeft(): number[];
  43078. /**
  43079. * Set the keys for camera movement left.
  43080. */
  43081. set keysLeft(value: number[]);
  43082. /**
  43083. * Set the keys for camera movement right.
  43084. */
  43085. get keysRight(): number[];
  43086. /**
  43087. * Set the keys for camera movement right.
  43088. */
  43089. set keysRight(value: number[]);
  43090. /**
  43091. * Event raised when the camera collides with a mesh in the scene.
  43092. */
  43093. onCollide: (collidedMesh: AbstractMesh) => void;
  43094. private _collider;
  43095. private _needMoveForGravity;
  43096. private _oldPosition;
  43097. private _diffPosition;
  43098. private _newPosition;
  43099. /** @hidden */
  43100. _localDirection: Vector3;
  43101. /** @hidden */
  43102. _transformedDirection: Vector3;
  43103. /**
  43104. * Instantiates a FlyCamera.
  43105. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43106. * such as in a 3D Space Shooter or a Flight Simulator.
  43107. * @param name Define the name of the camera in the scene.
  43108. * @param position Define the starting position of the camera in the scene.
  43109. * @param scene Define the scene the camera belongs to.
  43110. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43111. */
  43112. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43113. /**
  43114. * Attach a control to the HTML DOM element.
  43115. * @param element Defines the element that listens to the input events.
  43116. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43117. */
  43118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43119. /**
  43120. * Detach a control from the HTML DOM element.
  43121. * The camera will stop reacting to that input.
  43122. * @param element Defines the element that listens to the input events.
  43123. */
  43124. detachControl(element: HTMLElement): void;
  43125. private _collisionMask;
  43126. /**
  43127. * Get the mask that the camera ignores in collision events.
  43128. */
  43129. get collisionMask(): number;
  43130. /**
  43131. * Set the mask that the camera ignores in collision events.
  43132. */
  43133. set collisionMask(mask: number);
  43134. /** @hidden */
  43135. _collideWithWorld(displacement: Vector3): void;
  43136. /** @hidden */
  43137. private _onCollisionPositionChange;
  43138. /** @hidden */
  43139. _checkInputs(): void;
  43140. /** @hidden */
  43141. _decideIfNeedsToMove(): boolean;
  43142. /** @hidden */
  43143. _updatePosition(): void;
  43144. /**
  43145. * Restore the Roll to its target value at the rate specified.
  43146. * @param rate - Higher means slower restoring.
  43147. * @hidden
  43148. */
  43149. restoreRoll(rate: number): void;
  43150. /**
  43151. * Destroy the camera and release the current resources held by it.
  43152. */
  43153. dispose(): void;
  43154. /**
  43155. * Get the current object class name.
  43156. * @returns the class name.
  43157. */
  43158. getClassName(): string;
  43159. }
  43160. }
  43161. declare module BABYLON {
  43162. /**
  43163. * Listen to keyboard events to control the camera.
  43164. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43165. */
  43166. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43167. /**
  43168. * Defines the camera the input is attached to.
  43169. */
  43170. camera: FlyCamera;
  43171. /**
  43172. * The list of keyboard keys used to control the forward move of the camera.
  43173. */
  43174. keysForward: number[];
  43175. /**
  43176. * The list of keyboard keys used to control the backward move of the camera.
  43177. */
  43178. keysBackward: number[];
  43179. /**
  43180. * The list of keyboard keys used to control the forward move of the camera.
  43181. */
  43182. keysUp: number[];
  43183. /**
  43184. * The list of keyboard keys used to control the backward move of the camera.
  43185. */
  43186. keysDown: number[];
  43187. /**
  43188. * The list of keyboard keys used to control the right strafe move of the camera.
  43189. */
  43190. keysRight: number[];
  43191. /**
  43192. * The list of keyboard keys used to control the left strafe move of the camera.
  43193. */
  43194. keysLeft: number[];
  43195. private _keys;
  43196. private _onCanvasBlurObserver;
  43197. private _onKeyboardObserver;
  43198. private _engine;
  43199. private _scene;
  43200. /**
  43201. * Attach the input controls to a specific dom element to get the input from.
  43202. * @param element Defines the element the controls should be listened from
  43203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43204. */
  43205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43206. /**
  43207. * Detach the current controls from the specified dom element.
  43208. * @param element Defines the element to stop listening the inputs from
  43209. */
  43210. detachControl(element: Nullable<HTMLElement>): void;
  43211. /**
  43212. * Gets the class name of the current intput.
  43213. * @returns the class name
  43214. */
  43215. getClassName(): string;
  43216. /** @hidden */
  43217. _onLostFocus(e: FocusEvent): void;
  43218. /**
  43219. * Get the friendly name associated with the input class.
  43220. * @returns the input friendly name
  43221. */
  43222. getSimpleName(): string;
  43223. /**
  43224. * Update the current camera state depending on the inputs that have been used this frame.
  43225. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43226. */
  43227. checkInputs(): void;
  43228. }
  43229. }
  43230. declare module BABYLON {
  43231. /**
  43232. * Manage the mouse wheel inputs to control a follow camera.
  43233. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43234. */
  43235. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43236. /**
  43237. * Defines the camera the input is attached to.
  43238. */
  43239. camera: FollowCamera;
  43240. /**
  43241. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43242. */
  43243. axisControlRadius: boolean;
  43244. /**
  43245. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43246. */
  43247. axisControlHeight: boolean;
  43248. /**
  43249. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43250. */
  43251. axisControlRotation: boolean;
  43252. /**
  43253. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43254. * relation to mouseWheel events.
  43255. */
  43256. wheelPrecision: number;
  43257. /**
  43258. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43259. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43260. */
  43261. wheelDeltaPercentage: number;
  43262. private _wheel;
  43263. private _observer;
  43264. /**
  43265. * Attach the input controls to a specific dom element to get the input from.
  43266. * @param element Defines the element the controls should be listened from
  43267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43268. */
  43269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43270. /**
  43271. * Detach the current controls from the specified dom element.
  43272. * @param element Defines the element to stop listening the inputs from
  43273. */
  43274. detachControl(element: Nullable<HTMLElement>): void;
  43275. /**
  43276. * Gets the class name of the current intput.
  43277. * @returns the class name
  43278. */
  43279. getClassName(): string;
  43280. /**
  43281. * Get the friendly name associated with the input class.
  43282. * @returns the input friendly name
  43283. */
  43284. getSimpleName(): string;
  43285. }
  43286. }
  43287. declare module BABYLON {
  43288. /**
  43289. * Manage the pointers inputs to control an follow camera.
  43290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43291. */
  43292. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43293. /**
  43294. * Defines the camera the input is attached to.
  43295. */
  43296. camera: FollowCamera;
  43297. /**
  43298. * Gets the class name of the current input.
  43299. * @returns the class name
  43300. */
  43301. getClassName(): string;
  43302. /**
  43303. * Defines the pointer angular sensibility along the X axis or how fast is
  43304. * the camera rotating.
  43305. * A negative number will reverse the axis direction.
  43306. */
  43307. angularSensibilityX: number;
  43308. /**
  43309. * Defines the pointer angular sensibility along the Y axis or how fast is
  43310. * the camera rotating.
  43311. * A negative number will reverse the axis direction.
  43312. */
  43313. angularSensibilityY: number;
  43314. /**
  43315. * Defines the pointer pinch precision or how fast is the camera zooming.
  43316. * A negative number will reverse the axis direction.
  43317. */
  43318. pinchPrecision: number;
  43319. /**
  43320. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43321. * from 0.
  43322. * It defines the percentage of current camera.radius to use as delta when
  43323. * pinch zoom is used.
  43324. */
  43325. pinchDeltaPercentage: number;
  43326. /**
  43327. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43328. */
  43329. axisXControlRadius: boolean;
  43330. /**
  43331. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43332. */
  43333. axisXControlHeight: boolean;
  43334. /**
  43335. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43336. */
  43337. axisXControlRotation: boolean;
  43338. /**
  43339. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43340. */
  43341. axisYControlRadius: boolean;
  43342. /**
  43343. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43344. */
  43345. axisYControlHeight: boolean;
  43346. /**
  43347. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43348. */
  43349. axisYControlRotation: boolean;
  43350. /**
  43351. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43352. */
  43353. axisPinchControlRadius: boolean;
  43354. /**
  43355. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43356. */
  43357. axisPinchControlHeight: boolean;
  43358. /**
  43359. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43360. */
  43361. axisPinchControlRotation: boolean;
  43362. /**
  43363. * Log error messages if basic misconfiguration has occurred.
  43364. */
  43365. warningEnable: boolean;
  43366. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43367. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43368. private _warningCounter;
  43369. private _warning;
  43370. }
  43371. }
  43372. declare module BABYLON {
  43373. /**
  43374. * Default Inputs manager for the FollowCamera.
  43375. * It groups all the default supported inputs for ease of use.
  43376. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43377. */
  43378. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43379. /**
  43380. * Instantiates a new FollowCameraInputsManager.
  43381. * @param camera Defines the camera the inputs belong to
  43382. */
  43383. constructor(camera: FollowCamera);
  43384. /**
  43385. * Add keyboard input support to the input manager.
  43386. * @returns the current input manager
  43387. */
  43388. addKeyboard(): FollowCameraInputsManager;
  43389. /**
  43390. * Add mouse wheel input support to the input manager.
  43391. * @returns the current input manager
  43392. */
  43393. addMouseWheel(): FollowCameraInputsManager;
  43394. /**
  43395. * Add pointers input support to the input manager.
  43396. * @returns the current input manager
  43397. */
  43398. addPointers(): FollowCameraInputsManager;
  43399. /**
  43400. * Add orientation input support to the input manager.
  43401. * @returns the current input manager
  43402. */
  43403. addVRDeviceOrientation(): FollowCameraInputsManager;
  43404. }
  43405. }
  43406. declare module BABYLON {
  43407. /**
  43408. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43409. * an arc rotate version arcFollowCamera are available.
  43410. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43411. */
  43412. export class FollowCamera extends TargetCamera {
  43413. /**
  43414. * Distance the follow camera should follow an object at
  43415. */
  43416. radius: number;
  43417. /**
  43418. * Minimum allowed distance of the camera to the axis of rotation
  43419. * (The camera can not get closer).
  43420. * This can help limiting how the Camera is able to move in the scene.
  43421. */
  43422. lowerRadiusLimit: Nullable<number>;
  43423. /**
  43424. * Maximum allowed distance of the camera to the axis of rotation
  43425. * (The camera can not get further).
  43426. * This can help limiting how the Camera is able to move in the scene.
  43427. */
  43428. upperRadiusLimit: Nullable<number>;
  43429. /**
  43430. * Define a rotation offset between the camera and the object it follows
  43431. */
  43432. rotationOffset: number;
  43433. /**
  43434. * Minimum allowed angle to camera position relative to target object.
  43435. * This can help limiting how the Camera is able to move in the scene.
  43436. */
  43437. lowerRotationOffsetLimit: Nullable<number>;
  43438. /**
  43439. * Maximum allowed angle to camera position relative to target object.
  43440. * This can help limiting how the Camera is able to move in the scene.
  43441. */
  43442. upperRotationOffsetLimit: Nullable<number>;
  43443. /**
  43444. * Define a height offset between the camera and the object it follows.
  43445. * It can help following an object from the top (like a car chaing a plane)
  43446. */
  43447. heightOffset: number;
  43448. /**
  43449. * Minimum allowed height of camera position relative to target object.
  43450. * This can help limiting how the Camera is able to move in the scene.
  43451. */
  43452. lowerHeightOffsetLimit: Nullable<number>;
  43453. /**
  43454. * Maximum allowed height of camera position relative to target object.
  43455. * This can help limiting how the Camera is able to move in the scene.
  43456. */
  43457. upperHeightOffsetLimit: Nullable<number>;
  43458. /**
  43459. * Define how fast the camera can accelerate to follow it s target.
  43460. */
  43461. cameraAcceleration: number;
  43462. /**
  43463. * Define the speed limit of the camera following an object.
  43464. */
  43465. maxCameraSpeed: number;
  43466. /**
  43467. * Define the target of the camera.
  43468. */
  43469. lockedTarget: Nullable<AbstractMesh>;
  43470. /**
  43471. * Defines the input associated with the camera.
  43472. */
  43473. inputs: FollowCameraInputsManager;
  43474. /**
  43475. * Instantiates the follow camera.
  43476. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43477. * @param name Define the name of the camera in the scene
  43478. * @param position Define the position of the camera
  43479. * @param scene Define the scene the camera belong to
  43480. * @param lockedTarget Define the target of the camera
  43481. */
  43482. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43483. private _follow;
  43484. /**
  43485. * Attached controls to the current camera.
  43486. * @param element Defines the element the controls should be listened from
  43487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43488. */
  43489. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43490. /**
  43491. * Detach the current controls from the camera.
  43492. * The camera will stop reacting to inputs.
  43493. * @param element Defines the element to stop listening the inputs from
  43494. */
  43495. detachControl(element: HTMLElement): void;
  43496. /** @hidden */
  43497. _checkInputs(): void;
  43498. private _checkLimits;
  43499. /**
  43500. * Gets the camera class name.
  43501. * @returns the class name
  43502. */
  43503. getClassName(): string;
  43504. }
  43505. /**
  43506. * Arc Rotate version of the follow camera.
  43507. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43508. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43509. */
  43510. export class ArcFollowCamera extends TargetCamera {
  43511. /** The longitudinal angle of the camera */
  43512. alpha: number;
  43513. /** The latitudinal angle of the camera */
  43514. beta: number;
  43515. /** The radius of the camera from its target */
  43516. radius: number;
  43517. /** Define the camera target (the messh it should follow) */
  43518. target: Nullable<AbstractMesh>;
  43519. private _cartesianCoordinates;
  43520. /**
  43521. * Instantiates a new ArcFollowCamera
  43522. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43523. * @param name Define the name of the camera
  43524. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43525. * @param beta Define the rotation angle of the camera around the elevation axis
  43526. * @param radius Define the radius of the camera from its target point
  43527. * @param target Define the target of the camera
  43528. * @param scene Define the scene the camera belongs to
  43529. */
  43530. constructor(name: string,
  43531. /** The longitudinal angle of the camera */
  43532. alpha: number,
  43533. /** The latitudinal angle of the camera */
  43534. beta: number,
  43535. /** The radius of the camera from its target */
  43536. radius: number,
  43537. /** Define the camera target (the messh it should follow) */
  43538. target: Nullable<AbstractMesh>, scene: Scene);
  43539. private _follow;
  43540. /** @hidden */
  43541. _checkInputs(): void;
  43542. /**
  43543. * Returns the class name of the object.
  43544. * It is mostly used internally for serialization purposes.
  43545. */
  43546. getClassName(): string;
  43547. }
  43548. }
  43549. declare module BABYLON {
  43550. /**
  43551. * Manage the keyboard inputs to control the movement of a follow camera.
  43552. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43553. */
  43554. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43555. /**
  43556. * Defines the camera the input is attached to.
  43557. */
  43558. camera: FollowCamera;
  43559. /**
  43560. * Defines the list of key codes associated with the up action (increase heightOffset)
  43561. */
  43562. keysHeightOffsetIncr: number[];
  43563. /**
  43564. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43565. */
  43566. keysHeightOffsetDecr: number[];
  43567. /**
  43568. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43569. */
  43570. keysHeightOffsetModifierAlt: boolean;
  43571. /**
  43572. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43573. */
  43574. keysHeightOffsetModifierCtrl: boolean;
  43575. /**
  43576. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43577. */
  43578. keysHeightOffsetModifierShift: boolean;
  43579. /**
  43580. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43581. */
  43582. keysRotationOffsetIncr: number[];
  43583. /**
  43584. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43585. */
  43586. keysRotationOffsetDecr: number[];
  43587. /**
  43588. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43589. */
  43590. keysRotationOffsetModifierAlt: boolean;
  43591. /**
  43592. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43593. */
  43594. keysRotationOffsetModifierCtrl: boolean;
  43595. /**
  43596. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43597. */
  43598. keysRotationOffsetModifierShift: boolean;
  43599. /**
  43600. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43601. */
  43602. keysRadiusIncr: number[];
  43603. /**
  43604. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43605. */
  43606. keysRadiusDecr: number[];
  43607. /**
  43608. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43609. */
  43610. keysRadiusModifierAlt: boolean;
  43611. /**
  43612. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43613. */
  43614. keysRadiusModifierCtrl: boolean;
  43615. /**
  43616. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43617. */
  43618. keysRadiusModifierShift: boolean;
  43619. /**
  43620. * Defines the rate of change of heightOffset.
  43621. */
  43622. heightSensibility: number;
  43623. /**
  43624. * Defines the rate of change of rotationOffset.
  43625. */
  43626. rotationSensibility: number;
  43627. /**
  43628. * Defines the rate of change of radius.
  43629. */
  43630. radiusSensibility: number;
  43631. private _keys;
  43632. private _ctrlPressed;
  43633. private _altPressed;
  43634. private _shiftPressed;
  43635. private _onCanvasBlurObserver;
  43636. private _onKeyboardObserver;
  43637. private _engine;
  43638. private _scene;
  43639. /**
  43640. * Attach the input controls to a specific dom element to get the input from.
  43641. * @param element Defines the element the controls should be listened from
  43642. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43643. */
  43644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43645. /**
  43646. * Detach the current controls from the specified dom element.
  43647. * @param element Defines the element to stop listening the inputs from
  43648. */
  43649. detachControl(element: Nullable<HTMLElement>): void;
  43650. /**
  43651. * Update the current camera state depending on the inputs that have been used this frame.
  43652. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43653. */
  43654. checkInputs(): void;
  43655. /**
  43656. * Gets the class name of the current input.
  43657. * @returns the class name
  43658. */
  43659. getClassName(): string;
  43660. /**
  43661. * Get the friendly name associated with the input class.
  43662. * @returns the input friendly name
  43663. */
  43664. getSimpleName(): string;
  43665. /**
  43666. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43667. * allow modification of the heightOffset value.
  43668. */
  43669. private _modifierHeightOffset;
  43670. /**
  43671. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43672. * allow modification of the rotationOffset value.
  43673. */
  43674. private _modifierRotationOffset;
  43675. /**
  43676. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43677. * allow modification of the radius value.
  43678. */
  43679. private _modifierRadius;
  43680. }
  43681. }
  43682. declare module BABYLON {
  43683. interface FreeCameraInputsManager {
  43684. /**
  43685. * @hidden
  43686. */
  43687. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43688. /**
  43689. * Add orientation input support to the input manager.
  43690. * @returns the current input manager
  43691. */
  43692. addDeviceOrientation(): FreeCameraInputsManager;
  43693. }
  43694. /**
  43695. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43696. * Screen rotation is taken into account.
  43697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43698. */
  43699. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43700. private _camera;
  43701. private _screenOrientationAngle;
  43702. private _constantTranform;
  43703. private _screenQuaternion;
  43704. private _alpha;
  43705. private _beta;
  43706. private _gamma;
  43707. /**
  43708. * Can be used to detect if a device orientation sensor is available on a device
  43709. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43710. * @returns a promise that will resolve on orientation change
  43711. */
  43712. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43713. /**
  43714. * @hidden
  43715. */
  43716. _onDeviceOrientationChangedObservable: Observable<void>;
  43717. /**
  43718. * Instantiates a new input
  43719. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43720. */
  43721. constructor();
  43722. /**
  43723. * Define the camera controlled by the input.
  43724. */
  43725. get camera(): FreeCamera;
  43726. set camera(camera: FreeCamera);
  43727. /**
  43728. * Attach the input controls to a specific dom element to get the input from.
  43729. * @param element Defines the element the controls should be listened from
  43730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43731. */
  43732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43733. private _orientationChanged;
  43734. private _deviceOrientation;
  43735. /**
  43736. * Detach the current controls from the specified dom element.
  43737. * @param element Defines the element to stop listening the inputs from
  43738. */
  43739. detachControl(element: Nullable<HTMLElement>): void;
  43740. /**
  43741. * Update the current camera state depending on the inputs that have been used this frame.
  43742. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43743. */
  43744. checkInputs(): void;
  43745. /**
  43746. * Gets the class name of the current intput.
  43747. * @returns the class name
  43748. */
  43749. getClassName(): string;
  43750. /**
  43751. * Get the friendly name associated with the input class.
  43752. * @returns the input friendly name
  43753. */
  43754. getSimpleName(): string;
  43755. }
  43756. }
  43757. declare module BABYLON {
  43758. /**
  43759. * Manage the gamepad inputs to control a free camera.
  43760. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43761. */
  43762. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43763. /**
  43764. * Define the camera the input is attached to.
  43765. */
  43766. camera: FreeCamera;
  43767. /**
  43768. * Define the Gamepad controlling the input
  43769. */
  43770. gamepad: Nullable<Gamepad>;
  43771. /**
  43772. * Defines the gamepad rotation sensiblity.
  43773. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43774. */
  43775. gamepadAngularSensibility: number;
  43776. /**
  43777. * Defines the gamepad move sensiblity.
  43778. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43779. */
  43780. gamepadMoveSensibility: number;
  43781. private _yAxisScale;
  43782. /**
  43783. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43784. */
  43785. get invertYAxis(): boolean;
  43786. set invertYAxis(value: boolean);
  43787. private _onGamepadConnectedObserver;
  43788. private _onGamepadDisconnectedObserver;
  43789. private _cameraTransform;
  43790. private _deltaTransform;
  43791. private _vector3;
  43792. private _vector2;
  43793. /**
  43794. * Attach the input controls to a specific dom element to get the input from.
  43795. * @param element Defines the element the controls should be listened from
  43796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43797. */
  43798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43799. /**
  43800. * Detach the current controls from the specified dom element.
  43801. * @param element Defines the element to stop listening the inputs from
  43802. */
  43803. detachControl(element: Nullable<HTMLElement>): void;
  43804. /**
  43805. * Update the current camera state depending on the inputs that have been used this frame.
  43806. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43807. */
  43808. checkInputs(): void;
  43809. /**
  43810. * Gets the class name of the current intput.
  43811. * @returns the class name
  43812. */
  43813. getClassName(): string;
  43814. /**
  43815. * Get the friendly name associated with the input class.
  43816. * @returns the input friendly name
  43817. */
  43818. getSimpleName(): string;
  43819. }
  43820. }
  43821. declare module BABYLON {
  43822. /**
  43823. * Defines the potential axis of a Joystick
  43824. */
  43825. export enum JoystickAxis {
  43826. /** X axis */
  43827. X = 0,
  43828. /** Y axis */
  43829. Y = 1,
  43830. /** Z axis */
  43831. Z = 2
  43832. }
  43833. /**
  43834. * Class used to define virtual joystick (used in touch mode)
  43835. */
  43836. export class VirtualJoystick {
  43837. /**
  43838. * Gets or sets a boolean indicating that left and right values must be inverted
  43839. */
  43840. reverseLeftRight: boolean;
  43841. /**
  43842. * Gets or sets a boolean indicating that up and down values must be inverted
  43843. */
  43844. reverseUpDown: boolean;
  43845. /**
  43846. * Gets the offset value for the position (ie. the change of the position value)
  43847. */
  43848. deltaPosition: Vector3;
  43849. /**
  43850. * Gets a boolean indicating if the virtual joystick was pressed
  43851. */
  43852. pressed: boolean;
  43853. /**
  43854. * Canvas the virtual joystick will render onto, default z-index of this is 5
  43855. */
  43856. static Canvas: Nullable<HTMLCanvasElement>;
  43857. private static _globalJoystickIndex;
  43858. private static vjCanvasContext;
  43859. private static vjCanvasWidth;
  43860. private static vjCanvasHeight;
  43861. private static halfWidth;
  43862. private _action;
  43863. private _axisTargetedByLeftAndRight;
  43864. private _axisTargetedByUpAndDown;
  43865. private _joystickSensibility;
  43866. private _inversedSensibility;
  43867. private _joystickPointerID;
  43868. private _joystickColor;
  43869. private _joystickPointerPos;
  43870. private _joystickPreviousPointerPos;
  43871. private _joystickPointerStartPos;
  43872. private _deltaJoystickVector;
  43873. private _leftJoystick;
  43874. private _touches;
  43875. private _onPointerDownHandlerRef;
  43876. private _onPointerMoveHandlerRef;
  43877. private _onPointerUpHandlerRef;
  43878. private _onResize;
  43879. /**
  43880. * Creates a new virtual joystick
  43881. * @param leftJoystick defines that the joystick is for left hand (false by default)
  43882. */
  43883. constructor(leftJoystick?: boolean);
  43884. /**
  43885. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  43886. * @param newJoystickSensibility defines the new sensibility
  43887. */
  43888. setJoystickSensibility(newJoystickSensibility: number): void;
  43889. private _onPointerDown;
  43890. private _onPointerMove;
  43891. private _onPointerUp;
  43892. /**
  43893. * Change the color of the virtual joystick
  43894. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  43895. */
  43896. setJoystickColor(newColor: string): void;
  43897. /**
  43898. * Defines a callback to call when the joystick is touched
  43899. * @param action defines the callback
  43900. */
  43901. setActionOnTouch(action: () => any): void;
  43902. /**
  43903. * Defines which axis you'd like to control for left & right
  43904. * @param axis defines the axis to use
  43905. */
  43906. setAxisForLeftRight(axis: JoystickAxis): void;
  43907. /**
  43908. * Defines which axis you'd like to control for up & down
  43909. * @param axis defines the axis to use
  43910. */
  43911. setAxisForUpDown(axis: JoystickAxis): void;
  43912. private _drawVirtualJoystick;
  43913. /**
  43914. * Release internal HTML canvas
  43915. */
  43916. releaseCanvas(): void;
  43917. }
  43918. }
  43919. declare module BABYLON {
  43920. interface FreeCameraInputsManager {
  43921. /**
  43922. * Add virtual joystick input support to the input manager.
  43923. * @returns the current input manager
  43924. */
  43925. addVirtualJoystick(): FreeCameraInputsManager;
  43926. }
  43927. /**
  43928. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  43929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43930. */
  43931. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  43932. /**
  43933. * Defines the camera the input is attached to.
  43934. */
  43935. camera: FreeCamera;
  43936. private _leftjoystick;
  43937. private _rightjoystick;
  43938. /**
  43939. * Gets the left stick of the virtual joystick.
  43940. * @returns The virtual Joystick
  43941. */
  43942. getLeftJoystick(): VirtualJoystick;
  43943. /**
  43944. * Gets the right stick of the virtual joystick.
  43945. * @returns The virtual Joystick
  43946. */
  43947. getRightJoystick(): VirtualJoystick;
  43948. /**
  43949. * Update the current camera state depending on the inputs that have been used this frame.
  43950. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43951. */
  43952. checkInputs(): void;
  43953. /**
  43954. * Attach the input controls to a specific dom element to get the input from.
  43955. * @param element Defines the element the controls should be listened from
  43956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43957. */
  43958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43959. /**
  43960. * Detach the current controls from the specified dom element.
  43961. * @param element Defines the element to stop listening the inputs from
  43962. */
  43963. detachControl(element: Nullable<HTMLElement>): void;
  43964. /**
  43965. * Gets the class name of the current intput.
  43966. * @returns the class name
  43967. */
  43968. getClassName(): string;
  43969. /**
  43970. * Get the friendly name associated with the input class.
  43971. * @returns the input friendly name
  43972. */
  43973. getSimpleName(): string;
  43974. }
  43975. }
  43976. declare module BABYLON {
  43977. /**
  43978. * This represents a FPS type of camera controlled by touch.
  43979. * This is like a universal camera minus the Gamepad controls.
  43980. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43981. */
  43982. export class TouchCamera extends FreeCamera {
  43983. /**
  43984. * Defines the touch sensibility for rotation.
  43985. * The higher the faster.
  43986. */
  43987. get touchAngularSensibility(): number;
  43988. set touchAngularSensibility(value: number);
  43989. /**
  43990. * Defines the touch sensibility for move.
  43991. * The higher the faster.
  43992. */
  43993. get touchMoveSensibility(): number;
  43994. set touchMoveSensibility(value: number);
  43995. /**
  43996. * Instantiates a new touch camera.
  43997. * This represents a FPS type of camera controlled by touch.
  43998. * This is like a universal camera minus the Gamepad controls.
  43999. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44000. * @param name Define the name of the camera in the scene
  44001. * @param position Define the start position of the camera in the scene
  44002. * @param scene Define the scene the camera belongs to
  44003. */
  44004. constructor(name: string, position: Vector3, scene: Scene);
  44005. /**
  44006. * Gets the current object class name.
  44007. * @return the class name
  44008. */
  44009. getClassName(): string;
  44010. /** @hidden */
  44011. _setupInputs(): void;
  44012. }
  44013. }
  44014. declare module BABYLON {
  44015. /**
  44016. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  44017. * being tilted forward or back and left or right.
  44018. */
  44019. export class DeviceOrientationCamera extends FreeCamera {
  44020. private _initialQuaternion;
  44021. private _quaternionCache;
  44022. private _tmpDragQuaternion;
  44023. private _disablePointerInputWhenUsingDeviceOrientation;
  44024. /**
  44025. * Creates a new device orientation camera
  44026. * @param name The name of the camera
  44027. * @param position The start position camera
  44028. * @param scene The scene the camera belongs to
  44029. */
  44030. constructor(name: string, position: Vector3, scene: Scene);
  44031. /**
  44032. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  44033. */
  44034. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  44035. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  44036. private _dragFactor;
  44037. /**
  44038. * Enabled turning on the y axis when the orientation sensor is active
  44039. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  44040. */
  44041. enableHorizontalDragging(dragFactor?: number): void;
  44042. /**
  44043. * Gets the current instance class name ("DeviceOrientationCamera").
  44044. * This helps avoiding instanceof at run time.
  44045. * @returns the class name
  44046. */
  44047. getClassName(): string;
  44048. /**
  44049. * @hidden
  44050. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44051. */
  44052. _checkInputs(): void;
  44053. /**
  44054. * Reset the camera to its default orientation on the specified axis only.
  44055. * @param axis The axis to reset
  44056. */
  44057. resetToCurrentRotation(axis?: Axis): void;
  44058. }
  44059. }
  44060. declare module BABYLON {
  44061. /**
  44062. * Defines supported buttons for XBox360 compatible gamepads
  44063. */
  44064. export enum Xbox360Button {
  44065. /** A */
  44066. A = 0,
  44067. /** B */
  44068. B = 1,
  44069. /** X */
  44070. X = 2,
  44071. /** Y */
  44072. Y = 3,
  44073. /** Left button */
  44074. LB = 4,
  44075. /** Right button */
  44076. RB = 5,
  44077. /** Back */
  44078. Back = 8,
  44079. /** Start */
  44080. Start = 9,
  44081. /** Left stick */
  44082. LeftStick = 10,
  44083. /** Right stick */
  44084. RightStick = 11
  44085. }
  44086. /** Defines values for XBox360 DPad */
  44087. export enum Xbox360Dpad {
  44088. /** Up */
  44089. Up = 12,
  44090. /** Down */
  44091. Down = 13,
  44092. /** Left */
  44093. Left = 14,
  44094. /** Right */
  44095. Right = 15
  44096. }
  44097. /**
  44098. * Defines a XBox360 gamepad
  44099. */
  44100. export class Xbox360Pad extends Gamepad {
  44101. private _leftTrigger;
  44102. private _rightTrigger;
  44103. private _onlefttriggerchanged;
  44104. private _onrighttriggerchanged;
  44105. private _onbuttondown;
  44106. private _onbuttonup;
  44107. private _ondpaddown;
  44108. private _ondpadup;
  44109. /** Observable raised when a button is pressed */
  44110. onButtonDownObservable: Observable<Xbox360Button>;
  44111. /** Observable raised when a button is released */
  44112. onButtonUpObservable: Observable<Xbox360Button>;
  44113. /** Observable raised when a pad is pressed */
  44114. onPadDownObservable: Observable<Xbox360Dpad>;
  44115. /** Observable raised when a pad is released */
  44116. onPadUpObservable: Observable<Xbox360Dpad>;
  44117. private _buttonA;
  44118. private _buttonB;
  44119. private _buttonX;
  44120. private _buttonY;
  44121. private _buttonBack;
  44122. private _buttonStart;
  44123. private _buttonLB;
  44124. private _buttonRB;
  44125. private _buttonLeftStick;
  44126. private _buttonRightStick;
  44127. private _dPadUp;
  44128. private _dPadDown;
  44129. private _dPadLeft;
  44130. private _dPadRight;
  44131. private _isXboxOnePad;
  44132. /**
  44133. * Creates a new XBox360 gamepad object
  44134. * @param id defines the id of this gamepad
  44135. * @param index defines its index
  44136. * @param gamepad defines the internal HTML gamepad object
  44137. * @param xboxOne defines if it is a XBox One gamepad
  44138. */
  44139. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44140. /**
  44141. * Defines the callback to call when left trigger is pressed
  44142. * @param callback defines the callback to use
  44143. */
  44144. onlefttriggerchanged(callback: (value: number) => void): void;
  44145. /**
  44146. * Defines the callback to call when right trigger is pressed
  44147. * @param callback defines the callback to use
  44148. */
  44149. onrighttriggerchanged(callback: (value: number) => void): void;
  44150. /**
  44151. * Gets the left trigger value
  44152. */
  44153. get leftTrigger(): number;
  44154. /**
  44155. * Sets the left trigger value
  44156. */
  44157. set leftTrigger(newValue: number);
  44158. /**
  44159. * Gets the right trigger value
  44160. */
  44161. get rightTrigger(): number;
  44162. /**
  44163. * Sets the right trigger value
  44164. */
  44165. set rightTrigger(newValue: number);
  44166. /**
  44167. * Defines the callback to call when a button is pressed
  44168. * @param callback defines the callback to use
  44169. */
  44170. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44171. /**
  44172. * Defines the callback to call when a button is released
  44173. * @param callback defines the callback to use
  44174. */
  44175. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44176. /**
  44177. * Defines the callback to call when a pad is pressed
  44178. * @param callback defines the callback to use
  44179. */
  44180. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44181. /**
  44182. * Defines the callback to call when a pad is released
  44183. * @param callback defines the callback to use
  44184. */
  44185. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44186. private _setButtonValue;
  44187. private _setDPadValue;
  44188. /**
  44189. * Gets the value of the `A` button
  44190. */
  44191. get buttonA(): number;
  44192. /**
  44193. * Sets the value of the `A` button
  44194. */
  44195. set buttonA(value: number);
  44196. /**
  44197. * Gets the value of the `B` button
  44198. */
  44199. get buttonB(): number;
  44200. /**
  44201. * Sets the value of the `B` button
  44202. */
  44203. set buttonB(value: number);
  44204. /**
  44205. * Gets the value of the `X` button
  44206. */
  44207. get buttonX(): number;
  44208. /**
  44209. * Sets the value of the `X` button
  44210. */
  44211. set buttonX(value: number);
  44212. /**
  44213. * Gets the value of the `Y` button
  44214. */
  44215. get buttonY(): number;
  44216. /**
  44217. * Sets the value of the `Y` button
  44218. */
  44219. set buttonY(value: number);
  44220. /**
  44221. * Gets the value of the `Start` button
  44222. */
  44223. get buttonStart(): number;
  44224. /**
  44225. * Sets the value of the `Start` button
  44226. */
  44227. set buttonStart(value: number);
  44228. /**
  44229. * Gets the value of the `Back` button
  44230. */
  44231. get buttonBack(): number;
  44232. /**
  44233. * Sets the value of the `Back` button
  44234. */
  44235. set buttonBack(value: number);
  44236. /**
  44237. * Gets the value of the `Left` button
  44238. */
  44239. get buttonLB(): number;
  44240. /**
  44241. * Sets the value of the `Left` button
  44242. */
  44243. set buttonLB(value: number);
  44244. /**
  44245. * Gets the value of the `Right` button
  44246. */
  44247. get buttonRB(): number;
  44248. /**
  44249. * Sets the value of the `Right` button
  44250. */
  44251. set buttonRB(value: number);
  44252. /**
  44253. * Gets the value of the Left joystick
  44254. */
  44255. get buttonLeftStick(): number;
  44256. /**
  44257. * Sets the value of the Left joystick
  44258. */
  44259. set buttonLeftStick(value: number);
  44260. /**
  44261. * Gets the value of the Right joystick
  44262. */
  44263. get buttonRightStick(): number;
  44264. /**
  44265. * Sets the value of the Right joystick
  44266. */
  44267. set buttonRightStick(value: number);
  44268. /**
  44269. * Gets the value of D-pad up
  44270. */
  44271. get dPadUp(): number;
  44272. /**
  44273. * Sets the value of D-pad up
  44274. */
  44275. set dPadUp(value: number);
  44276. /**
  44277. * Gets the value of D-pad down
  44278. */
  44279. get dPadDown(): number;
  44280. /**
  44281. * Sets the value of D-pad down
  44282. */
  44283. set dPadDown(value: number);
  44284. /**
  44285. * Gets the value of D-pad left
  44286. */
  44287. get dPadLeft(): number;
  44288. /**
  44289. * Sets the value of D-pad left
  44290. */
  44291. set dPadLeft(value: number);
  44292. /**
  44293. * Gets the value of D-pad right
  44294. */
  44295. get dPadRight(): number;
  44296. /**
  44297. * Sets the value of D-pad right
  44298. */
  44299. set dPadRight(value: number);
  44300. /**
  44301. * Force the gamepad to synchronize with device values
  44302. */
  44303. update(): void;
  44304. /**
  44305. * Disposes the gamepad
  44306. */
  44307. dispose(): void;
  44308. }
  44309. }
  44310. declare module BABYLON {
  44311. /**
  44312. * Defines supported buttons for DualShock compatible gamepads
  44313. */
  44314. export enum DualShockButton {
  44315. /** Cross */
  44316. Cross = 0,
  44317. /** Circle */
  44318. Circle = 1,
  44319. /** Square */
  44320. Square = 2,
  44321. /** Triangle */
  44322. Triangle = 3,
  44323. /** L1 */
  44324. L1 = 4,
  44325. /** R1 */
  44326. R1 = 5,
  44327. /** Share */
  44328. Share = 8,
  44329. /** Options */
  44330. Options = 9,
  44331. /** Left stick */
  44332. LeftStick = 10,
  44333. /** Right stick */
  44334. RightStick = 11
  44335. }
  44336. /** Defines values for DualShock DPad */
  44337. export enum DualShockDpad {
  44338. /** Up */
  44339. Up = 12,
  44340. /** Down */
  44341. Down = 13,
  44342. /** Left */
  44343. Left = 14,
  44344. /** Right */
  44345. Right = 15
  44346. }
  44347. /**
  44348. * Defines a DualShock gamepad
  44349. */
  44350. export class DualShockPad extends Gamepad {
  44351. private _leftTrigger;
  44352. private _rightTrigger;
  44353. private _onlefttriggerchanged;
  44354. private _onrighttriggerchanged;
  44355. private _onbuttondown;
  44356. private _onbuttonup;
  44357. private _ondpaddown;
  44358. private _ondpadup;
  44359. /** Observable raised when a button is pressed */
  44360. onButtonDownObservable: Observable<DualShockButton>;
  44361. /** Observable raised when a button is released */
  44362. onButtonUpObservable: Observable<DualShockButton>;
  44363. /** Observable raised when a pad is pressed */
  44364. onPadDownObservable: Observable<DualShockDpad>;
  44365. /** Observable raised when a pad is released */
  44366. onPadUpObservable: Observable<DualShockDpad>;
  44367. private _buttonCross;
  44368. private _buttonCircle;
  44369. private _buttonSquare;
  44370. private _buttonTriangle;
  44371. private _buttonShare;
  44372. private _buttonOptions;
  44373. private _buttonL1;
  44374. private _buttonR1;
  44375. private _buttonLeftStick;
  44376. private _buttonRightStick;
  44377. private _dPadUp;
  44378. private _dPadDown;
  44379. private _dPadLeft;
  44380. private _dPadRight;
  44381. /**
  44382. * Creates a new DualShock gamepad object
  44383. * @param id defines the id of this gamepad
  44384. * @param index defines its index
  44385. * @param gamepad defines the internal HTML gamepad object
  44386. */
  44387. constructor(id: string, index: number, gamepad: any);
  44388. /**
  44389. * Defines the callback to call when left trigger is pressed
  44390. * @param callback defines the callback to use
  44391. */
  44392. onlefttriggerchanged(callback: (value: number) => void): void;
  44393. /**
  44394. * Defines the callback to call when right trigger is pressed
  44395. * @param callback defines the callback to use
  44396. */
  44397. onrighttriggerchanged(callback: (value: number) => void): void;
  44398. /**
  44399. * Gets the left trigger value
  44400. */
  44401. get leftTrigger(): number;
  44402. /**
  44403. * Sets the left trigger value
  44404. */
  44405. set leftTrigger(newValue: number);
  44406. /**
  44407. * Gets the right trigger value
  44408. */
  44409. get rightTrigger(): number;
  44410. /**
  44411. * Sets the right trigger value
  44412. */
  44413. set rightTrigger(newValue: number);
  44414. /**
  44415. * Defines the callback to call when a button is pressed
  44416. * @param callback defines the callback to use
  44417. */
  44418. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44419. /**
  44420. * Defines the callback to call when a button is released
  44421. * @param callback defines the callback to use
  44422. */
  44423. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44424. /**
  44425. * Defines the callback to call when a pad is pressed
  44426. * @param callback defines the callback to use
  44427. */
  44428. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44429. /**
  44430. * Defines the callback to call when a pad is released
  44431. * @param callback defines the callback to use
  44432. */
  44433. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44434. private _setButtonValue;
  44435. private _setDPadValue;
  44436. /**
  44437. * Gets the value of the `Cross` button
  44438. */
  44439. get buttonCross(): number;
  44440. /**
  44441. * Sets the value of the `Cross` button
  44442. */
  44443. set buttonCross(value: number);
  44444. /**
  44445. * Gets the value of the `Circle` button
  44446. */
  44447. get buttonCircle(): number;
  44448. /**
  44449. * Sets the value of the `Circle` button
  44450. */
  44451. set buttonCircle(value: number);
  44452. /**
  44453. * Gets the value of the `Square` button
  44454. */
  44455. get buttonSquare(): number;
  44456. /**
  44457. * Sets the value of the `Square` button
  44458. */
  44459. set buttonSquare(value: number);
  44460. /**
  44461. * Gets the value of the `Triangle` button
  44462. */
  44463. get buttonTriangle(): number;
  44464. /**
  44465. * Sets the value of the `Triangle` button
  44466. */
  44467. set buttonTriangle(value: number);
  44468. /**
  44469. * Gets the value of the `Options` button
  44470. */
  44471. get buttonOptions(): number;
  44472. /**
  44473. * Sets the value of the `Options` button
  44474. */
  44475. set buttonOptions(value: number);
  44476. /**
  44477. * Gets the value of the `Share` button
  44478. */
  44479. get buttonShare(): number;
  44480. /**
  44481. * Sets the value of the `Share` button
  44482. */
  44483. set buttonShare(value: number);
  44484. /**
  44485. * Gets the value of the `L1` button
  44486. */
  44487. get buttonL1(): number;
  44488. /**
  44489. * Sets the value of the `L1` button
  44490. */
  44491. set buttonL1(value: number);
  44492. /**
  44493. * Gets the value of the `R1` button
  44494. */
  44495. get buttonR1(): number;
  44496. /**
  44497. * Sets the value of the `R1` button
  44498. */
  44499. set buttonR1(value: number);
  44500. /**
  44501. * Gets the value of the Left joystick
  44502. */
  44503. get buttonLeftStick(): number;
  44504. /**
  44505. * Sets the value of the Left joystick
  44506. */
  44507. set buttonLeftStick(value: number);
  44508. /**
  44509. * Gets the value of the Right joystick
  44510. */
  44511. get buttonRightStick(): number;
  44512. /**
  44513. * Sets the value of the Right joystick
  44514. */
  44515. set buttonRightStick(value: number);
  44516. /**
  44517. * Gets the value of D-pad up
  44518. */
  44519. get dPadUp(): number;
  44520. /**
  44521. * Sets the value of D-pad up
  44522. */
  44523. set dPadUp(value: number);
  44524. /**
  44525. * Gets the value of D-pad down
  44526. */
  44527. get dPadDown(): number;
  44528. /**
  44529. * Sets the value of D-pad down
  44530. */
  44531. set dPadDown(value: number);
  44532. /**
  44533. * Gets the value of D-pad left
  44534. */
  44535. get dPadLeft(): number;
  44536. /**
  44537. * Sets the value of D-pad left
  44538. */
  44539. set dPadLeft(value: number);
  44540. /**
  44541. * Gets the value of D-pad right
  44542. */
  44543. get dPadRight(): number;
  44544. /**
  44545. * Sets the value of D-pad right
  44546. */
  44547. set dPadRight(value: number);
  44548. /**
  44549. * Force the gamepad to synchronize with device values
  44550. */
  44551. update(): void;
  44552. /**
  44553. * Disposes the gamepad
  44554. */
  44555. dispose(): void;
  44556. }
  44557. }
  44558. declare module BABYLON {
  44559. /**
  44560. * Manager for handling gamepads
  44561. */
  44562. export class GamepadManager {
  44563. private _scene?;
  44564. private _babylonGamepads;
  44565. private _oneGamepadConnected;
  44566. /** @hidden */
  44567. _isMonitoring: boolean;
  44568. private _gamepadEventSupported;
  44569. private _gamepadSupport?;
  44570. /**
  44571. * observable to be triggered when the gamepad controller has been connected
  44572. */
  44573. onGamepadConnectedObservable: Observable<Gamepad>;
  44574. /**
  44575. * observable to be triggered when the gamepad controller has been disconnected
  44576. */
  44577. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44578. private _onGamepadConnectedEvent;
  44579. private _onGamepadDisconnectedEvent;
  44580. /**
  44581. * Initializes the gamepad manager
  44582. * @param _scene BabylonJS scene
  44583. */
  44584. constructor(_scene?: Scene | undefined);
  44585. /**
  44586. * The gamepads in the game pad manager
  44587. */
  44588. get gamepads(): Gamepad[];
  44589. /**
  44590. * Get the gamepad controllers based on type
  44591. * @param type The type of gamepad controller
  44592. * @returns Nullable gamepad
  44593. */
  44594. getGamepadByType(type?: number): Nullable<Gamepad>;
  44595. /**
  44596. * Disposes the gamepad manager
  44597. */
  44598. dispose(): void;
  44599. private _addNewGamepad;
  44600. private _startMonitoringGamepads;
  44601. private _stopMonitoringGamepads;
  44602. /** @hidden */
  44603. _checkGamepadsStatus(): void;
  44604. private _updateGamepadObjects;
  44605. }
  44606. }
  44607. declare module BABYLON {
  44608. interface Scene {
  44609. /** @hidden */
  44610. _gamepadManager: Nullable<GamepadManager>;
  44611. /**
  44612. * Gets the gamepad manager associated with the scene
  44613. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44614. */
  44615. gamepadManager: GamepadManager;
  44616. }
  44617. /**
  44618. * Interface representing a free camera inputs manager
  44619. */
  44620. interface FreeCameraInputsManager {
  44621. /**
  44622. * Adds gamepad input support to the FreeCameraInputsManager.
  44623. * @returns the FreeCameraInputsManager
  44624. */
  44625. addGamepad(): FreeCameraInputsManager;
  44626. }
  44627. /**
  44628. * Interface representing an arc rotate camera inputs manager
  44629. */
  44630. interface ArcRotateCameraInputsManager {
  44631. /**
  44632. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44633. * @returns the camera inputs manager
  44634. */
  44635. addGamepad(): ArcRotateCameraInputsManager;
  44636. }
  44637. /**
  44638. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44639. */
  44640. export class GamepadSystemSceneComponent implements ISceneComponent {
  44641. /**
  44642. * The component name helpfull to identify the component in the list of scene components.
  44643. */
  44644. readonly name: string;
  44645. /**
  44646. * The scene the component belongs to.
  44647. */
  44648. scene: Scene;
  44649. /**
  44650. * Creates a new instance of the component for the given scene
  44651. * @param scene Defines the scene to register the component in
  44652. */
  44653. constructor(scene: Scene);
  44654. /**
  44655. * Registers the component in a given scene
  44656. */
  44657. register(): void;
  44658. /**
  44659. * Rebuilds the elements related to this component in case of
  44660. * context lost for instance.
  44661. */
  44662. rebuild(): void;
  44663. /**
  44664. * Disposes the component and the associated ressources
  44665. */
  44666. dispose(): void;
  44667. private _beforeCameraUpdate;
  44668. }
  44669. }
  44670. declare module BABYLON {
  44671. /**
  44672. * 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,
  44673. * which still works and will still be found in many Playgrounds.
  44674. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44675. */
  44676. export class UniversalCamera extends TouchCamera {
  44677. /**
  44678. * Defines the gamepad rotation sensiblity.
  44679. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44680. */
  44681. get gamepadAngularSensibility(): number;
  44682. set gamepadAngularSensibility(value: number);
  44683. /**
  44684. * Defines the gamepad move sensiblity.
  44685. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44686. */
  44687. get gamepadMoveSensibility(): number;
  44688. set gamepadMoveSensibility(value: number);
  44689. /**
  44690. * 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,
  44691. * which still works and will still be found in many Playgrounds.
  44692. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44693. * @param name Define the name of the camera in the scene
  44694. * @param position Define the start position of the camera in the scene
  44695. * @param scene Define the scene the camera belongs to
  44696. */
  44697. constructor(name: string, position: Vector3, scene: Scene);
  44698. /**
  44699. * Gets the current object class name.
  44700. * @return the class name
  44701. */
  44702. getClassName(): string;
  44703. }
  44704. }
  44705. declare module BABYLON {
  44706. /**
  44707. * This represents a FPS type of camera. This is only here for back compat purpose.
  44708. * Please use the UniversalCamera instead as both are identical.
  44709. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44710. */
  44711. export class GamepadCamera extends UniversalCamera {
  44712. /**
  44713. * Instantiates a new Gamepad Camera
  44714. * This represents a FPS type of camera. This is only here for back compat purpose.
  44715. * Please use the UniversalCamera instead as both are identical.
  44716. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44717. * @param name Define the name of the camera in the scene
  44718. * @param position Define the start position of the camera in the scene
  44719. * @param scene Define the scene the camera belongs to
  44720. */
  44721. constructor(name: string, position: Vector3, scene: Scene);
  44722. /**
  44723. * Gets the current object class name.
  44724. * @return the class name
  44725. */
  44726. getClassName(): string;
  44727. }
  44728. }
  44729. declare module BABYLON {
  44730. /** @hidden */
  44731. export var passPixelShader: {
  44732. name: string;
  44733. shader: string;
  44734. };
  44735. }
  44736. declare module BABYLON {
  44737. /** @hidden */
  44738. export var passCubePixelShader: {
  44739. name: string;
  44740. shader: string;
  44741. };
  44742. }
  44743. declare module BABYLON {
  44744. /**
  44745. * PassPostProcess which produces an output the same as it's input
  44746. */
  44747. export class PassPostProcess extends PostProcess {
  44748. /**
  44749. * Creates the PassPostProcess
  44750. * @param name The name of the effect.
  44751. * @param options The required width/height ratio to downsize to before computing the render pass.
  44752. * @param camera The camera to apply the render pass to.
  44753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44754. * @param engine The engine which the post process will be applied. (default: current engine)
  44755. * @param reusable If the post process can be reused on the same frame. (default: false)
  44756. * @param textureType The type of texture to be used when performing the post processing.
  44757. * @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)
  44758. */
  44759. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44760. }
  44761. /**
  44762. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  44763. */
  44764. export class PassCubePostProcess extends PostProcess {
  44765. private _face;
  44766. /**
  44767. * Gets or sets the cube face to display.
  44768. * * 0 is +X
  44769. * * 1 is -X
  44770. * * 2 is +Y
  44771. * * 3 is -Y
  44772. * * 4 is +Z
  44773. * * 5 is -Z
  44774. */
  44775. get face(): number;
  44776. set face(value: number);
  44777. /**
  44778. * Creates the PassCubePostProcess
  44779. * @param name The name of the effect.
  44780. * @param options The required width/height ratio to downsize to before computing the render pass.
  44781. * @param camera The camera to apply the render pass to.
  44782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44783. * @param engine The engine which the post process will be applied. (default: current engine)
  44784. * @param reusable If the post process can be reused on the same frame. (default: false)
  44785. * @param textureType The type of texture to be used when performing the post processing.
  44786. * @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)
  44787. */
  44788. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44789. }
  44790. }
  44791. declare module BABYLON {
  44792. /** @hidden */
  44793. export var anaglyphPixelShader: {
  44794. name: string;
  44795. shader: string;
  44796. };
  44797. }
  44798. declare module BABYLON {
  44799. /**
  44800. * Postprocess used to generate anaglyphic rendering
  44801. */
  44802. export class AnaglyphPostProcess extends PostProcess {
  44803. private _passedProcess;
  44804. /**
  44805. * Creates a new AnaglyphPostProcess
  44806. * @param name defines postprocess name
  44807. * @param options defines creation options or target ratio scale
  44808. * @param rigCameras defines cameras using this postprocess
  44809. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  44810. * @param engine defines hosting engine
  44811. * @param reusable defines if the postprocess will be reused multiple times per frame
  44812. */
  44813. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  44814. }
  44815. }
  44816. declare module BABYLON {
  44817. /**
  44818. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  44819. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44820. */
  44821. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  44822. /**
  44823. * Creates a new AnaglyphArcRotateCamera
  44824. * @param name defines camera name
  44825. * @param alpha defines alpha angle (in radians)
  44826. * @param beta defines beta angle (in radians)
  44827. * @param radius defines radius
  44828. * @param target defines camera target
  44829. * @param interaxialDistance defines distance between each color axis
  44830. * @param scene defines the hosting scene
  44831. */
  44832. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  44833. /**
  44834. * Gets camera class name
  44835. * @returns AnaglyphArcRotateCamera
  44836. */
  44837. getClassName(): string;
  44838. }
  44839. }
  44840. declare module BABYLON {
  44841. /**
  44842. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  44843. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44844. */
  44845. export class AnaglyphFreeCamera extends FreeCamera {
  44846. /**
  44847. * Creates a new AnaglyphFreeCamera
  44848. * @param name defines camera name
  44849. * @param position defines initial position
  44850. * @param interaxialDistance defines distance between each color axis
  44851. * @param scene defines the hosting scene
  44852. */
  44853. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44854. /**
  44855. * Gets camera class name
  44856. * @returns AnaglyphFreeCamera
  44857. */
  44858. getClassName(): string;
  44859. }
  44860. }
  44861. declare module BABYLON {
  44862. /**
  44863. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  44864. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44865. */
  44866. export class AnaglyphGamepadCamera extends GamepadCamera {
  44867. /**
  44868. * Creates a new AnaglyphGamepadCamera
  44869. * @param name defines camera name
  44870. * @param position defines initial position
  44871. * @param interaxialDistance defines distance between each color axis
  44872. * @param scene defines the hosting scene
  44873. */
  44874. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44875. /**
  44876. * Gets camera class name
  44877. * @returns AnaglyphGamepadCamera
  44878. */
  44879. getClassName(): string;
  44880. }
  44881. }
  44882. declare module BABYLON {
  44883. /**
  44884. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  44885. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44886. */
  44887. export class AnaglyphUniversalCamera extends UniversalCamera {
  44888. /**
  44889. * Creates a new AnaglyphUniversalCamera
  44890. * @param name defines camera name
  44891. * @param position defines initial position
  44892. * @param interaxialDistance defines distance between each color axis
  44893. * @param scene defines the hosting scene
  44894. */
  44895. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44896. /**
  44897. * Gets camera class name
  44898. * @returns AnaglyphUniversalCamera
  44899. */
  44900. getClassName(): string;
  44901. }
  44902. }
  44903. declare module BABYLON {
  44904. /**
  44905. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  44906. * @see http://doc.babylonjs.com/features/cameras
  44907. */
  44908. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  44909. /**
  44910. * Creates a new StereoscopicArcRotateCamera
  44911. * @param name defines camera name
  44912. * @param alpha defines alpha angle (in radians)
  44913. * @param beta defines beta angle (in radians)
  44914. * @param radius defines radius
  44915. * @param target defines camera target
  44916. * @param interaxialDistance defines distance between each color axis
  44917. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44918. * @param scene defines the hosting scene
  44919. */
  44920. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44921. /**
  44922. * Gets camera class name
  44923. * @returns StereoscopicArcRotateCamera
  44924. */
  44925. getClassName(): string;
  44926. }
  44927. }
  44928. declare module BABYLON {
  44929. /**
  44930. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  44931. * @see http://doc.babylonjs.com/features/cameras
  44932. */
  44933. export class StereoscopicFreeCamera extends FreeCamera {
  44934. /**
  44935. * Creates a new StereoscopicFreeCamera
  44936. * @param name defines camera name
  44937. * @param position defines initial position
  44938. * @param interaxialDistance defines distance between each color axis
  44939. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44940. * @param scene defines the hosting scene
  44941. */
  44942. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44943. /**
  44944. * Gets camera class name
  44945. * @returns StereoscopicFreeCamera
  44946. */
  44947. getClassName(): string;
  44948. }
  44949. }
  44950. declare module BABYLON {
  44951. /**
  44952. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  44953. * @see http://doc.babylonjs.com/features/cameras
  44954. */
  44955. export class StereoscopicGamepadCamera extends GamepadCamera {
  44956. /**
  44957. * Creates a new StereoscopicGamepadCamera
  44958. * @param name defines camera name
  44959. * @param position defines initial position
  44960. * @param interaxialDistance defines distance between each color axis
  44961. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44962. * @param scene defines the hosting scene
  44963. */
  44964. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44965. /**
  44966. * Gets camera class name
  44967. * @returns StereoscopicGamepadCamera
  44968. */
  44969. getClassName(): string;
  44970. }
  44971. }
  44972. declare module BABYLON {
  44973. /**
  44974. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  44975. * @see http://doc.babylonjs.com/features/cameras
  44976. */
  44977. export class StereoscopicUniversalCamera extends UniversalCamera {
  44978. /**
  44979. * Creates a new StereoscopicUniversalCamera
  44980. * @param name defines camera name
  44981. * @param position defines initial position
  44982. * @param interaxialDistance defines distance between each color axis
  44983. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44984. * @param scene defines the hosting scene
  44985. */
  44986. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44987. /**
  44988. * Gets camera class name
  44989. * @returns StereoscopicUniversalCamera
  44990. */
  44991. getClassName(): string;
  44992. }
  44993. }
  44994. declare module BABYLON {
  44995. /**
  44996. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  44997. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44998. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44999. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45000. */
  45001. export class VirtualJoysticksCamera extends FreeCamera {
  45002. /**
  45003. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  45004. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45005. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45006. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45007. * @param name Define the name of the camera in the scene
  45008. * @param position Define the start position of the camera in the scene
  45009. * @param scene Define the scene the camera belongs to
  45010. */
  45011. constructor(name: string, position: Vector3, scene: Scene);
  45012. /**
  45013. * Gets the current object class name.
  45014. * @return the class name
  45015. */
  45016. getClassName(): string;
  45017. }
  45018. }
  45019. declare module BABYLON {
  45020. /**
  45021. * This represents all the required metrics to create a VR camera.
  45022. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  45023. */
  45024. export class VRCameraMetrics {
  45025. /**
  45026. * Define the horizontal resolution off the screen.
  45027. */
  45028. hResolution: number;
  45029. /**
  45030. * Define the vertical resolution off the screen.
  45031. */
  45032. vResolution: number;
  45033. /**
  45034. * Define the horizontal screen size.
  45035. */
  45036. hScreenSize: number;
  45037. /**
  45038. * Define the vertical screen size.
  45039. */
  45040. vScreenSize: number;
  45041. /**
  45042. * Define the vertical screen center position.
  45043. */
  45044. vScreenCenter: number;
  45045. /**
  45046. * Define the distance of the eyes to the screen.
  45047. */
  45048. eyeToScreenDistance: number;
  45049. /**
  45050. * Define the distance between both lenses
  45051. */
  45052. lensSeparationDistance: number;
  45053. /**
  45054. * Define the distance between both viewer's eyes.
  45055. */
  45056. interpupillaryDistance: number;
  45057. /**
  45058. * Define the distortion factor of the VR postprocess.
  45059. * Please, touch with care.
  45060. */
  45061. distortionK: number[];
  45062. /**
  45063. * Define the chromatic aberration correction factors for the VR post process.
  45064. */
  45065. chromaAbCorrection: number[];
  45066. /**
  45067. * Define the scale factor of the post process.
  45068. * The smaller the better but the slower.
  45069. */
  45070. postProcessScaleFactor: number;
  45071. /**
  45072. * Define an offset for the lens center.
  45073. */
  45074. lensCenterOffset: number;
  45075. /**
  45076. * Define if the current vr camera should compensate the distortion of the lense or not.
  45077. */
  45078. compensateDistortion: boolean;
  45079. /**
  45080. * Defines if multiview should be enabled when rendering (Default: false)
  45081. */
  45082. multiviewEnabled: boolean;
  45083. /**
  45084. * Gets the rendering aspect ratio based on the provided resolutions.
  45085. */
  45086. get aspectRatio(): number;
  45087. /**
  45088. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45089. */
  45090. get aspectRatioFov(): number;
  45091. /**
  45092. * @hidden
  45093. */
  45094. get leftHMatrix(): Matrix;
  45095. /**
  45096. * @hidden
  45097. */
  45098. get rightHMatrix(): Matrix;
  45099. /**
  45100. * @hidden
  45101. */
  45102. get leftPreViewMatrix(): Matrix;
  45103. /**
  45104. * @hidden
  45105. */
  45106. get rightPreViewMatrix(): Matrix;
  45107. /**
  45108. * Get the default VRMetrics based on the most generic setup.
  45109. * @returns the default vr metrics
  45110. */
  45111. static GetDefault(): VRCameraMetrics;
  45112. }
  45113. }
  45114. declare module BABYLON {
  45115. /** @hidden */
  45116. export var vrDistortionCorrectionPixelShader: {
  45117. name: string;
  45118. shader: string;
  45119. };
  45120. }
  45121. declare module BABYLON {
  45122. /**
  45123. * VRDistortionCorrectionPostProcess used for mobile VR
  45124. */
  45125. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45126. private _isRightEye;
  45127. private _distortionFactors;
  45128. private _postProcessScaleFactor;
  45129. private _lensCenterOffset;
  45130. private _scaleIn;
  45131. private _scaleFactor;
  45132. private _lensCenter;
  45133. /**
  45134. * Initializes the VRDistortionCorrectionPostProcess
  45135. * @param name The name of the effect.
  45136. * @param camera The camera to apply the render pass to.
  45137. * @param isRightEye If this is for the right eye distortion
  45138. * @param vrMetrics All the required metrics for the VR camera
  45139. */
  45140. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45141. }
  45142. }
  45143. declare module BABYLON {
  45144. /**
  45145. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45146. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45147. */
  45148. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45149. /**
  45150. * Creates a new VRDeviceOrientationArcRotateCamera
  45151. * @param name defines camera name
  45152. * @param alpha defines the camera rotation along the logitudinal axis
  45153. * @param beta defines the camera rotation along the latitudinal axis
  45154. * @param radius defines the camera distance from its target
  45155. * @param target defines the camera target
  45156. * @param scene defines the scene the camera belongs to
  45157. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45158. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45159. */
  45160. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45161. /**
  45162. * Gets camera class name
  45163. * @returns VRDeviceOrientationArcRotateCamera
  45164. */
  45165. getClassName(): string;
  45166. }
  45167. }
  45168. declare module BABYLON {
  45169. /**
  45170. * Camera used to simulate VR rendering (based on FreeCamera)
  45171. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45172. */
  45173. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45174. /**
  45175. * Creates a new VRDeviceOrientationFreeCamera
  45176. * @param name defines camera name
  45177. * @param position defines the start position of the camera
  45178. * @param scene defines the scene the camera belongs to
  45179. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45180. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45181. */
  45182. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45183. /**
  45184. * Gets camera class name
  45185. * @returns VRDeviceOrientationFreeCamera
  45186. */
  45187. getClassName(): string;
  45188. }
  45189. }
  45190. declare module BABYLON {
  45191. /**
  45192. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45193. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45194. */
  45195. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45196. /**
  45197. * Creates a new VRDeviceOrientationGamepadCamera
  45198. * @param name defines camera name
  45199. * @param position defines the start position of the camera
  45200. * @param scene defines the scene the camera belongs to
  45201. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45202. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45203. */
  45204. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45205. /**
  45206. * Gets camera class name
  45207. * @returns VRDeviceOrientationGamepadCamera
  45208. */
  45209. getClassName(): string;
  45210. }
  45211. }
  45212. declare module BABYLON {
  45213. /** @hidden */
  45214. export var imageProcessingPixelShader: {
  45215. name: string;
  45216. shader: string;
  45217. };
  45218. }
  45219. declare module BABYLON {
  45220. /**
  45221. * ImageProcessingPostProcess
  45222. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45223. */
  45224. export class ImageProcessingPostProcess extends PostProcess {
  45225. /**
  45226. * Default configuration related to image processing available in the PBR Material.
  45227. */
  45228. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45229. /**
  45230. * Gets the image processing configuration used either in this material.
  45231. */
  45232. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45233. /**
  45234. * Sets the Default image processing configuration used either in the this material.
  45235. *
  45236. * If sets to null, the scene one is in use.
  45237. */
  45238. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45239. /**
  45240. * Keep track of the image processing observer to allow dispose and replace.
  45241. */
  45242. private _imageProcessingObserver;
  45243. /**
  45244. * Attaches a new image processing configuration to the PBR Material.
  45245. * @param configuration
  45246. */
  45247. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45248. /**
  45249. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45250. */
  45251. get colorCurves(): Nullable<ColorCurves>;
  45252. /**
  45253. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45254. */
  45255. set colorCurves(value: Nullable<ColorCurves>);
  45256. /**
  45257. * Gets wether the color curves effect is enabled.
  45258. */
  45259. get colorCurvesEnabled(): boolean;
  45260. /**
  45261. * Sets wether the color curves effect is enabled.
  45262. */
  45263. set colorCurvesEnabled(value: boolean);
  45264. /**
  45265. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45266. */
  45267. get colorGradingTexture(): Nullable<BaseTexture>;
  45268. /**
  45269. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45270. */
  45271. set colorGradingTexture(value: Nullable<BaseTexture>);
  45272. /**
  45273. * Gets wether the color grading effect is enabled.
  45274. */
  45275. get colorGradingEnabled(): boolean;
  45276. /**
  45277. * Gets wether the color grading effect is enabled.
  45278. */
  45279. set colorGradingEnabled(value: boolean);
  45280. /**
  45281. * Gets exposure used in the effect.
  45282. */
  45283. get exposure(): number;
  45284. /**
  45285. * Sets exposure used in the effect.
  45286. */
  45287. set exposure(value: number);
  45288. /**
  45289. * Gets wether tonemapping is enabled or not.
  45290. */
  45291. get toneMappingEnabled(): boolean;
  45292. /**
  45293. * Sets wether tonemapping is enabled or not
  45294. */
  45295. set toneMappingEnabled(value: boolean);
  45296. /**
  45297. * Gets the type of tone mapping effect.
  45298. */
  45299. get toneMappingType(): number;
  45300. /**
  45301. * Sets the type of tone mapping effect.
  45302. */
  45303. set toneMappingType(value: number);
  45304. /**
  45305. * Gets contrast used in the effect.
  45306. */
  45307. get contrast(): number;
  45308. /**
  45309. * Sets contrast used in the effect.
  45310. */
  45311. set contrast(value: number);
  45312. /**
  45313. * Gets Vignette stretch size.
  45314. */
  45315. get vignetteStretch(): number;
  45316. /**
  45317. * Sets Vignette stretch size.
  45318. */
  45319. set vignetteStretch(value: number);
  45320. /**
  45321. * Gets Vignette centre X Offset.
  45322. */
  45323. get vignetteCentreX(): number;
  45324. /**
  45325. * Sets Vignette centre X Offset.
  45326. */
  45327. set vignetteCentreX(value: number);
  45328. /**
  45329. * Gets Vignette centre Y Offset.
  45330. */
  45331. get vignetteCentreY(): number;
  45332. /**
  45333. * Sets Vignette centre Y Offset.
  45334. */
  45335. set vignetteCentreY(value: number);
  45336. /**
  45337. * Gets Vignette weight or intensity of the vignette effect.
  45338. */
  45339. get vignetteWeight(): number;
  45340. /**
  45341. * Sets Vignette weight or intensity of the vignette effect.
  45342. */
  45343. set vignetteWeight(value: number);
  45344. /**
  45345. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45346. * if vignetteEnabled is set to true.
  45347. */
  45348. get vignetteColor(): Color4;
  45349. /**
  45350. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45351. * if vignetteEnabled is set to true.
  45352. */
  45353. set vignetteColor(value: Color4);
  45354. /**
  45355. * Gets Camera field of view used by the Vignette effect.
  45356. */
  45357. get vignetteCameraFov(): number;
  45358. /**
  45359. * Sets Camera field of view used by the Vignette effect.
  45360. */
  45361. set vignetteCameraFov(value: number);
  45362. /**
  45363. * Gets the vignette blend mode allowing different kind of effect.
  45364. */
  45365. get vignetteBlendMode(): number;
  45366. /**
  45367. * Sets the vignette blend mode allowing different kind of effect.
  45368. */
  45369. set vignetteBlendMode(value: number);
  45370. /**
  45371. * Gets wether the vignette effect is enabled.
  45372. */
  45373. get vignetteEnabled(): boolean;
  45374. /**
  45375. * Sets wether the vignette effect is enabled.
  45376. */
  45377. set vignetteEnabled(value: boolean);
  45378. private _fromLinearSpace;
  45379. /**
  45380. * Gets wether the input of the processing is in Gamma or Linear Space.
  45381. */
  45382. get fromLinearSpace(): boolean;
  45383. /**
  45384. * Sets wether the input of the processing is in Gamma or Linear Space.
  45385. */
  45386. set fromLinearSpace(value: boolean);
  45387. /**
  45388. * Defines cache preventing GC.
  45389. */
  45390. private _defines;
  45391. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45392. /**
  45393. * "ImageProcessingPostProcess"
  45394. * @returns "ImageProcessingPostProcess"
  45395. */
  45396. getClassName(): string;
  45397. protected _updateParameters(): void;
  45398. dispose(camera?: Camera): void;
  45399. }
  45400. }
  45401. declare module BABYLON {
  45402. /**
  45403. * Class containing static functions to help procedurally build meshes
  45404. */
  45405. export class GroundBuilder {
  45406. /**
  45407. * Creates a ground mesh
  45408. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45409. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45411. * @param name defines the name of the mesh
  45412. * @param options defines the options used to create the mesh
  45413. * @param scene defines the hosting scene
  45414. * @returns the ground mesh
  45415. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45416. */
  45417. static CreateGround(name: string, options: {
  45418. width?: number;
  45419. height?: number;
  45420. subdivisions?: number;
  45421. subdivisionsX?: number;
  45422. subdivisionsY?: number;
  45423. updatable?: boolean;
  45424. }, scene: any): Mesh;
  45425. /**
  45426. * Creates a tiled ground mesh
  45427. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45428. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45429. * * 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
  45430. * * 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
  45431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45432. * @param name defines the name of the mesh
  45433. * @param options defines the options used to create the mesh
  45434. * @param scene defines the hosting scene
  45435. * @returns the tiled ground mesh
  45436. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45437. */
  45438. static CreateTiledGround(name: string, options: {
  45439. xmin: number;
  45440. zmin: number;
  45441. xmax: number;
  45442. zmax: number;
  45443. subdivisions?: {
  45444. w: number;
  45445. h: number;
  45446. };
  45447. precision?: {
  45448. w: number;
  45449. h: number;
  45450. };
  45451. updatable?: boolean;
  45452. }, scene?: Nullable<Scene>): Mesh;
  45453. /**
  45454. * Creates a ground mesh from a height map
  45455. * * The parameter `url` sets the URL of the height map image resource.
  45456. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45457. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45458. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45459. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45460. * * 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.
  45461. * * 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).
  45462. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45464. * @param name defines the name of the mesh
  45465. * @param url defines the url to the height map
  45466. * @param options defines the options used to create the mesh
  45467. * @param scene defines the hosting scene
  45468. * @returns the ground mesh
  45469. * @see https://doc.babylonjs.com/babylon101/height_map
  45470. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45471. */
  45472. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45473. width?: number;
  45474. height?: number;
  45475. subdivisions?: number;
  45476. minHeight?: number;
  45477. maxHeight?: number;
  45478. colorFilter?: Color3;
  45479. alphaFilter?: number;
  45480. updatable?: boolean;
  45481. onReady?: (mesh: GroundMesh) => void;
  45482. }, scene?: Nullable<Scene>): GroundMesh;
  45483. }
  45484. }
  45485. declare module BABYLON {
  45486. /**
  45487. * Class containing static functions to help procedurally build meshes
  45488. */
  45489. export class TorusBuilder {
  45490. /**
  45491. * Creates a torus mesh
  45492. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45493. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45494. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45496. * * 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
  45497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45498. * @param name defines the name of the mesh
  45499. * @param options defines the options used to create the mesh
  45500. * @param scene defines the hosting scene
  45501. * @returns the torus mesh
  45502. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45503. */
  45504. static CreateTorus(name: string, options: {
  45505. diameter?: number;
  45506. thickness?: number;
  45507. tessellation?: number;
  45508. updatable?: boolean;
  45509. sideOrientation?: number;
  45510. frontUVs?: Vector4;
  45511. backUVs?: Vector4;
  45512. }, scene: any): Mesh;
  45513. }
  45514. }
  45515. declare module BABYLON {
  45516. /**
  45517. * Class containing static functions to help procedurally build meshes
  45518. */
  45519. export class CylinderBuilder {
  45520. /**
  45521. * Creates a cylinder or a cone mesh
  45522. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45523. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45524. * * 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.
  45525. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45526. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45527. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45528. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45529. * * 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).
  45530. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45531. * * 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).
  45532. * * 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
  45533. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45534. * * 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
  45535. * * 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.
  45536. * * If `enclose` is false, a ring surface is one element.
  45537. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45538. * * 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
  45539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45540. * * 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
  45541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45542. * @param name defines the name of the mesh
  45543. * @param options defines the options used to create the mesh
  45544. * @param scene defines the hosting scene
  45545. * @returns the cylinder mesh
  45546. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45547. */
  45548. static CreateCylinder(name: string, options: {
  45549. height?: number;
  45550. diameterTop?: number;
  45551. diameterBottom?: number;
  45552. diameter?: number;
  45553. tessellation?: number;
  45554. subdivisions?: number;
  45555. arc?: number;
  45556. faceColors?: Color4[];
  45557. faceUV?: Vector4[];
  45558. updatable?: boolean;
  45559. hasRings?: boolean;
  45560. enclose?: boolean;
  45561. cap?: number;
  45562. sideOrientation?: number;
  45563. frontUVs?: Vector4;
  45564. backUVs?: Vector4;
  45565. }, scene: any): Mesh;
  45566. }
  45567. }
  45568. declare module BABYLON {
  45569. /**
  45570. * States of the webXR experience
  45571. */
  45572. export enum WebXRState {
  45573. /**
  45574. * Transitioning to being in XR mode
  45575. */
  45576. ENTERING_XR = 0,
  45577. /**
  45578. * Transitioning to non XR mode
  45579. */
  45580. EXITING_XR = 1,
  45581. /**
  45582. * In XR mode and presenting
  45583. */
  45584. IN_XR = 2,
  45585. /**
  45586. * Not entered XR mode
  45587. */
  45588. NOT_IN_XR = 3
  45589. }
  45590. /**
  45591. * Abstraction of the XR render target
  45592. */
  45593. export interface WebXRRenderTarget extends IDisposable {
  45594. /**
  45595. * xrpresent context of the canvas which can be used to display/mirror xr content
  45596. */
  45597. canvasContext: WebGLRenderingContext;
  45598. /**
  45599. * xr layer for the canvas
  45600. */
  45601. xrLayer: Nullable<XRWebGLLayer>;
  45602. /**
  45603. * Initializes the xr layer for the session
  45604. * @param xrSession xr session
  45605. * @returns a promise that will resolve once the XR Layer has been created
  45606. */
  45607. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45608. }
  45609. }
  45610. declare module BABYLON {
  45611. /**
  45612. * COnfiguration object for WebXR output canvas
  45613. */
  45614. export class WebXRManagedOutputCanvasOptions {
  45615. /**
  45616. * An optional canvas in case you wish to create it yourself and provide it here.
  45617. * If not provided, a new canvas will be created
  45618. */
  45619. canvasElement?: HTMLCanvasElement;
  45620. /**
  45621. * Options for this XR Layer output
  45622. */
  45623. canvasOptions?: XRWebGLLayerOptions;
  45624. /**
  45625. * CSS styling for a newly created canvas (if not provided)
  45626. */
  45627. newCanvasCssStyle?: string;
  45628. /**
  45629. * Get the default values of the configuration object
  45630. * @returns default values of this configuration object
  45631. */
  45632. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45633. }
  45634. /**
  45635. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45636. */
  45637. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45638. private _options;
  45639. private _canvas;
  45640. private _engine;
  45641. /**
  45642. * Rendering context of the canvas which can be used to display/mirror xr content
  45643. */
  45644. canvasContext: WebGLRenderingContext;
  45645. /**
  45646. * xr layer for the canvas
  45647. */
  45648. xrLayer: Nullable<XRWebGLLayer>;
  45649. /**
  45650. * Initializes the canvas to be added/removed upon entering/exiting xr
  45651. * @param _xrSessionManager The XR Session manager
  45652. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45653. */
  45654. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45655. /**
  45656. * Disposes of the object
  45657. */
  45658. dispose(): void;
  45659. /**
  45660. * Initializes the xr layer for the session
  45661. * @param xrSession xr session
  45662. * @returns a promise that will resolve once the XR Layer has been created
  45663. */
  45664. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45665. private _addCanvas;
  45666. private _removeCanvas;
  45667. private _setManagedOutputCanvas;
  45668. }
  45669. }
  45670. declare module BABYLON {
  45671. /**
  45672. * Manages an XRSession to work with Babylon's engine
  45673. * @see https://doc.babylonjs.com/how_to/webxr
  45674. */
  45675. export class WebXRSessionManager implements IDisposable {
  45676. /** The scene which the session should be created for */
  45677. scene: Scene;
  45678. private _referenceSpace;
  45679. private _rttProvider;
  45680. private _sessionEnded;
  45681. private _xrNavigator;
  45682. private baseLayer;
  45683. /**
  45684. * The base reference space from which the session started. good if you want to reset your
  45685. * reference space
  45686. */
  45687. baseReferenceSpace: XRReferenceSpace;
  45688. /**
  45689. * Current XR frame
  45690. */
  45691. currentFrame: Nullable<XRFrame>;
  45692. /** WebXR timestamp updated every frame */
  45693. currentTimestamp: number;
  45694. /**
  45695. * Used just in case of a failure to initialize an immersive session.
  45696. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45697. */
  45698. defaultHeightCompensation: number;
  45699. /**
  45700. * Fires every time a new xrFrame arrives which can be used to update the camera
  45701. */
  45702. onXRFrameObservable: Observable<XRFrame>;
  45703. /**
  45704. * Fires when the reference space changed
  45705. */
  45706. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45707. /**
  45708. * Fires when the xr session is ended either by the device or manually done
  45709. */
  45710. onXRSessionEnded: Observable<any>;
  45711. /**
  45712. * Fires when the xr session is ended either by the device or manually done
  45713. */
  45714. onXRSessionInit: Observable<XRSession>;
  45715. /**
  45716. * Underlying xr session
  45717. */
  45718. session: XRSession;
  45719. /**
  45720. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45721. * or get the offset the player is currently at.
  45722. */
  45723. viewerReferenceSpace: XRReferenceSpace;
  45724. /**
  45725. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45726. * @param scene The scene which the session should be created for
  45727. */
  45728. constructor(
  45729. /** The scene which the session should be created for */
  45730. scene: Scene);
  45731. /**
  45732. * The current reference space used in this session. This reference space can constantly change!
  45733. * It is mainly used to offset the camera's position.
  45734. */
  45735. get referenceSpace(): XRReferenceSpace;
  45736. /**
  45737. * Set a new reference space and triggers the observable
  45738. */
  45739. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45740. /**
  45741. * Disposes of the session manager
  45742. */
  45743. dispose(): void;
  45744. /**
  45745. * Stops the xrSession and restores the render loop
  45746. * @returns Promise which resolves after it exits XR
  45747. */
  45748. exitXRAsync(): Promise<void>;
  45749. /**
  45750. * Gets the correct render target texture to be rendered this frame for this eye
  45751. * @param eye the eye for which to get the render target
  45752. * @returns the render target for the specified eye
  45753. */
  45754. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  45755. /**
  45756. * Creates a WebXRRenderTarget object for the XR session
  45757. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  45758. * @param options optional options to provide when creating a new render target
  45759. * @returns a WebXR render target to which the session can render
  45760. */
  45761. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  45762. /**
  45763. * Initializes the manager
  45764. * After initialization enterXR can be called to start an XR session
  45765. * @returns Promise which resolves after it is initialized
  45766. */
  45767. initializeAsync(): Promise<void>;
  45768. /**
  45769. * Initializes an xr session
  45770. * @param xrSessionMode mode to initialize
  45771. * @param xrSessionInit defines optional and required values to pass to the session builder
  45772. * @returns a promise which will resolve once the session has been initialized
  45773. */
  45774. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  45775. /**
  45776. * Checks if a session would be supported for the creation options specified
  45777. * @param sessionMode session mode to check if supported eg. immersive-vr
  45778. * @returns A Promise that resolves to true if supported and false if not
  45779. */
  45780. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45781. /**
  45782. * Resets the reference space to the one started the session
  45783. */
  45784. resetReferenceSpace(): void;
  45785. /**
  45786. * Starts rendering to the xr layer
  45787. */
  45788. runXRRenderLoop(): void;
  45789. /**
  45790. * Sets the reference space on the xr session
  45791. * @param referenceSpaceType space to set
  45792. * @returns a promise that will resolve once the reference space has been set
  45793. */
  45794. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  45795. /**
  45796. * Updates the render state of the session
  45797. * @param state state to set
  45798. * @returns a promise that resolves once the render state has been updated
  45799. */
  45800. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  45801. /**
  45802. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  45803. * @param sessionMode defines the session to test
  45804. * @returns a promise with boolean as final value
  45805. */
  45806. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45807. private _createRenderTargetTexture;
  45808. }
  45809. }
  45810. declare module BABYLON {
  45811. /**
  45812. * WebXR Camera which holds the views for the xrSession
  45813. * @see https://doc.babylonjs.com/how_to/webxr_camera
  45814. */
  45815. export class WebXRCamera extends FreeCamera {
  45816. private _xrSessionManager;
  45817. private _firstFrame;
  45818. private _referenceQuaternion;
  45819. private _referencedPosition;
  45820. private _xrInvPositionCache;
  45821. private _xrInvQuaternionCache;
  45822. /**
  45823. * Should position compensation execute on first frame.
  45824. * This is used when copying the position from a native (non XR) camera
  45825. */
  45826. compensateOnFirstFrame: boolean;
  45827. /**
  45828. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  45829. * @param name the name of the camera
  45830. * @param scene the scene to add the camera to
  45831. * @param _xrSessionManager a constructed xr session manager
  45832. */
  45833. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  45834. /**
  45835. * Return the user's height, unrelated to the current ground.
  45836. * This will be the y position of this camera, when ground level is 0.
  45837. */
  45838. get realWorldHeight(): number;
  45839. /** @hidden */
  45840. _updateForDualEyeDebugging(): void;
  45841. /**
  45842. * Sets this camera's transformation based on a non-vr camera
  45843. * @param otherCamera the non-vr camera to copy the transformation from
  45844. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  45845. */
  45846. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  45847. /**
  45848. * Gets the current instance class name ("WebXRCamera").
  45849. * @returns the class name
  45850. */
  45851. getClassName(): string;
  45852. /**
  45853. * Overriding the _getViewMatrix function, as it is computed by WebXR
  45854. */
  45855. _getViewMatrix(): Matrix;
  45856. private _updateFromXRSession;
  45857. private _updateNumberOfRigCameras;
  45858. private _updateReferenceSpace;
  45859. private _updateReferenceSpaceOffset;
  45860. }
  45861. }
  45862. declare module BABYLON {
  45863. /**
  45864. * Defining the interface required for a (webxr) feature
  45865. */
  45866. export interface IWebXRFeature extends IDisposable {
  45867. /**
  45868. * Is this feature attached
  45869. */
  45870. attached: boolean;
  45871. /**
  45872. * Should auto-attach be disabled?
  45873. */
  45874. disableAutoAttach: boolean;
  45875. /**
  45876. * Attach the feature to the session
  45877. * Will usually be called by the features manager
  45878. *
  45879. * @param force should attachment be forced (even when already attached)
  45880. * @returns true if successful.
  45881. */
  45882. attach(force?: boolean): boolean;
  45883. /**
  45884. * Detach the feature from the session
  45885. * Will usually be called by the features manager
  45886. *
  45887. * @returns true if successful.
  45888. */
  45889. detach(): boolean;
  45890. }
  45891. /**
  45892. * A list of the currently available features without referencing them
  45893. */
  45894. export class WebXRFeatureName {
  45895. /**
  45896. * The name of the anchor system feature
  45897. */
  45898. static ANCHOR_SYSTEM: string;
  45899. /**
  45900. * The name of the background remover feature
  45901. */
  45902. static BACKGROUND_REMOVER: string;
  45903. /**
  45904. * The name of the hit test feature
  45905. */
  45906. static HIT_TEST: string;
  45907. /**
  45908. * physics impostors for xr controllers feature
  45909. */
  45910. static PHYSICS_CONTROLLERS: string;
  45911. /**
  45912. * The name of the plane detection feature
  45913. */
  45914. static PLANE_DETECTION: string;
  45915. /**
  45916. * The name of the pointer selection feature
  45917. */
  45918. static POINTER_SELECTION: string;
  45919. /**
  45920. * The name of the teleportation feature
  45921. */
  45922. static TELEPORTATION: string;
  45923. }
  45924. /**
  45925. * Defining the constructor of a feature. Used to register the modules.
  45926. */
  45927. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  45928. /**
  45929. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  45930. * It is mainly used in AR sessions.
  45931. *
  45932. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  45933. */
  45934. export class WebXRFeaturesManager implements IDisposable {
  45935. private _xrSessionManager;
  45936. private static readonly _AvailableFeatures;
  45937. private _features;
  45938. /**
  45939. * constructs a new features manages.
  45940. *
  45941. * @param _xrSessionManager an instance of WebXRSessionManager
  45942. */
  45943. constructor(_xrSessionManager: WebXRSessionManager);
  45944. /**
  45945. * Used to register a module. After calling this function a developer can use this feature in the scene.
  45946. * Mainly used internally.
  45947. *
  45948. * @param featureName the name of the feature to register
  45949. * @param constructorFunction the function used to construct the module
  45950. * @param version the (babylon) version of the module
  45951. * @param stable is that a stable version of this module
  45952. */
  45953. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  45954. /**
  45955. * Returns a constructor of a specific feature.
  45956. *
  45957. * @param featureName the name of the feature to construct
  45958. * @param version the version of the feature to load
  45959. * @param xrSessionManager the xrSessionManager. Used to construct the module
  45960. * @param options optional options provided to the module.
  45961. * @returns a function that, when called, will return a new instance of this feature
  45962. */
  45963. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  45964. /**
  45965. * Can be used to return the list of features currently registered
  45966. *
  45967. * @returns an Array of available features
  45968. */
  45969. static GetAvailableFeatures(): string[];
  45970. /**
  45971. * Gets the versions available for a specific feature
  45972. * @param featureName the name of the feature
  45973. * @returns an array with the available versions
  45974. */
  45975. static GetAvailableVersions(featureName: string): string[];
  45976. /**
  45977. * Return the latest unstable version of this feature
  45978. * @param featureName the name of the feature to search
  45979. * @returns the version number. if not found will return -1
  45980. */
  45981. static GetLatestVersionOfFeature(featureName: string): number;
  45982. /**
  45983. * Return the latest stable version of this feature
  45984. * @param featureName the name of the feature to search
  45985. * @returns the version number. if not found will return -1
  45986. */
  45987. static GetStableVersionOfFeature(featureName: string): number;
  45988. /**
  45989. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  45990. * Can be used during a session to start a feature
  45991. * @param featureName the name of feature to attach
  45992. */
  45993. attachFeature(featureName: string): void;
  45994. /**
  45995. * Can be used inside a session or when the session ends to detach a specific feature
  45996. * @param featureName the name of the feature to detach
  45997. */
  45998. detachFeature(featureName: string): void;
  45999. /**
  46000. * Used to disable an already-enabled feature
  46001. * The feature will be disposed and will be recreated once enabled.
  46002. * @param featureName the feature to disable
  46003. * @returns true if disable was successful
  46004. */
  46005. disableFeature(featureName: string | {
  46006. Name: string;
  46007. }): boolean;
  46008. /**
  46009. * dispose this features manager
  46010. */
  46011. dispose(): void;
  46012. /**
  46013. * 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.
  46014. * 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.
  46015. *
  46016. * @param featureName the name of the feature to load or the class of the feature
  46017. * @param version optional version to load. if not provided the latest version will be enabled
  46018. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46019. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46020. * @returns a new constructed feature or throws an error if feature not found.
  46021. */
  46022. enableFeature(featureName: string | {
  46023. Name: string;
  46024. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46025. /**
  46026. * get the implementation of an enabled feature.
  46027. * @param featureName the name of the feature to load
  46028. * @returns the feature class, if found
  46029. */
  46030. getEnabledFeature(featureName: string): IWebXRFeature;
  46031. /**
  46032. * Get the list of enabled features
  46033. * @returns an array of enabled features
  46034. */
  46035. getEnabledFeatures(): string[];
  46036. }
  46037. }
  46038. declare module BABYLON {
  46039. /**
  46040. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46041. * @see https://doc.babylonjs.com/how_to/webxr
  46042. */
  46043. export class WebXRExperienceHelper implements IDisposable {
  46044. private scene;
  46045. private _nonVRCamera;
  46046. private _originalSceneAutoClear;
  46047. private _supported;
  46048. /**
  46049. * Camera used to render xr content
  46050. */
  46051. camera: WebXRCamera;
  46052. /** A features manager for this xr session */
  46053. featuresManager: WebXRFeaturesManager;
  46054. /**
  46055. * Observers registered here will be triggered after the camera's initial transformation is set
  46056. * This can be used to set a different ground level or an extra rotation.
  46057. *
  46058. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46059. * to the position set after this observable is done executing.
  46060. */
  46061. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46062. /**
  46063. * Fires when the state of the experience helper has changed
  46064. */
  46065. onStateChangedObservable: Observable<WebXRState>;
  46066. /** Session manager used to keep track of xr session */
  46067. sessionManager: WebXRSessionManager;
  46068. /**
  46069. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46070. */
  46071. state: WebXRState;
  46072. /**
  46073. * Creates a WebXRExperienceHelper
  46074. * @param scene The scene the helper should be created in
  46075. */
  46076. private constructor();
  46077. /**
  46078. * Creates the experience helper
  46079. * @param scene the scene to attach the experience helper to
  46080. * @returns a promise for the experience helper
  46081. */
  46082. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46083. /**
  46084. * Disposes of the experience helper
  46085. */
  46086. dispose(): void;
  46087. /**
  46088. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46089. * @param sessionMode options for the XR session
  46090. * @param referenceSpaceType frame of reference of the XR session
  46091. * @param renderTarget the output canvas that will be used to enter XR mode
  46092. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46093. * @returns promise that resolves after xr mode has entered
  46094. */
  46095. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46096. /**
  46097. * Exits XR mode and returns the scene to its original state
  46098. * @returns promise that resolves after xr mode has exited
  46099. */
  46100. exitXRAsync(): Promise<void>;
  46101. private _nonXRToXRCamera;
  46102. private _setState;
  46103. }
  46104. }
  46105. declare module BABYLON {
  46106. /**
  46107. * X-Y values for axes in WebXR
  46108. */
  46109. export interface IWebXRMotionControllerAxesValue {
  46110. /**
  46111. * The value of the x axis
  46112. */
  46113. x: number;
  46114. /**
  46115. * The value of the y-axis
  46116. */
  46117. y: number;
  46118. }
  46119. /**
  46120. * changed / previous values for the values of this component
  46121. */
  46122. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46123. /**
  46124. * current (this frame) value
  46125. */
  46126. current: T;
  46127. /**
  46128. * previous (last change) value
  46129. */
  46130. previous: T;
  46131. }
  46132. /**
  46133. * Represents changes in the component between current frame and last values recorded
  46134. */
  46135. export interface IWebXRMotionControllerComponentChanges {
  46136. /**
  46137. * will be populated with previous and current values if axes changed
  46138. */
  46139. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46140. /**
  46141. * will be populated with previous and current values if pressed changed
  46142. */
  46143. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46144. /**
  46145. * will be populated with previous and current values if touched changed
  46146. */
  46147. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46148. /**
  46149. * will be populated with previous and current values if value changed
  46150. */
  46151. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46152. }
  46153. /**
  46154. * This class represents a single component (for example button or thumbstick) of a motion controller
  46155. */
  46156. export class WebXRControllerComponent implements IDisposable {
  46157. /**
  46158. * the id of this component
  46159. */
  46160. id: string;
  46161. /**
  46162. * the type of the component
  46163. */
  46164. type: MotionControllerComponentType;
  46165. private _buttonIndex;
  46166. private _axesIndices;
  46167. private _axes;
  46168. private _changes;
  46169. private _currentValue;
  46170. private _hasChanges;
  46171. private _pressed;
  46172. private _touched;
  46173. /**
  46174. * button component type
  46175. */
  46176. static BUTTON_TYPE: MotionControllerComponentType;
  46177. /**
  46178. * squeeze component type
  46179. */
  46180. static SQUEEZE_TYPE: MotionControllerComponentType;
  46181. /**
  46182. * Thumbstick component type
  46183. */
  46184. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46185. /**
  46186. * Touchpad component type
  46187. */
  46188. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46189. /**
  46190. * trigger component type
  46191. */
  46192. static TRIGGER_TYPE: MotionControllerComponentType;
  46193. /**
  46194. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46195. * the axes data changes
  46196. */
  46197. onAxisValueChangedObservable: Observable<{
  46198. x: number;
  46199. y: number;
  46200. }>;
  46201. /**
  46202. * Observers registered here will be triggered when the state of a button changes
  46203. * State change is either pressed / touched / value
  46204. */
  46205. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46206. /**
  46207. * Creates a new component for a motion controller.
  46208. * It is created by the motion controller itself
  46209. *
  46210. * @param id the id of this component
  46211. * @param type the type of the component
  46212. * @param _buttonIndex index in the buttons array of the gamepad
  46213. * @param _axesIndices indices of the values in the axes array of the gamepad
  46214. */
  46215. constructor(
  46216. /**
  46217. * the id of this component
  46218. */
  46219. id: string,
  46220. /**
  46221. * the type of the component
  46222. */
  46223. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46224. /**
  46225. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46226. */
  46227. get axes(): IWebXRMotionControllerAxesValue;
  46228. /**
  46229. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46230. */
  46231. get changes(): IWebXRMotionControllerComponentChanges;
  46232. /**
  46233. * Return whether or not the component changed the last frame
  46234. */
  46235. get hasChanges(): boolean;
  46236. /**
  46237. * is the button currently pressed
  46238. */
  46239. get pressed(): boolean;
  46240. /**
  46241. * is the button currently touched
  46242. */
  46243. get touched(): boolean;
  46244. /**
  46245. * Get the current value of this component
  46246. */
  46247. get value(): number;
  46248. /**
  46249. * Dispose this component
  46250. */
  46251. dispose(): void;
  46252. /**
  46253. * Are there axes correlating to this component
  46254. * @return true is axes data is available
  46255. */
  46256. isAxes(): boolean;
  46257. /**
  46258. * Is this component a button (hence - pressable)
  46259. * @returns true if can be pressed
  46260. */
  46261. isButton(): boolean;
  46262. /**
  46263. * update this component using the gamepad object it is in. Called on every frame
  46264. * @param nativeController the native gamepad controller object
  46265. */
  46266. update(nativeController: IMinimalMotionControllerObject): void;
  46267. }
  46268. }
  46269. declare module BABYLON {
  46270. /**
  46271. * Class used to represent data loading progression
  46272. */
  46273. export class SceneLoaderProgressEvent {
  46274. /** defines if data length to load can be evaluated */
  46275. readonly lengthComputable: boolean;
  46276. /** defines the loaded data length */
  46277. readonly loaded: number;
  46278. /** defines the data length to load */
  46279. readonly total: number;
  46280. /**
  46281. * Create a new progress event
  46282. * @param lengthComputable defines if data length to load can be evaluated
  46283. * @param loaded defines the loaded data length
  46284. * @param total defines the data length to load
  46285. */
  46286. constructor(
  46287. /** defines if data length to load can be evaluated */
  46288. lengthComputable: boolean,
  46289. /** defines the loaded data length */
  46290. loaded: number,
  46291. /** defines the data length to load */
  46292. total: number);
  46293. /**
  46294. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  46295. * @param event defines the source event
  46296. * @returns a new SceneLoaderProgressEvent
  46297. */
  46298. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  46299. }
  46300. /**
  46301. * Interface used by SceneLoader plugins to define supported file extensions
  46302. */
  46303. export interface ISceneLoaderPluginExtensions {
  46304. /**
  46305. * Defines the list of supported extensions
  46306. */
  46307. [extension: string]: {
  46308. isBinary: boolean;
  46309. };
  46310. }
  46311. /**
  46312. * Interface used by SceneLoader plugin factory
  46313. */
  46314. export interface ISceneLoaderPluginFactory {
  46315. /**
  46316. * Defines the name of the factory
  46317. */
  46318. name: string;
  46319. /**
  46320. * Function called to create a new plugin
  46321. * @return the new plugin
  46322. */
  46323. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46324. /**
  46325. * The callback that returns true if the data can be directly loaded.
  46326. * @param data string containing the file data
  46327. * @returns if the data can be loaded directly
  46328. */
  46329. canDirectLoad?(data: string): boolean;
  46330. }
  46331. /**
  46332. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46333. */
  46334. export interface ISceneLoaderPluginBase {
  46335. /**
  46336. * The friendly name of this plugin.
  46337. */
  46338. name: string;
  46339. /**
  46340. * The file extensions supported by this plugin.
  46341. */
  46342. extensions: string | ISceneLoaderPluginExtensions;
  46343. /**
  46344. * The callback called when loading from a url.
  46345. * @param scene scene loading this url
  46346. * @param url url to load
  46347. * @param onSuccess callback called when the file successfully loads
  46348. * @param onProgress callback called while file is loading (if the server supports this mode)
  46349. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46350. * @param onError callback called when the file fails to load
  46351. * @returns a file request object
  46352. */
  46353. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46354. /**
  46355. * The callback called when loading from a file object.
  46356. * @param scene scene loading this file
  46357. * @param file defines the file to load
  46358. * @param onSuccess defines the callback to call when data is loaded
  46359. * @param onProgress defines the callback to call during loading process
  46360. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46361. * @param onError defines the callback to call when an error occurs
  46362. * @returns a file request object
  46363. */
  46364. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46365. /**
  46366. * The callback that returns true if the data can be directly loaded.
  46367. * @param data string containing the file data
  46368. * @returns if the data can be loaded directly
  46369. */
  46370. canDirectLoad?(data: string): boolean;
  46371. /**
  46372. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46373. * @param scene scene loading this data
  46374. * @param data string containing the data
  46375. * @returns data to pass to the plugin
  46376. */
  46377. directLoad?(scene: Scene, data: string): any;
  46378. /**
  46379. * The callback that allows custom handling of the root url based on the response url.
  46380. * @param rootUrl the original root url
  46381. * @param responseURL the response url if available
  46382. * @returns the new root url
  46383. */
  46384. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46385. }
  46386. /**
  46387. * Interface used to define a SceneLoader plugin
  46388. */
  46389. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46390. /**
  46391. * Import meshes into a scene.
  46392. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46393. * @param scene The scene to import into
  46394. * @param data The data to import
  46395. * @param rootUrl The root url for scene and resources
  46396. * @param meshes The meshes array to import into
  46397. * @param particleSystems The particle systems array to import into
  46398. * @param skeletons The skeletons array to import into
  46399. * @param onError The callback when import fails
  46400. * @returns True if successful or false otherwise
  46401. */
  46402. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46403. /**
  46404. * Load into a scene.
  46405. * @param scene The scene to load into
  46406. * @param data The data to import
  46407. * @param rootUrl The root url for scene and resources
  46408. * @param onError The callback when import fails
  46409. * @returns True if successful or false otherwise
  46410. */
  46411. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46412. /**
  46413. * Load into an asset container.
  46414. * @param scene The scene to load into
  46415. * @param data The data to import
  46416. * @param rootUrl The root url for scene and resources
  46417. * @param onError The callback when import fails
  46418. * @returns The loaded asset container
  46419. */
  46420. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46421. }
  46422. /**
  46423. * Interface used to define an async SceneLoader plugin
  46424. */
  46425. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46426. /**
  46427. * Import meshes into a scene.
  46428. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46429. * @param scene The scene to import into
  46430. * @param data The data to import
  46431. * @param rootUrl The root url for scene and resources
  46432. * @param onProgress The callback when the load progresses
  46433. * @param fileName Defines the name of the file to load
  46434. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46435. */
  46436. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46437. meshes: AbstractMesh[];
  46438. particleSystems: IParticleSystem[];
  46439. skeletons: Skeleton[];
  46440. animationGroups: AnimationGroup[];
  46441. }>;
  46442. /**
  46443. * Load into a scene.
  46444. * @param scene The scene to load into
  46445. * @param data The data to import
  46446. * @param rootUrl The root url for scene and resources
  46447. * @param onProgress The callback when the load progresses
  46448. * @param fileName Defines the name of the file to load
  46449. * @returns Nothing
  46450. */
  46451. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46452. /**
  46453. * Load into an asset container.
  46454. * @param scene The scene to load into
  46455. * @param data The data to import
  46456. * @param rootUrl The root url for scene and resources
  46457. * @param onProgress The callback when the load progresses
  46458. * @param fileName Defines the name of the file to load
  46459. * @returns The loaded asset container
  46460. */
  46461. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46462. }
  46463. /**
  46464. * Mode that determines how to handle old animation groups before loading new ones.
  46465. */
  46466. export enum SceneLoaderAnimationGroupLoadingMode {
  46467. /**
  46468. * Reset all old animations to initial state then dispose them.
  46469. */
  46470. Clean = 0,
  46471. /**
  46472. * Stop all old animations.
  46473. */
  46474. Stop = 1,
  46475. /**
  46476. * Restart old animations from first frame.
  46477. */
  46478. Sync = 2,
  46479. /**
  46480. * Old animations remains untouched.
  46481. */
  46482. NoSync = 3
  46483. }
  46484. /**
  46485. * Class used to load scene from various file formats using registered plugins
  46486. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46487. */
  46488. export class SceneLoader {
  46489. /**
  46490. * No logging while loading
  46491. */
  46492. static readonly NO_LOGGING: number;
  46493. /**
  46494. * Minimal logging while loading
  46495. */
  46496. static readonly MINIMAL_LOGGING: number;
  46497. /**
  46498. * Summary logging while loading
  46499. */
  46500. static readonly SUMMARY_LOGGING: number;
  46501. /**
  46502. * Detailled logging while loading
  46503. */
  46504. static readonly DETAILED_LOGGING: number;
  46505. /**
  46506. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46507. */
  46508. static get ForceFullSceneLoadingForIncremental(): boolean;
  46509. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46510. /**
  46511. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46512. */
  46513. static get ShowLoadingScreen(): boolean;
  46514. static set ShowLoadingScreen(value: boolean);
  46515. /**
  46516. * Defines the current logging level (while loading the scene)
  46517. * @ignorenaming
  46518. */
  46519. static get loggingLevel(): number;
  46520. static set loggingLevel(value: number);
  46521. /**
  46522. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46523. */
  46524. static get CleanBoneMatrixWeights(): boolean;
  46525. static set CleanBoneMatrixWeights(value: boolean);
  46526. /**
  46527. * Event raised when a plugin is used to load a scene
  46528. */
  46529. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46530. private static _registeredPlugins;
  46531. private static _getDefaultPlugin;
  46532. private static _getPluginForExtension;
  46533. private static _getPluginForDirectLoad;
  46534. private static _getPluginForFilename;
  46535. private static _getDirectLoad;
  46536. private static _loadData;
  46537. private static _getFileInfo;
  46538. /**
  46539. * Gets a plugin that can load the given extension
  46540. * @param extension defines the extension to load
  46541. * @returns a plugin or null if none works
  46542. */
  46543. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46544. /**
  46545. * Gets a boolean indicating that the given extension can be loaded
  46546. * @param extension defines the extension to load
  46547. * @returns true if the extension is supported
  46548. */
  46549. static IsPluginForExtensionAvailable(extension: string): boolean;
  46550. /**
  46551. * Adds a new plugin to the list of registered plugins
  46552. * @param plugin defines the plugin to add
  46553. */
  46554. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46555. /**
  46556. * Import meshes into a scene
  46557. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46558. * @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)
  46559. * @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)
  46560. * @param scene the instance of BABYLON.Scene to append to
  46561. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46562. * @param onProgress a callback with a progress event for each file being loaded
  46563. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46564. * @param pluginExtension the extension used to determine the plugin
  46565. * @returns The loaded plugin
  46566. */
  46567. 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>;
  46568. /**
  46569. * Import meshes into a scene
  46570. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46571. * @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)
  46572. * @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)
  46573. * @param scene the instance of BABYLON.Scene to append to
  46574. * @param onProgress a callback with a progress event for each file being loaded
  46575. * @param pluginExtension the extension used to determine the plugin
  46576. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46577. */
  46578. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46579. meshes: AbstractMesh[];
  46580. particleSystems: IParticleSystem[];
  46581. skeletons: Skeleton[];
  46582. animationGroups: AnimationGroup[];
  46583. }>;
  46584. /**
  46585. * Load a scene
  46586. * @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)
  46587. * @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)
  46588. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46589. * @param onSuccess a callback with the scene when import succeeds
  46590. * @param onProgress a callback with a progress event for each file being loaded
  46591. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46592. * @param pluginExtension the extension used to determine the plugin
  46593. * @returns The loaded plugin
  46594. */
  46595. 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>;
  46596. /**
  46597. * Load a scene
  46598. * @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)
  46599. * @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)
  46600. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46601. * @param onProgress a callback with a progress event for each file being loaded
  46602. * @param pluginExtension the extension used to determine the plugin
  46603. * @returns The loaded scene
  46604. */
  46605. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46606. /**
  46607. * Append a scene
  46608. * @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)
  46609. * @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)
  46610. * @param scene is the instance of BABYLON.Scene to append to
  46611. * @param onSuccess a callback with the scene when import succeeds
  46612. * @param onProgress a callback with a progress event for each file being loaded
  46613. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46614. * @param pluginExtension the extension used to determine the plugin
  46615. * @returns The loaded plugin
  46616. */
  46617. 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>;
  46618. /**
  46619. * Append a scene
  46620. * @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)
  46621. * @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)
  46622. * @param scene is the instance of BABYLON.Scene to append to
  46623. * @param onProgress a callback with a progress event for each file being loaded
  46624. * @param pluginExtension the extension used to determine the plugin
  46625. * @returns The given scene
  46626. */
  46627. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46628. /**
  46629. * Load a scene into an asset container
  46630. * @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)
  46631. * @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)
  46632. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46633. * @param onSuccess a callback with the scene when import succeeds
  46634. * @param onProgress a callback with a progress event for each file being loaded
  46635. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46636. * @param pluginExtension the extension used to determine the plugin
  46637. * @returns The loaded plugin
  46638. */
  46639. 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>;
  46640. /**
  46641. * Load a scene into an asset container
  46642. * @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)
  46643. * @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)
  46644. * @param scene is the instance of Scene to append to
  46645. * @param onProgress a callback with a progress event for each file being loaded
  46646. * @param pluginExtension the extension used to determine the plugin
  46647. * @returns The loaded asset container
  46648. */
  46649. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46650. /**
  46651. * Import animations from a file into a scene
  46652. * @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)
  46653. * @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)
  46654. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46655. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46656. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46657. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46658. * @param onSuccess a callback with the scene when import succeeds
  46659. * @param onProgress a callback with a progress event for each file being loaded
  46660. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46661. */
  46662. 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;
  46663. /**
  46664. * Import animations from a file into a scene
  46665. * @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)
  46666. * @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)
  46667. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46668. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46669. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46670. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46671. * @param onSuccess a callback with the scene when import succeeds
  46672. * @param onProgress a callback with a progress event for each file being loaded
  46673. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46674. * @returns the updated scene with imported animations
  46675. */
  46676. 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>;
  46677. }
  46678. }
  46679. declare module BABYLON {
  46680. /**
  46681. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46682. */
  46683. export type MotionControllerHandedness = "none" | "left" | "right";
  46684. /**
  46685. * The type of components available in motion controllers.
  46686. * This is not the name of the component.
  46687. */
  46688. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46689. /**
  46690. * The state of a controller component
  46691. */
  46692. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46693. /**
  46694. * The schema of motion controller layout.
  46695. * No object will be initialized using this interface
  46696. * This is used just to define the profile.
  46697. */
  46698. export interface IMotionControllerLayout {
  46699. /**
  46700. * Path to load the assets. Usually relative to the base path
  46701. */
  46702. assetPath: string;
  46703. /**
  46704. * Available components (unsorted)
  46705. */
  46706. components: {
  46707. /**
  46708. * A map of component Ids
  46709. */
  46710. [componentId: string]: {
  46711. /**
  46712. * The type of input the component outputs
  46713. */
  46714. type: MotionControllerComponentType;
  46715. /**
  46716. * The indices of this component in the gamepad object
  46717. */
  46718. gamepadIndices: {
  46719. /**
  46720. * Index of button
  46721. */
  46722. button?: number;
  46723. /**
  46724. * If available, index of x-axis
  46725. */
  46726. xAxis?: number;
  46727. /**
  46728. * If available, index of y-axis
  46729. */
  46730. yAxis?: number;
  46731. };
  46732. /**
  46733. * The mesh's root node name
  46734. */
  46735. rootNodeName: string;
  46736. /**
  46737. * Animation definitions for this model
  46738. */
  46739. visualResponses: {
  46740. [stateKey: string]: {
  46741. /**
  46742. * What property will be animated
  46743. */
  46744. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46745. /**
  46746. * What states influence this visual response
  46747. */
  46748. states: MotionControllerComponentStateType[];
  46749. /**
  46750. * Type of animation - movement or visibility
  46751. */
  46752. valueNodeProperty: "transform" | "visibility";
  46753. /**
  46754. * Base node name to move. Its position will be calculated according to the min and max nodes
  46755. */
  46756. valueNodeName?: string;
  46757. /**
  46758. * Minimum movement node
  46759. */
  46760. minNodeName?: string;
  46761. /**
  46762. * Max movement node
  46763. */
  46764. maxNodeName?: string;
  46765. };
  46766. };
  46767. /**
  46768. * If touch enabled, what is the name of node to display user feedback
  46769. */
  46770. touchPointNodeName?: string;
  46771. };
  46772. };
  46773. /**
  46774. * Is it xr standard mapping or not
  46775. */
  46776. gamepadMapping: "" | "xr-standard";
  46777. /**
  46778. * Base root node of this entire model
  46779. */
  46780. rootNodeName: string;
  46781. /**
  46782. * Defines the main button component id
  46783. */
  46784. selectComponentId: string;
  46785. }
  46786. /**
  46787. * A definition for the layout map in the input profile
  46788. */
  46789. export interface IMotionControllerLayoutMap {
  46790. /**
  46791. * Layouts with handedness type as a key
  46792. */
  46793. [handedness: string]: IMotionControllerLayout;
  46794. }
  46795. /**
  46796. * The XR Input profile schema
  46797. * Profiles can be found here:
  46798. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  46799. */
  46800. export interface IMotionControllerProfile {
  46801. /**
  46802. * fallback profiles for this profileId
  46803. */
  46804. fallbackProfileIds: string[];
  46805. /**
  46806. * The layout map, with handedness as key
  46807. */
  46808. layouts: IMotionControllerLayoutMap;
  46809. /**
  46810. * The id of this profile
  46811. * correlates to the profile(s) in the xrInput.profiles array
  46812. */
  46813. profileId: string;
  46814. }
  46815. /**
  46816. * A helper-interface for the 3 meshes needed for controller button animation
  46817. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  46818. */
  46819. export interface IMotionControllerButtonMeshMap {
  46820. /**
  46821. * the mesh that defines the pressed value mesh position.
  46822. * This is used to find the max-position of this button
  46823. */
  46824. pressedMesh: AbstractMesh;
  46825. /**
  46826. * the mesh that defines the unpressed value mesh position.
  46827. * This is used to find the min (or initial) position of this button
  46828. */
  46829. unpressedMesh: AbstractMesh;
  46830. /**
  46831. * The mesh that will be changed when value changes
  46832. */
  46833. valueMesh: AbstractMesh;
  46834. }
  46835. /**
  46836. * A helper-interface for the 3 meshes needed for controller axis animation.
  46837. * This will be expanded when touchpad animations are fully supported
  46838. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  46839. */
  46840. export interface IMotionControllerMeshMap {
  46841. /**
  46842. * the mesh that defines the maximum value mesh position.
  46843. */
  46844. maxMesh?: AbstractMesh;
  46845. /**
  46846. * the mesh that defines the minimum value mesh position.
  46847. */
  46848. minMesh?: AbstractMesh;
  46849. /**
  46850. * The mesh that will be changed when axis value changes
  46851. */
  46852. valueMesh: AbstractMesh;
  46853. }
  46854. /**
  46855. * The elements needed for change-detection of the gamepad objects in motion controllers
  46856. */
  46857. export interface IMinimalMotionControllerObject {
  46858. /**
  46859. * Available axes of this controller
  46860. */
  46861. axes: number[];
  46862. /**
  46863. * An array of available buttons
  46864. */
  46865. buttons: Array<{
  46866. /**
  46867. * Value of the button/trigger
  46868. */
  46869. value: number;
  46870. /**
  46871. * If the button/trigger is currently touched
  46872. */
  46873. touched: boolean;
  46874. /**
  46875. * If the button/trigger is currently pressed
  46876. */
  46877. pressed: boolean;
  46878. }>;
  46879. /**
  46880. * EXPERIMENTAL haptic support.
  46881. */
  46882. hapticActuators?: Array<{
  46883. pulse: (value: number, duration: number) => Promise<boolean>;
  46884. }>;
  46885. }
  46886. /**
  46887. * An Abstract Motion controller
  46888. * This class receives an xrInput and a profile layout and uses those to initialize the components
  46889. * Each component has an observable to check for changes in value and state
  46890. */
  46891. export abstract class WebXRAbstractMotionController implements IDisposable {
  46892. protected scene: Scene;
  46893. protected layout: IMotionControllerLayout;
  46894. /**
  46895. * The gamepad object correlating to this controller
  46896. */
  46897. gamepadObject: IMinimalMotionControllerObject;
  46898. /**
  46899. * handedness (left/right/none) of this controller
  46900. */
  46901. handedness: MotionControllerHandedness;
  46902. private _initComponent;
  46903. private _modelReady;
  46904. /**
  46905. * A map of components (WebXRControllerComponent) in this motion controller
  46906. * Components have a ComponentType and can also have both button and axis definitions
  46907. */
  46908. readonly components: {
  46909. [id: string]: WebXRControllerComponent;
  46910. };
  46911. /**
  46912. * Disable the model's animation. Can be set at any time.
  46913. */
  46914. disableAnimation: boolean;
  46915. /**
  46916. * Observers registered here will be triggered when the model of this controller is done loading
  46917. */
  46918. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  46919. /**
  46920. * The profile id of this motion controller
  46921. */
  46922. abstract profileId: string;
  46923. /**
  46924. * The root mesh of the model. It is null if the model was not yet initialized
  46925. */
  46926. rootMesh: Nullable<AbstractMesh>;
  46927. /**
  46928. * constructs a new abstract motion controller
  46929. * @param scene the scene to which the model of the controller will be added
  46930. * @param layout The profile layout to load
  46931. * @param gamepadObject The gamepad object correlating to this controller
  46932. * @param handedness handedness (left/right/none) of this controller
  46933. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  46934. */
  46935. constructor(scene: Scene, layout: IMotionControllerLayout,
  46936. /**
  46937. * The gamepad object correlating to this controller
  46938. */
  46939. gamepadObject: IMinimalMotionControllerObject,
  46940. /**
  46941. * handedness (left/right/none) of this controller
  46942. */
  46943. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  46944. /**
  46945. * Dispose this controller, the model mesh and all its components
  46946. */
  46947. dispose(): void;
  46948. /**
  46949. * Returns all components of specific type
  46950. * @param type the type to search for
  46951. * @return an array of components with this type
  46952. */
  46953. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  46954. /**
  46955. * get a component based an its component id as defined in layout.components
  46956. * @param id the id of the component
  46957. * @returns the component correlates to the id or undefined if not found
  46958. */
  46959. getComponent(id: string): WebXRControllerComponent;
  46960. /**
  46961. * Get the list of components available in this motion controller
  46962. * @returns an array of strings correlating to available components
  46963. */
  46964. getComponentIds(): string[];
  46965. /**
  46966. * Get the first component of specific type
  46967. * @param type type of component to find
  46968. * @return a controller component or null if not found
  46969. */
  46970. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  46971. /**
  46972. * Get the main (Select) component of this controller as defined in the layout
  46973. * @returns the main component of this controller
  46974. */
  46975. getMainComponent(): WebXRControllerComponent;
  46976. /**
  46977. * Loads the model correlating to this controller
  46978. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  46979. * @returns A promise fulfilled with the result of the model loading
  46980. */
  46981. loadModel(): Promise<boolean>;
  46982. /**
  46983. * Update this model using the current XRFrame
  46984. * @param xrFrame the current xr frame to use and update the model
  46985. */
  46986. updateFromXRFrame(xrFrame: XRFrame): void;
  46987. /**
  46988. * Backwards compatibility due to a deeply-integrated typo
  46989. */
  46990. get handness(): XREye;
  46991. /**
  46992. * Pulse (vibrate) this controller
  46993. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  46994. * Consecutive calls to this function will cancel the last pulse call
  46995. *
  46996. * @param value the strength of the pulse in 0.0...1.0 range
  46997. * @param duration Duration of the pulse in milliseconds
  46998. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  46999. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  47000. */
  47001. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47002. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47003. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47004. /**
  47005. * Moves the axis on the controller mesh based on its current state
  47006. * @param axis the index of the axis
  47007. * @param axisValue the value of the axis which determines the meshes new position
  47008. * @hidden
  47009. */
  47010. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47011. /**
  47012. * Update the model itself with the current frame data
  47013. * @param xrFrame the frame to use for updating the model mesh
  47014. */
  47015. protected updateModel(xrFrame: XRFrame): void;
  47016. /**
  47017. * Get the filename and path for this controller's model
  47018. * @returns a map of filename and path
  47019. */
  47020. protected abstract _getFilenameAndPath(): {
  47021. filename: string;
  47022. path: string;
  47023. };
  47024. /**
  47025. * This function is called before the mesh is loaded. It checks for loading constraints.
  47026. * For example, this function can check if the GLB loader is available
  47027. * If this function returns false, the generic controller will be loaded instead
  47028. * @returns Is the client ready to load the mesh
  47029. */
  47030. protected abstract _getModelLoadingConstraints(): boolean;
  47031. /**
  47032. * This function will be called after the model was successfully loaded and can be used
  47033. * for mesh transformations before it is available for the user
  47034. * @param meshes the loaded meshes
  47035. */
  47036. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47037. /**
  47038. * Set the root mesh for this controller. Important for the WebXR controller class
  47039. * @param meshes the loaded meshes
  47040. */
  47041. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47042. /**
  47043. * A function executed each frame that updates the mesh (if needed)
  47044. * @param xrFrame the current xrFrame
  47045. */
  47046. protected abstract _updateModel(xrFrame: XRFrame): void;
  47047. private _getGenericFilenameAndPath;
  47048. private _getGenericParentMesh;
  47049. }
  47050. }
  47051. declare module BABYLON {
  47052. /**
  47053. * A generic trigger-only motion controller for WebXR
  47054. */
  47055. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47056. /**
  47057. * Static version of the profile id of this controller
  47058. */
  47059. static ProfileId: string;
  47060. profileId: string;
  47061. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47062. protected _getFilenameAndPath(): {
  47063. filename: string;
  47064. path: string;
  47065. };
  47066. protected _getModelLoadingConstraints(): boolean;
  47067. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47068. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47069. protected _updateModel(): void;
  47070. }
  47071. }
  47072. declare module BABYLON {
  47073. /**
  47074. * Class containing static functions to help procedurally build meshes
  47075. */
  47076. export class SphereBuilder {
  47077. /**
  47078. * Creates a sphere mesh
  47079. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47080. * * 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`)
  47081. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47082. * * 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
  47083. * * 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)
  47084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47085. * * 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
  47086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47087. * @param name defines the name of the mesh
  47088. * @param options defines the options used to create the mesh
  47089. * @param scene defines the hosting scene
  47090. * @returns the sphere mesh
  47091. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47092. */
  47093. static CreateSphere(name: string, options: {
  47094. segments?: number;
  47095. diameter?: number;
  47096. diameterX?: number;
  47097. diameterY?: number;
  47098. diameterZ?: number;
  47099. arc?: number;
  47100. slice?: number;
  47101. sideOrientation?: number;
  47102. frontUVs?: Vector4;
  47103. backUVs?: Vector4;
  47104. updatable?: boolean;
  47105. }, scene?: Nullable<Scene>): Mesh;
  47106. }
  47107. }
  47108. declare module BABYLON {
  47109. /**
  47110. * A profiled motion controller has its profile loaded from an online repository.
  47111. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47112. */
  47113. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47114. private _repositoryUrl;
  47115. private _buttonMeshMapping;
  47116. private _touchDots;
  47117. /**
  47118. * The profile ID of this controller. Will be populated when the controller initializes.
  47119. */
  47120. profileId: string;
  47121. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47122. dispose(): void;
  47123. protected _getFilenameAndPath(): {
  47124. filename: string;
  47125. path: string;
  47126. };
  47127. protected _getModelLoadingConstraints(): boolean;
  47128. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47129. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47130. protected _updateModel(_xrFrame: XRFrame): void;
  47131. }
  47132. }
  47133. declare module BABYLON {
  47134. /**
  47135. * A construction function type to create a new controller based on an xrInput object
  47136. */
  47137. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47138. /**
  47139. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47140. *
  47141. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47142. * it should be replaced with auto-loaded controllers.
  47143. *
  47144. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47145. */
  47146. export class WebXRMotionControllerManager {
  47147. private static _AvailableControllers;
  47148. private static _Fallbacks;
  47149. private static _ProfileLoadingPromises;
  47150. private static _ProfilesList;
  47151. /**
  47152. * The base URL of the online controller repository. Can be changed at any time.
  47153. */
  47154. static BaseRepositoryUrl: string;
  47155. /**
  47156. * Which repository gets priority - local or online
  47157. */
  47158. static PrioritizeOnlineRepository: boolean;
  47159. /**
  47160. * Use the online repository, or use only locally-defined controllers
  47161. */
  47162. static UseOnlineRepository: boolean;
  47163. /**
  47164. * Clear the cache used for profile loading and reload when requested again
  47165. */
  47166. static ClearProfilesCache(): void;
  47167. /**
  47168. * Register the default fallbacks.
  47169. * This function is called automatically when this file is imported.
  47170. */
  47171. static DefaultFallbacks(): void;
  47172. /**
  47173. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47174. * @param profileId the profile to which a fallback needs to be found
  47175. * @return an array with corresponding fallback profiles
  47176. */
  47177. static FindFallbackWithProfileId(profileId: string): string[];
  47178. /**
  47179. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47180. * The order of search:
  47181. *
  47182. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47183. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47184. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47185. * 4) return the generic trigger controller if none were found
  47186. *
  47187. * @param xrInput the xrInput to which a new controller is initialized
  47188. * @param scene the scene to which the model will be added
  47189. * @param forceProfile force a certain profile for this controller
  47190. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47191. */
  47192. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47193. /**
  47194. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47195. *
  47196. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47197. *
  47198. * @param type the profile type to register
  47199. * @param constructFunction the function to be called when loading this profile
  47200. */
  47201. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47202. /**
  47203. * Register a fallback to a specific profile.
  47204. * @param profileId the profileId that will receive the fallbacks
  47205. * @param fallbacks A list of fallback profiles
  47206. */
  47207. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47208. /**
  47209. * Will update the list of profiles available in the repository
  47210. * @return a promise that resolves to a map of profiles available online
  47211. */
  47212. static UpdateProfilesList(): Promise<{
  47213. [profile: string]: string;
  47214. }>;
  47215. private static _LoadProfileFromRepository;
  47216. private static _LoadProfilesFromAvailableControllers;
  47217. }
  47218. }
  47219. declare module BABYLON {
  47220. /**
  47221. * Configuration options for the WebXR controller creation
  47222. */
  47223. export interface IWebXRControllerOptions {
  47224. /**
  47225. * Should the controller mesh be animated when a user interacts with it
  47226. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47227. */
  47228. disableMotionControllerAnimation?: boolean;
  47229. /**
  47230. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47231. */
  47232. doNotLoadControllerMesh?: boolean;
  47233. /**
  47234. * Force a specific controller type for this controller.
  47235. * This can be used when creating your own profile or when testing different controllers
  47236. */
  47237. forceControllerProfile?: string;
  47238. /**
  47239. * Defines a rendering group ID for meshes that will be loaded.
  47240. * This is for the default controllers only.
  47241. */
  47242. renderingGroupId?: number;
  47243. }
  47244. /**
  47245. * Represents an XR controller
  47246. */
  47247. export class WebXRInputSource {
  47248. private _scene;
  47249. /** The underlying input source for the controller */
  47250. inputSource: XRInputSource;
  47251. private _options;
  47252. private _tmpVector;
  47253. private _uniqueId;
  47254. /**
  47255. * 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
  47256. */
  47257. grip?: AbstractMesh;
  47258. /**
  47259. * If available, this is the gamepad object related to this controller.
  47260. * Using this object it is possible to get click events and trackpad changes of the
  47261. * webxr controller that is currently being used.
  47262. */
  47263. motionController?: WebXRAbstractMotionController;
  47264. /**
  47265. * Event that fires when the controller is removed/disposed.
  47266. * The object provided as event data is this controller, after associated assets were disposed.
  47267. * uniqueId is still available.
  47268. */
  47269. onDisposeObservable: Observable<WebXRInputSource>;
  47270. /**
  47271. * Will be triggered when the mesh associated with the motion controller is done loading.
  47272. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47273. * A shortened version of controller -> motion controller -> on mesh loaded.
  47274. */
  47275. onMeshLoadedObservable: Observable<AbstractMesh>;
  47276. /**
  47277. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47278. */
  47279. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47280. /**
  47281. * Pointer which can be used to select objects or attach a visible laser to
  47282. */
  47283. pointer: AbstractMesh;
  47284. /**
  47285. * Creates the controller
  47286. * @see https://doc.babylonjs.com/how_to/webxr
  47287. * @param _scene the scene which the controller should be associated to
  47288. * @param inputSource the underlying input source for the controller
  47289. * @param _options options for this controller creation
  47290. */
  47291. constructor(_scene: Scene,
  47292. /** The underlying input source for the controller */
  47293. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47294. /**
  47295. * Get this controllers unique id
  47296. */
  47297. get uniqueId(): string;
  47298. /**
  47299. * Disposes of the object
  47300. */
  47301. dispose(): void;
  47302. /**
  47303. * Gets a world space ray coming from the pointer or grip
  47304. * @param result the resulting ray
  47305. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47306. */
  47307. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47308. /**
  47309. * Updates the controller pose based on the given XRFrame
  47310. * @param xrFrame xr frame to update the pose with
  47311. * @param referenceSpace reference space to use
  47312. */
  47313. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47314. }
  47315. }
  47316. declare module BABYLON {
  47317. /**
  47318. * The schema for initialization options of the XR Input class
  47319. */
  47320. export interface IWebXRInputOptions {
  47321. /**
  47322. * If set to true no model will be automatically loaded
  47323. */
  47324. doNotLoadControllerMeshes?: boolean;
  47325. /**
  47326. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47327. * If not found, the xr input profile data will be used.
  47328. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47329. */
  47330. forceInputProfile?: string;
  47331. /**
  47332. * Do not send a request to the controller repository to load the profile.
  47333. *
  47334. * Instead, use the controllers available in babylon itself.
  47335. */
  47336. disableOnlineControllerRepository?: boolean;
  47337. /**
  47338. * A custom URL for the controllers repository
  47339. */
  47340. customControllersRepositoryURL?: string;
  47341. /**
  47342. * Should the controller model's components not move according to the user input
  47343. */
  47344. disableControllerAnimation?: boolean;
  47345. /**
  47346. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47347. */
  47348. controllerOptions?: IWebXRControllerOptions;
  47349. }
  47350. /**
  47351. * XR input used to track XR inputs such as controllers/rays
  47352. */
  47353. export class WebXRInput implements IDisposable {
  47354. /**
  47355. * the xr session manager for this session
  47356. */
  47357. xrSessionManager: WebXRSessionManager;
  47358. /**
  47359. * the WebXR camera for this session. Mainly used for teleportation
  47360. */
  47361. xrCamera: WebXRCamera;
  47362. private readonly options;
  47363. /**
  47364. * XR controllers being tracked
  47365. */
  47366. controllers: Array<WebXRInputSource>;
  47367. private _frameObserver;
  47368. private _sessionEndedObserver;
  47369. private _sessionInitObserver;
  47370. /**
  47371. * Event when a controller has been connected/added
  47372. */
  47373. onControllerAddedObservable: Observable<WebXRInputSource>;
  47374. /**
  47375. * Event when a controller has been removed/disconnected
  47376. */
  47377. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47378. /**
  47379. * Initializes the WebXRInput
  47380. * @param xrSessionManager the xr session manager for this session
  47381. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47382. * @param options = initialization options for this xr input
  47383. */
  47384. constructor(
  47385. /**
  47386. * the xr session manager for this session
  47387. */
  47388. xrSessionManager: WebXRSessionManager,
  47389. /**
  47390. * the WebXR camera for this session. Mainly used for teleportation
  47391. */
  47392. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47393. private _onInputSourcesChange;
  47394. private _addAndRemoveControllers;
  47395. /**
  47396. * Disposes of the object
  47397. */
  47398. dispose(): void;
  47399. }
  47400. }
  47401. declare module BABYLON {
  47402. /**
  47403. * This is the base class for all WebXR features.
  47404. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47405. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47406. */
  47407. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47408. protected _xrSessionManager: WebXRSessionManager;
  47409. private _attached;
  47410. private _removeOnDetach;
  47411. /**
  47412. * Should auto-attach be disabled?
  47413. */
  47414. disableAutoAttach: boolean;
  47415. /**
  47416. * Construct a new (abstract) WebXR feature
  47417. * @param _xrSessionManager the xr session manager for this feature
  47418. */
  47419. constructor(_xrSessionManager: WebXRSessionManager);
  47420. /**
  47421. * Is this feature attached
  47422. */
  47423. get attached(): boolean;
  47424. /**
  47425. * attach this feature
  47426. *
  47427. * @param force should attachment be forced (even when already attached)
  47428. * @returns true if successful, false is failed or already attached
  47429. */
  47430. attach(force?: boolean): boolean;
  47431. /**
  47432. * detach this feature.
  47433. *
  47434. * @returns true if successful, false if failed or already detached
  47435. */
  47436. detach(): boolean;
  47437. /**
  47438. * Dispose this feature and all of the resources attached
  47439. */
  47440. dispose(): void;
  47441. /**
  47442. * This is used to register callbacks that will automatically be removed when detach is called.
  47443. * @param observable the observable to which the observer will be attached
  47444. * @param callback the callback to register
  47445. */
  47446. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47447. /**
  47448. * Code in this function will be executed on each xrFrame received from the browser.
  47449. * This function will not execute after the feature is detached.
  47450. * @param _xrFrame the current frame
  47451. */
  47452. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47453. }
  47454. }
  47455. declare module BABYLON {
  47456. /**
  47457. * Renders a layer on top of an existing scene
  47458. */
  47459. export class UtilityLayerRenderer implements IDisposable {
  47460. /** the original scene that will be rendered on top of */
  47461. originalScene: Scene;
  47462. private _pointerCaptures;
  47463. private _lastPointerEvents;
  47464. private static _DefaultUtilityLayer;
  47465. private static _DefaultKeepDepthUtilityLayer;
  47466. private _sharedGizmoLight;
  47467. private _renderCamera;
  47468. /**
  47469. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47470. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47471. * @returns the camera that is used when rendering the utility layer
  47472. */
  47473. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47474. /**
  47475. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47476. * @param cam the camera that should be used when rendering the utility layer
  47477. */
  47478. setRenderCamera(cam: Nullable<Camera>): void;
  47479. /**
  47480. * @hidden
  47481. * Light which used by gizmos to get light shading
  47482. */
  47483. _getSharedGizmoLight(): HemisphericLight;
  47484. /**
  47485. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47486. */
  47487. pickUtilitySceneFirst: boolean;
  47488. /**
  47489. * 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)
  47490. */
  47491. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47492. /**
  47493. * 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)
  47494. */
  47495. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47496. /**
  47497. * The scene that is rendered on top of the original scene
  47498. */
  47499. utilityLayerScene: Scene;
  47500. /**
  47501. * If the utility layer should automatically be rendered on top of existing scene
  47502. */
  47503. shouldRender: boolean;
  47504. /**
  47505. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47506. */
  47507. onlyCheckPointerDownEvents: boolean;
  47508. /**
  47509. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47510. */
  47511. processAllEvents: boolean;
  47512. /**
  47513. * Observable raised when the pointer move from the utility layer scene to the main scene
  47514. */
  47515. onPointerOutObservable: Observable<number>;
  47516. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47517. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47518. private _afterRenderObserver;
  47519. private _sceneDisposeObserver;
  47520. private _originalPointerObserver;
  47521. /**
  47522. * Instantiates a UtilityLayerRenderer
  47523. * @param originalScene the original scene that will be rendered on top of
  47524. * @param handleEvents boolean indicating if the utility layer should handle events
  47525. */
  47526. constructor(
  47527. /** the original scene that will be rendered on top of */
  47528. originalScene: Scene, handleEvents?: boolean);
  47529. private _notifyObservers;
  47530. /**
  47531. * Renders the utility layers scene on top of the original scene
  47532. */
  47533. render(): void;
  47534. /**
  47535. * Disposes of the renderer
  47536. */
  47537. dispose(): void;
  47538. private _updateCamera;
  47539. }
  47540. }
  47541. declare module BABYLON {
  47542. /**
  47543. * Options interface for the pointer selection module
  47544. */
  47545. export interface IWebXRControllerPointerSelectionOptions {
  47546. /**
  47547. * if provided, this scene will be used to render meshes.
  47548. */
  47549. customUtilityLayerScene?: Scene;
  47550. /**
  47551. * 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)
  47552. * If not disabled, the last picked point will be used to execute a pointer up event
  47553. * If disabled, pointer up event will be triggered right after the pointer down event.
  47554. * Used in screen and gaze target ray mode only
  47555. */
  47556. disablePointerUpOnTouchOut: boolean;
  47557. /**
  47558. * For gaze mode (time to select instead of press)
  47559. */
  47560. forceGazeMode: boolean;
  47561. /**
  47562. * 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
  47563. * to start a new countdown to the pointer down event.
  47564. * Defaults to 1.
  47565. */
  47566. gazeModePointerMovedFactor?: number;
  47567. /**
  47568. * Different button type to use instead of the main component
  47569. */
  47570. overrideButtonId?: string;
  47571. /**
  47572. * use this rendering group id for the meshes (optional)
  47573. */
  47574. renderingGroupId?: number;
  47575. /**
  47576. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47577. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47578. * 3000 means 3 seconds between pointing at something and selecting it
  47579. */
  47580. timeToSelect?: number;
  47581. /**
  47582. * Should meshes created here be added to a utility layer or the main scene
  47583. */
  47584. useUtilityLayer?: boolean;
  47585. /**
  47586. * the xr input to use with this pointer selection
  47587. */
  47588. xrInput: WebXRInput;
  47589. }
  47590. /**
  47591. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47592. */
  47593. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47594. private readonly _options;
  47595. private static _idCounter;
  47596. private _attachController;
  47597. private _controllers;
  47598. private _scene;
  47599. private _tmpVectorForPickCompare;
  47600. /**
  47601. * The module's name
  47602. */
  47603. static readonly Name: string;
  47604. /**
  47605. * The (Babylon) version of this module.
  47606. * This is an integer representing the implementation version.
  47607. * This number does not correspond to the WebXR specs version
  47608. */
  47609. static readonly Version: number;
  47610. /**
  47611. * Disable lighting on the laser pointer (so it will always be visible)
  47612. */
  47613. disablePointerLighting: boolean;
  47614. /**
  47615. * Disable lighting on the selection mesh (so it will always be visible)
  47616. */
  47617. disableSelectionMeshLighting: boolean;
  47618. /**
  47619. * Should the laser pointer be displayed
  47620. */
  47621. displayLaserPointer: boolean;
  47622. /**
  47623. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47624. */
  47625. displaySelectionMesh: boolean;
  47626. /**
  47627. * This color will be set to the laser pointer when selection is triggered
  47628. */
  47629. laserPointerPickedColor: Color3;
  47630. /**
  47631. * Default color of the laser pointer
  47632. */
  47633. lasterPointerDefaultColor: Color3;
  47634. /**
  47635. * default color of the selection ring
  47636. */
  47637. selectionMeshDefaultColor: Color3;
  47638. /**
  47639. * This color will be applied to the selection ring when selection is triggered
  47640. */
  47641. selectionMeshPickedColor: Color3;
  47642. /**
  47643. * Optional filter to be used for ray selection. This predicate shares behavior with
  47644. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47645. */
  47646. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47647. /**
  47648. * constructs a new background remover module
  47649. * @param _xrSessionManager the session manager for this module
  47650. * @param _options read-only options to be used in this module
  47651. */
  47652. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47653. /**
  47654. * attach this feature
  47655. * Will usually be called by the features manager
  47656. *
  47657. * @returns true if successful.
  47658. */
  47659. attach(): boolean;
  47660. /**
  47661. * detach this feature.
  47662. * Will usually be called by the features manager
  47663. *
  47664. * @returns true if successful.
  47665. */
  47666. detach(): boolean;
  47667. /**
  47668. * Will get the mesh under a specific pointer.
  47669. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47670. * @param controllerId the controllerId to check
  47671. * @returns The mesh under pointer or null if no mesh is under the pointer
  47672. */
  47673. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47674. /**
  47675. * Get the xr controller that correlates to the pointer id in the pointer event
  47676. *
  47677. * @param id the pointer id to search for
  47678. * @returns the controller that correlates to this id or null if not found
  47679. */
  47680. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47681. protected _onXRFrame(_xrFrame: XRFrame): void;
  47682. private _attachGazeMode;
  47683. private _attachScreenRayMode;
  47684. private _attachTrackedPointerRayMode;
  47685. private _convertNormalToDirectionOfRay;
  47686. private _detachController;
  47687. private _generateNewMeshPair;
  47688. private _pickingMoved;
  47689. private _updatePointerDistance;
  47690. }
  47691. }
  47692. declare module BABYLON {
  47693. /**
  47694. * Button which can be used to enter a different mode of XR
  47695. */
  47696. export class WebXREnterExitUIButton {
  47697. /** button element */
  47698. element: HTMLElement;
  47699. /** XR initialization options for the button */
  47700. sessionMode: XRSessionMode;
  47701. /** Reference space type */
  47702. referenceSpaceType: XRReferenceSpaceType;
  47703. /**
  47704. * Creates a WebXREnterExitUIButton
  47705. * @param element button element
  47706. * @param sessionMode XR initialization session mode
  47707. * @param referenceSpaceType the type of reference space to be used
  47708. */
  47709. constructor(
  47710. /** button element */
  47711. element: HTMLElement,
  47712. /** XR initialization options for the button */
  47713. sessionMode: XRSessionMode,
  47714. /** Reference space type */
  47715. referenceSpaceType: XRReferenceSpaceType);
  47716. /**
  47717. * Extendable function which can be used to update the button's visuals when the state changes
  47718. * @param activeButton the current active button in the UI
  47719. */
  47720. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47721. }
  47722. /**
  47723. * Options to create the webXR UI
  47724. */
  47725. export class WebXREnterExitUIOptions {
  47726. /**
  47727. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47728. */
  47729. customButtons?: Array<WebXREnterExitUIButton>;
  47730. /**
  47731. * A reference space type to use when creating the default button.
  47732. * Default is local-floor
  47733. */
  47734. referenceSpaceType?: XRReferenceSpaceType;
  47735. /**
  47736. * Context to enter xr with
  47737. */
  47738. renderTarget?: Nullable<WebXRRenderTarget>;
  47739. /**
  47740. * A session mode to use when creating the default button.
  47741. * Default is immersive-vr
  47742. */
  47743. sessionMode?: XRSessionMode;
  47744. /**
  47745. * A list of optional features to init the session with
  47746. */
  47747. optionalFeatures?: string[];
  47748. }
  47749. /**
  47750. * UI to allow the user to enter/exit XR mode
  47751. */
  47752. export class WebXREnterExitUI implements IDisposable {
  47753. private scene;
  47754. /** version of the options passed to this UI */
  47755. options: WebXREnterExitUIOptions;
  47756. private _activeButton;
  47757. private _buttons;
  47758. private _overlay;
  47759. /**
  47760. * Fired every time the active button is changed.
  47761. *
  47762. * When xr is entered via a button that launches xr that button will be the callback parameter
  47763. *
  47764. * When exiting xr the callback parameter will be null)
  47765. */
  47766. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  47767. /**
  47768. *
  47769. * @param scene babylon scene object to use
  47770. * @param options (read-only) version of the options passed to this UI
  47771. */
  47772. private constructor();
  47773. /**
  47774. * Creates UI to allow the user to enter/exit XR mode
  47775. * @param scene the scene to add the ui to
  47776. * @param helper the xr experience helper to enter/exit xr with
  47777. * @param options options to configure the UI
  47778. * @returns the created ui
  47779. */
  47780. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  47781. /**
  47782. * Disposes of the XR UI component
  47783. */
  47784. dispose(): void;
  47785. private _updateButtons;
  47786. }
  47787. }
  47788. declare module BABYLON {
  47789. /**
  47790. * Class containing static functions to help procedurally build meshes
  47791. */
  47792. export class LinesBuilder {
  47793. /**
  47794. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47795. * * 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
  47796. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47797. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47798. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47799. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47800. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47801. * * 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
  47802. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47804. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47805. * @param name defines the name of the new line system
  47806. * @param options defines the options used to create the line system
  47807. * @param scene defines the hosting scene
  47808. * @returns a new line system mesh
  47809. */
  47810. static CreateLineSystem(name: string, options: {
  47811. lines: Vector3[][];
  47812. updatable?: boolean;
  47813. instance?: Nullable<LinesMesh>;
  47814. colors?: Nullable<Color4[][]>;
  47815. useVertexAlpha?: boolean;
  47816. }, scene: Nullable<Scene>): LinesMesh;
  47817. /**
  47818. * Creates a line mesh
  47819. * 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
  47820. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47821. * * The parameter `points` is an array successive Vector3
  47822. * * 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
  47823. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47824. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47825. * * When updating an instance, remember that only point positions can change, not the number of points
  47826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47827. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47828. * @param name defines the name of the new line system
  47829. * @param options defines the options used to create the line system
  47830. * @param scene defines the hosting scene
  47831. * @returns a new line mesh
  47832. */
  47833. static CreateLines(name: string, options: {
  47834. points: Vector3[];
  47835. updatable?: boolean;
  47836. instance?: Nullable<LinesMesh>;
  47837. colors?: Color4[];
  47838. useVertexAlpha?: boolean;
  47839. }, scene?: Nullable<Scene>): LinesMesh;
  47840. /**
  47841. * Creates a dashed line mesh
  47842. * * 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
  47843. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47844. * * The parameter `points` is an array successive Vector3
  47845. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47846. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47847. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47848. * * 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
  47849. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47850. * * When updating an instance, remember that only point positions can change, not the number of points
  47851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47852. * @param name defines the name of the mesh
  47853. * @param options defines the options used to create the mesh
  47854. * @param scene defines the hosting scene
  47855. * @returns the dashed line mesh
  47856. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47857. */
  47858. static CreateDashedLines(name: string, options: {
  47859. points: Vector3[];
  47860. dashSize?: number;
  47861. gapSize?: number;
  47862. dashNb?: number;
  47863. updatable?: boolean;
  47864. instance?: LinesMesh;
  47865. useVertexAlpha?: boolean;
  47866. }, scene?: Nullable<Scene>): LinesMesh;
  47867. }
  47868. }
  47869. declare module BABYLON {
  47870. /**
  47871. * The options container for the teleportation module
  47872. */
  47873. export interface IWebXRTeleportationOptions {
  47874. /**
  47875. * if provided, this scene will be used to render meshes.
  47876. */
  47877. customUtilityLayerScene?: Scene;
  47878. /**
  47879. * Values to configure the default target mesh
  47880. */
  47881. defaultTargetMeshOptions?: {
  47882. /**
  47883. * Fill color of the teleportation area
  47884. */
  47885. teleportationFillColor?: string;
  47886. /**
  47887. * Border color for the teleportation area
  47888. */
  47889. teleportationBorderColor?: string;
  47890. /**
  47891. * Disable the mesh's animation sequence
  47892. */
  47893. disableAnimation?: boolean;
  47894. /**
  47895. * Disable lighting on the material or the ring and arrow
  47896. */
  47897. disableLighting?: boolean;
  47898. /**
  47899. * Override the default material of the torus and arrow
  47900. */
  47901. torusArrowMaterial?: Material;
  47902. };
  47903. /**
  47904. * A list of meshes to use as floor meshes.
  47905. * Meshes can be added and removed after initializing the feature using the
  47906. * addFloorMesh and removeFloorMesh functions
  47907. * If empty, rotation will still work
  47908. */
  47909. floorMeshes?: AbstractMesh[];
  47910. /**
  47911. * use this rendering group id for the meshes (optional)
  47912. */
  47913. renderingGroupId?: number;
  47914. /**
  47915. * Should teleportation move only to snap points
  47916. */
  47917. snapPointsOnly?: boolean;
  47918. /**
  47919. * An array of points to which the teleportation will snap to.
  47920. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  47921. */
  47922. snapPositions?: Vector3[];
  47923. /**
  47924. * How close should the teleportation ray be in order to snap to position.
  47925. * Default to 0.8 units (meters)
  47926. */
  47927. snapToPositionRadius?: number;
  47928. /**
  47929. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  47930. * If you want to support rotation, make sure your mesh has a direction indicator.
  47931. *
  47932. * When left untouched, the default mesh will be initialized.
  47933. */
  47934. teleportationTargetMesh?: AbstractMesh;
  47935. /**
  47936. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  47937. */
  47938. timeToTeleport?: number;
  47939. /**
  47940. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  47941. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  47942. */
  47943. useMainComponentOnly?: boolean;
  47944. /**
  47945. * Should meshes created here be added to a utility layer or the main scene
  47946. */
  47947. useUtilityLayer?: boolean;
  47948. /**
  47949. * Babylon XR Input class for controller
  47950. */
  47951. xrInput: WebXRInput;
  47952. }
  47953. /**
  47954. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  47955. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  47956. * the input of the attached controllers.
  47957. */
  47958. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  47959. private _options;
  47960. private _controllers;
  47961. private _currentTeleportationControllerId;
  47962. private _floorMeshes;
  47963. private _quadraticBezierCurve;
  47964. private _selectionFeature;
  47965. private _snapToPositions;
  47966. private _snappedToPoint;
  47967. private _teleportationRingMaterial?;
  47968. private _tmpRay;
  47969. private _tmpVector;
  47970. /**
  47971. * The module's name
  47972. */
  47973. static readonly Name: string;
  47974. /**
  47975. * The (Babylon) version of this module.
  47976. * This is an integer representing the implementation version.
  47977. * This number does not correspond to the webxr specs version
  47978. */
  47979. static readonly Version: number;
  47980. /**
  47981. * Is movement backwards enabled
  47982. */
  47983. backwardsMovementEnabled: boolean;
  47984. /**
  47985. * Distance to travel when moving backwards
  47986. */
  47987. backwardsTeleportationDistance: number;
  47988. /**
  47989. * The distance from the user to the inspection point in the direction of the controller
  47990. * A higher number will allow the user to move further
  47991. * defaults to 5 (meters, in xr units)
  47992. */
  47993. parabolicCheckRadius: number;
  47994. /**
  47995. * Should the module support parabolic ray on top of direct ray
  47996. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  47997. * Very helpful when moving between floors / different heights
  47998. */
  47999. parabolicRayEnabled: boolean;
  48000. /**
  48001. * How much rotation should be applied when rotating right and left
  48002. */
  48003. rotationAngle: number;
  48004. /**
  48005. * Is rotation enabled when moving forward?
  48006. * Disabling this feature will prevent the user from deciding the direction when teleporting
  48007. */
  48008. rotationEnabled: boolean;
  48009. /**
  48010. * constructs a new anchor system
  48011. * @param _xrSessionManager an instance of WebXRSessionManager
  48012. * @param _options configuration object for this feature
  48013. */
  48014. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  48015. /**
  48016. * Get the snapPointsOnly flag
  48017. */
  48018. get snapPointsOnly(): boolean;
  48019. /**
  48020. * Sets the snapPointsOnly flag
  48021. * @param snapToPoints should teleportation be exclusively to snap points
  48022. */
  48023. set snapPointsOnly(snapToPoints: boolean);
  48024. /**
  48025. * Add a new mesh to the floor meshes array
  48026. * @param mesh the mesh to use as floor mesh
  48027. */
  48028. addFloorMesh(mesh: AbstractMesh): void;
  48029. /**
  48030. * Add a new snap-to point to fix teleportation to this position
  48031. * @param newSnapPoint The new Snap-To point
  48032. */
  48033. addSnapPoint(newSnapPoint: Vector3): void;
  48034. attach(): boolean;
  48035. detach(): boolean;
  48036. dispose(): void;
  48037. /**
  48038. * Remove a mesh from the floor meshes array
  48039. * @param mesh the mesh to remove
  48040. */
  48041. removeFloorMesh(mesh: AbstractMesh): void;
  48042. /**
  48043. * Remove a mesh from the floor meshes array using its name
  48044. * @param name the mesh name to remove
  48045. */
  48046. removeFloorMeshByName(name: string): void;
  48047. /**
  48048. * 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
  48049. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48050. * @returns was the point found and removed or not
  48051. */
  48052. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48053. /**
  48054. * This function sets a selection feature that will be disabled when
  48055. * the forward ray is shown and will be reattached when hidden.
  48056. * This is used to remove the selection rays when moving.
  48057. * @param selectionFeature the feature to disable when forward movement is enabled
  48058. */
  48059. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48060. protected _onXRFrame(_xrFrame: XRFrame): void;
  48061. private _attachController;
  48062. private _createDefaultTargetMesh;
  48063. private _detachController;
  48064. private _findClosestSnapPointWithRadius;
  48065. private _setTargetMeshPosition;
  48066. private _setTargetMeshVisibility;
  48067. private _showParabolicPath;
  48068. private _teleportForward;
  48069. }
  48070. }
  48071. declare module BABYLON {
  48072. /**
  48073. * Options for the default xr helper
  48074. */
  48075. export class WebXRDefaultExperienceOptions {
  48076. /**
  48077. * Enable or disable default UI to enter XR
  48078. */
  48079. disableDefaultUI?: boolean;
  48080. /**
  48081. * Should teleportation not initialize. defaults to false.
  48082. */
  48083. disableTeleportation?: boolean;
  48084. /**
  48085. * Floor meshes that will be used for teleport
  48086. */
  48087. floorMeshes?: Array<AbstractMesh>;
  48088. /**
  48089. * If set to true, the first frame will not be used to reset position
  48090. * The first frame is mainly used when copying transformation from the old camera
  48091. * Mainly used in AR
  48092. */
  48093. ignoreNativeCameraTransformation?: boolean;
  48094. /**
  48095. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48096. */
  48097. inputOptions?: IWebXRInputOptions;
  48098. /**
  48099. * optional configuration for the output canvas
  48100. */
  48101. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48102. /**
  48103. * optional UI options. This can be used among other to change session mode and reference space type
  48104. */
  48105. uiOptions?: WebXREnterExitUIOptions;
  48106. /**
  48107. * When loading teleportation and pointer select, use stable versions instead of latest.
  48108. */
  48109. useStablePlugins?: boolean;
  48110. /**
  48111. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48112. */
  48113. renderingGroupId?: number;
  48114. /**
  48115. * A list of optional features to init the session with
  48116. * If set to true, all features we support will be added
  48117. */
  48118. optionalFeatures?: boolean | string[];
  48119. }
  48120. /**
  48121. * Default experience which provides a similar setup to the previous webVRExperience
  48122. */
  48123. export class WebXRDefaultExperience {
  48124. /**
  48125. * Base experience
  48126. */
  48127. baseExperience: WebXRExperienceHelper;
  48128. /**
  48129. * Enables ui for entering/exiting xr
  48130. */
  48131. enterExitUI: WebXREnterExitUI;
  48132. /**
  48133. * Input experience extension
  48134. */
  48135. input: WebXRInput;
  48136. /**
  48137. * Enables laser pointer and selection
  48138. */
  48139. pointerSelection: WebXRControllerPointerSelection;
  48140. /**
  48141. * Default target xr should render to
  48142. */
  48143. renderTarget: WebXRRenderTarget;
  48144. /**
  48145. * Enables teleportation
  48146. */
  48147. teleportation: WebXRMotionControllerTeleportation;
  48148. private constructor();
  48149. /**
  48150. * Creates the default xr experience
  48151. * @param scene scene
  48152. * @param options options for basic configuration
  48153. * @returns resulting WebXRDefaultExperience
  48154. */
  48155. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48156. /**
  48157. * DIsposes of the experience helper
  48158. */
  48159. dispose(): void;
  48160. }
  48161. }
  48162. declare module BABYLON {
  48163. /**
  48164. * Options to modify the vr teleportation behavior.
  48165. */
  48166. export interface VRTeleportationOptions {
  48167. /**
  48168. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48169. */
  48170. floorMeshName?: string;
  48171. /**
  48172. * A list of meshes to be used as the teleportation floor. (default: empty)
  48173. */
  48174. floorMeshes?: Mesh[];
  48175. /**
  48176. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48177. */
  48178. teleportationMode?: number;
  48179. /**
  48180. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48181. */
  48182. teleportationTime?: number;
  48183. /**
  48184. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48185. */
  48186. teleportationSpeed?: number;
  48187. /**
  48188. * The easing function used in the animation or null for Linear. (default CircleEase)
  48189. */
  48190. easingFunction?: EasingFunction;
  48191. }
  48192. /**
  48193. * Options to modify the vr experience helper's behavior.
  48194. */
  48195. export interface VRExperienceHelperOptions extends WebVROptions {
  48196. /**
  48197. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48198. */
  48199. createDeviceOrientationCamera?: boolean;
  48200. /**
  48201. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48202. */
  48203. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48204. /**
  48205. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48206. */
  48207. laserToggle?: boolean;
  48208. /**
  48209. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48210. */
  48211. floorMeshes?: Mesh[];
  48212. /**
  48213. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48214. */
  48215. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48216. /**
  48217. * Defines if WebXR should be used instead of WebVR (if available)
  48218. */
  48219. useXR?: boolean;
  48220. }
  48221. /**
  48222. * Event containing information after VR has been entered
  48223. */
  48224. export class OnAfterEnteringVRObservableEvent {
  48225. /**
  48226. * If entering vr was successful
  48227. */
  48228. success: boolean;
  48229. }
  48230. /**
  48231. * Helps to quickly add VR support to an existing scene.
  48232. * See http://doc.babylonjs.com/how_to/webvr_helper
  48233. */
  48234. export class VRExperienceHelper {
  48235. /** Options to modify the vr experience helper's behavior. */
  48236. webVROptions: VRExperienceHelperOptions;
  48237. private _scene;
  48238. private _position;
  48239. private _btnVR;
  48240. private _btnVRDisplayed;
  48241. private _webVRsupported;
  48242. private _webVRready;
  48243. private _webVRrequesting;
  48244. private _webVRpresenting;
  48245. private _hasEnteredVR;
  48246. private _fullscreenVRpresenting;
  48247. private _inputElement;
  48248. private _webVRCamera;
  48249. private _vrDeviceOrientationCamera;
  48250. private _deviceOrientationCamera;
  48251. private _existingCamera;
  48252. private _onKeyDown;
  48253. private _onVrDisplayPresentChange;
  48254. private _onVRDisplayChanged;
  48255. private _onVRRequestPresentStart;
  48256. private _onVRRequestPresentComplete;
  48257. /**
  48258. * 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)
  48259. */
  48260. enableGazeEvenWhenNoPointerLock: boolean;
  48261. /**
  48262. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48263. */
  48264. exitVROnDoubleTap: boolean;
  48265. /**
  48266. * Observable raised right before entering VR.
  48267. */
  48268. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48269. /**
  48270. * Observable raised when entering VR has completed.
  48271. */
  48272. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48273. /**
  48274. * Observable raised when exiting VR.
  48275. */
  48276. onExitingVRObservable: Observable<VRExperienceHelper>;
  48277. /**
  48278. * Observable raised when controller mesh is loaded.
  48279. */
  48280. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48281. /** Return this.onEnteringVRObservable
  48282. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48283. */
  48284. get onEnteringVR(): Observable<VRExperienceHelper>;
  48285. /** Return this.onExitingVRObservable
  48286. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48287. */
  48288. get onExitingVR(): Observable<VRExperienceHelper>;
  48289. /** Return this.onControllerMeshLoadedObservable
  48290. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48291. */
  48292. get onControllerMeshLoaded(): Observable<WebVRController>;
  48293. private _rayLength;
  48294. private _useCustomVRButton;
  48295. private _teleportationRequested;
  48296. private _teleportActive;
  48297. private _floorMeshName;
  48298. private _floorMeshesCollection;
  48299. private _teleportationMode;
  48300. private _teleportationTime;
  48301. private _teleportationSpeed;
  48302. private _teleportationEasing;
  48303. private _rotationAllowed;
  48304. private _teleportBackwardsVector;
  48305. private _teleportationTarget;
  48306. private _isDefaultTeleportationTarget;
  48307. private _postProcessMove;
  48308. private _teleportationFillColor;
  48309. private _teleportationBorderColor;
  48310. private _rotationAngle;
  48311. private _haloCenter;
  48312. private _cameraGazer;
  48313. private _padSensibilityUp;
  48314. private _padSensibilityDown;
  48315. private _leftController;
  48316. private _rightController;
  48317. private _gazeColor;
  48318. private _laserColor;
  48319. private _pickedLaserColor;
  48320. private _pickedGazeColor;
  48321. /**
  48322. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48323. */
  48324. onNewMeshSelected: Observable<AbstractMesh>;
  48325. /**
  48326. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48327. * This observable will provide the mesh and the controller used to select the mesh
  48328. */
  48329. onMeshSelectedWithController: Observable<{
  48330. mesh: AbstractMesh;
  48331. controller: WebVRController;
  48332. }>;
  48333. /**
  48334. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48335. */
  48336. onNewMeshPicked: Observable<PickingInfo>;
  48337. private _circleEase;
  48338. /**
  48339. * Observable raised before camera teleportation
  48340. */
  48341. onBeforeCameraTeleport: Observable<Vector3>;
  48342. /**
  48343. * Observable raised after camera teleportation
  48344. */
  48345. onAfterCameraTeleport: Observable<Vector3>;
  48346. /**
  48347. * Observable raised when current selected mesh gets unselected
  48348. */
  48349. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48350. private _raySelectionPredicate;
  48351. /**
  48352. * To be optionaly changed by user to define custom ray selection
  48353. */
  48354. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48355. /**
  48356. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48357. */
  48358. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48359. /**
  48360. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48361. */
  48362. teleportationEnabled: boolean;
  48363. private _defaultHeight;
  48364. private _teleportationInitialized;
  48365. private _interactionsEnabled;
  48366. private _interactionsRequested;
  48367. private _displayGaze;
  48368. private _displayLaserPointer;
  48369. /**
  48370. * The mesh used to display where the user is going to teleport.
  48371. */
  48372. get teleportationTarget(): Mesh;
  48373. /**
  48374. * Sets the mesh to be used to display where the user is going to teleport.
  48375. */
  48376. set teleportationTarget(value: Mesh);
  48377. /**
  48378. * 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
  48379. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48380. * See http://doc.babylonjs.com/resources/baking_transformations
  48381. */
  48382. get gazeTrackerMesh(): Mesh;
  48383. set gazeTrackerMesh(value: Mesh);
  48384. /**
  48385. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48386. */
  48387. updateGazeTrackerScale: boolean;
  48388. /**
  48389. * If the gaze trackers color should be updated when selecting meshes
  48390. */
  48391. updateGazeTrackerColor: boolean;
  48392. /**
  48393. * If the controller laser color should be updated when selecting meshes
  48394. */
  48395. updateControllerLaserColor: boolean;
  48396. /**
  48397. * The gaze tracking mesh corresponding to the left controller
  48398. */
  48399. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48400. /**
  48401. * The gaze tracking mesh corresponding to the right controller
  48402. */
  48403. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48404. /**
  48405. * If the ray of the gaze should be displayed.
  48406. */
  48407. get displayGaze(): boolean;
  48408. /**
  48409. * Sets if the ray of the gaze should be displayed.
  48410. */
  48411. set displayGaze(value: boolean);
  48412. /**
  48413. * If the ray of the LaserPointer should be displayed.
  48414. */
  48415. get displayLaserPointer(): boolean;
  48416. /**
  48417. * Sets if the ray of the LaserPointer should be displayed.
  48418. */
  48419. set displayLaserPointer(value: boolean);
  48420. /**
  48421. * The deviceOrientationCamera used as the camera when not in VR.
  48422. */
  48423. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48424. /**
  48425. * Based on the current WebVR support, returns the current VR camera used.
  48426. */
  48427. get currentVRCamera(): Nullable<Camera>;
  48428. /**
  48429. * The webVRCamera which is used when in VR.
  48430. */
  48431. get webVRCamera(): WebVRFreeCamera;
  48432. /**
  48433. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48434. */
  48435. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48436. /**
  48437. * The html button that is used to trigger entering into VR.
  48438. */
  48439. get vrButton(): Nullable<HTMLButtonElement>;
  48440. private get _teleportationRequestInitiated();
  48441. /**
  48442. * Defines whether or not Pointer lock should be requested when switching to
  48443. * full screen.
  48444. */
  48445. requestPointerLockOnFullScreen: boolean;
  48446. /**
  48447. * If asking to force XR, this will be populated with the default xr experience
  48448. */
  48449. xr: WebXRDefaultExperience;
  48450. /**
  48451. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48452. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48453. */
  48454. xrTestDone: boolean;
  48455. /**
  48456. * Instantiates a VRExperienceHelper.
  48457. * Helps to quickly add VR support to an existing scene.
  48458. * @param scene The scene the VRExperienceHelper belongs to.
  48459. * @param webVROptions Options to modify the vr experience helper's behavior.
  48460. */
  48461. constructor(scene: Scene,
  48462. /** Options to modify the vr experience helper's behavior. */
  48463. webVROptions?: VRExperienceHelperOptions);
  48464. private completeVRInit;
  48465. private _onDefaultMeshLoaded;
  48466. private _onResize;
  48467. private _onFullscreenChange;
  48468. /**
  48469. * Gets a value indicating if we are currently in VR mode.
  48470. */
  48471. get isInVRMode(): boolean;
  48472. private onVrDisplayPresentChange;
  48473. private onVRDisplayChanged;
  48474. private moveButtonToBottomRight;
  48475. private displayVRButton;
  48476. private updateButtonVisibility;
  48477. private _cachedAngularSensibility;
  48478. /**
  48479. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48480. * Otherwise, will use the fullscreen API.
  48481. */
  48482. enterVR(): void;
  48483. /**
  48484. * Attempt to exit VR, or fullscreen.
  48485. */
  48486. exitVR(): void;
  48487. /**
  48488. * The position of the vr experience helper.
  48489. */
  48490. get position(): Vector3;
  48491. /**
  48492. * Sets the position of the vr experience helper.
  48493. */
  48494. set position(value: Vector3);
  48495. /**
  48496. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48497. */
  48498. enableInteractions(): void;
  48499. private get _noControllerIsActive();
  48500. private beforeRender;
  48501. private _isTeleportationFloor;
  48502. /**
  48503. * Adds a floor mesh to be used for teleportation.
  48504. * @param floorMesh the mesh to be used for teleportation.
  48505. */
  48506. addFloorMesh(floorMesh: Mesh): void;
  48507. /**
  48508. * Removes a floor mesh from being used for teleportation.
  48509. * @param floorMesh the mesh to be removed.
  48510. */
  48511. removeFloorMesh(floorMesh: Mesh): void;
  48512. /**
  48513. * Enables interactions and teleportation using the VR controllers and gaze.
  48514. * @param vrTeleportationOptions options to modify teleportation behavior.
  48515. */
  48516. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48517. private _onNewGamepadConnected;
  48518. private _tryEnableInteractionOnController;
  48519. private _onNewGamepadDisconnected;
  48520. private _enableInteractionOnController;
  48521. private _checkTeleportWithRay;
  48522. private _checkRotate;
  48523. private _checkTeleportBackwards;
  48524. private _enableTeleportationOnController;
  48525. private _createTeleportationCircles;
  48526. private _displayTeleportationTarget;
  48527. private _hideTeleportationTarget;
  48528. private _rotateCamera;
  48529. private _moveTeleportationSelectorTo;
  48530. private _workingVector;
  48531. private _workingQuaternion;
  48532. private _workingMatrix;
  48533. /**
  48534. * Time Constant Teleportation Mode
  48535. */
  48536. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48537. /**
  48538. * Speed Constant Teleportation Mode
  48539. */
  48540. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48541. /**
  48542. * Teleports the users feet to the desired location
  48543. * @param location The location where the user's feet should be placed
  48544. */
  48545. teleportCamera(location: Vector3): void;
  48546. private _convertNormalToDirectionOfRay;
  48547. private _castRayAndSelectObject;
  48548. private _notifySelectedMeshUnselected;
  48549. /**
  48550. * Permanently set new colors for the laser pointer
  48551. * @param color the new laser color
  48552. * @param pickedColor the new laser color when picked mesh detected
  48553. */
  48554. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48555. /**
  48556. * Set lighting enabled / disabled on the laser pointer of both controllers
  48557. * @param enabled should the lighting be enabled on the laser pointer
  48558. */
  48559. setLaserLightingState(enabled?: boolean): void;
  48560. /**
  48561. * Permanently set new colors for the gaze pointer
  48562. * @param color the new gaze color
  48563. * @param pickedColor the new gaze color when picked mesh detected
  48564. */
  48565. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48566. /**
  48567. * Sets the color of the laser ray from the vr controllers.
  48568. * @param color new color for the ray.
  48569. */
  48570. changeLaserColor(color: Color3): void;
  48571. /**
  48572. * Sets the color of the ray from the vr headsets gaze.
  48573. * @param color new color for the ray.
  48574. */
  48575. changeGazeColor(color: Color3): void;
  48576. /**
  48577. * Exits VR and disposes of the vr experience helper
  48578. */
  48579. dispose(): void;
  48580. /**
  48581. * Gets the name of the VRExperienceHelper class
  48582. * @returns "VRExperienceHelper"
  48583. */
  48584. getClassName(): string;
  48585. }
  48586. }
  48587. declare module BABYLON {
  48588. /**
  48589. * Contains an array of blocks representing the octree
  48590. */
  48591. export interface IOctreeContainer<T> {
  48592. /**
  48593. * Blocks within the octree
  48594. */
  48595. blocks: Array<OctreeBlock<T>>;
  48596. }
  48597. /**
  48598. * Class used to store a cell in an octree
  48599. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48600. */
  48601. export class OctreeBlock<T> {
  48602. /**
  48603. * Gets the content of the current block
  48604. */
  48605. entries: T[];
  48606. /**
  48607. * Gets the list of block children
  48608. */
  48609. blocks: Array<OctreeBlock<T>>;
  48610. private _depth;
  48611. private _maxDepth;
  48612. private _capacity;
  48613. private _minPoint;
  48614. private _maxPoint;
  48615. private _boundingVectors;
  48616. private _creationFunc;
  48617. /**
  48618. * Creates a new block
  48619. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  48620. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  48621. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48622. * @param depth defines the current depth of this block in the octree
  48623. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  48624. * @param creationFunc defines a callback to call when an element is added to the block
  48625. */
  48626. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  48627. /**
  48628. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48629. */
  48630. get capacity(): number;
  48631. /**
  48632. * Gets the minimum vector (in world space) of the block's bounding box
  48633. */
  48634. get minPoint(): Vector3;
  48635. /**
  48636. * Gets the maximum vector (in world space) of the block's bounding box
  48637. */
  48638. get maxPoint(): Vector3;
  48639. /**
  48640. * Add a new element to this block
  48641. * @param entry defines the element to add
  48642. */
  48643. addEntry(entry: T): void;
  48644. /**
  48645. * Remove an element from this block
  48646. * @param entry defines the element to remove
  48647. */
  48648. removeEntry(entry: T): void;
  48649. /**
  48650. * Add an array of elements to this block
  48651. * @param entries defines the array of elements to add
  48652. */
  48653. addEntries(entries: T[]): void;
  48654. /**
  48655. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  48656. * @param frustumPlanes defines the frustum planes to test
  48657. * @param selection defines the array to store current content if selection is positive
  48658. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48659. */
  48660. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48661. /**
  48662. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  48663. * @param sphereCenter defines the bounding sphere center
  48664. * @param sphereRadius defines the bounding sphere radius
  48665. * @param selection defines the array to store current content if selection is positive
  48666. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48667. */
  48668. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48669. /**
  48670. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  48671. * @param ray defines the ray to test with
  48672. * @param selection defines the array to store current content if selection is positive
  48673. */
  48674. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  48675. /**
  48676. * Subdivide the content into child blocks (this block will then be empty)
  48677. */
  48678. createInnerBlocks(): void;
  48679. /**
  48680. * @hidden
  48681. */
  48682. 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;
  48683. }
  48684. }
  48685. declare module BABYLON {
  48686. /**
  48687. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  48688. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48689. */
  48690. export class Octree<T> {
  48691. /** 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.) */
  48692. maxDepth: number;
  48693. /**
  48694. * Blocks within the octree containing objects
  48695. */
  48696. blocks: Array<OctreeBlock<T>>;
  48697. /**
  48698. * Content stored in the octree
  48699. */
  48700. dynamicContent: T[];
  48701. private _maxBlockCapacity;
  48702. private _selectionContent;
  48703. private _creationFunc;
  48704. /**
  48705. * Creates a octree
  48706. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48707. * @param creationFunc function to be used to instatiate the octree
  48708. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  48709. * @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.)
  48710. */
  48711. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  48712. /** 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.) */
  48713. maxDepth?: number);
  48714. /**
  48715. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  48716. * @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);
  48717. * @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);
  48718. * @param entries meshes to be added to the octree blocks
  48719. */
  48720. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  48721. /**
  48722. * Adds a mesh to the octree
  48723. * @param entry Mesh to add to the octree
  48724. */
  48725. addMesh(entry: T): void;
  48726. /**
  48727. * Remove an element from the octree
  48728. * @param entry defines the element to remove
  48729. */
  48730. removeMesh(entry: T): void;
  48731. /**
  48732. * Selects an array of meshes within the frustum
  48733. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  48734. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  48735. * @returns array of meshes within the frustum
  48736. */
  48737. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  48738. /**
  48739. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  48740. * @param sphereCenter defines the bounding sphere center
  48741. * @param sphereRadius defines the bounding sphere radius
  48742. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48743. * @returns an array of objects that intersect the sphere
  48744. */
  48745. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  48746. /**
  48747. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  48748. * @param ray defines the ray to test with
  48749. * @returns array of intersected objects
  48750. */
  48751. intersectsRay(ray: Ray): SmartArray<T>;
  48752. /**
  48753. * Adds a mesh into the octree block if it intersects the block
  48754. */
  48755. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  48756. /**
  48757. * Adds a submesh into the octree block if it intersects the block
  48758. */
  48759. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  48760. }
  48761. }
  48762. declare module BABYLON {
  48763. interface Scene {
  48764. /**
  48765. * @hidden
  48766. * Backing Filed
  48767. */
  48768. _selectionOctree: Octree<AbstractMesh>;
  48769. /**
  48770. * Gets the octree used to boost mesh selection (picking)
  48771. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48772. */
  48773. selectionOctree: Octree<AbstractMesh>;
  48774. /**
  48775. * Creates or updates the octree used to boost selection (picking)
  48776. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48777. * @param maxCapacity defines the maximum capacity per leaf
  48778. * @param maxDepth defines the maximum depth of the octree
  48779. * @returns an octree of AbstractMesh
  48780. */
  48781. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  48782. }
  48783. interface AbstractMesh {
  48784. /**
  48785. * @hidden
  48786. * Backing Field
  48787. */
  48788. _submeshesOctree: Octree<SubMesh>;
  48789. /**
  48790. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  48791. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  48792. * @param maxCapacity defines the maximum size of each block (64 by default)
  48793. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  48794. * @returns the new octree
  48795. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  48796. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48797. */
  48798. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  48799. }
  48800. /**
  48801. * Defines the octree scene component responsible to manage any octrees
  48802. * in a given scene.
  48803. */
  48804. export class OctreeSceneComponent {
  48805. /**
  48806. * The component name help to identify the component in the list of scene components.
  48807. */
  48808. readonly name: string;
  48809. /**
  48810. * The scene the component belongs to.
  48811. */
  48812. scene: Scene;
  48813. /**
  48814. * Indicates if the meshes have been checked to make sure they are isEnabled()
  48815. */
  48816. readonly checksIsEnabled: boolean;
  48817. /**
  48818. * Creates a new instance of the component for the given scene
  48819. * @param scene Defines the scene to register the component in
  48820. */
  48821. constructor(scene: Scene);
  48822. /**
  48823. * Registers the component in a given scene
  48824. */
  48825. register(): void;
  48826. /**
  48827. * Return the list of active meshes
  48828. * @returns the list of active meshes
  48829. */
  48830. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48831. /**
  48832. * Return the list of active sub meshes
  48833. * @param mesh The mesh to get the candidates sub meshes from
  48834. * @returns the list of active sub meshes
  48835. */
  48836. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48837. private _tempRay;
  48838. /**
  48839. * Return the list of sub meshes intersecting with a given local ray
  48840. * @param mesh defines the mesh to find the submesh for
  48841. * @param localRay defines the ray in local space
  48842. * @returns the list of intersecting sub meshes
  48843. */
  48844. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  48845. /**
  48846. * Return the list of sub meshes colliding with a collider
  48847. * @param mesh defines the mesh to find the submesh for
  48848. * @param collider defines the collider to evaluate the collision against
  48849. * @returns the list of colliding sub meshes
  48850. */
  48851. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  48852. /**
  48853. * Rebuilds the elements related to this component in case of
  48854. * context lost for instance.
  48855. */
  48856. rebuild(): void;
  48857. /**
  48858. * Disposes the component and the associated ressources.
  48859. */
  48860. dispose(): void;
  48861. }
  48862. }
  48863. declare module BABYLON {
  48864. /**
  48865. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  48866. */
  48867. export class Gizmo implements IDisposable {
  48868. /** The utility layer the gizmo will be added to */
  48869. gizmoLayer: UtilityLayerRenderer;
  48870. /**
  48871. * The root mesh of the gizmo
  48872. */
  48873. _rootMesh: Mesh;
  48874. private _attachedMesh;
  48875. /**
  48876. * Ratio for the scale of the gizmo (Default: 1)
  48877. */
  48878. scaleRatio: number;
  48879. /**
  48880. * If a custom mesh has been set (Default: false)
  48881. */
  48882. protected _customMeshSet: boolean;
  48883. /**
  48884. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  48885. * * When set, interactions will be enabled
  48886. */
  48887. get attachedMesh(): Nullable<AbstractMesh>;
  48888. set attachedMesh(value: Nullable<AbstractMesh>);
  48889. /**
  48890. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48891. * @param mesh The mesh to replace the default mesh of the gizmo
  48892. */
  48893. setCustomMesh(mesh: Mesh): void;
  48894. /**
  48895. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  48896. */
  48897. updateGizmoRotationToMatchAttachedMesh: boolean;
  48898. /**
  48899. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  48900. */
  48901. updateGizmoPositionToMatchAttachedMesh: boolean;
  48902. /**
  48903. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  48904. */
  48905. updateScale: boolean;
  48906. protected _interactionsEnabled: boolean;
  48907. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48908. private _beforeRenderObserver;
  48909. private _tempVector;
  48910. /**
  48911. * Creates a gizmo
  48912. * @param gizmoLayer The utility layer the gizmo will be added to
  48913. */
  48914. constructor(
  48915. /** The utility layer the gizmo will be added to */
  48916. gizmoLayer?: UtilityLayerRenderer);
  48917. /**
  48918. * Updates the gizmo to match the attached mesh's position/rotation
  48919. */
  48920. protected _update(): void;
  48921. /**
  48922. * Disposes of the gizmo
  48923. */
  48924. dispose(): void;
  48925. }
  48926. }
  48927. declare module BABYLON {
  48928. /**
  48929. * Single plane drag gizmo
  48930. */
  48931. export class PlaneDragGizmo extends Gizmo {
  48932. /**
  48933. * Drag behavior responsible for the gizmos dragging interactions
  48934. */
  48935. dragBehavior: PointerDragBehavior;
  48936. private _pointerObserver;
  48937. /**
  48938. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48939. */
  48940. snapDistance: number;
  48941. /**
  48942. * Event that fires each time the gizmo snaps to a new location.
  48943. * * snapDistance is the the change in distance
  48944. */
  48945. onSnapObservable: Observable<{
  48946. snapDistance: number;
  48947. }>;
  48948. private _plane;
  48949. private _coloredMaterial;
  48950. private _hoverMaterial;
  48951. private _isEnabled;
  48952. private _parent;
  48953. /** @hidden */
  48954. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  48955. /** @hidden */
  48956. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48957. /**
  48958. * Creates a PlaneDragGizmo
  48959. * @param gizmoLayer The utility layer the gizmo will be added to
  48960. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  48961. * @param color The color of the gizmo
  48962. */
  48963. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48964. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48965. /**
  48966. * If the gizmo is enabled
  48967. */
  48968. set isEnabled(value: boolean);
  48969. get isEnabled(): boolean;
  48970. /**
  48971. * Disposes of the gizmo
  48972. */
  48973. dispose(): void;
  48974. }
  48975. }
  48976. declare module BABYLON {
  48977. /**
  48978. * Gizmo that enables dragging a mesh along 3 axis
  48979. */
  48980. export class PositionGizmo extends Gizmo {
  48981. /**
  48982. * Internal gizmo used for interactions on the x axis
  48983. */
  48984. xGizmo: AxisDragGizmo;
  48985. /**
  48986. * Internal gizmo used for interactions on the y axis
  48987. */
  48988. yGizmo: AxisDragGizmo;
  48989. /**
  48990. * Internal gizmo used for interactions on the z axis
  48991. */
  48992. zGizmo: AxisDragGizmo;
  48993. /**
  48994. * Internal gizmo used for interactions on the yz plane
  48995. */
  48996. xPlaneGizmo: PlaneDragGizmo;
  48997. /**
  48998. * Internal gizmo used for interactions on the xz plane
  48999. */
  49000. yPlaneGizmo: PlaneDragGizmo;
  49001. /**
  49002. * Internal gizmo used for interactions on the xy plane
  49003. */
  49004. zPlaneGizmo: PlaneDragGizmo;
  49005. /**
  49006. * private variables
  49007. */
  49008. private _meshAttached;
  49009. private _updateGizmoRotationToMatchAttachedMesh;
  49010. private _snapDistance;
  49011. private _scaleRatio;
  49012. /** Fires an event when any of it's sub gizmos are dragged */
  49013. onDragStartObservable: Observable<unknown>;
  49014. /** Fires an event when any of it's sub gizmos are released from dragging */
  49015. onDragEndObservable: Observable<unknown>;
  49016. /**
  49017. * If set to true, planar drag is enabled
  49018. */
  49019. private _planarGizmoEnabled;
  49020. get attachedMesh(): Nullable<AbstractMesh>;
  49021. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49022. /**
  49023. * Creates a PositionGizmo
  49024. * @param gizmoLayer The utility layer the gizmo will be added to
  49025. */
  49026. constructor(gizmoLayer?: UtilityLayerRenderer);
  49027. /**
  49028. * If the planar drag gizmo is enabled
  49029. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  49030. */
  49031. set planarGizmoEnabled(value: boolean);
  49032. get planarGizmoEnabled(): boolean;
  49033. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49034. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49035. /**
  49036. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49037. */
  49038. set snapDistance(value: number);
  49039. get snapDistance(): number;
  49040. /**
  49041. * Ratio for the scale of the gizmo (Default: 1)
  49042. */
  49043. set scaleRatio(value: number);
  49044. get scaleRatio(): number;
  49045. /**
  49046. * Disposes of the gizmo
  49047. */
  49048. dispose(): void;
  49049. /**
  49050. * CustomMeshes are not supported by this gizmo
  49051. * @param mesh The mesh to replace the default mesh of the gizmo
  49052. */
  49053. setCustomMesh(mesh: Mesh): void;
  49054. }
  49055. }
  49056. declare module BABYLON {
  49057. /**
  49058. * Single axis drag gizmo
  49059. */
  49060. export class AxisDragGizmo extends Gizmo {
  49061. /**
  49062. * Drag behavior responsible for the gizmos dragging interactions
  49063. */
  49064. dragBehavior: PointerDragBehavior;
  49065. private _pointerObserver;
  49066. /**
  49067. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49068. */
  49069. snapDistance: number;
  49070. /**
  49071. * Event that fires each time the gizmo snaps to a new location.
  49072. * * snapDistance is the the change in distance
  49073. */
  49074. onSnapObservable: Observable<{
  49075. snapDistance: number;
  49076. }>;
  49077. private _isEnabled;
  49078. private _parent;
  49079. private _arrow;
  49080. private _coloredMaterial;
  49081. private _hoverMaterial;
  49082. /** @hidden */
  49083. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49084. /** @hidden */
  49085. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49086. /**
  49087. * Creates an AxisDragGizmo
  49088. * @param gizmoLayer The utility layer the gizmo will be added to
  49089. * @param dragAxis The axis which the gizmo will be able to drag on
  49090. * @param color The color of the gizmo
  49091. */
  49092. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49093. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49094. /**
  49095. * If the gizmo is enabled
  49096. */
  49097. set isEnabled(value: boolean);
  49098. get isEnabled(): boolean;
  49099. /**
  49100. * Disposes of the gizmo
  49101. */
  49102. dispose(): void;
  49103. }
  49104. }
  49105. declare module BABYLON.Debug {
  49106. /**
  49107. * The Axes viewer will show 3 axes in a specific point in space
  49108. */
  49109. export class AxesViewer {
  49110. private _xAxis;
  49111. private _yAxis;
  49112. private _zAxis;
  49113. private _scaleLinesFactor;
  49114. private _instanced;
  49115. /**
  49116. * Gets the hosting scene
  49117. */
  49118. scene: Scene;
  49119. /**
  49120. * Gets or sets a number used to scale line length
  49121. */
  49122. scaleLines: number;
  49123. /** Gets the node hierarchy used to render x-axis */
  49124. get xAxis(): TransformNode;
  49125. /** Gets the node hierarchy used to render y-axis */
  49126. get yAxis(): TransformNode;
  49127. /** Gets the node hierarchy used to render z-axis */
  49128. get zAxis(): TransformNode;
  49129. /**
  49130. * Creates a new AxesViewer
  49131. * @param scene defines the hosting scene
  49132. * @param scaleLines defines a number used to scale line length (1 by default)
  49133. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49134. * @param xAxis defines the node hierarchy used to render the x-axis
  49135. * @param yAxis defines the node hierarchy used to render the y-axis
  49136. * @param zAxis defines the node hierarchy used to render the z-axis
  49137. */
  49138. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49139. /**
  49140. * Force the viewer to update
  49141. * @param position defines the position of the viewer
  49142. * @param xaxis defines the x axis of the viewer
  49143. * @param yaxis defines the y axis of the viewer
  49144. * @param zaxis defines the z axis of the viewer
  49145. */
  49146. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49147. /**
  49148. * Creates an instance of this axes viewer.
  49149. * @returns a new axes viewer with instanced meshes
  49150. */
  49151. createInstance(): AxesViewer;
  49152. /** Releases resources */
  49153. dispose(): void;
  49154. private static _SetRenderingGroupId;
  49155. }
  49156. }
  49157. declare module BABYLON.Debug {
  49158. /**
  49159. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49160. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49161. */
  49162. export class BoneAxesViewer extends AxesViewer {
  49163. /**
  49164. * Gets or sets the target mesh where to display the axes viewer
  49165. */
  49166. mesh: Nullable<Mesh>;
  49167. /**
  49168. * Gets or sets the target bone where to display the axes viewer
  49169. */
  49170. bone: Nullable<Bone>;
  49171. /** Gets current position */
  49172. pos: Vector3;
  49173. /** Gets direction of X axis */
  49174. xaxis: Vector3;
  49175. /** Gets direction of Y axis */
  49176. yaxis: Vector3;
  49177. /** Gets direction of Z axis */
  49178. zaxis: Vector3;
  49179. /**
  49180. * Creates a new BoneAxesViewer
  49181. * @param scene defines the hosting scene
  49182. * @param bone defines the target bone
  49183. * @param mesh defines the target mesh
  49184. * @param scaleLines defines a scaling factor for line length (1 by default)
  49185. */
  49186. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49187. /**
  49188. * Force the viewer to update
  49189. */
  49190. update(): void;
  49191. /** Releases resources */
  49192. dispose(): void;
  49193. }
  49194. }
  49195. declare module BABYLON {
  49196. /**
  49197. * Interface used to define scene explorer extensibility option
  49198. */
  49199. export interface IExplorerExtensibilityOption {
  49200. /**
  49201. * Define the option label
  49202. */
  49203. label: string;
  49204. /**
  49205. * Defines the action to execute on click
  49206. */
  49207. action: (entity: any) => void;
  49208. }
  49209. /**
  49210. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49211. */
  49212. export interface IExplorerExtensibilityGroup {
  49213. /**
  49214. * Defines a predicate to test if a given type mut be extended
  49215. */
  49216. predicate: (entity: any) => boolean;
  49217. /**
  49218. * Gets the list of options added to a type
  49219. */
  49220. entries: IExplorerExtensibilityOption[];
  49221. }
  49222. /**
  49223. * Interface used to define the options to use to create the Inspector
  49224. */
  49225. export interface IInspectorOptions {
  49226. /**
  49227. * Display in overlay mode (default: false)
  49228. */
  49229. overlay?: boolean;
  49230. /**
  49231. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49232. */
  49233. globalRoot?: HTMLElement;
  49234. /**
  49235. * Display the Scene explorer
  49236. */
  49237. showExplorer?: boolean;
  49238. /**
  49239. * Display the property inspector
  49240. */
  49241. showInspector?: boolean;
  49242. /**
  49243. * Display in embed mode (both panes on the right)
  49244. */
  49245. embedMode?: boolean;
  49246. /**
  49247. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49248. */
  49249. handleResize?: boolean;
  49250. /**
  49251. * Allow the panes to popup (default: true)
  49252. */
  49253. enablePopup?: boolean;
  49254. /**
  49255. * Allow the panes to be closed by users (default: true)
  49256. */
  49257. enableClose?: boolean;
  49258. /**
  49259. * Optional list of extensibility entries
  49260. */
  49261. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49262. /**
  49263. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49264. */
  49265. inspectorURL?: string;
  49266. /**
  49267. * Optional initial tab (default to DebugLayerTab.Properties)
  49268. */
  49269. initialTab?: DebugLayerTab;
  49270. }
  49271. interface Scene {
  49272. /**
  49273. * @hidden
  49274. * Backing field
  49275. */
  49276. _debugLayer: DebugLayer;
  49277. /**
  49278. * Gets the debug layer (aka Inspector) associated with the scene
  49279. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49280. */
  49281. debugLayer: DebugLayer;
  49282. }
  49283. /**
  49284. * Enum of inspector action tab
  49285. */
  49286. export enum DebugLayerTab {
  49287. /**
  49288. * Properties tag (default)
  49289. */
  49290. Properties = 0,
  49291. /**
  49292. * Debug tab
  49293. */
  49294. Debug = 1,
  49295. /**
  49296. * Statistics tab
  49297. */
  49298. Statistics = 2,
  49299. /**
  49300. * Tools tab
  49301. */
  49302. Tools = 3,
  49303. /**
  49304. * Settings tab
  49305. */
  49306. Settings = 4
  49307. }
  49308. /**
  49309. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49310. * what is happening in your scene
  49311. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49312. */
  49313. export class DebugLayer {
  49314. /**
  49315. * Define the url to get the inspector script from.
  49316. * By default it uses the babylonjs CDN.
  49317. * @ignoreNaming
  49318. */
  49319. static InspectorURL: string;
  49320. private _scene;
  49321. private BJSINSPECTOR;
  49322. private _onPropertyChangedObservable?;
  49323. /**
  49324. * Observable triggered when a property is changed through the inspector.
  49325. */
  49326. get onPropertyChangedObservable(): any;
  49327. /**
  49328. * Instantiates a new debug layer.
  49329. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49330. * what is happening in your scene
  49331. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49332. * @param scene Defines the scene to inspect
  49333. */
  49334. constructor(scene: Scene);
  49335. /** Creates the inspector window. */
  49336. private _createInspector;
  49337. /**
  49338. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49339. * @param entity defines the entity to select
  49340. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  49341. */
  49342. select(entity: any, lineContainerTitles?: string | string[]): void;
  49343. /** Get the inspector from bundle or global */
  49344. private _getGlobalInspector;
  49345. /**
  49346. * Get if the inspector is visible or not.
  49347. * @returns true if visible otherwise, false
  49348. */
  49349. isVisible(): boolean;
  49350. /**
  49351. * Hide the inspector and close its window.
  49352. */
  49353. hide(): void;
  49354. /**
  49355. * Update the scene in the inspector
  49356. */
  49357. setAsActiveScene(): void;
  49358. /**
  49359. * Launch the debugLayer.
  49360. * @param config Define the configuration of the inspector
  49361. * @return a promise fulfilled when the debug layer is visible
  49362. */
  49363. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49364. }
  49365. }
  49366. declare module BABYLON {
  49367. /**
  49368. * Class containing static functions to help procedurally build meshes
  49369. */
  49370. export class BoxBuilder {
  49371. /**
  49372. * Creates a box mesh
  49373. * * The parameter `size` sets the size (float) of each box side (default 1)
  49374. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49375. * * 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)
  49376. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49378. * * 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
  49379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49380. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49381. * @param name defines the name of the mesh
  49382. * @param options defines the options used to create the mesh
  49383. * @param scene defines the hosting scene
  49384. * @returns the box mesh
  49385. */
  49386. static CreateBox(name: string, options: {
  49387. size?: number;
  49388. width?: number;
  49389. height?: number;
  49390. depth?: number;
  49391. faceUV?: Vector4[];
  49392. faceColors?: Color4[];
  49393. sideOrientation?: number;
  49394. frontUVs?: Vector4;
  49395. backUVs?: Vector4;
  49396. wrap?: boolean;
  49397. topBaseAt?: number;
  49398. bottomBaseAt?: number;
  49399. updatable?: boolean;
  49400. }, scene?: Nullable<Scene>): Mesh;
  49401. }
  49402. }
  49403. declare module BABYLON.Debug {
  49404. /**
  49405. * Used to show the physics impostor around the specific mesh
  49406. */
  49407. export class PhysicsViewer {
  49408. /** @hidden */
  49409. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49410. /** @hidden */
  49411. protected _meshes: Array<Nullable<AbstractMesh>>;
  49412. /** @hidden */
  49413. protected _scene: Nullable<Scene>;
  49414. /** @hidden */
  49415. protected _numMeshes: number;
  49416. /** @hidden */
  49417. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49418. private _renderFunction;
  49419. private _utilityLayer;
  49420. private _debugBoxMesh;
  49421. private _debugSphereMesh;
  49422. private _debugCylinderMesh;
  49423. private _debugMaterial;
  49424. private _debugMeshMeshes;
  49425. /**
  49426. * Creates a new PhysicsViewer
  49427. * @param scene defines the hosting scene
  49428. */
  49429. constructor(scene: Scene);
  49430. /** @hidden */
  49431. protected _updateDebugMeshes(): void;
  49432. /**
  49433. * Renders a specified physic impostor
  49434. * @param impostor defines the impostor to render
  49435. * @param targetMesh defines the mesh represented by the impostor
  49436. * @returns the new debug mesh used to render the impostor
  49437. */
  49438. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49439. /**
  49440. * Hides a specified physic impostor
  49441. * @param impostor defines the impostor to hide
  49442. */
  49443. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49444. private _getDebugMaterial;
  49445. private _getDebugBoxMesh;
  49446. private _getDebugSphereMesh;
  49447. private _getDebugCylinderMesh;
  49448. private _getDebugMeshMesh;
  49449. private _getDebugMesh;
  49450. /** Releases all resources */
  49451. dispose(): void;
  49452. }
  49453. }
  49454. declare module BABYLON {
  49455. /**
  49456. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49457. * in order to better appreciate the issue one might have.
  49458. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49459. */
  49460. export class RayHelper {
  49461. /**
  49462. * Defines the ray we are currently tryin to visualize.
  49463. */
  49464. ray: Nullable<Ray>;
  49465. private _renderPoints;
  49466. private _renderLine;
  49467. private _renderFunction;
  49468. private _scene;
  49469. private _updateToMeshFunction;
  49470. private _attachedToMesh;
  49471. private _meshSpaceDirection;
  49472. private _meshSpaceOrigin;
  49473. /**
  49474. * Helper function to create a colored helper in a scene in one line.
  49475. * @param ray Defines the ray we are currently tryin to visualize
  49476. * @param scene Defines the scene the ray is used in
  49477. * @param color Defines the color we want to see the ray in
  49478. * @returns The newly created ray helper.
  49479. */
  49480. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49481. /**
  49482. * Instantiate a new ray helper.
  49483. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49484. * in order to better appreciate the issue one might have.
  49485. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49486. * @param ray Defines the ray we are currently tryin to visualize
  49487. */
  49488. constructor(ray: Ray);
  49489. /**
  49490. * Shows the ray we are willing to debug.
  49491. * @param scene Defines the scene the ray needs to be rendered in
  49492. * @param color Defines the color the ray needs to be rendered in
  49493. */
  49494. show(scene: Scene, color?: Color3): void;
  49495. /**
  49496. * Hides the ray we are debugging.
  49497. */
  49498. hide(): void;
  49499. private _render;
  49500. /**
  49501. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49502. * @param mesh Defines the mesh we want the helper attached to
  49503. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49504. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49505. * @param length Defines the length of the ray
  49506. */
  49507. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49508. /**
  49509. * Detach the ray helper from the mesh it has previously been attached to.
  49510. */
  49511. detachFromMesh(): void;
  49512. private _updateToMesh;
  49513. /**
  49514. * Dispose the helper and release its associated resources.
  49515. */
  49516. dispose(): void;
  49517. }
  49518. }
  49519. declare module BABYLON.Debug {
  49520. /**
  49521. * Class used to render a debug view of a given skeleton
  49522. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49523. */
  49524. export class SkeletonViewer {
  49525. /** defines the skeleton to render */
  49526. skeleton: Skeleton;
  49527. /** defines the mesh attached to the skeleton */
  49528. mesh: AbstractMesh;
  49529. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49530. autoUpdateBonesMatrices: boolean;
  49531. /** defines the rendering group id to use with the viewer */
  49532. renderingGroupId: number;
  49533. /** Gets or sets the color used to render the skeleton */
  49534. color: Color3;
  49535. private _scene;
  49536. private _debugLines;
  49537. private _debugMesh;
  49538. private _isEnabled;
  49539. private _renderFunction;
  49540. private _utilityLayer;
  49541. /**
  49542. * Returns the mesh used to render the bones
  49543. */
  49544. get debugMesh(): Nullable<LinesMesh>;
  49545. /**
  49546. * Creates a new SkeletonViewer
  49547. * @param skeleton defines the skeleton to render
  49548. * @param mesh defines the mesh attached to the skeleton
  49549. * @param scene defines the hosting scene
  49550. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49551. * @param renderingGroupId defines the rendering group id to use with the viewer
  49552. */
  49553. constructor(
  49554. /** defines the skeleton to render */
  49555. skeleton: Skeleton,
  49556. /** defines the mesh attached to the skeleton */
  49557. mesh: AbstractMesh, scene: Scene,
  49558. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49559. autoUpdateBonesMatrices?: boolean,
  49560. /** defines the rendering group id to use with the viewer */
  49561. renderingGroupId?: number);
  49562. /** Gets or sets a boolean indicating if the viewer is enabled */
  49563. set isEnabled(value: boolean);
  49564. get isEnabled(): boolean;
  49565. private _getBonePosition;
  49566. private _getLinesForBonesWithLength;
  49567. private _getLinesForBonesNoLength;
  49568. /** Update the viewer to sync with current skeleton state */
  49569. update(): void;
  49570. /** Release associated resources */
  49571. dispose(): void;
  49572. }
  49573. }
  49574. declare module BABYLON {
  49575. /**
  49576. * Enum for Device Types
  49577. */
  49578. export enum DeviceType {
  49579. /** Generic */
  49580. Generic = 0,
  49581. /** Keyboard */
  49582. Keyboard = 1,
  49583. /** Mouse */
  49584. Mouse = 2,
  49585. /** Touch Pointers */
  49586. Touch = 3,
  49587. /** PS4 Dual Shock */
  49588. DualShock = 4,
  49589. /** Xbox */
  49590. Xbox = 5,
  49591. /** Switch Controller */
  49592. Switch = 6
  49593. }
  49594. /**
  49595. * Enum for All Pointers (Touch/Mouse)
  49596. */
  49597. export enum PointerInput {
  49598. /** Horizontal Axis */
  49599. Horizontal = 0,
  49600. /** Vertical Axis */
  49601. Vertical = 1,
  49602. /** Left Click or Touch */
  49603. LeftClick = 2,
  49604. /** Middle Click */
  49605. MiddleClick = 3,
  49606. /** Right Click */
  49607. RightClick = 4,
  49608. /** Browser Back */
  49609. BrowserBack = 5,
  49610. /** Browser Forward */
  49611. BrowserForward = 6
  49612. }
  49613. /**
  49614. * Enum for Dual Shock Gamepad
  49615. */
  49616. export enum DualShockInput {
  49617. /** Cross */
  49618. Cross = 0,
  49619. /** Circle */
  49620. Circle = 1,
  49621. /** Square */
  49622. Square = 2,
  49623. /** Triangle */
  49624. Triangle = 3,
  49625. /** L1 */
  49626. L1 = 4,
  49627. /** R1 */
  49628. R1 = 5,
  49629. /** L2 */
  49630. L2 = 6,
  49631. /** R2 */
  49632. R2 = 7,
  49633. /** Share */
  49634. Share = 8,
  49635. /** Options */
  49636. Options = 9,
  49637. /** L3 */
  49638. L3 = 10,
  49639. /** R3 */
  49640. R3 = 11,
  49641. /** DPadUp */
  49642. DPadUp = 12,
  49643. /** DPadDown */
  49644. DPadDown = 13,
  49645. /** DPadLeft */
  49646. DPadLeft = 14,
  49647. /** DRight */
  49648. DPadRight = 15,
  49649. /** Home */
  49650. Home = 16,
  49651. /** TouchPad */
  49652. TouchPad = 17,
  49653. /** LStickXAxis */
  49654. LStickXAxis = 18,
  49655. /** LStickYAxis */
  49656. LStickYAxis = 19,
  49657. /** RStickXAxis */
  49658. RStickXAxis = 20,
  49659. /** RStickYAxis */
  49660. RStickYAxis = 21
  49661. }
  49662. /**
  49663. * Enum for Xbox Gamepad
  49664. */
  49665. export enum XboxInput {
  49666. /** A */
  49667. A = 0,
  49668. /** B */
  49669. B = 1,
  49670. /** X */
  49671. X = 2,
  49672. /** Y */
  49673. Y = 3,
  49674. /** LB */
  49675. LB = 4,
  49676. /** RB */
  49677. RB = 5,
  49678. /** LT */
  49679. LT = 6,
  49680. /** RT */
  49681. RT = 7,
  49682. /** Back */
  49683. Back = 8,
  49684. /** Start */
  49685. Start = 9,
  49686. /** LS */
  49687. LS = 10,
  49688. /** RS */
  49689. RS = 11,
  49690. /** DPadUp */
  49691. DPadUp = 12,
  49692. /** DPadDown */
  49693. DPadDown = 13,
  49694. /** DPadLeft */
  49695. DPadLeft = 14,
  49696. /** DRight */
  49697. DPadRight = 15,
  49698. /** Home */
  49699. Home = 16,
  49700. /** LStickXAxis */
  49701. LStickXAxis = 17,
  49702. /** LStickYAxis */
  49703. LStickYAxis = 18,
  49704. /** RStickXAxis */
  49705. RStickXAxis = 19,
  49706. /** RStickYAxis */
  49707. RStickYAxis = 20
  49708. }
  49709. /**
  49710. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  49711. */
  49712. export enum SwitchInput {
  49713. /** B */
  49714. B = 0,
  49715. /** A */
  49716. A = 1,
  49717. /** Y */
  49718. Y = 2,
  49719. /** X */
  49720. X = 3,
  49721. /** L */
  49722. L = 4,
  49723. /** R */
  49724. R = 5,
  49725. /** ZL */
  49726. ZL = 6,
  49727. /** ZR */
  49728. ZR = 7,
  49729. /** Minus */
  49730. Minus = 8,
  49731. /** Plus */
  49732. Plus = 9,
  49733. /** LS */
  49734. LS = 10,
  49735. /** RS */
  49736. RS = 11,
  49737. /** DPadUp */
  49738. DPadUp = 12,
  49739. /** DPadDown */
  49740. DPadDown = 13,
  49741. /** DPadLeft */
  49742. DPadLeft = 14,
  49743. /** DRight */
  49744. DPadRight = 15,
  49745. /** Home */
  49746. Home = 16,
  49747. /** Capture */
  49748. Capture = 17,
  49749. /** LStickXAxis */
  49750. LStickXAxis = 18,
  49751. /** LStickYAxis */
  49752. LStickYAxis = 19,
  49753. /** RStickXAxis */
  49754. RStickXAxis = 20,
  49755. /** RStickYAxis */
  49756. RStickYAxis = 21
  49757. }
  49758. }
  49759. declare module BABYLON {
  49760. /**
  49761. * This class will take all inputs from Keyboard, Pointer, and
  49762. * any Gamepads and provide a polling system that all devices
  49763. * will use. This class assumes that there will only be one
  49764. * pointer device and one keyboard.
  49765. */
  49766. export class DeviceInputSystem implements IDisposable {
  49767. /**
  49768. * Callback to be triggered when a device is connected
  49769. */
  49770. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49771. /**
  49772. * Callback to be triggered when a device is disconnected
  49773. */
  49774. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49775. /**
  49776. * Callback to be triggered when event driven input is updated
  49777. */
  49778. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  49779. private _inputs;
  49780. private _gamepads;
  49781. private _keyboardActive;
  49782. private _pointerActive;
  49783. private _elementToAttachTo;
  49784. private _keyboardDownEvent;
  49785. private _keyboardUpEvent;
  49786. private _pointerMoveEvent;
  49787. private _pointerDownEvent;
  49788. private _pointerUpEvent;
  49789. private _gamepadConnectedEvent;
  49790. private _gamepadDisconnectedEvent;
  49791. private static _MAX_KEYCODES;
  49792. private static _MAX_POINTER_INPUTS;
  49793. private constructor();
  49794. /**
  49795. * Creates a new DeviceInputSystem instance
  49796. * @param engine Engine to pull input element from
  49797. * @returns The new instance
  49798. */
  49799. static Create(engine: Engine): DeviceInputSystem;
  49800. /**
  49801. * Checks for current device input value, given an id and input index
  49802. * @param deviceName Id of connected device
  49803. * @param inputIndex Index of device input
  49804. * @returns Current value of input
  49805. */
  49806. /**
  49807. * Checks for current device input value, given an id and input index
  49808. * @param deviceType Enum specifiying device type
  49809. * @param deviceSlot "Slot" or index that device is referenced in
  49810. * @param inputIndex Id of input to be checked
  49811. * @returns Current value of input
  49812. */
  49813. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  49814. /**
  49815. * Dispose of all the eventlisteners
  49816. */
  49817. dispose(): void;
  49818. /**
  49819. * Add device and inputs to device array
  49820. * @param deviceType Enum specifiying device type
  49821. * @param deviceSlot "Slot" or index that device is referenced in
  49822. * @param numberOfInputs Number of input entries to create for given device
  49823. */
  49824. private _registerDevice;
  49825. /**
  49826. * Given a specific device name, remove that device from the device map
  49827. * @param deviceType Enum specifiying device type
  49828. * @param deviceSlot "Slot" or index that device is referenced in
  49829. */
  49830. private _unregisterDevice;
  49831. /**
  49832. * Handle all actions that come from keyboard interaction
  49833. */
  49834. private _handleKeyActions;
  49835. /**
  49836. * Handle all actions that come from pointer interaction
  49837. */
  49838. private _handlePointerActions;
  49839. /**
  49840. * Handle all actions that come from gamepad interaction
  49841. */
  49842. private _handleGamepadActions;
  49843. /**
  49844. * Update all non-event based devices with each frame
  49845. * @param deviceType Enum specifiying device type
  49846. * @param deviceSlot "Slot" or index that device is referenced in
  49847. * @param inputIndex Id of input to be checked
  49848. */
  49849. private _updateDevice;
  49850. /**
  49851. * Gets DeviceType from the device name
  49852. * @param deviceName Name of Device from DeviceInputSystem
  49853. * @returns DeviceType enum value
  49854. */
  49855. private _getGamepadDeviceType;
  49856. }
  49857. }
  49858. declare module BABYLON {
  49859. /**
  49860. * Type to handle enforcement of inputs
  49861. */
  49862. export type DeviceInput<T extends DeviceType> = T extends DeviceType.Keyboard | DeviceType.Generic ? number : T extends DeviceType.Mouse | DeviceType.Touch ? PointerInput : T extends DeviceType.DualShock ? DualShockInput : T extends DeviceType.Xbox ? XboxInput : T extends DeviceType.Switch ? SwitchInput : never;
  49863. }
  49864. declare module BABYLON {
  49865. /**
  49866. * Class that handles all input for a specific device
  49867. */
  49868. export class DeviceSource<T extends DeviceType> {
  49869. /** Type of device */
  49870. readonly deviceType: DeviceType;
  49871. /** "Slot" or index that device is referenced in */
  49872. readonly deviceSlot: number;
  49873. /**
  49874. * Observable to handle device input changes per device
  49875. */
  49876. readonly onInputChangedObservable: Observable<{
  49877. inputIndex: DeviceInput<T>;
  49878. previousState: Nullable<number>;
  49879. currentState: Nullable<number>;
  49880. }>;
  49881. private readonly _deviceInputSystem;
  49882. /**
  49883. * Default Constructor
  49884. * @param deviceInputSystem Reference to DeviceInputSystem
  49885. * @param deviceType Type of device
  49886. * @param deviceSlot "Slot" or index that device is referenced in
  49887. */
  49888. constructor(deviceInputSystem: DeviceInputSystem,
  49889. /** Type of device */
  49890. deviceType: DeviceType,
  49891. /** "Slot" or index that device is referenced in */
  49892. deviceSlot?: number);
  49893. /**
  49894. * Get input for specific input
  49895. * @param inputIndex index of specific input on device
  49896. * @returns Input value from DeviceInputSystem
  49897. */
  49898. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  49899. }
  49900. /**
  49901. * Class to keep track of devices
  49902. */
  49903. export class DeviceSourceManager implements IDisposable {
  49904. /**
  49905. * Observable to be triggered when before a device is connected
  49906. */
  49907. readonly onBeforeDeviceConnectedObservable: Observable<{
  49908. deviceType: DeviceType;
  49909. deviceSlot: number;
  49910. }>;
  49911. /**
  49912. * Observable to be triggered when before a device is disconnected
  49913. */
  49914. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  49915. deviceType: DeviceType;
  49916. deviceSlot: number;
  49917. }>;
  49918. /**
  49919. * Observable to be triggered when after a device is connected
  49920. */
  49921. readonly onAfterDeviceConnectedObservable: Observable<{
  49922. deviceType: DeviceType;
  49923. deviceSlot: number;
  49924. }>;
  49925. /**
  49926. * Observable to be triggered when after a device is disconnected
  49927. */
  49928. readonly onAfterDeviceDisconnectedObservable: Observable<{
  49929. deviceType: DeviceType;
  49930. deviceSlot: number;
  49931. }>;
  49932. private readonly _devices;
  49933. private readonly _firstDevice;
  49934. private readonly _deviceInputSystem;
  49935. /**
  49936. * Default Constructor
  49937. * @param engine engine to pull input element from
  49938. */
  49939. constructor(engine: Engine);
  49940. /**
  49941. * Gets a DeviceSource, given a type and slot
  49942. * @param deviceType Enum specifying device type
  49943. * @param deviceSlot "Slot" or index that device is referenced in
  49944. * @returns DeviceSource object
  49945. */
  49946. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  49947. /**
  49948. * Gets an array of DeviceSource objects for a given device type
  49949. * @param deviceType Enum specifying device type
  49950. * @returns Array of DeviceSource objects
  49951. */
  49952. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  49953. /**
  49954. * Dispose of DeviceInputSystem and other parts
  49955. */
  49956. dispose(): void;
  49957. /**
  49958. * Function to add device name to device list
  49959. * @param deviceType Enum specifying device type
  49960. * @param deviceSlot "Slot" or index that device is referenced in
  49961. */
  49962. private _addDevice;
  49963. /**
  49964. * Function to remove device name to device list
  49965. * @param deviceType Enum specifying device type
  49966. * @param deviceSlot "Slot" or index that device is referenced in
  49967. */
  49968. private _removeDevice;
  49969. /**
  49970. * Updates array storing first connected device of each type
  49971. * @param type Type of Device
  49972. */
  49973. private _updateFirstDevices;
  49974. }
  49975. }
  49976. declare module BABYLON {
  49977. /**
  49978. * Options to create the null engine
  49979. */
  49980. export class NullEngineOptions {
  49981. /**
  49982. * Render width (Default: 512)
  49983. */
  49984. renderWidth: number;
  49985. /**
  49986. * Render height (Default: 256)
  49987. */
  49988. renderHeight: number;
  49989. /**
  49990. * Texture size (Default: 512)
  49991. */
  49992. textureSize: number;
  49993. /**
  49994. * If delta time between frames should be constant
  49995. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49996. */
  49997. deterministicLockstep: boolean;
  49998. /**
  49999. * Maximum about of steps between frames (Default: 4)
  50000. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50001. */
  50002. lockstepMaxSteps: number;
  50003. }
  50004. /**
  50005. * The null engine class provides support for headless version of babylon.js.
  50006. * This can be used in server side scenario or for testing purposes
  50007. */
  50008. export class NullEngine extends Engine {
  50009. private _options;
  50010. /**
  50011. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  50012. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50013. * @returns true if engine is in deterministic lock step mode
  50014. */
  50015. isDeterministicLockStep(): boolean;
  50016. /**
  50017. * Gets the max steps when engine is running in deterministic lock step
  50018. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50019. * @returns the max steps
  50020. */
  50021. getLockstepMaxSteps(): number;
  50022. /**
  50023. * Gets the current hardware scaling level.
  50024. * By default the hardware scaling level is computed from the window device ratio.
  50025. * 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.
  50026. * @returns a number indicating the current hardware scaling level
  50027. */
  50028. getHardwareScalingLevel(): number;
  50029. constructor(options?: NullEngineOptions);
  50030. /**
  50031. * Creates a vertex buffer
  50032. * @param vertices the data for the vertex buffer
  50033. * @returns the new WebGL static buffer
  50034. */
  50035. createVertexBuffer(vertices: FloatArray): DataBuffer;
  50036. /**
  50037. * Creates a new index buffer
  50038. * @param indices defines the content of the index buffer
  50039. * @param updatable defines if the index buffer must be updatable
  50040. * @returns a new webGL buffer
  50041. */
  50042. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50043. /**
  50044. * Clear the current render buffer or the current render target (if any is set up)
  50045. * @param color defines the color to use
  50046. * @param backBuffer defines if the back buffer must be cleared
  50047. * @param depth defines if the depth buffer must be cleared
  50048. * @param stencil defines if the stencil buffer must be cleared
  50049. */
  50050. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50051. /**
  50052. * Gets the current render width
  50053. * @param useScreen defines if screen size must be used (or the current render target if any)
  50054. * @returns a number defining the current render width
  50055. */
  50056. getRenderWidth(useScreen?: boolean): number;
  50057. /**
  50058. * Gets the current render height
  50059. * @param useScreen defines if screen size must be used (or the current render target if any)
  50060. * @returns a number defining the current render height
  50061. */
  50062. getRenderHeight(useScreen?: boolean): number;
  50063. /**
  50064. * Set the WebGL's viewport
  50065. * @param viewport defines the viewport element to be used
  50066. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50067. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50068. */
  50069. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50070. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50071. /**
  50072. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50073. * @param pipelineContext defines the pipeline context to use
  50074. * @param uniformsNames defines the list of uniform names
  50075. * @returns an array of webGL uniform locations
  50076. */
  50077. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50078. /**
  50079. * Gets the lsit of active attributes for a given webGL program
  50080. * @param pipelineContext defines the pipeline context to use
  50081. * @param attributesNames defines the list of attribute names to get
  50082. * @returns an array of indices indicating the offset of each attribute
  50083. */
  50084. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50085. /**
  50086. * Binds an effect to the webGL context
  50087. * @param effect defines the effect to bind
  50088. */
  50089. bindSamplers(effect: Effect): void;
  50090. /**
  50091. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50092. * @param effect defines the effect to activate
  50093. */
  50094. enableEffect(effect: Effect): void;
  50095. /**
  50096. * Set various states to the webGL context
  50097. * @param culling defines backface culling state
  50098. * @param zOffset defines the value to apply to zOffset (0 by default)
  50099. * @param force defines if states must be applied even if cache is up to date
  50100. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50101. */
  50102. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50103. /**
  50104. * Set the value of an uniform to an array of int32
  50105. * @param uniform defines the webGL uniform location where to store the value
  50106. * @param array defines the array of int32 to store
  50107. */
  50108. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50109. /**
  50110. * Set the value of an uniform to an array of int32 (stored as vec2)
  50111. * @param uniform defines the webGL uniform location where to store the value
  50112. * @param array defines the array of int32 to store
  50113. */
  50114. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50115. /**
  50116. * Set the value of an uniform to an array of int32 (stored as vec3)
  50117. * @param uniform defines the webGL uniform location where to store the value
  50118. * @param array defines the array of int32 to store
  50119. */
  50120. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50121. /**
  50122. * Set the value of an uniform to an array of int32 (stored as vec4)
  50123. * @param uniform defines the webGL uniform location where to store the value
  50124. * @param array defines the array of int32 to store
  50125. */
  50126. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50127. /**
  50128. * Set the value of an uniform to an array of float32
  50129. * @param uniform defines the webGL uniform location where to store the value
  50130. * @param array defines the array of float32 to store
  50131. */
  50132. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50133. /**
  50134. * Set the value of an uniform to an array of float32 (stored as vec2)
  50135. * @param uniform defines the webGL uniform location where to store the value
  50136. * @param array defines the array of float32 to store
  50137. */
  50138. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50139. /**
  50140. * Set the value of an uniform to an array of float32 (stored as vec3)
  50141. * @param uniform defines the webGL uniform location where to store the value
  50142. * @param array defines the array of float32 to store
  50143. */
  50144. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50145. /**
  50146. * Set the value of an uniform to an array of float32 (stored as vec4)
  50147. * @param uniform defines the webGL uniform location where to store the value
  50148. * @param array defines the array of float32 to store
  50149. */
  50150. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50151. /**
  50152. * Set the value of an uniform to an array of number
  50153. * @param uniform defines the webGL uniform location where to store the value
  50154. * @param array defines the array of number to store
  50155. */
  50156. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50157. /**
  50158. * Set the value of an uniform to an array of number (stored as vec2)
  50159. * @param uniform defines the webGL uniform location where to store the value
  50160. * @param array defines the array of number to store
  50161. */
  50162. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50163. /**
  50164. * Set the value of an uniform to an array of number (stored as vec3)
  50165. * @param uniform defines the webGL uniform location where to store the value
  50166. * @param array defines the array of number to store
  50167. */
  50168. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50169. /**
  50170. * Set the value of an uniform to an array of number (stored as vec4)
  50171. * @param uniform defines the webGL uniform location where to store the value
  50172. * @param array defines the array of number to store
  50173. */
  50174. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50175. /**
  50176. * Set the value of an uniform to an array of float32 (stored as matrices)
  50177. * @param uniform defines the webGL uniform location where to store the value
  50178. * @param matrices defines the array of float32 to store
  50179. */
  50180. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50181. /**
  50182. * Set the value of an uniform to a matrix (3x3)
  50183. * @param uniform defines the webGL uniform location where to store the value
  50184. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50185. */
  50186. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50187. /**
  50188. * Set the value of an uniform to a matrix (2x2)
  50189. * @param uniform defines the webGL uniform location where to store the value
  50190. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50191. */
  50192. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50193. /**
  50194. * Set the value of an uniform to a number (float)
  50195. * @param uniform defines the webGL uniform location where to store the value
  50196. * @param value defines the float number to store
  50197. */
  50198. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50199. /**
  50200. * Set the value of an uniform to a vec2
  50201. * @param uniform defines the webGL uniform location where to store the value
  50202. * @param x defines the 1st component of the value
  50203. * @param y defines the 2nd component of the value
  50204. */
  50205. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50206. /**
  50207. * Set the value of an uniform to a vec3
  50208. * @param uniform defines the webGL uniform location where to store the value
  50209. * @param x defines the 1st component of the value
  50210. * @param y defines the 2nd component of the value
  50211. * @param z defines the 3rd component of the value
  50212. */
  50213. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50214. /**
  50215. * Set the value of an uniform to a boolean
  50216. * @param uniform defines the webGL uniform location where to store the value
  50217. * @param bool defines the boolean to store
  50218. */
  50219. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50220. /**
  50221. * Set the value of an uniform to a vec4
  50222. * @param uniform defines the webGL uniform location where to store the value
  50223. * @param x defines the 1st component of the value
  50224. * @param y defines the 2nd component of the value
  50225. * @param z defines the 3rd component of the value
  50226. * @param w defines the 4th component of the value
  50227. */
  50228. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50229. /**
  50230. * Sets the current alpha mode
  50231. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50232. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50233. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50234. */
  50235. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50236. /**
  50237. * Bind webGl buffers directly to the webGL context
  50238. * @param vertexBuffers defines the vertex buffer to bind
  50239. * @param indexBuffer defines the index buffer to bind
  50240. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50241. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50242. * @param effect defines the effect associated with the vertex buffer
  50243. */
  50244. bindBuffers(vertexBuffers: {
  50245. [key: string]: VertexBuffer;
  50246. }, indexBuffer: DataBuffer, effect: Effect): void;
  50247. /**
  50248. * Force the entire cache to be cleared
  50249. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50250. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50251. */
  50252. wipeCaches(bruteForce?: boolean): void;
  50253. /**
  50254. * Send a draw order
  50255. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50256. * @param indexStart defines the starting index
  50257. * @param indexCount defines the number of index to draw
  50258. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50259. */
  50260. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50261. /**
  50262. * Draw a list of indexed primitives
  50263. * @param fillMode defines the primitive to use
  50264. * @param indexStart defines the starting index
  50265. * @param indexCount defines the number of index to draw
  50266. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50267. */
  50268. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50269. /**
  50270. * Draw a list of unindexed primitives
  50271. * @param fillMode defines the primitive to use
  50272. * @param verticesStart defines the index of first vertex to draw
  50273. * @param verticesCount defines the count of vertices to draw
  50274. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50275. */
  50276. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50277. /** @hidden */
  50278. _createTexture(): WebGLTexture;
  50279. /** @hidden */
  50280. _releaseTexture(texture: InternalTexture): void;
  50281. /**
  50282. * Usually called from Texture.ts.
  50283. * Passed information to create a WebGLTexture
  50284. * @param urlArg defines a value which contains one of the following:
  50285. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50286. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50287. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50288. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50289. * @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)
  50290. * @param scene needed for loading to the correct scene
  50291. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50292. * @param onLoad optional callback to be called upon successful completion
  50293. * @param onError optional callback to be called upon failure
  50294. * @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
  50295. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50296. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50297. * @param forcedExtension defines the extension to use to pick the right loader
  50298. * @param mimeType defines an optional mime type
  50299. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50300. */
  50301. 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;
  50302. /**
  50303. * Creates a new render target texture
  50304. * @param size defines the size of the texture
  50305. * @param options defines the options used to create the texture
  50306. * @returns a new render target texture stored in an InternalTexture
  50307. */
  50308. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50309. /**
  50310. * Update the sampling mode of a given texture
  50311. * @param samplingMode defines the required sampling mode
  50312. * @param texture defines the texture to update
  50313. */
  50314. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50315. /**
  50316. * Binds the frame buffer to the specified texture.
  50317. * @param texture The texture to render to or null for the default canvas
  50318. * @param faceIndex The face of the texture to render to in case of cube texture
  50319. * @param requiredWidth The width of the target to render to
  50320. * @param requiredHeight The height of the target to render to
  50321. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50322. * @param lodLevel defines le lod level to bind to the frame buffer
  50323. */
  50324. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50325. /**
  50326. * Unbind the current render target texture from the webGL context
  50327. * @param texture defines the render target texture to unbind
  50328. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50329. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50330. */
  50331. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50332. /**
  50333. * Creates a dynamic vertex buffer
  50334. * @param vertices the data for the dynamic vertex buffer
  50335. * @returns the new WebGL dynamic buffer
  50336. */
  50337. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50338. /**
  50339. * Update the content of a dynamic texture
  50340. * @param texture defines the texture to update
  50341. * @param canvas defines the canvas containing the source
  50342. * @param invertY defines if data must be stored with Y axis inverted
  50343. * @param premulAlpha defines if alpha is stored as premultiplied
  50344. * @param format defines the format of the data
  50345. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50346. */
  50347. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50348. /**
  50349. * Gets a boolean indicating if all created effects are ready
  50350. * @returns true if all effects are ready
  50351. */
  50352. areAllEffectsReady(): boolean;
  50353. /**
  50354. * @hidden
  50355. * Get the current error code of the webGL context
  50356. * @returns the error code
  50357. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50358. */
  50359. getError(): number;
  50360. /** @hidden */
  50361. _getUnpackAlignement(): number;
  50362. /** @hidden */
  50363. _unpackFlipY(value: boolean): void;
  50364. /**
  50365. * Update a dynamic index buffer
  50366. * @param indexBuffer defines the target index buffer
  50367. * @param indices defines the data to update
  50368. * @param offset defines the offset in the target index buffer where update should start
  50369. */
  50370. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50371. /**
  50372. * Updates a dynamic vertex buffer.
  50373. * @param vertexBuffer the vertex buffer to update
  50374. * @param vertices the data used to update the vertex buffer
  50375. * @param byteOffset the byte offset of the data (optional)
  50376. * @param byteLength the byte length of the data (optional)
  50377. */
  50378. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50379. /** @hidden */
  50380. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50381. /** @hidden */
  50382. _bindTexture(channel: number, texture: InternalTexture): void;
  50383. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50384. /**
  50385. * 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
  50386. */
  50387. releaseEffects(): void;
  50388. displayLoadingUI(): void;
  50389. hideLoadingUI(): void;
  50390. /** @hidden */
  50391. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50392. /** @hidden */
  50393. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50394. /** @hidden */
  50395. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50396. /** @hidden */
  50397. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50398. }
  50399. }
  50400. declare module BABYLON {
  50401. /**
  50402. * @hidden
  50403. **/
  50404. export class _TimeToken {
  50405. _startTimeQuery: Nullable<WebGLQuery>;
  50406. _endTimeQuery: Nullable<WebGLQuery>;
  50407. _timeElapsedQuery: Nullable<WebGLQuery>;
  50408. _timeElapsedQueryEnded: boolean;
  50409. }
  50410. }
  50411. declare module BABYLON {
  50412. /** @hidden */
  50413. export class _OcclusionDataStorage {
  50414. /** @hidden */
  50415. occlusionInternalRetryCounter: number;
  50416. /** @hidden */
  50417. isOcclusionQueryInProgress: boolean;
  50418. /** @hidden */
  50419. isOccluded: boolean;
  50420. /** @hidden */
  50421. occlusionRetryCount: number;
  50422. /** @hidden */
  50423. occlusionType: number;
  50424. /** @hidden */
  50425. occlusionQueryAlgorithmType: number;
  50426. }
  50427. interface Engine {
  50428. /**
  50429. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50430. * @return the new query
  50431. */
  50432. createQuery(): WebGLQuery;
  50433. /**
  50434. * Delete and release a webGL query
  50435. * @param query defines the query to delete
  50436. * @return the current engine
  50437. */
  50438. deleteQuery(query: WebGLQuery): Engine;
  50439. /**
  50440. * Check if a given query has resolved and got its value
  50441. * @param query defines the query to check
  50442. * @returns true if the query got its value
  50443. */
  50444. isQueryResultAvailable(query: WebGLQuery): boolean;
  50445. /**
  50446. * Gets the value of a given query
  50447. * @param query defines the query to check
  50448. * @returns the value of the query
  50449. */
  50450. getQueryResult(query: WebGLQuery): number;
  50451. /**
  50452. * Initiates an occlusion query
  50453. * @param algorithmType defines the algorithm to use
  50454. * @param query defines the query to use
  50455. * @returns the current engine
  50456. * @see http://doc.babylonjs.com/features/occlusionquery
  50457. */
  50458. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50459. /**
  50460. * Ends an occlusion query
  50461. * @see http://doc.babylonjs.com/features/occlusionquery
  50462. * @param algorithmType defines the algorithm to use
  50463. * @returns the current engine
  50464. */
  50465. endOcclusionQuery(algorithmType: number): Engine;
  50466. /**
  50467. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50468. * Please note that only one query can be issued at a time
  50469. * @returns a time token used to track the time span
  50470. */
  50471. startTimeQuery(): Nullable<_TimeToken>;
  50472. /**
  50473. * Ends a time query
  50474. * @param token defines the token used to measure the time span
  50475. * @returns the time spent (in ns)
  50476. */
  50477. endTimeQuery(token: _TimeToken): int;
  50478. /** @hidden */
  50479. _currentNonTimestampToken: Nullable<_TimeToken>;
  50480. /** @hidden */
  50481. _createTimeQuery(): WebGLQuery;
  50482. /** @hidden */
  50483. _deleteTimeQuery(query: WebGLQuery): void;
  50484. /** @hidden */
  50485. _getGlAlgorithmType(algorithmType: number): number;
  50486. /** @hidden */
  50487. _getTimeQueryResult(query: WebGLQuery): any;
  50488. /** @hidden */
  50489. _getTimeQueryAvailability(query: WebGLQuery): any;
  50490. }
  50491. interface AbstractMesh {
  50492. /**
  50493. * Backing filed
  50494. * @hidden
  50495. */
  50496. __occlusionDataStorage: _OcclusionDataStorage;
  50497. /**
  50498. * Access property
  50499. * @hidden
  50500. */
  50501. _occlusionDataStorage: _OcclusionDataStorage;
  50502. /**
  50503. * 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.
  50504. * The default value is -1 which means don't break the query and wait till the result
  50505. * @see http://doc.babylonjs.com/features/occlusionquery
  50506. */
  50507. occlusionRetryCount: number;
  50508. /**
  50509. * 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:
  50510. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50511. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50512. * * 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.
  50513. * @see http://doc.babylonjs.com/features/occlusionquery
  50514. */
  50515. occlusionType: number;
  50516. /**
  50517. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50518. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50519. * * 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.
  50520. * @see http://doc.babylonjs.com/features/occlusionquery
  50521. */
  50522. occlusionQueryAlgorithmType: number;
  50523. /**
  50524. * 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
  50525. * @see http://doc.babylonjs.com/features/occlusionquery
  50526. */
  50527. isOccluded: boolean;
  50528. /**
  50529. * Flag to check the progress status of the query
  50530. * @see http://doc.babylonjs.com/features/occlusionquery
  50531. */
  50532. isOcclusionQueryInProgress: boolean;
  50533. }
  50534. }
  50535. declare module BABYLON {
  50536. /** @hidden */
  50537. export var _forceTransformFeedbackToBundle: boolean;
  50538. interface Engine {
  50539. /**
  50540. * Creates a webGL transform feedback object
  50541. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50542. * @returns the webGL transform feedback object
  50543. */
  50544. createTransformFeedback(): WebGLTransformFeedback;
  50545. /**
  50546. * Delete a webGL transform feedback object
  50547. * @param value defines the webGL transform feedback object to delete
  50548. */
  50549. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50550. /**
  50551. * Bind a webGL transform feedback object to the webgl context
  50552. * @param value defines the webGL transform feedback object to bind
  50553. */
  50554. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50555. /**
  50556. * Begins a transform feedback operation
  50557. * @param usePoints defines if points or triangles must be used
  50558. */
  50559. beginTransformFeedback(usePoints: boolean): void;
  50560. /**
  50561. * Ends a transform feedback operation
  50562. */
  50563. endTransformFeedback(): void;
  50564. /**
  50565. * Specify the varyings to use with transform feedback
  50566. * @param program defines the associated webGL program
  50567. * @param value defines the list of strings representing the varying names
  50568. */
  50569. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50570. /**
  50571. * Bind a webGL buffer for a transform feedback operation
  50572. * @param value defines the webGL buffer to bind
  50573. */
  50574. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50575. }
  50576. }
  50577. declare module BABYLON {
  50578. /**
  50579. * Creation options of the multi render target texture.
  50580. */
  50581. export interface IMultiRenderTargetOptions {
  50582. /**
  50583. * Define if the texture needs to create mip maps after render.
  50584. */
  50585. generateMipMaps?: boolean;
  50586. /**
  50587. * Define the types of all the draw buffers we want to create
  50588. */
  50589. types?: number[];
  50590. /**
  50591. * Define the sampling modes of all the draw buffers we want to create
  50592. */
  50593. samplingModes?: number[];
  50594. /**
  50595. * Define if a depth buffer is required
  50596. */
  50597. generateDepthBuffer?: boolean;
  50598. /**
  50599. * Define if a stencil buffer is required
  50600. */
  50601. generateStencilBuffer?: boolean;
  50602. /**
  50603. * Define if a depth texture is required instead of a depth buffer
  50604. */
  50605. generateDepthTexture?: boolean;
  50606. /**
  50607. * Define the number of desired draw buffers
  50608. */
  50609. textureCount?: number;
  50610. /**
  50611. * Define if aspect ratio should be adapted to the texture or stay the scene one
  50612. */
  50613. doNotChangeAspectRatio?: boolean;
  50614. /**
  50615. * Define the default type of the buffers we are creating
  50616. */
  50617. defaultType?: number;
  50618. }
  50619. /**
  50620. * A multi render target, like a render target provides the ability to render to a texture.
  50621. * Unlike the render target, it can render to several draw buffers in one draw.
  50622. * This is specially interesting in deferred rendering or for any effects requiring more than
  50623. * just one color from a single pass.
  50624. */
  50625. export class MultiRenderTarget extends RenderTargetTexture {
  50626. private _internalTextures;
  50627. private _textures;
  50628. private _multiRenderTargetOptions;
  50629. /**
  50630. * Get if draw buffers are currently supported by the used hardware and browser.
  50631. */
  50632. get isSupported(): boolean;
  50633. /**
  50634. * Get the list of textures generated by the multi render target.
  50635. */
  50636. get textures(): Texture[];
  50637. /**
  50638. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  50639. */
  50640. get depthTexture(): Texture;
  50641. /**
  50642. * Set the wrapping mode on U of all the textures we are rendering to.
  50643. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50644. */
  50645. set wrapU(wrap: number);
  50646. /**
  50647. * Set the wrapping mode on V of all the textures we are rendering to.
  50648. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50649. */
  50650. set wrapV(wrap: number);
  50651. /**
  50652. * Instantiate a new multi render target texture.
  50653. * A multi render target, like a render target provides the ability to render to a texture.
  50654. * Unlike the render target, it can render to several draw buffers in one draw.
  50655. * This is specially interesting in deferred rendering or for any effects requiring more than
  50656. * just one color from a single pass.
  50657. * @param name Define the name of the texture
  50658. * @param size Define the size of the buffers to render to
  50659. * @param count Define the number of target we are rendering into
  50660. * @param scene Define the scene the texture belongs to
  50661. * @param options Define the options used to create the multi render target
  50662. */
  50663. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  50664. /** @hidden */
  50665. _rebuild(): void;
  50666. private _createInternalTextures;
  50667. private _createTextures;
  50668. /**
  50669. * Define the number of samples used if MSAA is enabled.
  50670. */
  50671. get samples(): number;
  50672. set samples(value: number);
  50673. /**
  50674. * Resize all the textures in the multi render target.
  50675. * Be carrefull as it will recreate all the data in the new texture.
  50676. * @param size Define the new size
  50677. */
  50678. resize(size: any): void;
  50679. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  50680. /**
  50681. * Dispose the render targets and their associated resources
  50682. */
  50683. dispose(): void;
  50684. /**
  50685. * Release all the underlying texture used as draw buffers.
  50686. */
  50687. releaseInternalTextures(): void;
  50688. }
  50689. }
  50690. declare module BABYLON {
  50691. interface ThinEngine {
  50692. /**
  50693. * Unbind a list of render target textures from the webGL context
  50694. * This is used only when drawBuffer extension or webGL2 are active
  50695. * @param textures defines the render target textures to unbind
  50696. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50697. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50698. */
  50699. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  50700. /**
  50701. * Create a multi render target texture
  50702. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  50703. * @param size defines the size of the texture
  50704. * @param options defines the creation options
  50705. * @returns the cube texture as an InternalTexture
  50706. */
  50707. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  50708. /**
  50709. * Update the sample count for a given multiple render target texture
  50710. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  50711. * @param textures defines the textures to update
  50712. * @param samples defines the sample count to set
  50713. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  50714. */
  50715. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  50716. }
  50717. }
  50718. declare module BABYLON {
  50719. /**
  50720. * Class used to define an additional view for the engine
  50721. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50722. */
  50723. export class EngineView {
  50724. /** Defines the canvas where to render the view */
  50725. target: HTMLCanvasElement;
  50726. /** Defines an optional camera used to render the view (will use active camera else) */
  50727. camera?: Camera;
  50728. }
  50729. interface Engine {
  50730. /**
  50731. * Gets or sets the HTML element to use for attaching events
  50732. */
  50733. inputElement: Nullable<HTMLElement>;
  50734. /**
  50735. * Gets the current engine view
  50736. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50737. */
  50738. activeView: Nullable<EngineView>;
  50739. /** Gets or sets the list of views */
  50740. views: EngineView[];
  50741. /**
  50742. * Register a new child canvas
  50743. * @param canvas defines the canvas to register
  50744. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  50745. * @returns the associated view
  50746. */
  50747. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  50748. /**
  50749. * Remove a registered child canvas
  50750. * @param canvas defines the canvas to remove
  50751. * @returns the current engine
  50752. */
  50753. unRegisterView(canvas: HTMLCanvasElement): Engine;
  50754. }
  50755. }
  50756. declare module BABYLON {
  50757. interface Engine {
  50758. /** @hidden */
  50759. _excludedCompressedTextures: string[];
  50760. /** @hidden */
  50761. _textureFormatInUse: string;
  50762. /**
  50763. * Gets the list of texture formats supported
  50764. */
  50765. readonly texturesSupported: Array<string>;
  50766. /**
  50767. * Gets the texture format in use
  50768. */
  50769. readonly textureFormatInUse: Nullable<string>;
  50770. /**
  50771. * Set the compressed texture extensions or file names to skip.
  50772. *
  50773. * @param skippedFiles defines the list of those texture files you want to skip
  50774. * Example: [".dds", ".env", "myfile.png"]
  50775. */
  50776. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  50777. /**
  50778. * Set the compressed texture format to use, based on the formats you have, and the formats
  50779. * supported by the hardware / browser.
  50780. *
  50781. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  50782. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  50783. * to API arguments needed to compressed textures. This puts the burden on the container
  50784. * generator to house the arcane code for determining these for current & future formats.
  50785. *
  50786. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50787. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50788. *
  50789. * Note: The result of this call is not taken into account when a texture is base64.
  50790. *
  50791. * @param formatsAvailable defines the list of those format families you have created
  50792. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  50793. *
  50794. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  50795. * @returns The extension selected.
  50796. */
  50797. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  50798. }
  50799. }
  50800. declare module BABYLON {
  50801. /**
  50802. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  50803. */
  50804. export interface CubeMapInfo {
  50805. /**
  50806. * The pixel array for the front face.
  50807. * This is stored in format, left to right, up to down format.
  50808. */
  50809. front: Nullable<ArrayBufferView>;
  50810. /**
  50811. * The pixel array for the back face.
  50812. * This is stored in format, left to right, up to down format.
  50813. */
  50814. back: Nullable<ArrayBufferView>;
  50815. /**
  50816. * The pixel array for the left face.
  50817. * This is stored in format, left to right, up to down format.
  50818. */
  50819. left: Nullable<ArrayBufferView>;
  50820. /**
  50821. * The pixel array for the right face.
  50822. * This is stored in format, left to right, up to down format.
  50823. */
  50824. right: Nullable<ArrayBufferView>;
  50825. /**
  50826. * The pixel array for the up face.
  50827. * This is stored in format, left to right, up to down format.
  50828. */
  50829. up: Nullable<ArrayBufferView>;
  50830. /**
  50831. * The pixel array for the down face.
  50832. * This is stored in format, left to right, up to down format.
  50833. */
  50834. down: Nullable<ArrayBufferView>;
  50835. /**
  50836. * The size of the cubemap stored.
  50837. *
  50838. * Each faces will be size * size pixels.
  50839. */
  50840. size: number;
  50841. /**
  50842. * The format of the texture.
  50843. *
  50844. * RGBA, RGB.
  50845. */
  50846. format: number;
  50847. /**
  50848. * The type of the texture data.
  50849. *
  50850. * UNSIGNED_INT, FLOAT.
  50851. */
  50852. type: number;
  50853. /**
  50854. * Specifies whether the texture is in gamma space.
  50855. */
  50856. gammaSpace: boolean;
  50857. }
  50858. /**
  50859. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  50860. */
  50861. export class PanoramaToCubeMapTools {
  50862. private static FACE_LEFT;
  50863. private static FACE_RIGHT;
  50864. private static FACE_FRONT;
  50865. private static FACE_BACK;
  50866. private static FACE_DOWN;
  50867. private static FACE_UP;
  50868. /**
  50869. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50870. *
  50871. * @param float32Array The source data.
  50872. * @param inputWidth The width of the input panorama.
  50873. * @param inputHeight The height of the input panorama.
  50874. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50875. * @return The cubemap data
  50876. */
  50877. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50878. private static CreateCubemapTexture;
  50879. private static CalcProjectionSpherical;
  50880. }
  50881. }
  50882. declare module BABYLON {
  50883. /**
  50884. * Helper class dealing with the extraction of spherical polynomial dataArray
  50885. * from a cube map.
  50886. */
  50887. export class CubeMapToSphericalPolynomialTools {
  50888. private static FileFaces;
  50889. /**
  50890. * Converts a texture to the according Spherical Polynomial data.
  50891. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50892. *
  50893. * @param texture The texture to extract the information from.
  50894. * @return The Spherical Polynomial data.
  50895. */
  50896. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  50897. /**
  50898. * Converts a cubemap to the according Spherical Polynomial data.
  50899. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50900. *
  50901. * @param cubeInfo The Cube map to extract the information from.
  50902. * @return The Spherical Polynomial data.
  50903. */
  50904. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  50905. }
  50906. }
  50907. declare module BABYLON {
  50908. interface BaseTexture {
  50909. /**
  50910. * Get the polynomial representation of the texture data.
  50911. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  50912. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  50913. */
  50914. sphericalPolynomial: Nullable<SphericalPolynomial>;
  50915. }
  50916. }
  50917. declare module BABYLON {
  50918. /** @hidden */
  50919. export var rgbdEncodePixelShader: {
  50920. name: string;
  50921. shader: string;
  50922. };
  50923. }
  50924. declare module BABYLON {
  50925. /** @hidden */
  50926. export var rgbdDecodePixelShader: {
  50927. name: string;
  50928. shader: string;
  50929. };
  50930. }
  50931. declare module BABYLON {
  50932. /**
  50933. * Raw texture data and descriptor sufficient for WebGL texture upload
  50934. */
  50935. export interface EnvironmentTextureInfo {
  50936. /**
  50937. * Version of the environment map
  50938. */
  50939. version: number;
  50940. /**
  50941. * Width of image
  50942. */
  50943. width: number;
  50944. /**
  50945. * Irradiance information stored in the file.
  50946. */
  50947. irradiance: any;
  50948. /**
  50949. * Specular information stored in the file.
  50950. */
  50951. specular: any;
  50952. }
  50953. /**
  50954. * Defines One Image in the file. It requires only the position in the file
  50955. * as well as the length.
  50956. */
  50957. interface BufferImageData {
  50958. /**
  50959. * Length of the image data.
  50960. */
  50961. length: number;
  50962. /**
  50963. * Position of the data from the null terminator delimiting the end of the JSON.
  50964. */
  50965. position: number;
  50966. }
  50967. /**
  50968. * Defines the specular data enclosed in the file.
  50969. * This corresponds to the version 1 of the data.
  50970. */
  50971. export interface EnvironmentTextureSpecularInfoV1 {
  50972. /**
  50973. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  50974. */
  50975. specularDataPosition?: number;
  50976. /**
  50977. * This contains all the images data needed to reconstruct the cubemap.
  50978. */
  50979. mipmaps: Array<BufferImageData>;
  50980. /**
  50981. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  50982. */
  50983. lodGenerationScale: number;
  50984. }
  50985. /**
  50986. * Sets of helpers addressing the serialization and deserialization of environment texture
  50987. * stored in a BabylonJS env file.
  50988. * Those files are usually stored as .env files.
  50989. */
  50990. export class EnvironmentTextureTools {
  50991. /**
  50992. * Magic number identifying the env file.
  50993. */
  50994. private static _MagicBytes;
  50995. /**
  50996. * Gets the environment info from an env file.
  50997. * @param data The array buffer containing the .env bytes.
  50998. * @returns the environment file info (the json header) if successfully parsed.
  50999. */
  51000. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  51001. /**
  51002. * Creates an environment texture from a loaded cube texture.
  51003. * @param texture defines the cube texture to convert in env file
  51004. * @return a promise containing the environment data if succesfull.
  51005. */
  51006. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51007. /**
  51008. * Creates a JSON representation of the spherical data.
  51009. * @param texture defines the texture containing the polynomials
  51010. * @return the JSON representation of the spherical info
  51011. */
  51012. private static _CreateEnvTextureIrradiance;
  51013. /**
  51014. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51015. * @param data the image data
  51016. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51017. * @return the views described by info providing access to the underlying buffer
  51018. */
  51019. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51020. /**
  51021. * Uploads the texture info contained in the env file to the GPU.
  51022. * @param texture defines the internal texture to upload to
  51023. * @param data defines the data to load
  51024. * @param info defines the texture info retrieved through the GetEnvInfo method
  51025. * @returns a promise
  51026. */
  51027. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51028. private static _OnImageReadyAsync;
  51029. /**
  51030. * Uploads the levels of image data to the GPU.
  51031. * @param texture defines the internal texture to upload to
  51032. * @param imageData defines the array buffer views of image data [mipmap][face]
  51033. * @returns a promise
  51034. */
  51035. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51036. /**
  51037. * Uploads spherical polynomials information to the texture.
  51038. * @param texture defines the texture we are trying to upload the information to
  51039. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  51040. */
  51041. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51042. /** @hidden */
  51043. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51044. }
  51045. }
  51046. declare module BABYLON {
  51047. /** @hidden */
  51048. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  51049. private _genericAttributeLocation;
  51050. private _varyingLocationCount;
  51051. private _varyingLocationMap;
  51052. private _replacements;
  51053. private _textureCount;
  51054. private _uniforms;
  51055. lineProcessor(line: string): string;
  51056. attributeProcessor(attribute: string): string;
  51057. varyingProcessor(varying: string, isFragment: boolean): string;
  51058. uniformProcessor(uniform: string): string;
  51059. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  51060. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  51061. }
  51062. }
  51063. declare module BABYLON {
  51064. /**
  51065. * Class used to inline functions in shader code
  51066. */
  51067. export class ShaderCodeInliner {
  51068. private static readonly _RegexpFindFunctionNameAndType;
  51069. private _sourceCode;
  51070. private _functionDescr;
  51071. private _numMaxIterations;
  51072. /** Gets or sets the token used to mark the functions to inline */
  51073. inlineToken: string;
  51074. /** Gets or sets the debug mode */
  51075. debug: boolean;
  51076. /** Gets the code after the inlining process */
  51077. get code(): string;
  51078. /**
  51079. * Initializes the inliner
  51080. * @param sourceCode shader code source to inline
  51081. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51082. */
  51083. constructor(sourceCode: string, numMaxIterations?: number);
  51084. /**
  51085. * Start the processing of the shader code
  51086. */
  51087. processCode(): void;
  51088. private _collectFunctions;
  51089. private _processInlining;
  51090. private _extractBetweenMarkers;
  51091. private _skipWhitespaces;
  51092. private _removeComments;
  51093. private _replaceFunctionCallsByCode;
  51094. private _findBackward;
  51095. private _escapeRegExp;
  51096. private _replaceNames;
  51097. }
  51098. }
  51099. declare module BABYLON {
  51100. /**
  51101. * Container for accessors for natively-stored mesh data buffers.
  51102. */
  51103. class NativeDataBuffer extends DataBuffer {
  51104. /**
  51105. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51106. */
  51107. nativeIndexBuffer?: any;
  51108. /**
  51109. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51110. */
  51111. nativeVertexBuffer?: any;
  51112. }
  51113. /** @hidden */
  51114. class NativeTexture extends InternalTexture {
  51115. getInternalTexture(): InternalTexture;
  51116. getViewCount(): number;
  51117. }
  51118. /** @hidden */
  51119. export class NativeEngine extends Engine {
  51120. private readonly _native;
  51121. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51122. private readonly INVALID_HANDLE;
  51123. getHardwareScalingLevel(): number;
  51124. constructor();
  51125. dispose(): void;
  51126. /**
  51127. * Can be used to override the current requestAnimationFrame requester.
  51128. * @hidden
  51129. */
  51130. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51131. /**
  51132. * Override default engine behavior.
  51133. * @param color
  51134. * @param backBuffer
  51135. * @param depth
  51136. * @param stencil
  51137. */
  51138. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51139. /**
  51140. * Gets host document
  51141. * @returns the host document object
  51142. */
  51143. getHostDocument(): Nullable<Document>;
  51144. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51145. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51146. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51147. recordVertexArrayObject(vertexBuffers: {
  51148. [key: string]: VertexBuffer;
  51149. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51150. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51151. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51152. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51153. /**
  51154. * Draw a list of indexed primitives
  51155. * @param fillMode defines the primitive to use
  51156. * @param indexStart defines the starting index
  51157. * @param indexCount defines the number of index to draw
  51158. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51159. */
  51160. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51161. /**
  51162. * Draw a list of unindexed primitives
  51163. * @param fillMode defines the primitive to use
  51164. * @param verticesStart defines the index of first vertex to draw
  51165. * @param verticesCount defines the count of vertices to draw
  51166. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51167. */
  51168. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51169. createPipelineContext(): IPipelineContext;
  51170. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51171. /** @hidden */
  51172. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51173. /** @hidden */
  51174. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51175. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51176. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51177. protected _setProgram(program: WebGLProgram): void;
  51178. _releaseEffect(effect: Effect): void;
  51179. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51180. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51181. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51182. bindSamplers(effect: Effect): void;
  51183. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51184. getRenderWidth(useScreen?: boolean): number;
  51185. getRenderHeight(useScreen?: boolean): number;
  51186. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51187. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51188. /**
  51189. * Set the z offset to apply to current rendering
  51190. * @param value defines the offset to apply
  51191. */
  51192. setZOffset(value: number): void;
  51193. /**
  51194. * Gets the current value of the zOffset
  51195. * @returns the current zOffset state
  51196. */
  51197. getZOffset(): number;
  51198. /**
  51199. * Enable or disable depth buffering
  51200. * @param enable defines the state to set
  51201. */
  51202. setDepthBuffer(enable: boolean): void;
  51203. /**
  51204. * Gets a boolean indicating if depth writing is enabled
  51205. * @returns the current depth writing state
  51206. */
  51207. getDepthWrite(): boolean;
  51208. /**
  51209. * Enable or disable depth writing
  51210. * @param enable defines the state to set
  51211. */
  51212. setDepthWrite(enable: boolean): void;
  51213. /**
  51214. * Enable or disable color writing
  51215. * @param enable defines the state to set
  51216. */
  51217. setColorWrite(enable: boolean): void;
  51218. /**
  51219. * Gets a boolean indicating if color writing is enabled
  51220. * @returns the current color writing state
  51221. */
  51222. getColorWrite(): boolean;
  51223. /**
  51224. * Sets alpha constants used by some alpha blending modes
  51225. * @param r defines the red component
  51226. * @param g defines the green component
  51227. * @param b defines the blue component
  51228. * @param a defines the alpha component
  51229. */
  51230. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51231. /**
  51232. * Sets the current alpha mode
  51233. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51234. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51235. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51236. */
  51237. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51238. /**
  51239. * Gets the current alpha mode
  51240. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51241. * @returns the current alpha mode
  51242. */
  51243. getAlphaMode(): number;
  51244. setInt(uniform: WebGLUniformLocation, int: number): void;
  51245. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51246. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51247. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51248. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51249. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51250. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51251. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51252. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51253. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51254. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51255. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51256. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51257. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51258. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51259. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51260. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51261. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51262. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51263. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51264. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51265. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51266. wipeCaches(bruteForce?: boolean): void;
  51267. _createTexture(): WebGLTexture;
  51268. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51269. /**
  51270. * Usually called from Texture.ts.
  51271. * Passed information to create a WebGLTexture
  51272. * @param url defines a value which contains one of the following:
  51273. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51274. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51275. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51276. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51277. * @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)
  51278. * @param scene needed for loading to the correct scene
  51279. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51280. * @param onLoad optional callback to be called upon successful completion
  51281. * @param onError optional callback to be called upon failure
  51282. * @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
  51283. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51284. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51285. * @param forcedExtension defines the extension to use to pick the right loader
  51286. * @param mimeType defines an optional mime type
  51287. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51288. */
  51289. 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;
  51290. /**
  51291. * Creates a cube texture
  51292. * @param rootUrl defines the url where the files to load is located
  51293. * @param scene defines the current scene
  51294. * @param files defines the list of files to load (1 per face)
  51295. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51296. * @param onLoad defines an optional callback raised when the texture is loaded
  51297. * @param onError defines an optional callback raised if there is an issue to load the texture
  51298. * @param format defines the format of the data
  51299. * @param forcedExtension defines the extension to use to pick the right loader
  51300. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51301. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51302. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51303. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51304. * @returns the cube texture as an InternalTexture
  51305. */
  51306. 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;
  51307. private _getSamplingFilter;
  51308. private static _GetNativeTextureFormat;
  51309. createRenderTargetTexture(size: number | {
  51310. width: number;
  51311. height: number;
  51312. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51313. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51314. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51315. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51316. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51317. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51318. /**
  51319. * Updates a dynamic vertex buffer.
  51320. * @param vertexBuffer the vertex buffer to update
  51321. * @param data the data used to update the vertex buffer
  51322. * @param byteOffset the byte offset of the data (optional)
  51323. * @param byteLength the byte length of the data (optional)
  51324. */
  51325. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51326. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51327. private _updateAnisotropicLevel;
  51328. private _getAddressMode;
  51329. /** @hidden */
  51330. _bindTexture(channel: number, texture: InternalTexture): void;
  51331. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51332. releaseEffects(): void;
  51333. /** @hidden */
  51334. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51335. /** @hidden */
  51336. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51337. /** @hidden */
  51338. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51339. /** @hidden */
  51340. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51341. }
  51342. }
  51343. declare module BABYLON {
  51344. /**
  51345. * Gather the list of clipboard event types as constants.
  51346. */
  51347. export class ClipboardEventTypes {
  51348. /**
  51349. * The clipboard event is fired when a copy command is active (pressed).
  51350. */
  51351. static readonly COPY: number;
  51352. /**
  51353. * The clipboard event is fired when a cut command is active (pressed).
  51354. */
  51355. static readonly CUT: number;
  51356. /**
  51357. * The clipboard event is fired when a paste command is active (pressed).
  51358. */
  51359. static readonly PASTE: number;
  51360. }
  51361. /**
  51362. * This class is used to store clipboard related info for the onClipboardObservable event.
  51363. */
  51364. export class ClipboardInfo {
  51365. /**
  51366. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51367. */
  51368. type: number;
  51369. /**
  51370. * Defines the related dom event
  51371. */
  51372. event: ClipboardEvent;
  51373. /**
  51374. *Creates an instance of ClipboardInfo.
  51375. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51376. * @param event Defines the related dom event
  51377. */
  51378. constructor(
  51379. /**
  51380. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51381. */
  51382. type: number,
  51383. /**
  51384. * Defines the related dom event
  51385. */
  51386. event: ClipboardEvent);
  51387. /**
  51388. * Get the clipboard event's type from the keycode.
  51389. * @param keyCode Defines the keyCode for the current keyboard event.
  51390. * @return {number}
  51391. */
  51392. static GetTypeFromCharacter(keyCode: number): number;
  51393. }
  51394. }
  51395. declare module BABYLON {
  51396. /**
  51397. * Google Daydream controller
  51398. */
  51399. export class DaydreamController extends WebVRController {
  51400. /**
  51401. * Base Url for the controller model.
  51402. */
  51403. static MODEL_BASE_URL: string;
  51404. /**
  51405. * File name for the controller model.
  51406. */
  51407. static MODEL_FILENAME: string;
  51408. /**
  51409. * Gamepad Id prefix used to identify Daydream Controller.
  51410. */
  51411. static readonly GAMEPAD_ID_PREFIX: string;
  51412. /**
  51413. * Creates a new DaydreamController from a gamepad
  51414. * @param vrGamepad the gamepad that the controller should be created from
  51415. */
  51416. constructor(vrGamepad: any);
  51417. /**
  51418. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51419. * @param scene scene in which to add meshes
  51420. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51421. */
  51422. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51423. /**
  51424. * Called once for each button that changed state since the last frame
  51425. * @param buttonIdx Which button index changed
  51426. * @param state New state of the button
  51427. * @param changes Which properties on the state changed since last frame
  51428. */
  51429. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51430. }
  51431. }
  51432. declare module BABYLON {
  51433. /**
  51434. * Gear VR Controller
  51435. */
  51436. export class GearVRController extends WebVRController {
  51437. /**
  51438. * Base Url for the controller model.
  51439. */
  51440. static MODEL_BASE_URL: string;
  51441. /**
  51442. * File name for the controller model.
  51443. */
  51444. static MODEL_FILENAME: string;
  51445. /**
  51446. * Gamepad Id prefix used to identify this controller.
  51447. */
  51448. static readonly GAMEPAD_ID_PREFIX: string;
  51449. private readonly _buttonIndexToObservableNameMap;
  51450. /**
  51451. * Creates a new GearVRController from a gamepad
  51452. * @param vrGamepad the gamepad that the controller should be created from
  51453. */
  51454. constructor(vrGamepad: any);
  51455. /**
  51456. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51457. * @param scene scene in which to add meshes
  51458. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51459. */
  51460. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51461. /**
  51462. * Called once for each button that changed state since the last frame
  51463. * @param buttonIdx Which button index changed
  51464. * @param state New state of the button
  51465. * @param changes Which properties on the state changed since last frame
  51466. */
  51467. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51468. }
  51469. }
  51470. declare module BABYLON {
  51471. /**
  51472. * Generic Controller
  51473. */
  51474. export class GenericController extends WebVRController {
  51475. /**
  51476. * Base Url for the controller model.
  51477. */
  51478. static readonly MODEL_BASE_URL: string;
  51479. /**
  51480. * File name for the controller model.
  51481. */
  51482. static readonly MODEL_FILENAME: string;
  51483. /**
  51484. * Creates a new GenericController from a gamepad
  51485. * @param vrGamepad the gamepad that the controller should be created from
  51486. */
  51487. constructor(vrGamepad: any);
  51488. /**
  51489. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51490. * @param scene scene in which to add meshes
  51491. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51492. */
  51493. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51494. /**
  51495. * Called once for each button that changed state since the last frame
  51496. * @param buttonIdx Which button index changed
  51497. * @param state New state of the button
  51498. * @param changes Which properties on the state changed since last frame
  51499. */
  51500. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51501. }
  51502. }
  51503. declare module BABYLON {
  51504. /**
  51505. * Oculus Touch Controller
  51506. */
  51507. export class OculusTouchController extends WebVRController {
  51508. /**
  51509. * Base Url for the controller model.
  51510. */
  51511. static MODEL_BASE_URL: string;
  51512. /**
  51513. * File name for the left controller model.
  51514. */
  51515. static MODEL_LEFT_FILENAME: string;
  51516. /**
  51517. * File name for the right controller model.
  51518. */
  51519. static MODEL_RIGHT_FILENAME: string;
  51520. /**
  51521. * Base Url for the Quest controller model.
  51522. */
  51523. static QUEST_MODEL_BASE_URL: string;
  51524. /**
  51525. * @hidden
  51526. * If the controllers are running on a device that needs the updated Quest controller models
  51527. */
  51528. static _IsQuest: boolean;
  51529. /**
  51530. * Fired when the secondary trigger on this controller is modified
  51531. */
  51532. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51533. /**
  51534. * Fired when the thumb rest on this controller is modified
  51535. */
  51536. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51537. /**
  51538. * Creates a new OculusTouchController from a gamepad
  51539. * @param vrGamepad the gamepad that the controller should be created from
  51540. */
  51541. constructor(vrGamepad: any);
  51542. /**
  51543. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51544. * @param scene scene in which to add meshes
  51545. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51546. */
  51547. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51548. /**
  51549. * Fired when the A button on this controller is modified
  51550. */
  51551. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51552. /**
  51553. * Fired when the B button on this controller is modified
  51554. */
  51555. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51556. /**
  51557. * Fired when the X button on this controller is modified
  51558. */
  51559. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51560. /**
  51561. * Fired when the Y button on this controller is modified
  51562. */
  51563. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51564. /**
  51565. * Called once for each button that changed state since the last frame
  51566. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51567. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51568. * 2) secondary trigger (same)
  51569. * 3) A (right) X (left), touch, pressed = value
  51570. * 4) B / Y
  51571. * 5) thumb rest
  51572. * @param buttonIdx Which button index changed
  51573. * @param state New state of the button
  51574. * @param changes Which properties on the state changed since last frame
  51575. */
  51576. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51577. }
  51578. }
  51579. declare module BABYLON {
  51580. /**
  51581. * Vive Controller
  51582. */
  51583. export class ViveController extends WebVRController {
  51584. /**
  51585. * Base Url for the controller model.
  51586. */
  51587. static MODEL_BASE_URL: string;
  51588. /**
  51589. * File name for the controller model.
  51590. */
  51591. static MODEL_FILENAME: string;
  51592. /**
  51593. * Creates a new ViveController from a gamepad
  51594. * @param vrGamepad the gamepad that the controller should be created from
  51595. */
  51596. constructor(vrGamepad: any);
  51597. /**
  51598. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51599. * @param scene scene in which to add meshes
  51600. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51601. */
  51602. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51603. /**
  51604. * Fired when the left button on this controller is modified
  51605. */
  51606. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51607. /**
  51608. * Fired when the right button on this controller is modified
  51609. */
  51610. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51611. /**
  51612. * Fired when the menu button on this controller is modified
  51613. */
  51614. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51615. /**
  51616. * Called once for each button that changed state since the last frame
  51617. * Vive mapping:
  51618. * 0: touchpad
  51619. * 1: trigger
  51620. * 2: left AND right buttons
  51621. * 3: menu button
  51622. * @param buttonIdx Which button index changed
  51623. * @param state New state of the button
  51624. * @param changes Which properties on the state changed since last frame
  51625. */
  51626. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51627. }
  51628. }
  51629. declare module BABYLON {
  51630. /**
  51631. * Defines the WindowsMotionController object that the state of the windows motion controller
  51632. */
  51633. export class WindowsMotionController extends WebVRController {
  51634. /**
  51635. * The base url used to load the left and right controller models
  51636. */
  51637. static MODEL_BASE_URL: string;
  51638. /**
  51639. * The name of the left controller model file
  51640. */
  51641. static MODEL_LEFT_FILENAME: string;
  51642. /**
  51643. * The name of the right controller model file
  51644. */
  51645. static MODEL_RIGHT_FILENAME: string;
  51646. /**
  51647. * The controller name prefix for this controller type
  51648. */
  51649. static readonly GAMEPAD_ID_PREFIX: string;
  51650. /**
  51651. * The controller id pattern for this controller type
  51652. */
  51653. private static readonly GAMEPAD_ID_PATTERN;
  51654. private _loadedMeshInfo;
  51655. protected readonly _mapping: {
  51656. buttons: string[];
  51657. buttonMeshNames: {
  51658. trigger: string;
  51659. menu: string;
  51660. grip: string;
  51661. thumbstick: string;
  51662. trackpad: string;
  51663. };
  51664. buttonObservableNames: {
  51665. trigger: string;
  51666. menu: string;
  51667. grip: string;
  51668. thumbstick: string;
  51669. trackpad: string;
  51670. };
  51671. axisMeshNames: string[];
  51672. pointingPoseMeshName: string;
  51673. };
  51674. /**
  51675. * Fired when the trackpad on this controller is clicked
  51676. */
  51677. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51678. /**
  51679. * Fired when the trackpad on this controller is modified
  51680. */
  51681. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51682. /**
  51683. * The current x and y values of this controller's trackpad
  51684. */
  51685. trackpad: StickValues;
  51686. /**
  51687. * Creates a new WindowsMotionController from a gamepad
  51688. * @param vrGamepad the gamepad that the controller should be created from
  51689. */
  51690. constructor(vrGamepad: any);
  51691. /**
  51692. * Fired when the trigger on this controller is modified
  51693. */
  51694. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51695. /**
  51696. * Fired when the menu button on this controller is modified
  51697. */
  51698. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51699. /**
  51700. * Fired when the grip button on this controller is modified
  51701. */
  51702. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51703. /**
  51704. * Fired when the thumbstick button on this controller is modified
  51705. */
  51706. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51707. /**
  51708. * Fired when the touchpad button on this controller is modified
  51709. */
  51710. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51711. /**
  51712. * Fired when the touchpad values on this controller are modified
  51713. */
  51714. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  51715. protected _updateTrackpad(): void;
  51716. /**
  51717. * Called once per frame by the engine.
  51718. */
  51719. update(): void;
  51720. /**
  51721. * Called once for each button that changed state since the last frame
  51722. * @param buttonIdx Which button index changed
  51723. * @param state New state of the button
  51724. * @param changes Which properties on the state changed since last frame
  51725. */
  51726. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51727. /**
  51728. * Moves the buttons on the controller mesh based on their current state
  51729. * @param buttonName the name of the button to move
  51730. * @param buttonValue the value of the button which determines the buttons new position
  51731. */
  51732. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  51733. /**
  51734. * Moves the axis on the controller mesh based on its current state
  51735. * @param axis the index of the axis
  51736. * @param axisValue the value of the axis which determines the meshes new position
  51737. * @hidden
  51738. */
  51739. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  51740. /**
  51741. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51742. * @param scene scene in which to add meshes
  51743. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51744. */
  51745. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  51746. /**
  51747. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  51748. * can be transformed by button presses and axes values, based on this._mapping.
  51749. *
  51750. * @param scene scene in which the meshes exist
  51751. * @param meshes list of meshes that make up the controller model to process
  51752. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  51753. */
  51754. private processModel;
  51755. private createMeshInfo;
  51756. /**
  51757. * Gets the ray of the controller in the direction the controller is pointing
  51758. * @param length the length the resulting ray should be
  51759. * @returns a ray in the direction the controller is pointing
  51760. */
  51761. getForwardRay(length?: number): Ray;
  51762. /**
  51763. * Disposes of the controller
  51764. */
  51765. dispose(): void;
  51766. }
  51767. /**
  51768. * This class represents a new windows motion controller in XR.
  51769. */
  51770. export class XRWindowsMotionController extends WindowsMotionController {
  51771. /**
  51772. * Changing the original WIndowsMotionController mapping to fir the new mapping
  51773. */
  51774. protected readonly _mapping: {
  51775. buttons: string[];
  51776. buttonMeshNames: {
  51777. trigger: string;
  51778. menu: string;
  51779. grip: string;
  51780. thumbstick: string;
  51781. trackpad: string;
  51782. };
  51783. buttonObservableNames: {
  51784. trigger: string;
  51785. menu: string;
  51786. grip: string;
  51787. thumbstick: string;
  51788. trackpad: string;
  51789. };
  51790. axisMeshNames: string[];
  51791. pointingPoseMeshName: string;
  51792. };
  51793. /**
  51794. * Construct a new XR-Based windows motion controller
  51795. *
  51796. * @param gamepadInfo the gamepad object from the browser
  51797. */
  51798. constructor(gamepadInfo: any);
  51799. /**
  51800. * holds the thumbstick values (X,Y)
  51801. */
  51802. thumbstickValues: StickValues;
  51803. /**
  51804. * Fired when the thumbstick on this controller is clicked
  51805. */
  51806. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  51807. /**
  51808. * Fired when the thumbstick on this controller is modified
  51809. */
  51810. onThumbstickValuesChangedObservable: Observable<StickValues>;
  51811. /**
  51812. * Fired when the touchpad button on this controller is modified
  51813. */
  51814. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51815. /**
  51816. * Fired when the touchpad values on this controller are modified
  51817. */
  51818. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51819. /**
  51820. * Fired when the thumbstick button on this controller is modified
  51821. * here to prevent breaking changes
  51822. */
  51823. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51824. /**
  51825. * updating the thumbstick(!) and not the trackpad.
  51826. * This is named this way due to the difference between WebVR and XR and to avoid
  51827. * changing the parent class.
  51828. */
  51829. protected _updateTrackpad(): void;
  51830. /**
  51831. * Disposes the class with joy
  51832. */
  51833. dispose(): void;
  51834. }
  51835. }
  51836. declare module BABYLON {
  51837. /**
  51838. * Class containing static functions to help procedurally build meshes
  51839. */
  51840. export class PolyhedronBuilder {
  51841. /**
  51842. * Creates a polyhedron mesh
  51843. * * 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
  51844. * * The parameter `size` (positive float, default 1) sets the polygon size
  51845. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51846. * * 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`
  51847. * * 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
  51848. * * 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)`)
  51849. * * 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
  51850. * * 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
  51851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51852. * * 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
  51853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51854. * @param name defines the name of the mesh
  51855. * @param options defines the options used to create the mesh
  51856. * @param scene defines the hosting scene
  51857. * @returns the polyhedron mesh
  51858. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51859. */
  51860. static CreatePolyhedron(name: string, options: {
  51861. type?: number;
  51862. size?: number;
  51863. sizeX?: number;
  51864. sizeY?: number;
  51865. sizeZ?: number;
  51866. custom?: any;
  51867. faceUV?: Vector4[];
  51868. faceColors?: Color4[];
  51869. flat?: boolean;
  51870. updatable?: boolean;
  51871. sideOrientation?: number;
  51872. frontUVs?: Vector4;
  51873. backUVs?: Vector4;
  51874. }, scene?: Nullable<Scene>): Mesh;
  51875. }
  51876. }
  51877. declare module BABYLON {
  51878. /**
  51879. * Gizmo that enables scaling a mesh along 3 axis
  51880. */
  51881. export class ScaleGizmo extends Gizmo {
  51882. /**
  51883. * Internal gizmo used for interactions on the x axis
  51884. */
  51885. xGizmo: AxisScaleGizmo;
  51886. /**
  51887. * Internal gizmo used for interactions on the y axis
  51888. */
  51889. yGizmo: AxisScaleGizmo;
  51890. /**
  51891. * Internal gizmo used for interactions on the z axis
  51892. */
  51893. zGizmo: AxisScaleGizmo;
  51894. /**
  51895. * Internal gizmo used to scale all axis equally
  51896. */
  51897. uniformScaleGizmo: AxisScaleGizmo;
  51898. private _meshAttached;
  51899. private _updateGizmoRotationToMatchAttachedMesh;
  51900. private _snapDistance;
  51901. private _scaleRatio;
  51902. private _uniformScalingMesh;
  51903. private _octahedron;
  51904. private _sensitivity;
  51905. /** Fires an event when any of it's sub gizmos are dragged */
  51906. onDragStartObservable: Observable<unknown>;
  51907. /** Fires an event when any of it's sub gizmos are released from dragging */
  51908. onDragEndObservable: Observable<unknown>;
  51909. get attachedMesh(): Nullable<AbstractMesh>;
  51910. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51911. /**
  51912. * Creates a ScaleGizmo
  51913. * @param gizmoLayer The utility layer the gizmo will be added to
  51914. */
  51915. constructor(gizmoLayer?: UtilityLayerRenderer);
  51916. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51917. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51918. /**
  51919. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51920. */
  51921. set snapDistance(value: number);
  51922. get snapDistance(): number;
  51923. /**
  51924. * Ratio for the scale of the gizmo (Default: 1)
  51925. */
  51926. set scaleRatio(value: number);
  51927. get scaleRatio(): number;
  51928. /**
  51929. * Sensitivity factor for dragging (Default: 1)
  51930. */
  51931. set sensitivity(value: number);
  51932. get sensitivity(): number;
  51933. /**
  51934. * Disposes of the gizmo
  51935. */
  51936. dispose(): void;
  51937. }
  51938. }
  51939. declare module BABYLON {
  51940. /**
  51941. * Single axis scale gizmo
  51942. */
  51943. export class AxisScaleGizmo extends Gizmo {
  51944. /**
  51945. * Drag behavior responsible for the gizmos dragging interactions
  51946. */
  51947. dragBehavior: PointerDragBehavior;
  51948. private _pointerObserver;
  51949. /**
  51950. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51951. */
  51952. snapDistance: number;
  51953. /**
  51954. * Event that fires each time the gizmo snaps to a new location.
  51955. * * snapDistance is the the change in distance
  51956. */
  51957. onSnapObservable: Observable<{
  51958. snapDistance: number;
  51959. }>;
  51960. /**
  51961. * If the scaling operation should be done on all axis (default: false)
  51962. */
  51963. uniformScaling: boolean;
  51964. /**
  51965. * Custom sensitivity value for the drag strength
  51966. */
  51967. sensitivity: number;
  51968. private _isEnabled;
  51969. private _parent;
  51970. private _arrow;
  51971. private _coloredMaterial;
  51972. private _hoverMaterial;
  51973. /**
  51974. * Creates an AxisScaleGizmo
  51975. * @param gizmoLayer The utility layer the gizmo will be added to
  51976. * @param dragAxis The axis which the gizmo will be able to scale on
  51977. * @param color The color of the gizmo
  51978. */
  51979. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  51980. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51981. /**
  51982. * If the gizmo is enabled
  51983. */
  51984. set isEnabled(value: boolean);
  51985. get isEnabled(): boolean;
  51986. /**
  51987. * Disposes of the gizmo
  51988. */
  51989. dispose(): void;
  51990. /**
  51991. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51992. * @param mesh The mesh to replace the default mesh of the gizmo
  51993. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  51994. */
  51995. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  51996. }
  51997. }
  51998. declare module BABYLON {
  51999. /**
  52000. * Bounding box gizmo
  52001. */
  52002. export class BoundingBoxGizmo extends Gizmo {
  52003. private _lineBoundingBox;
  52004. private _rotateSpheresParent;
  52005. private _scaleBoxesParent;
  52006. private _boundingDimensions;
  52007. private _renderObserver;
  52008. private _pointerObserver;
  52009. private _scaleDragSpeed;
  52010. private _tmpQuaternion;
  52011. private _tmpVector;
  52012. private _tmpRotationMatrix;
  52013. /**
  52014. * 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)
  52015. */
  52016. ignoreChildren: boolean;
  52017. /**
  52018. * 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)
  52019. */
  52020. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52021. /**
  52022. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52023. */
  52024. rotationSphereSize: number;
  52025. /**
  52026. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52027. */
  52028. scaleBoxSize: number;
  52029. /**
  52030. * 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)
  52031. */
  52032. fixedDragMeshScreenSize: boolean;
  52033. /**
  52034. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52035. */
  52036. fixedDragMeshScreenSizeDistanceFactor: number;
  52037. /**
  52038. * Fired when a rotation sphere or scale box is dragged
  52039. */
  52040. onDragStartObservable: Observable<{}>;
  52041. /**
  52042. * Fired when a scale box is dragged
  52043. */
  52044. onScaleBoxDragObservable: Observable<{}>;
  52045. /**
  52046. * Fired when a scale box drag is ended
  52047. */
  52048. onScaleBoxDragEndObservable: Observable<{}>;
  52049. /**
  52050. * Fired when a rotation sphere is dragged
  52051. */
  52052. onRotationSphereDragObservable: Observable<{}>;
  52053. /**
  52054. * Fired when a rotation sphere drag is ended
  52055. */
  52056. onRotationSphereDragEndObservable: Observable<{}>;
  52057. /**
  52058. * 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)
  52059. */
  52060. scalePivot: Nullable<Vector3>;
  52061. /**
  52062. * Mesh used as a pivot to rotate the attached mesh
  52063. */
  52064. private _anchorMesh;
  52065. private _existingMeshScale;
  52066. private _dragMesh;
  52067. private pointerDragBehavior;
  52068. private coloredMaterial;
  52069. private hoverColoredMaterial;
  52070. /**
  52071. * Sets the color of the bounding box gizmo
  52072. * @param color the color to set
  52073. */
  52074. setColor(color: Color3): void;
  52075. /**
  52076. * Creates an BoundingBoxGizmo
  52077. * @param gizmoLayer The utility layer the gizmo will be added to
  52078. * @param color The color of the gizmo
  52079. */
  52080. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52081. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52082. private _selectNode;
  52083. /**
  52084. * Updates the bounding box information for the Gizmo
  52085. */
  52086. updateBoundingBox(): void;
  52087. private _updateRotationSpheres;
  52088. private _updateScaleBoxes;
  52089. /**
  52090. * Enables rotation on the specified axis and disables rotation on the others
  52091. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52092. */
  52093. setEnabledRotationAxis(axis: string): void;
  52094. /**
  52095. * Enables/disables scaling
  52096. * @param enable if scaling should be enabled
  52097. * @param homogeneousScaling defines if scaling should only be homogeneous
  52098. */
  52099. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52100. private _updateDummy;
  52101. /**
  52102. * Enables a pointer drag behavior on the bounding box of the gizmo
  52103. */
  52104. enableDragBehavior(): void;
  52105. /**
  52106. * Disposes of the gizmo
  52107. */
  52108. dispose(): void;
  52109. /**
  52110. * 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)
  52111. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52112. * @returns the bounding box mesh with the passed in mesh as a child
  52113. */
  52114. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52115. /**
  52116. * CustomMeshes are not supported by this gizmo
  52117. * @param mesh The mesh to replace the default mesh of the gizmo
  52118. */
  52119. setCustomMesh(mesh: Mesh): void;
  52120. }
  52121. }
  52122. declare module BABYLON {
  52123. /**
  52124. * Single plane rotation gizmo
  52125. */
  52126. export class PlaneRotationGizmo extends Gizmo {
  52127. /**
  52128. * Drag behavior responsible for the gizmos dragging interactions
  52129. */
  52130. dragBehavior: PointerDragBehavior;
  52131. private _pointerObserver;
  52132. /**
  52133. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52134. */
  52135. snapDistance: number;
  52136. /**
  52137. * Event that fires each time the gizmo snaps to a new location.
  52138. * * snapDistance is the the change in distance
  52139. */
  52140. onSnapObservable: Observable<{
  52141. snapDistance: number;
  52142. }>;
  52143. private _isEnabled;
  52144. private _parent;
  52145. /**
  52146. * Creates a PlaneRotationGizmo
  52147. * @param gizmoLayer The utility layer the gizmo will be added to
  52148. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52149. * @param color The color of the gizmo
  52150. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52151. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52152. */
  52153. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52154. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52155. /**
  52156. * If the gizmo is enabled
  52157. */
  52158. set isEnabled(value: boolean);
  52159. get isEnabled(): boolean;
  52160. /**
  52161. * Disposes of the gizmo
  52162. */
  52163. dispose(): void;
  52164. }
  52165. }
  52166. declare module BABYLON {
  52167. /**
  52168. * Gizmo that enables rotating a mesh along 3 axis
  52169. */
  52170. export class RotationGizmo extends Gizmo {
  52171. /**
  52172. * Internal gizmo used for interactions on the x axis
  52173. */
  52174. xGizmo: PlaneRotationGizmo;
  52175. /**
  52176. * Internal gizmo used for interactions on the y axis
  52177. */
  52178. yGizmo: PlaneRotationGizmo;
  52179. /**
  52180. * Internal gizmo used for interactions on the z axis
  52181. */
  52182. zGizmo: PlaneRotationGizmo;
  52183. /** Fires an event when any of it's sub gizmos are dragged */
  52184. onDragStartObservable: Observable<unknown>;
  52185. /** Fires an event when any of it's sub gizmos are released from dragging */
  52186. onDragEndObservable: Observable<unknown>;
  52187. private _meshAttached;
  52188. get attachedMesh(): Nullable<AbstractMesh>;
  52189. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52190. /**
  52191. * Creates a RotationGizmo
  52192. * @param gizmoLayer The utility layer the gizmo will be added to
  52193. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52194. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52195. */
  52196. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52197. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52198. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52199. /**
  52200. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52201. */
  52202. set snapDistance(value: number);
  52203. get snapDistance(): number;
  52204. /**
  52205. * Ratio for the scale of the gizmo (Default: 1)
  52206. */
  52207. set scaleRatio(value: number);
  52208. get scaleRatio(): number;
  52209. /**
  52210. * Disposes of the gizmo
  52211. */
  52212. dispose(): void;
  52213. /**
  52214. * CustomMeshes are not supported by this gizmo
  52215. * @param mesh The mesh to replace the default mesh of the gizmo
  52216. */
  52217. setCustomMesh(mesh: Mesh): void;
  52218. }
  52219. }
  52220. declare module BABYLON {
  52221. /**
  52222. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52223. */
  52224. export class GizmoManager implements IDisposable {
  52225. private scene;
  52226. /**
  52227. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52228. */
  52229. gizmos: {
  52230. positionGizmo: Nullable<PositionGizmo>;
  52231. rotationGizmo: Nullable<RotationGizmo>;
  52232. scaleGizmo: Nullable<ScaleGizmo>;
  52233. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52234. };
  52235. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52236. clearGizmoOnEmptyPointerEvent: boolean;
  52237. /** Fires an event when the manager is attached to a mesh */
  52238. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52239. private _gizmosEnabled;
  52240. private _pointerObserver;
  52241. private _attachedMesh;
  52242. private _boundingBoxColor;
  52243. private _defaultUtilityLayer;
  52244. private _defaultKeepDepthUtilityLayer;
  52245. /**
  52246. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52247. */
  52248. boundingBoxDragBehavior: SixDofDragBehavior;
  52249. /**
  52250. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52251. */
  52252. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52253. /**
  52254. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52255. */
  52256. usePointerToAttachGizmos: boolean;
  52257. /**
  52258. * Utility layer that the bounding box gizmo belongs to
  52259. */
  52260. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52261. /**
  52262. * Utility layer that all gizmos besides bounding box belong to
  52263. */
  52264. get utilityLayer(): UtilityLayerRenderer;
  52265. /**
  52266. * Instatiates a gizmo manager
  52267. * @param scene the scene to overlay the gizmos on top of
  52268. */
  52269. constructor(scene: Scene);
  52270. /**
  52271. * Attaches a set of gizmos to the specified mesh
  52272. * @param mesh The mesh the gizmo's should be attached to
  52273. */
  52274. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52275. /**
  52276. * If the position gizmo is enabled
  52277. */
  52278. set positionGizmoEnabled(value: boolean);
  52279. get positionGizmoEnabled(): boolean;
  52280. /**
  52281. * If the rotation gizmo is enabled
  52282. */
  52283. set rotationGizmoEnabled(value: boolean);
  52284. get rotationGizmoEnabled(): boolean;
  52285. /**
  52286. * If the scale gizmo is enabled
  52287. */
  52288. set scaleGizmoEnabled(value: boolean);
  52289. get scaleGizmoEnabled(): boolean;
  52290. /**
  52291. * If the boundingBox gizmo is enabled
  52292. */
  52293. set boundingBoxGizmoEnabled(value: boolean);
  52294. get boundingBoxGizmoEnabled(): boolean;
  52295. /**
  52296. * Disposes of the gizmo manager
  52297. */
  52298. dispose(): void;
  52299. }
  52300. }
  52301. declare module BABYLON {
  52302. /**
  52303. * A directional light is defined by a direction (what a surprise!).
  52304. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52305. * 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.
  52306. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52307. */
  52308. export class DirectionalLight extends ShadowLight {
  52309. private _shadowFrustumSize;
  52310. /**
  52311. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52312. */
  52313. get shadowFrustumSize(): number;
  52314. /**
  52315. * Specifies a fix frustum size for the shadow generation.
  52316. */
  52317. set shadowFrustumSize(value: number);
  52318. private _shadowOrthoScale;
  52319. /**
  52320. * Gets the shadow projection scale against the optimal computed one.
  52321. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52322. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52323. */
  52324. get shadowOrthoScale(): number;
  52325. /**
  52326. * Sets the shadow projection scale against the optimal computed one.
  52327. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52328. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52329. */
  52330. set shadowOrthoScale(value: number);
  52331. /**
  52332. * Automatically compute the projection matrix to best fit (including all the casters)
  52333. * on each frame.
  52334. */
  52335. autoUpdateExtends: boolean;
  52336. /**
  52337. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52338. * on each frame. autoUpdateExtends must be set to true for this to work
  52339. */
  52340. autoCalcShadowZBounds: boolean;
  52341. private _orthoLeft;
  52342. private _orthoRight;
  52343. private _orthoTop;
  52344. private _orthoBottom;
  52345. /**
  52346. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52347. * The directional light is emitted from everywhere in the given direction.
  52348. * It can cast shadows.
  52349. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52350. * @param name The friendly name of the light
  52351. * @param direction The direction of the light
  52352. * @param scene The scene the light belongs to
  52353. */
  52354. constructor(name: string, direction: Vector3, scene: Scene);
  52355. /**
  52356. * Returns the string "DirectionalLight".
  52357. * @return The class name
  52358. */
  52359. getClassName(): string;
  52360. /**
  52361. * Returns the integer 1.
  52362. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52363. */
  52364. getTypeID(): number;
  52365. /**
  52366. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52367. * Returns the DirectionalLight Shadow projection matrix.
  52368. */
  52369. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52370. /**
  52371. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52372. * Returns the DirectionalLight Shadow projection matrix.
  52373. */
  52374. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52375. /**
  52376. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52377. * Returns the DirectionalLight Shadow projection matrix.
  52378. */
  52379. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52380. protected _buildUniformLayout(): void;
  52381. /**
  52382. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52383. * @param effect The effect to update
  52384. * @param lightIndex The index of the light in the effect to update
  52385. * @returns The directional light
  52386. */
  52387. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52388. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52389. /**
  52390. * Gets the minZ used for shadow according to both the scene and the light.
  52391. *
  52392. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52393. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52394. * @param activeCamera The camera we are returning the min for
  52395. * @returns the depth min z
  52396. */
  52397. getDepthMinZ(activeCamera: Camera): number;
  52398. /**
  52399. * Gets the maxZ used for shadow according to both the scene and the light.
  52400. *
  52401. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52402. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52403. * @param activeCamera The camera we are returning the max for
  52404. * @returns the depth max z
  52405. */
  52406. getDepthMaxZ(activeCamera: Camera): number;
  52407. /**
  52408. * Prepares the list of defines specific to the light type.
  52409. * @param defines the list of defines
  52410. * @param lightIndex defines the index of the light for the effect
  52411. */
  52412. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52413. }
  52414. }
  52415. declare module BABYLON {
  52416. /**
  52417. * Class containing static functions to help procedurally build meshes
  52418. */
  52419. export class HemisphereBuilder {
  52420. /**
  52421. * Creates a hemisphere mesh
  52422. * @param name defines the name of the mesh
  52423. * @param options defines the options used to create the mesh
  52424. * @param scene defines the hosting scene
  52425. * @returns the hemisphere mesh
  52426. */
  52427. static CreateHemisphere(name: string, options: {
  52428. segments?: number;
  52429. diameter?: number;
  52430. sideOrientation?: number;
  52431. }, scene: any): Mesh;
  52432. }
  52433. }
  52434. declare module BABYLON {
  52435. /**
  52436. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52437. * These values define a cone of light starting from the position, emitting toward the direction.
  52438. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52439. * and the exponent defines the speed of the decay of the light with distance (reach).
  52440. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52441. */
  52442. export class SpotLight extends ShadowLight {
  52443. private _angle;
  52444. private _innerAngle;
  52445. private _cosHalfAngle;
  52446. private _lightAngleScale;
  52447. private _lightAngleOffset;
  52448. /**
  52449. * Gets the cone angle of the spot light in Radians.
  52450. */
  52451. get angle(): number;
  52452. /**
  52453. * Sets the cone angle of the spot light in Radians.
  52454. */
  52455. set angle(value: number);
  52456. /**
  52457. * Only used in gltf falloff mode, this defines the angle where
  52458. * the directional falloff will start before cutting at angle which could be seen
  52459. * as outer angle.
  52460. */
  52461. get innerAngle(): number;
  52462. /**
  52463. * Only used in gltf falloff mode, this defines the angle where
  52464. * the directional falloff will start before cutting at angle which could be seen
  52465. * as outer angle.
  52466. */
  52467. set innerAngle(value: number);
  52468. private _shadowAngleScale;
  52469. /**
  52470. * Allows scaling the angle of the light for shadow generation only.
  52471. */
  52472. get shadowAngleScale(): number;
  52473. /**
  52474. * Allows scaling the angle of the light for shadow generation only.
  52475. */
  52476. set shadowAngleScale(value: number);
  52477. /**
  52478. * The light decay speed with the distance from the emission spot.
  52479. */
  52480. exponent: number;
  52481. private _projectionTextureMatrix;
  52482. /**
  52483. * Allows reading the projecton texture
  52484. */
  52485. get projectionTextureMatrix(): Matrix;
  52486. protected _projectionTextureLightNear: number;
  52487. /**
  52488. * Gets the near clip of the Spotlight for texture projection.
  52489. */
  52490. get projectionTextureLightNear(): number;
  52491. /**
  52492. * Sets the near clip of the Spotlight for texture projection.
  52493. */
  52494. set projectionTextureLightNear(value: number);
  52495. protected _projectionTextureLightFar: number;
  52496. /**
  52497. * Gets the far clip of the Spotlight for texture projection.
  52498. */
  52499. get projectionTextureLightFar(): number;
  52500. /**
  52501. * Sets the far clip of the Spotlight for texture projection.
  52502. */
  52503. set projectionTextureLightFar(value: number);
  52504. protected _projectionTextureUpDirection: Vector3;
  52505. /**
  52506. * Gets the Up vector of the Spotlight for texture projection.
  52507. */
  52508. get projectionTextureUpDirection(): Vector3;
  52509. /**
  52510. * Sets the Up vector of the Spotlight for texture projection.
  52511. */
  52512. set projectionTextureUpDirection(value: Vector3);
  52513. private _projectionTexture;
  52514. /**
  52515. * Gets the projection texture of the light.
  52516. */
  52517. get projectionTexture(): Nullable<BaseTexture>;
  52518. /**
  52519. * Sets the projection texture of the light.
  52520. */
  52521. set projectionTexture(value: Nullable<BaseTexture>);
  52522. private _projectionTextureViewLightDirty;
  52523. private _projectionTextureProjectionLightDirty;
  52524. private _projectionTextureDirty;
  52525. private _projectionTextureViewTargetVector;
  52526. private _projectionTextureViewLightMatrix;
  52527. private _projectionTextureProjectionLightMatrix;
  52528. private _projectionTextureScalingMatrix;
  52529. /**
  52530. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52531. * It can cast shadows.
  52532. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52533. * @param name The light friendly name
  52534. * @param position The position of the spot light in the scene
  52535. * @param direction The direction of the light in the scene
  52536. * @param angle The cone angle of the light in Radians
  52537. * @param exponent The light decay speed with the distance from the emission spot
  52538. * @param scene The scene the lights belongs to
  52539. */
  52540. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52541. /**
  52542. * Returns the string "SpotLight".
  52543. * @returns the class name
  52544. */
  52545. getClassName(): string;
  52546. /**
  52547. * Returns the integer 2.
  52548. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52549. */
  52550. getTypeID(): number;
  52551. /**
  52552. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52553. */
  52554. protected _setDirection(value: Vector3): void;
  52555. /**
  52556. * Overrides the position setter to recompute the projection texture view light Matrix.
  52557. */
  52558. protected _setPosition(value: Vector3): void;
  52559. /**
  52560. * 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.
  52561. * Returns the SpotLight.
  52562. */
  52563. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52564. protected _computeProjectionTextureViewLightMatrix(): void;
  52565. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52566. /**
  52567. * Main function for light texture projection matrix computing.
  52568. */
  52569. protected _computeProjectionTextureMatrix(): void;
  52570. protected _buildUniformLayout(): void;
  52571. private _computeAngleValues;
  52572. /**
  52573. * Sets the passed Effect "effect" with the Light textures.
  52574. * @param effect The effect to update
  52575. * @param lightIndex The index of the light in the effect to update
  52576. * @returns The light
  52577. */
  52578. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52579. /**
  52580. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52581. * @param effect The effect to update
  52582. * @param lightIndex The index of the light in the effect to update
  52583. * @returns The spot light
  52584. */
  52585. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52586. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52587. /**
  52588. * Disposes the light and the associated resources.
  52589. */
  52590. dispose(): void;
  52591. /**
  52592. * Prepares the list of defines specific to the light type.
  52593. * @param defines the list of defines
  52594. * @param lightIndex defines the index of the light for the effect
  52595. */
  52596. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52597. }
  52598. }
  52599. declare module BABYLON {
  52600. /**
  52601. * Gizmo that enables viewing a light
  52602. */
  52603. export class LightGizmo extends Gizmo {
  52604. private _lightMesh;
  52605. private _material;
  52606. private _cachedPosition;
  52607. private _cachedForward;
  52608. private _attachedMeshParent;
  52609. /**
  52610. * Creates a LightGizmo
  52611. * @param gizmoLayer The utility layer the gizmo will be added to
  52612. */
  52613. constructor(gizmoLayer?: UtilityLayerRenderer);
  52614. private _light;
  52615. /**
  52616. * The light that the gizmo is attached to
  52617. */
  52618. set light(light: Nullable<Light>);
  52619. get light(): Nullable<Light>;
  52620. /**
  52621. * Gets the material used to render the light gizmo
  52622. */
  52623. get material(): StandardMaterial;
  52624. /**
  52625. * @hidden
  52626. * Updates the gizmo to match the attached mesh's position/rotation
  52627. */
  52628. protected _update(): void;
  52629. private static _Scale;
  52630. /**
  52631. * Creates the lines for a light mesh
  52632. */
  52633. private static _CreateLightLines;
  52634. /**
  52635. * Disposes of the light gizmo
  52636. */
  52637. dispose(): void;
  52638. private static _CreateHemisphericLightMesh;
  52639. private static _CreatePointLightMesh;
  52640. private static _CreateSpotLightMesh;
  52641. private static _CreateDirectionalLightMesh;
  52642. }
  52643. }
  52644. declare module BABYLON {
  52645. /** @hidden */
  52646. export var backgroundFragmentDeclaration: {
  52647. name: string;
  52648. shader: string;
  52649. };
  52650. }
  52651. declare module BABYLON {
  52652. /** @hidden */
  52653. export var backgroundUboDeclaration: {
  52654. name: string;
  52655. shader: string;
  52656. };
  52657. }
  52658. declare module BABYLON {
  52659. /** @hidden */
  52660. export var backgroundPixelShader: {
  52661. name: string;
  52662. shader: string;
  52663. };
  52664. }
  52665. declare module BABYLON {
  52666. /** @hidden */
  52667. export var backgroundVertexDeclaration: {
  52668. name: string;
  52669. shader: string;
  52670. };
  52671. }
  52672. declare module BABYLON {
  52673. /** @hidden */
  52674. export var backgroundVertexShader: {
  52675. name: string;
  52676. shader: string;
  52677. };
  52678. }
  52679. declare module BABYLON {
  52680. /**
  52681. * Background material used to create an efficient environement around your scene.
  52682. */
  52683. export class BackgroundMaterial extends PushMaterial {
  52684. /**
  52685. * Standard reflectance value at parallel view angle.
  52686. */
  52687. static StandardReflectance0: number;
  52688. /**
  52689. * Standard reflectance value at grazing angle.
  52690. */
  52691. static StandardReflectance90: number;
  52692. protected _primaryColor: Color3;
  52693. /**
  52694. * Key light Color (multiply against the environement texture)
  52695. */
  52696. primaryColor: Color3;
  52697. protected __perceptualColor: Nullable<Color3>;
  52698. /**
  52699. * Experimental Internal Use Only.
  52700. *
  52701. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  52702. * This acts as a helper to set the primary color to a more "human friendly" value.
  52703. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  52704. * output color as close as possible from the chosen value.
  52705. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  52706. * part of lighting setup.)
  52707. */
  52708. get _perceptualColor(): Nullable<Color3>;
  52709. set _perceptualColor(value: Nullable<Color3>);
  52710. protected _primaryColorShadowLevel: float;
  52711. /**
  52712. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  52713. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  52714. */
  52715. get primaryColorShadowLevel(): float;
  52716. set primaryColorShadowLevel(value: float);
  52717. protected _primaryColorHighlightLevel: float;
  52718. /**
  52719. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  52720. * The primary color is used at the level chosen to define what the white area would look.
  52721. */
  52722. get primaryColorHighlightLevel(): float;
  52723. set primaryColorHighlightLevel(value: float);
  52724. protected _reflectionTexture: Nullable<BaseTexture>;
  52725. /**
  52726. * Reflection Texture used in the material.
  52727. * Should be author in a specific way for the best result (refer to the documentation).
  52728. */
  52729. reflectionTexture: Nullable<BaseTexture>;
  52730. protected _reflectionBlur: float;
  52731. /**
  52732. * Reflection Texture level of blur.
  52733. *
  52734. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  52735. * texture twice.
  52736. */
  52737. reflectionBlur: float;
  52738. protected _diffuseTexture: Nullable<BaseTexture>;
  52739. /**
  52740. * Diffuse Texture used in the material.
  52741. * Should be author in a specific way for the best result (refer to the documentation).
  52742. */
  52743. diffuseTexture: Nullable<BaseTexture>;
  52744. protected _shadowLights: Nullable<IShadowLight[]>;
  52745. /**
  52746. * Specify the list of lights casting shadow on the material.
  52747. * All scene shadow lights will be included if null.
  52748. */
  52749. shadowLights: Nullable<IShadowLight[]>;
  52750. protected _shadowLevel: float;
  52751. /**
  52752. * Helps adjusting the shadow to a softer level if required.
  52753. * 0 means black shadows and 1 means no shadows.
  52754. */
  52755. shadowLevel: float;
  52756. protected _sceneCenter: Vector3;
  52757. /**
  52758. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52759. * It is usually zero but might be interesting to modify according to your setup.
  52760. */
  52761. sceneCenter: Vector3;
  52762. protected _opacityFresnel: boolean;
  52763. /**
  52764. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52765. * This helps ensuring a nice transition when the camera goes under the ground.
  52766. */
  52767. opacityFresnel: boolean;
  52768. protected _reflectionFresnel: boolean;
  52769. /**
  52770. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  52771. * This helps adding a mirror texture on the ground.
  52772. */
  52773. reflectionFresnel: boolean;
  52774. protected _reflectionFalloffDistance: number;
  52775. /**
  52776. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  52777. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  52778. */
  52779. reflectionFalloffDistance: number;
  52780. protected _reflectionAmount: number;
  52781. /**
  52782. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  52783. */
  52784. reflectionAmount: number;
  52785. protected _reflectionReflectance0: number;
  52786. /**
  52787. * This specifies the weight of the reflection at grazing angle.
  52788. */
  52789. reflectionReflectance0: number;
  52790. protected _reflectionReflectance90: number;
  52791. /**
  52792. * This specifies the weight of the reflection at a perpendicular point of view.
  52793. */
  52794. reflectionReflectance90: number;
  52795. /**
  52796. * Sets the reflection reflectance fresnel values according to the default standard
  52797. * empirically know to work well :-)
  52798. */
  52799. set reflectionStandardFresnelWeight(value: number);
  52800. protected _useRGBColor: boolean;
  52801. /**
  52802. * Helps to directly use the maps channels instead of their level.
  52803. */
  52804. useRGBColor: boolean;
  52805. protected _enableNoise: boolean;
  52806. /**
  52807. * This helps reducing the banding effect that could occur on the background.
  52808. */
  52809. enableNoise: boolean;
  52810. /**
  52811. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52812. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  52813. * Recommended to be keep at 1.0 except for special cases.
  52814. */
  52815. get fovMultiplier(): number;
  52816. set fovMultiplier(value: number);
  52817. private _fovMultiplier;
  52818. /**
  52819. * Enable the FOV adjustment feature controlled by fovMultiplier.
  52820. */
  52821. useEquirectangularFOV: boolean;
  52822. private _maxSimultaneousLights;
  52823. /**
  52824. * Number of Simultaneous lights allowed on the material.
  52825. */
  52826. maxSimultaneousLights: int;
  52827. /**
  52828. * Default configuration related to image processing available in the Background Material.
  52829. */
  52830. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52831. /**
  52832. * Keep track of the image processing observer to allow dispose and replace.
  52833. */
  52834. private _imageProcessingObserver;
  52835. /**
  52836. * Attaches a new image processing configuration to the PBR Material.
  52837. * @param configuration (if null the scene configuration will be use)
  52838. */
  52839. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52840. /**
  52841. * Gets the image processing configuration used either in this material.
  52842. */
  52843. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  52844. /**
  52845. * Sets the Default image processing configuration used either in the this material.
  52846. *
  52847. * If sets to null, the scene one is in use.
  52848. */
  52849. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  52850. /**
  52851. * Gets wether the color curves effect is enabled.
  52852. */
  52853. get cameraColorCurvesEnabled(): boolean;
  52854. /**
  52855. * Sets wether the color curves effect is enabled.
  52856. */
  52857. set cameraColorCurvesEnabled(value: boolean);
  52858. /**
  52859. * Gets wether the color grading effect is enabled.
  52860. */
  52861. get cameraColorGradingEnabled(): boolean;
  52862. /**
  52863. * Gets wether the color grading effect is enabled.
  52864. */
  52865. set cameraColorGradingEnabled(value: boolean);
  52866. /**
  52867. * Gets wether tonemapping is enabled or not.
  52868. */
  52869. get cameraToneMappingEnabled(): boolean;
  52870. /**
  52871. * Sets wether tonemapping is enabled or not
  52872. */
  52873. set cameraToneMappingEnabled(value: boolean);
  52874. /**
  52875. * The camera exposure used on this material.
  52876. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52877. * This corresponds to a photographic exposure.
  52878. */
  52879. get cameraExposure(): float;
  52880. /**
  52881. * The camera exposure used on this material.
  52882. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52883. * This corresponds to a photographic exposure.
  52884. */
  52885. set cameraExposure(value: float);
  52886. /**
  52887. * Gets The camera contrast used on this material.
  52888. */
  52889. get cameraContrast(): float;
  52890. /**
  52891. * Sets The camera contrast used on this material.
  52892. */
  52893. set cameraContrast(value: float);
  52894. /**
  52895. * Gets the Color Grading 2D Lookup Texture.
  52896. */
  52897. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52898. /**
  52899. * Sets the Color Grading 2D Lookup Texture.
  52900. */
  52901. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52902. /**
  52903. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52904. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52905. * 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;
  52906. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52907. */
  52908. get cameraColorCurves(): Nullable<ColorCurves>;
  52909. /**
  52910. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52911. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52912. * 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;
  52913. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52914. */
  52915. set cameraColorCurves(value: Nullable<ColorCurves>);
  52916. /**
  52917. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  52918. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  52919. */
  52920. switchToBGR: boolean;
  52921. private _renderTargets;
  52922. private _reflectionControls;
  52923. private _white;
  52924. private _primaryShadowColor;
  52925. private _primaryHighlightColor;
  52926. /**
  52927. * Instantiates a Background Material in the given scene
  52928. * @param name The friendly name of the material
  52929. * @param scene The scene to add the material to
  52930. */
  52931. constructor(name: string, scene: Scene);
  52932. /**
  52933. * Gets a boolean indicating that current material needs to register RTT
  52934. */
  52935. get hasRenderTargetTextures(): boolean;
  52936. /**
  52937. * The entire material has been created in order to prevent overdraw.
  52938. * @returns false
  52939. */
  52940. needAlphaTesting(): boolean;
  52941. /**
  52942. * The entire material has been created in order to prevent overdraw.
  52943. * @returns true if blending is enable
  52944. */
  52945. needAlphaBlending(): boolean;
  52946. /**
  52947. * Checks wether the material is ready to be rendered for a given mesh.
  52948. * @param mesh The mesh to render
  52949. * @param subMesh The submesh to check against
  52950. * @param useInstances Specify wether or not the material is used with instances
  52951. * @returns true if all the dependencies are ready (Textures, Effects...)
  52952. */
  52953. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52954. /**
  52955. * Compute the primary color according to the chosen perceptual color.
  52956. */
  52957. private _computePrimaryColorFromPerceptualColor;
  52958. /**
  52959. * Compute the highlights and shadow colors according to their chosen levels.
  52960. */
  52961. private _computePrimaryColors;
  52962. /**
  52963. * Build the uniform buffer used in the material.
  52964. */
  52965. buildUniformLayout(): void;
  52966. /**
  52967. * Unbind the material.
  52968. */
  52969. unbind(): void;
  52970. /**
  52971. * Bind only the world matrix to the material.
  52972. * @param world The world matrix to bind.
  52973. */
  52974. bindOnlyWorldMatrix(world: Matrix): void;
  52975. /**
  52976. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52977. * @param world The world matrix to bind.
  52978. * @param subMesh The submesh to bind for.
  52979. */
  52980. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52981. /**
  52982. * Checks to see if a texture is used in the material.
  52983. * @param texture - Base texture to use.
  52984. * @returns - Boolean specifying if a texture is used in the material.
  52985. */
  52986. hasTexture(texture: BaseTexture): boolean;
  52987. /**
  52988. * Dispose the material.
  52989. * @param forceDisposeEffect Force disposal of the associated effect.
  52990. * @param forceDisposeTextures Force disposal of the associated textures.
  52991. */
  52992. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52993. /**
  52994. * Clones the material.
  52995. * @param name The cloned name.
  52996. * @returns The cloned material.
  52997. */
  52998. clone(name: string): BackgroundMaterial;
  52999. /**
  53000. * Serializes the current material to its JSON representation.
  53001. * @returns The JSON representation.
  53002. */
  53003. serialize(): any;
  53004. /**
  53005. * Gets the class name of the material
  53006. * @returns "BackgroundMaterial"
  53007. */
  53008. getClassName(): string;
  53009. /**
  53010. * Parse a JSON input to create back a background material.
  53011. * @param source The JSON data to parse
  53012. * @param scene The scene to create the parsed material in
  53013. * @param rootUrl The root url of the assets the material depends upon
  53014. * @returns the instantiated BackgroundMaterial.
  53015. */
  53016. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53017. }
  53018. }
  53019. declare module BABYLON {
  53020. /**
  53021. * Represents the different options available during the creation of
  53022. * a Environment helper.
  53023. *
  53024. * This can control the default ground, skybox and image processing setup of your scene.
  53025. */
  53026. export interface IEnvironmentHelperOptions {
  53027. /**
  53028. * Specifies whether or not to create a ground.
  53029. * True by default.
  53030. */
  53031. createGround: boolean;
  53032. /**
  53033. * Specifies the ground size.
  53034. * 15 by default.
  53035. */
  53036. groundSize: number;
  53037. /**
  53038. * The texture used on the ground for the main color.
  53039. * Comes from the BabylonJS CDN by default.
  53040. *
  53041. * Remarks: Can be either a texture or a url.
  53042. */
  53043. groundTexture: string | BaseTexture;
  53044. /**
  53045. * The color mixed in the ground texture by default.
  53046. * BabylonJS clearColor by default.
  53047. */
  53048. groundColor: Color3;
  53049. /**
  53050. * Specifies the ground opacity.
  53051. * 1 by default.
  53052. */
  53053. groundOpacity: number;
  53054. /**
  53055. * Enables the ground to receive shadows.
  53056. * True by default.
  53057. */
  53058. enableGroundShadow: boolean;
  53059. /**
  53060. * Helps preventing the shadow to be fully black on the ground.
  53061. * 0.5 by default.
  53062. */
  53063. groundShadowLevel: number;
  53064. /**
  53065. * Creates a mirror texture attach to the ground.
  53066. * false by default.
  53067. */
  53068. enableGroundMirror: boolean;
  53069. /**
  53070. * Specifies the ground mirror size ratio.
  53071. * 0.3 by default as the default kernel is 64.
  53072. */
  53073. groundMirrorSizeRatio: number;
  53074. /**
  53075. * Specifies the ground mirror blur kernel size.
  53076. * 64 by default.
  53077. */
  53078. groundMirrorBlurKernel: number;
  53079. /**
  53080. * Specifies the ground mirror visibility amount.
  53081. * 1 by default
  53082. */
  53083. groundMirrorAmount: number;
  53084. /**
  53085. * Specifies the ground mirror reflectance weight.
  53086. * This uses the standard weight of the background material to setup the fresnel effect
  53087. * of the mirror.
  53088. * 1 by default.
  53089. */
  53090. groundMirrorFresnelWeight: number;
  53091. /**
  53092. * Specifies the ground mirror Falloff distance.
  53093. * This can helps reducing the size of the reflection.
  53094. * 0 by Default.
  53095. */
  53096. groundMirrorFallOffDistance: number;
  53097. /**
  53098. * Specifies the ground mirror texture type.
  53099. * Unsigned Int by Default.
  53100. */
  53101. groundMirrorTextureType: number;
  53102. /**
  53103. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53104. * the shown objects.
  53105. */
  53106. groundYBias: number;
  53107. /**
  53108. * Specifies whether or not to create a skybox.
  53109. * True by default.
  53110. */
  53111. createSkybox: boolean;
  53112. /**
  53113. * Specifies the skybox size.
  53114. * 20 by default.
  53115. */
  53116. skyboxSize: number;
  53117. /**
  53118. * The texture used on the skybox for the main color.
  53119. * Comes from the BabylonJS CDN by default.
  53120. *
  53121. * Remarks: Can be either a texture or a url.
  53122. */
  53123. skyboxTexture: string | BaseTexture;
  53124. /**
  53125. * The color mixed in the skybox texture by default.
  53126. * BabylonJS clearColor by default.
  53127. */
  53128. skyboxColor: Color3;
  53129. /**
  53130. * The background rotation around the Y axis of the scene.
  53131. * This helps aligning the key lights of your scene with the background.
  53132. * 0 by default.
  53133. */
  53134. backgroundYRotation: number;
  53135. /**
  53136. * Compute automatically the size of the elements to best fit with the scene.
  53137. */
  53138. sizeAuto: boolean;
  53139. /**
  53140. * Default position of the rootMesh if autoSize is not true.
  53141. */
  53142. rootPosition: Vector3;
  53143. /**
  53144. * Sets up the image processing in the scene.
  53145. * true by default.
  53146. */
  53147. setupImageProcessing: boolean;
  53148. /**
  53149. * The texture used as your environment texture in the scene.
  53150. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53151. *
  53152. * Remarks: Can be either a texture or a url.
  53153. */
  53154. environmentTexture: string | BaseTexture;
  53155. /**
  53156. * The value of the exposure to apply to the scene.
  53157. * 0.6 by default if setupImageProcessing is true.
  53158. */
  53159. cameraExposure: number;
  53160. /**
  53161. * The value of the contrast to apply to the scene.
  53162. * 1.6 by default if setupImageProcessing is true.
  53163. */
  53164. cameraContrast: number;
  53165. /**
  53166. * Specifies whether or not tonemapping should be enabled in the scene.
  53167. * true by default if setupImageProcessing is true.
  53168. */
  53169. toneMappingEnabled: boolean;
  53170. }
  53171. /**
  53172. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53173. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53174. * It also helps with the default setup of your imageProcessing configuration.
  53175. */
  53176. export class EnvironmentHelper {
  53177. /**
  53178. * Default ground texture URL.
  53179. */
  53180. private static _groundTextureCDNUrl;
  53181. /**
  53182. * Default skybox texture URL.
  53183. */
  53184. private static _skyboxTextureCDNUrl;
  53185. /**
  53186. * Default environment texture URL.
  53187. */
  53188. private static _environmentTextureCDNUrl;
  53189. /**
  53190. * Creates the default options for the helper.
  53191. */
  53192. private static _getDefaultOptions;
  53193. private _rootMesh;
  53194. /**
  53195. * Gets the root mesh created by the helper.
  53196. */
  53197. get rootMesh(): Mesh;
  53198. private _skybox;
  53199. /**
  53200. * Gets the skybox created by the helper.
  53201. */
  53202. get skybox(): Nullable<Mesh>;
  53203. private _skyboxTexture;
  53204. /**
  53205. * Gets the skybox texture created by the helper.
  53206. */
  53207. get skyboxTexture(): Nullable<BaseTexture>;
  53208. private _skyboxMaterial;
  53209. /**
  53210. * Gets the skybox material created by the helper.
  53211. */
  53212. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53213. private _ground;
  53214. /**
  53215. * Gets the ground mesh created by the helper.
  53216. */
  53217. get ground(): Nullable<Mesh>;
  53218. private _groundTexture;
  53219. /**
  53220. * Gets the ground texture created by the helper.
  53221. */
  53222. get groundTexture(): Nullable<BaseTexture>;
  53223. private _groundMirror;
  53224. /**
  53225. * Gets the ground mirror created by the helper.
  53226. */
  53227. get groundMirror(): Nullable<MirrorTexture>;
  53228. /**
  53229. * Gets the ground mirror render list to helps pushing the meshes
  53230. * you wish in the ground reflection.
  53231. */
  53232. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53233. private _groundMaterial;
  53234. /**
  53235. * Gets the ground material created by the helper.
  53236. */
  53237. get groundMaterial(): Nullable<BackgroundMaterial>;
  53238. /**
  53239. * Stores the creation options.
  53240. */
  53241. private readonly _scene;
  53242. private _options;
  53243. /**
  53244. * This observable will be notified with any error during the creation of the environment,
  53245. * mainly texture creation errors.
  53246. */
  53247. onErrorObservable: Observable<{
  53248. message?: string;
  53249. exception?: any;
  53250. }>;
  53251. /**
  53252. * constructor
  53253. * @param options Defines the options we want to customize the helper
  53254. * @param scene The scene to add the material to
  53255. */
  53256. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53257. /**
  53258. * Updates the background according to the new options
  53259. * @param options
  53260. */
  53261. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53262. /**
  53263. * Sets the primary color of all the available elements.
  53264. * @param color the main color to affect to the ground and the background
  53265. */
  53266. setMainColor(color: Color3): void;
  53267. /**
  53268. * Setup the image processing according to the specified options.
  53269. */
  53270. private _setupImageProcessing;
  53271. /**
  53272. * Setup the environment texture according to the specified options.
  53273. */
  53274. private _setupEnvironmentTexture;
  53275. /**
  53276. * Setup the background according to the specified options.
  53277. */
  53278. private _setupBackground;
  53279. /**
  53280. * Get the scene sizes according to the setup.
  53281. */
  53282. private _getSceneSize;
  53283. /**
  53284. * Setup the ground according to the specified options.
  53285. */
  53286. private _setupGround;
  53287. /**
  53288. * Setup the ground material according to the specified options.
  53289. */
  53290. private _setupGroundMaterial;
  53291. /**
  53292. * Setup the ground diffuse texture according to the specified options.
  53293. */
  53294. private _setupGroundDiffuseTexture;
  53295. /**
  53296. * Setup the ground mirror texture according to the specified options.
  53297. */
  53298. private _setupGroundMirrorTexture;
  53299. /**
  53300. * Setup the ground to receive the mirror texture.
  53301. */
  53302. private _setupMirrorInGroundMaterial;
  53303. /**
  53304. * Setup the skybox according to the specified options.
  53305. */
  53306. private _setupSkybox;
  53307. /**
  53308. * Setup the skybox material according to the specified options.
  53309. */
  53310. private _setupSkyboxMaterial;
  53311. /**
  53312. * Setup the skybox reflection texture according to the specified options.
  53313. */
  53314. private _setupSkyboxReflectionTexture;
  53315. private _errorHandler;
  53316. /**
  53317. * Dispose all the elements created by the Helper.
  53318. */
  53319. dispose(): void;
  53320. }
  53321. }
  53322. declare module BABYLON {
  53323. /**
  53324. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53325. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53326. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53327. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53328. */
  53329. export class PhotoDome extends TransformNode {
  53330. /**
  53331. * Define the image as a Monoscopic panoramic 360 image.
  53332. */
  53333. static readonly MODE_MONOSCOPIC: number;
  53334. /**
  53335. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53336. */
  53337. static readonly MODE_TOPBOTTOM: number;
  53338. /**
  53339. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53340. */
  53341. static readonly MODE_SIDEBYSIDE: number;
  53342. private _useDirectMapping;
  53343. /**
  53344. * The texture being displayed on the sphere
  53345. */
  53346. protected _photoTexture: Texture;
  53347. /**
  53348. * Gets or sets the texture being displayed on the sphere
  53349. */
  53350. get photoTexture(): Texture;
  53351. set photoTexture(value: Texture);
  53352. /**
  53353. * Observable raised when an error occured while loading the 360 image
  53354. */
  53355. onLoadErrorObservable: Observable<string>;
  53356. /**
  53357. * The skybox material
  53358. */
  53359. protected _material: BackgroundMaterial;
  53360. /**
  53361. * The surface used for the skybox
  53362. */
  53363. protected _mesh: Mesh;
  53364. /**
  53365. * Gets the mesh used for the skybox.
  53366. */
  53367. get mesh(): Mesh;
  53368. /**
  53369. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53370. * Also see the options.resolution property.
  53371. */
  53372. get fovMultiplier(): number;
  53373. set fovMultiplier(value: number);
  53374. private _imageMode;
  53375. /**
  53376. * Gets or set the current video mode for the video. It can be:
  53377. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53378. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53379. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53380. */
  53381. get imageMode(): number;
  53382. set imageMode(value: number);
  53383. /**
  53384. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53385. * @param name Element's name, child elements will append suffixes for their own names.
  53386. * @param urlsOfPhoto defines the url of the photo to display
  53387. * @param options defines an object containing optional or exposed sub element properties
  53388. * @param onError defines a callback called when an error occured while loading the texture
  53389. */
  53390. constructor(name: string, urlOfPhoto: string, options: {
  53391. resolution?: number;
  53392. size?: number;
  53393. useDirectMapping?: boolean;
  53394. faceForward?: boolean;
  53395. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53396. private _onBeforeCameraRenderObserver;
  53397. private _changeImageMode;
  53398. /**
  53399. * Releases resources associated with this node.
  53400. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53401. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53402. */
  53403. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53404. }
  53405. }
  53406. declare module BABYLON {
  53407. /**
  53408. * Class used to host RGBD texture specific utilities
  53409. */
  53410. export class RGBDTextureTools {
  53411. /**
  53412. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53413. * @param texture the texture to expand.
  53414. */
  53415. static ExpandRGBDTexture(texture: Texture): void;
  53416. }
  53417. }
  53418. declare module BABYLON {
  53419. /**
  53420. * Class used to host texture specific utilities
  53421. */
  53422. export class BRDFTextureTools {
  53423. /**
  53424. * Prevents texture cache collision
  53425. */
  53426. private static _instanceNumber;
  53427. /**
  53428. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53429. * @param scene defines the hosting scene
  53430. * @returns the environment BRDF texture
  53431. */
  53432. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53433. private static _environmentBRDFBase64Texture;
  53434. }
  53435. }
  53436. declare module BABYLON {
  53437. /**
  53438. * @hidden
  53439. */
  53440. export interface IMaterialClearCoatDefines {
  53441. CLEARCOAT: boolean;
  53442. CLEARCOAT_DEFAULTIOR: boolean;
  53443. CLEARCOAT_TEXTURE: boolean;
  53444. CLEARCOAT_TEXTUREDIRECTUV: number;
  53445. CLEARCOAT_BUMP: boolean;
  53446. CLEARCOAT_BUMPDIRECTUV: number;
  53447. CLEARCOAT_TINT: boolean;
  53448. CLEARCOAT_TINT_TEXTURE: boolean;
  53449. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53450. /** @hidden */
  53451. _areTexturesDirty: boolean;
  53452. }
  53453. /**
  53454. * Define the code related to the clear coat parameters of the pbr material.
  53455. */
  53456. export class PBRClearCoatConfiguration {
  53457. /**
  53458. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53459. * The default fits with a polyurethane material.
  53460. */
  53461. private static readonly _DefaultIndexOfRefraction;
  53462. private _isEnabled;
  53463. /**
  53464. * Defines if the clear coat is enabled in the material.
  53465. */
  53466. isEnabled: boolean;
  53467. /**
  53468. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53469. */
  53470. intensity: number;
  53471. /**
  53472. * Defines the clear coat layer roughness.
  53473. */
  53474. roughness: number;
  53475. private _indexOfRefraction;
  53476. /**
  53477. * Defines the index of refraction of the clear coat.
  53478. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53479. * The default fits with a polyurethane material.
  53480. * Changing the default value is more performance intensive.
  53481. */
  53482. indexOfRefraction: number;
  53483. private _texture;
  53484. /**
  53485. * Stores the clear coat values in a texture.
  53486. */
  53487. texture: Nullable<BaseTexture>;
  53488. private _bumpTexture;
  53489. /**
  53490. * Define the clear coat specific bump texture.
  53491. */
  53492. bumpTexture: Nullable<BaseTexture>;
  53493. private _isTintEnabled;
  53494. /**
  53495. * Defines if the clear coat tint is enabled in the material.
  53496. */
  53497. isTintEnabled: boolean;
  53498. /**
  53499. * Defines the clear coat tint of the material.
  53500. * This is only use if tint is enabled
  53501. */
  53502. tintColor: Color3;
  53503. /**
  53504. * Defines the distance at which the tint color should be found in the
  53505. * clear coat media.
  53506. * This is only use if tint is enabled
  53507. */
  53508. tintColorAtDistance: number;
  53509. /**
  53510. * Defines the clear coat layer thickness.
  53511. * This is only use if tint is enabled
  53512. */
  53513. tintThickness: number;
  53514. private _tintTexture;
  53515. /**
  53516. * Stores the clear tint values in a texture.
  53517. * rgb is tint
  53518. * a is a thickness factor
  53519. */
  53520. tintTexture: Nullable<BaseTexture>;
  53521. /** @hidden */
  53522. private _internalMarkAllSubMeshesAsTexturesDirty;
  53523. /** @hidden */
  53524. _markAllSubMeshesAsTexturesDirty(): void;
  53525. /**
  53526. * Instantiate a new istance of clear coat configuration.
  53527. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53528. */
  53529. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53530. /**
  53531. * Gets wehter the submesh is ready to be used or not.
  53532. * @param defines the list of "defines" to update.
  53533. * @param scene defines the scene the material belongs to.
  53534. * @param engine defines the engine the material belongs to.
  53535. * @param disableBumpMap defines wether the material disables bump or not.
  53536. * @returns - boolean indicating that the submesh is ready or not.
  53537. */
  53538. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53539. /**
  53540. * Checks to see if a texture is used in the material.
  53541. * @param defines the list of "defines" to update.
  53542. * @param scene defines the scene to the material belongs to.
  53543. */
  53544. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53545. /**
  53546. * Binds the material data.
  53547. * @param uniformBuffer defines the Uniform buffer to fill in.
  53548. * @param scene defines the scene the material belongs to.
  53549. * @param engine defines the engine the material belongs to.
  53550. * @param disableBumpMap defines wether the material disables bump or not.
  53551. * @param isFrozen defines wether the material is frozen or not.
  53552. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53553. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53554. */
  53555. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53556. /**
  53557. * Checks to see if a texture is used in the material.
  53558. * @param texture - Base texture to use.
  53559. * @returns - Boolean specifying if a texture is used in the material.
  53560. */
  53561. hasTexture(texture: BaseTexture): boolean;
  53562. /**
  53563. * Returns an array of the actively used textures.
  53564. * @param activeTextures Array of BaseTextures
  53565. */
  53566. getActiveTextures(activeTextures: BaseTexture[]): void;
  53567. /**
  53568. * Returns the animatable textures.
  53569. * @param animatables Array of animatable textures.
  53570. */
  53571. getAnimatables(animatables: IAnimatable[]): void;
  53572. /**
  53573. * Disposes the resources of the material.
  53574. * @param forceDisposeTextures - Forces the disposal of all textures.
  53575. */
  53576. dispose(forceDisposeTextures?: boolean): void;
  53577. /**
  53578. * Get the current class name of the texture useful for serialization or dynamic coding.
  53579. * @returns "PBRClearCoatConfiguration"
  53580. */
  53581. getClassName(): string;
  53582. /**
  53583. * Add fallbacks to the effect fallbacks list.
  53584. * @param defines defines the Base texture to use.
  53585. * @param fallbacks defines the current fallback list.
  53586. * @param currentRank defines the current fallback rank.
  53587. * @returns the new fallback rank.
  53588. */
  53589. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53590. /**
  53591. * Add the required uniforms to the current list.
  53592. * @param uniforms defines the current uniform list.
  53593. */
  53594. static AddUniforms(uniforms: string[]): void;
  53595. /**
  53596. * Add the required samplers to the current list.
  53597. * @param samplers defines the current sampler list.
  53598. */
  53599. static AddSamplers(samplers: string[]): void;
  53600. /**
  53601. * Add the required uniforms to the current buffer.
  53602. * @param uniformBuffer defines the current uniform buffer.
  53603. */
  53604. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53605. /**
  53606. * Makes a duplicate of the current configuration into another one.
  53607. * @param clearCoatConfiguration define the config where to copy the info
  53608. */
  53609. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  53610. /**
  53611. * Serializes this clear coat configuration.
  53612. * @returns - An object with the serialized config.
  53613. */
  53614. serialize(): any;
  53615. /**
  53616. * Parses a anisotropy Configuration from a serialized object.
  53617. * @param source - Serialized object.
  53618. * @param scene Defines the scene we are parsing for
  53619. * @param rootUrl Defines the rootUrl to load from
  53620. */
  53621. parse(source: any, scene: Scene, rootUrl: string): void;
  53622. }
  53623. }
  53624. declare module BABYLON {
  53625. /**
  53626. * @hidden
  53627. */
  53628. export interface IMaterialAnisotropicDefines {
  53629. ANISOTROPIC: boolean;
  53630. ANISOTROPIC_TEXTURE: boolean;
  53631. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53632. MAINUV1: boolean;
  53633. _areTexturesDirty: boolean;
  53634. _needUVs: boolean;
  53635. }
  53636. /**
  53637. * Define the code related to the anisotropic parameters of the pbr material.
  53638. */
  53639. export class PBRAnisotropicConfiguration {
  53640. private _isEnabled;
  53641. /**
  53642. * Defines if the anisotropy is enabled in the material.
  53643. */
  53644. isEnabled: boolean;
  53645. /**
  53646. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  53647. */
  53648. intensity: number;
  53649. /**
  53650. * Defines if the effect is along the tangents, bitangents or in between.
  53651. * By default, the effect is "strectching" the highlights along the tangents.
  53652. */
  53653. direction: Vector2;
  53654. private _texture;
  53655. /**
  53656. * Stores the anisotropy values in a texture.
  53657. * rg is direction (like normal from -1 to 1)
  53658. * b is a intensity
  53659. */
  53660. texture: Nullable<BaseTexture>;
  53661. /** @hidden */
  53662. private _internalMarkAllSubMeshesAsTexturesDirty;
  53663. /** @hidden */
  53664. _markAllSubMeshesAsTexturesDirty(): void;
  53665. /**
  53666. * Instantiate a new istance of anisotropy configuration.
  53667. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53668. */
  53669. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53670. /**
  53671. * Specifies that the submesh is ready to be used.
  53672. * @param defines the list of "defines" to update.
  53673. * @param scene defines the scene the material belongs to.
  53674. * @returns - boolean indicating that the submesh is ready or not.
  53675. */
  53676. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  53677. /**
  53678. * Checks to see if a texture is used in the material.
  53679. * @param defines the list of "defines" to update.
  53680. * @param mesh the mesh we are preparing the defines for.
  53681. * @param scene defines the scene the material belongs to.
  53682. */
  53683. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  53684. /**
  53685. * Binds the material data.
  53686. * @param uniformBuffer defines the Uniform buffer to fill in.
  53687. * @param scene defines the scene the material belongs to.
  53688. * @param isFrozen defines wether the material is frozen or not.
  53689. */
  53690. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53691. /**
  53692. * Checks to see if a texture is used in the material.
  53693. * @param texture - Base texture to use.
  53694. * @returns - Boolean specifying if a texture is used in the material.
  53695. */
  53696. hasTexture(texture: BaseTexture): boolean;
  53697. /**
  53698. * Returns an array of the actively used textures.
  53699. * @param activeTextures Array of BaseTextures
  53700. */
  53701. getActiveTextures(activeTextures: BaseTexture[]): void;
  53702. /**
  53703. * Returns the animatable textures.
  53704. * @param animatables Array of animatable textures.
  53705. */
  53706. getAnimatables(animatables: IAnimatable[]): void;
  53707. /**
  53708. * Disposes the resources of the material.
  53709. * @param forceDisposeTextures - Forces the disposal of all textures.
  53710. */
  53711. dispose(forceDisposeTextures?: boolean): void;
  53712. /**
  53713. * Get the current class name of the texture useful for serialization or dynamic coding.
  53714. * @returns "PBRAnisotropicConfiguration"
  53715. */
  53716. getClassName(): string;
  53717. /**
  53718. * Add fallbacks to the effect fallbacks list.
  53719. * @param defines defines the Base texture to use.
  53720. * @param fallbacks defines the current fallback list.
  53721. * @param currentRank defines the current fallback rank.
  53722. * @returns the new fallback rank.
  53723. */
  53724. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53725. /**
  53726. * Add the required uniforms to the current list.
  53727. * @param uniforms defines the current uniform list.
  53728. */
  53729. static AddUniforms(uniforms: string[]): void;
  53730. /**
  53731. * Add the required uniforms to the current buffer.
  53732. * @param uniformBuffer defines the current uniform buffer.
  53733. */
  53734. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53735. /**
  53736. * Add the required samplers to the current list.
  53737. * @param samplers defines the current sampler list.
  53738. */
  53739. static AddSamplers(samplers: string[]): void;
  53740. /**
  53741. * Makes a duplicate of the current configuration into another one.
  53742. * @param anisotropicConfiguration define the config where to copy the info
  53743. */
  53744. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53745. /**
  53746. * Serializes this anisotropy configuration.
  53747. * @returns - An object with the serialized config.
  53748. */
  53749. serialize(): any;
  53750. /**
  53751. * Parses a anisotropy Configuration from a serialized object.
  53752. * @param source - Serialized object.
  53753. * @param scene Defines the scene we are parsing for
  53754. * @param rootUrl Defines the rootUrl to load from
  53755. */
  53756. parse(source: any, scene: Scene, rootUrl: string): void;
  53757. }
  53758. }
  53759. declare module BABYLON {
  53760. /**
  53761. * @hidden
  53762. */
  53763. export interface IMaterialBRDFDefines {
  53764. BRDF_V_HEIGHT_CORRELATED: boolean;
  53765. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53766. SPHERICAL_HARMONICS: boolean;
  53767. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53768. /** @hidden */
  53769. _areMiscDirty: boolean;
  53770. }
  53771. /**
  53772. * Define the code related to the BRDF parameters of the pbr material.
  53773. */
  53774. export class PBRBRDFConfiguration {
  53775. /**
  53776. * Default value used for the energy conservation.
  53777. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53778. */
  53779. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  53780. /**
  53781. * Default value used for the Smith Visibility Height Correlated mode.
  53782. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53783. */
  53784. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  53785. /**
  53786. * Default value used for the IBL diffuse part.
  53787. * This can help switching back to the polynomials mode globally which is a tiny bit
  53788. * less GPU intensive at the drawback of a lower quality.
  53789. */
  53790. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  53791. /**
  53792. * Default value used for activating energy conservation for the specular workflow.
  53793. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53794. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53795. */
  53796. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  53797. private _useEnergyConservation;
  53798. /**
  53799. * Defines if the material uses energy conservation.
  53800. */
  53801. useEnergyConservation: boolean;
  53802. private _useSmithVisibilityHeightCorrelated;
  53803. /**
  53804. * LEGACY Mode set to false
  53805. * Defines if the material uses height smith correlated visibility term.
  53806. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  53807. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53808. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53809. * Not relying on height correlated will also disable energy conservation.
  53810. */
  53811. useSmithVisibilityHeightCorrelated: boolean;
  53812. private _useSphericalHarmonics;
  53813. /**
  53814. * LEGACY Mode set to false
  53815. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53816. * diffuse part of the IBL.
  53817. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53818. * to the ground truth.
  53819. */
  53820. useSphericalHarmonics: boolean;
  53821. private _useSpecularGlossinessInputEnergyConservation;
  53822. /**
  53823. * Defines if the material uses energy conservation, when the specular workflow is active.
  53824. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53825. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53826. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  53827. */
  53828. useSpecularGlossinessInputEnergyConservation: boolean;
  53829. /** @hidden */
  53830. private _internalMarkAllSubMeshesAsMiscDirty;
  53831. /** @hidden */
  53832. _markAllSubMeshesAsMiscDirty(): void;
  53833. /**
  53834. * Instantiate a new istance of clear coat configuration.
  53835. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53836. */
  53837. constructor(markAllSubMeshesAsMiscDirty: () => void);
  53838. /**
  53839. * Checks to see if a texture is used in the material.
  53840. * @param defines the list of "defines" to update.
  53841. */
  53842. prepareDefines(defines: IMaterialBRDFDefines): void;
  53843. /**
  53844. * Get the current class name of the texture useful for serialization or dynamic coding.
  53845. * @returns "PBRClearCoatConfiguration"
  53846. */
  53847. getClassName(): string;
  53848. /**
  53849. * Makes a duplicate of the current configuration into another one.
  53850. * @param brdfConfiguration define the config where to copy the info
  53851. */
  53852. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  53853. /**
  53854. * Serializes this BRDF configuration.
  53855. * @returns - An object with the serialized config.
  53856. */
  53857. serialize(): any;
  53858. /**
  53859. * Parses a anisotropy Configuration from a serialized object.
  53860. * @param source - Serialized object.
  53861. * @param scene Defines the scene we are parsing for
  53862. * @param rootUrl Defines the rootUrl to load from
  53863. */
  53864. parse(source: any, scene: Scene, rootUrl: string): void;
  53865. }
  53866. }
  53867. declare module BABYLON {
  53868. /**
  53869. * @hidden
  53870. */
  53871. export interface IMaterialSheenDefines {
  53872. SHEEN: boolean;
  53873. SHEEN_TEXTURE: boolean;
  53874. SHEEN_TEXTUREDIRECTUV: number;
  53875. SHEEN_LINKWITHALBEDO: boolean;
  53876. SHEEN_ROUGHNESS: boolean;
  53877. SHEEN_ALBEDOSCALING: boolean;
  53878. /** @hidden */
  53879. _areTexturesDirty: boolean;
  53880. }
  53881. /**
  53882. * Define the code related to the Sheen parameters of the pbr material.
  53883. */
  53884. export class PBRSheenConfiguration {
  53885. private _isEnabled;
  53886. /**
  53887. * Defines if the material uses sheen.
  53888. */
  53889. isEnabled: boolean;
  53890. private _linkSheenWithAlbedo;
  53891. /**
  53892. * Defines if the sheen is linked to the sheen color.
  53893. */
  53894. linkSheenWithAlbedo: boolean;
  53895. /**
  53896. * Defines the sheen intensity.
  53897. */
  53898. intensity: number;
  53899. /**
  53900. * Defines the sheen color.
  53901. */
  53902. color: Color3;
  53903. private _texture;
  53904. /**
  53905. * Stores the sheen tint values in a texture.
  53906. * rgb is tint
  53907. * a is a intensity
  53908. */
  53909. texture: Nullable<BaseTexture>;
  53910. private _roughness;
  53911. /**
  53912. * Defines the sheen roughness.
  53913. * It is not taken into account if linkSheenWithAlbedo is true.
  53914. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  53915. */
  53916. roughness: Nullable<number>;
  53917. private _albedoScaling;
  53918. /**
  53919. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  53920. * It allows the strength of the sheen effect to not depend on the base color of the material,
  53921. * making it easier to setup and tweak the effect
  53922. */
  53923. albedoScaling: boolean;
  53924. /** @hidden */
  53925. private _internalMarkAllSubMeshesAsTexturesDirty;
  53926. /** @hidden */
  53927. _markAllSubMeshesAsTexturesDirty(): void;
  53928. /**
  53929. * Instantiate a new istance of clear coat configuration.
  53930. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53931. */
  53932. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53933. /**
  53934. * Specifies that the submesh is ready to be used.
  53935. * @param defines the list of "defines" to update.
  53936. * @param scene defines the scene the material belongs to.
  53937. * @returns - boolean indicating that the submesh is ready or not.
  53938. */
  53939. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  53940. /**
  53941. * Checks to see if a texture is used in the material.
  53942. * @param defines the list of "defines" to update.
  53943. * @param scene defines the scene the material belongs to.
  53944. */
  53945. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  53946. /**
  53947. * Binds the material data.
  53948. * @param uniformBuffer defines the Uniform buffer to fill in.
  53949. * @param scene defines the scene the material belongs to.
  53950. * @param isFrozen defines wether the material is frozen or not.
  53951. */
  53952. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53953. /**
  53954. * Checks to see if a texture is used in the material.
  53955. * @param texture - Base texture to use.
  53956. * @returns - Boolean specifying if a texture is used in the material.
  53957. */
  53958. hasTexture(texture: BaseTexture): boolean;
  53959. /**
  53960. * Returns an array of the actively used textures.
  53961. * @param activeTextures Array of BaseTextures
  53962. */
  53963. getActiveTextures(activeTextures: BaseTexture[]): void;
  53964. /**
  53965. * Returns the animatable textures.
  53966. * @param animatables Array of animatable textures.
  53967. */
  53968. getAnimatables(animatables: IAnimatable[]): void;
  53969. /**
  53970. * Disposes the resources of the material.
  53971. * @param forceDisposeTextures - Forces the disposal of all textures.
  53972. */
  53973. dispose(forceDisposeTextures?: boolean): void;
  53974. /**
  53975. * Get the current class name of the texture useful for serialization or dynamic coding.
  53976. * @returns "PBRSheenConfiguration"
  53977. */
  53978. getClassName(): string;
  53979. /**
  53980. * Add fallbacks to the effect fallbacks list.
  53981. * @param defines defines the Base texture to use.
  53982. * @param fallbacks defines the current fallback list.
  53983. * @param currentRank defines the current fallback rank.
  53984. * @returns the new fallback rank.
  53985. */
  53986. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53987. /**
  53988. * Add the required uniforms to the current list.
  53989. * @param uniforms defines the current uniform list.
  53990. */
  53991. static AddUniforms(uniforms: string[]): void;
  53992. /**
  53993. * Add the required uniforms to the current buffer.
  53994. * @param uniformBuffer defines the current uniform buffer.
  53995. */
  53996. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53997. /**
  53998. * Add the required samplers to the current list.
  53999. * @param samplers defines the current sampler list.
  54000. */
  54001. static AddSamplers(samplers: string[]): void;
  54002. /**
  54003. * Makes a duplicate of the current configuration into another one.
  54004. * @param sheenConfiguration define the config where to copy the info
  54005. */
  54006. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54007. /**
  54008. * Serializes this BRDF configuration.
  54009. * @returns - An object with the serialized config.
  54010. */
  54011. serialize(): any;
  54012. /**
  54013. * Parses a anisotropy Configuration from a serialized object.
  54014. * @param source - Serialized object.
  54015. * @param scene Defines the scene we are parsing for
  54016. * @param rootUrl Defines the rootUrl to load from
  54017. */
  54018. parse(source: any, scene: Scene, rootUrl: string): void;
  54019. }
  54020. }
  54021. declare module BABYLON {
  54022. /**
  54023. * @hidden
  54024. */
  54025. export interface IMaterialSubSurfaceDefines {
  54026. SUBSURFACE: boolean;
  54027. SS_REFRACTION: boolean;
  54028. SS_TRANSLUCENCY: boolean;
  54029. SS_SCATERRING: boolean;
  54030. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54031. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54032. SS_REFRACTIONMAP_3D: boolean;
  54033. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54034. SS_LODINREFRACTIONALPHA: boolean;
  54035. SS_GAMMAREFRACTION: boolean;
  54036. SS_RGBDREFRACTION: boolean;
  54037. SS_LINEARSPECULARREFRACTION: boolean;
  54038. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54039. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54040. /** @hidden */
  54041. _areTexturesDirty: boolean;
  54042. }
  54043. /**
  54044. * Define the code related to the sub surface parameters of the pbr material.
  54045. */
  54046. export class PBRSubSurfaceConfiguration {
  54047. private _isRefractionEnabled;
  54048. /**
  54049. * Defines if the refraction is enabled in the material.
  54050. */
  54051. isRefractionEnabled: boolean;
  54052. private _isTranslucencyEnabled;
  54053. /**
  54054. * Defines if the translucency is enabled in the material.
  54055. */
  54056. isTranslucencyEnabled: boolean;
  54057. private _isScatteringEnabled;
  54058. /**
  54059. * Defines the refraction intensity of the material.
  54060. * The refraction when enabled replaces the Diffuse part of the material.
  54061. * The intensity helps transitionning between diffuse and refraction.
  54062. */
  54063. refractionIntensity: number;
  54064. /**
  54065. * Defines the translucency intensity of the material.
  54066. * When translucency has been enabled, this defines how much of the "translucency"
  54067. * is addded to the diffuse part of the material.
  54068. */
  54069. translucencyIntensity: number;
  54070. /**
  54071. * Defines the scattering intensity of the material.
  54072. * When scattering has been enabled, this defines how much of the "scattered light"
  54073. * is addded to the diffuse part of the material.
  54074. */
  54075. scatteringIntensity: number;
  54076. private _thicknessTexture;
  54077. /**
  54078. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54079. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54080. * 0 would mean minimumThickness
  54081. * 1 would mean maximumThickness
  54082. * The other channels might be use as a mask to vary the different effects intensity.
  54083. */
  54084. thicknessTexture: Nullable<BaseTexture>;
  54085. private _refractionTexture;
  54086. /**
  54087. * Defines the texture to use for refraction.
  54088. */
  54089. refractionTexture: Nullable<BaseTexture>;
  54090. private _indexOfRefraction;
  54091. /**
  54092. * Index of refraction of the material base layer.
  54093. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54094. *
  54095. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54096. *
  54097. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54098. */
  54099. indexOfRefraction: number;
  54100. private _invertRefractionY;
  54101. /**
  54102. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54103. */
  54104. invertRefractionY: boolean;
  54105. private _linkRefractionWithTransparency;
  54106. /**
  54107. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54108. * Materials half opaque for instance using refraction could benefit from this control.
  54109. */
  54110. linkRefractionWithTransparency: boolean;
  54111. /**
  54112. * Defines the minimum thickness stored in the thickness map.
  54113. * If no thickness map is defined, this value will be used to simulate thickness.
  54114. */
  54115. minimumThickness: number;
  54116. /**
  54117. * Defines the maximum thickness stored in the thickness map.
  54118. */
  54119. maximumThickness: number;
  54120. /**
  54121. * Defines the volume tint of the material.
  54122. * This is used for both translucency and scattering.
  54123. */
  54124. tintColor: Color3;
  54125. /**
  54126. * Defines the distance at which the tint color should be found in the media.
  54127. * This is used for refraction only.
  54128. */
  54129. tintColorAtDistance: number;
  54130. /**
  54131. * Defines how far each channel transmit through the media.
  54132. * It is defined as a color to simplify it selection.
  54133. */
  54134. diffusionDistance: Color3;
  54135. private _useMaskFromThicknessTexture;
  54136. /**
  54137. * Stores the intensity of the different subsurface effects in the thickness texture.
  54138. * * the green channel is the translucency intensity.
  54139. * * the blue channel is the scattering intensity.
  54140. * * the alpha channel is the refraction intensity.
  54141. */
  54142. useMaskFromThicknessTexture: boolean;
  54143. /** @hidden */
  54144. private _internalMarkAllSubMeshesAsTexturesDirty;
  54145. /** @hidden */
  54146. _markAllSubMeshesAsTexturesDirty(): void;
  54147. /**
  54148. * Instantiate a new istance of sub surface configuration.
  54149. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54150. */
  54151. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54152. /**
  54153. * Gets wehter the submesh is ready to be used or not.
  54154. * @param defines the list of "defines" to update.
  54155. * @param scene defines the scene the material belongs to.
  54156. * @returns - boolean indicating that the submesh is ready or not.
  54157. */
  54158. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54159. /**
  54160. * Checks to see if a texture is used in the material.
  54161. * @param defines the list of "defines" to update.
  54162. * @param scene defines the scene to the material belongs to.
  54163. */
  54164. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54165. /**
  54166. * Binds the material data.
  54167. * @param uniformBuffer defines the Uniform buffer to fill in.
  54168. * @param scene defines the scene the material belongs to.
  54169. * @param engine defines the engine the material belongs to.
  54170. * @param isFrozen defines whether the material is frozen or not.
  54171. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54172. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54173. */
  54174. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54175. /**
  54176. * Unbinds the material from the mesh.
  54177. * @param activeEffect defines the effect that should be unbound from.
  54178. * @returns true if unbound, otherwise false
  54179. */
  54180. unbind(activeEffect: Effect): boolean;
  54181. /**
  54182. * Returns the texture used for refraction or null if none is used.
  54183. * @param scene defines the scene the material belongs to.
  54184. * @returns - Refraction texture if present. If no refraction texture and refraction
  54185. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54186. */
  54187. private _getRefractionTexture;
  54188. /**
  54189. * Returns true if alpha blending should be disabled.
  54190. */
  54191. get disableAlphaBlending(): boolean;
  54192. /**
  54193. * Fills the list of render target textures.
  54194. * @param renderTargets the list of render targets to update
  54195. */
  54196. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54197. /**
  54198. * Checks to see if a texture is used in the material.
  54199. * @param texture - Base texture to use.
  54200. * @returns - Boolean specifying if a texture is used in the material.
  54201. */
  54202. hasTexture(texture: BaseTexture): boolean;
  54203. /**
  54204. * Gets a boolean indicating that current material needs to register RTT
  54205. * @returns true if this uses a render target otherwise false.
  54206. */
  54207. hasRenderTargetTextures(): boolean;
  54208. /**
  54209. * Returns an array of the actively used textures.
  54210. * @param activeTextures Array of BaseTextures
  54211. */
  54212. getActiveTextures(activeTextures: BaseTexture[]): void;
  54213. /**
  54214. * Returns the animatable textures.
  54215. * @param animatables Array of animatable textures.
  54216. */
  54217. getAnimatables(animatables: IAnimatable[]): void;
  54218. /**
  54219. * Disposes the resources of the material.
  54220. * @param forceDisposeTextures - Forces the disposal of all textures.
  54221. */
  54222. dispose(forceDisposeTextures?: boolean): void;
  54223. /**
  54224. * Get the current class name of the texture useful for serialization or dynamic coding.
  54225. * @returns "PBRSubSurfaceConfiguration"
  54226. */
  54227. getClassName(): string;
  54228. /**
  54229. * Add fallbacks to the effect fallbacks list.
  54230. * @param defines defines the Base texture to use.
  54231. * @param fallbacks defines the current fallback list.
  54232. * @param currentRank defines the current fallback rank.
  54233. * @returns the new fallback rank.
  54234. */
  54235. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54236. /**
  54237. * Add the required uniforms to the current list.
  54238. * @param uniforms defines the current uniform list.
  54239. */
  54240. static AddUniforms(uniforms: string[]): void;
  54241. /**
  54242. * Add the required samplers to the current list.
  54243. * @param samplers defines the current sampler list.
  54244. */
  54245. static AddSamplers(samplers: string[]): void;
  54246. /**
  54247. * Add the required uniforms to the current buffer.
  54248. * @param uniformBuffer defines the current uniform buffer.
  54249. */
  54250. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54251. /**
  54252. * Makes a duplicate of the current configuration into another one.
  54253. * @param configuration define the config where to copy the info
  54254. */
  54255. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54256. /**
  54257. * Serializes this Sub Surface configuration.
  54258. * @returns - An object with the serialized config.
  54259. */
  54260. serialize(): any;
  54261. /**
  54262. * Parses a anisotropy Configuration from a serialized object.
  54263. * @param source - Serialized object.
  54264. * @param scene Defines the scene we are parsing for
  54265. * @param rootUrl Defines the rootUrl to load from
  54266. */
  54267. parse(source: any, scene: Scene, rootUrl: string): void;
  54268. }
  54269. }
  54270. declare module BABYLON {
  54271. /** @hidden */
  54272. export var pbrFragmentDeclaration: {
  54273. name: string;
  54274. shader: string;
  54275. };
  54276. }
  54277. declare module BABYLON {
  54278. /** @hidden */
  54279. export var pbrUboDeclaration: {
  54280. name: string;
  54281. shader: string;
  54282. };
  54283. }
  54284. declare module BABYLON {
  54285. /** @hidden */
  54286. export var pbrFragmentExtraDeclaration: {
  54287. name: string;
  54288. shader: string;
  54289. };
  54290. }
  54291. declare module BABYLON {
  54292. /** @hidden */
  54293. export var pbrFragmentSamplersDeclaration: {
  54294. name: string;
  54295. shader: string;
  54296. };
  54297. }
  54298. declare module BABYLON {
  54299. /** @hidden */
  54300. export var importanceSampling: {
  54301. name: string;
  54302. shader: string;
  54303. };
  54304. }
  54305. declare module BABYLON {
  54306. /** @hidden */
  54307. export var pbrHelperFunctions: {
  54308. name: string;
  54309. shader: string;
  54310. };
  54311. }
  54312. declare module BABYLON {
  54313. /** @hidden */
  54314. export var harmonicsFunctions: {
  54315. name: string;
  54316. shader: string;
  54317. };
  54318. }
  54319. declare module BABYLON {
  54320. /** @hidden */
  54321. export var pbrDirectLightingSetupFunctions: {
  54322. name: string;
  54323. shader: string;
  54324. };
  54325. }
  54326. declare module BABYLON {
  54327. /** @hidden */
  54328. export var pbrDirectLightingFalloffFunctions: {
  54329. name: string;
  54330. shader: string;
  54331. };
  54332. }
  54333. declare module BABYLON {
  54334. /** @hidden */
  54335. export var pbrBRDFFunctions: {
  54336. name: string;
  54337. shader: string;
  54338. };
  54339. }
  54340. declare module BABYLON {
  54341. /** @hidden */
  54342. export var hdrFilteringFunctions: {
  54343. name: string;
  54344. shader: string;
  54345. };
  54346. }
  54347. declare module BABYLON {
  54348. /** @hidden */
  54349. export var pbrDirectLightingFunctions: {
  54350. name: string;
  54351. shader: string;
  54352. };
  54353. }
  54354. declare module BABYLON {
  54355. /** @hidden */
  54356. export var pbrIBLFunctions: {
  54357. name: string;
  54358. shader: string;
  54359. };
  54360. }
  54361. declare module BABYLON {
  54362. /** @hidden */
  54363. export var pbrBlockAlbedoOpacity: {
  54364. name: string;
  54365. shader: string;
  54366. };
  54367. }
  54368. declare module BABYLON {
  54369. /** @hidden */
  54370. export var pbrBlockReflectivity: {
  54371. name: string;
  54372. shader: string;
  54373. };
  54374. }
  54375. declare module BABYLON {
  54376. /** @hidden */
  54377. export var pbrBlockAmbientOcclusion: {
  54378. name: string;
  54379. shader: string;
  54380. };
  54381. }
  54382. declare module BABYLON {
  54383. /** @hidden */
  54384. export var pbrBlockAlphaFresnel: {
  54385. name: string;
  54386. shader: string;
  54387. };
  54388. }
  54389. declare module BABYLON {
  54390. /** @hidden */
  54391. export var pbrBlockAnisotropic: {
  54392. name: string;
  54393. shader: string;
  54394. };
  54395. }
  54396. declare module BABYLON {
  54397. /** @hidden */
  54398. export var pbrBlockReflection: {
  54399. name: string;
  54400. shader: string;
  54401. };
  54402. }
  54403. declare module BABYLON {
  54404. /** @hidden */
  54405. export var pbrBlockSheen: {
  54406. name: string;
  54407. shader: string;
  54408. };
  54409. }
  54410. declare module BABYLON {
  54411. /** @hidden */
  54412. export var pbrBlockClearcoat: {
  54413. name: string;
  54414. shader: string;
  54415. };
  54416. }
  54417. declare module BABYLON {
  54418. /** @hidden */
  54419. export var pbrBlockSubSurface: {
  54420. name: string;
  54421. shader: string;
  54422. };
  54423. }
  54424. declare module BABYLON {
  54425. /** @hidden */
  54426. export var pbrBlockNormalGeometric: {
  54427. name: string;
  54428. shader: string;
  54429. };
  54430. }
  54431. declare module BABYLON {
  54432. /** @hidden */
  54433. export var pbrBlockNormalFinal: {
  54434. name: string;
  54435. shader: string;
  54436. };
  54437. }
  54438. declare module BABYLON {
  54439. /** @hidden */
  54440. export var pbrBlockGeometryInfo: {
  54441. name: string;
  54442. shader: string;
  54443. };
  54444. }
  54445. declare module BABYLON {
  54446. /** @hidden */
  54447. export var pbrBlockReflectance0: {
  54448. name: string;
  54449. shader: string;
  54450. };
  54451. }
  54452. declare module BABYLON {
  54453. /** @hidden */
  54454. export var pbrBlockReflectance: {
  54455. name: string;
  54456. shader: string;
  54457. };
  54458. }
  54459. declare module BABYLON {
  54460. /** @hidden */
  54461. export var pbrBlockDirectLighting: {
  54462. name: string;
  54463. shader: string;
  54464. };
  54465. }
  54466. declare module BABYLON {
  54467. /** @hidden */
  54468. export var pbrBlockFinalLitComponents: {
  54469. name: string;
  54470. shader: string;
  54471. };
  54472. }
  54473. declare module BABYLON {
  54474. /** @hidden */
  54475. export var pbrBlockFinalUnlitComponents: {
  54476. name: string;
  54477. shader: string;
  54478. };
  54479. }
  54480. declare module BABYLON {
  54481. /** @hidden */
  54482. export var pbrBlockFinalColorComposition: {
  54483. name: string;
  54484. shader: string;
  54485. };
  54486. }
  54487. declare module BABYLON {
  54488. /** @hidden */
  54489. export var pbrBlockImageProcessing: {
  54490. name: string;
  54491. shader: string;
  54492. };
  54493. }
  54494. declare module BABYLON {
  54495. /** @hidden */
  54496. export var pbrDebug: {
  54497. name: string;
  54498. shader: string;
  54499. };
  54500. }
  54501. declare module BABYLON {
  54502. /** @hidden */
  54503. export var pbrPixelShader: {
  54504. name: string;
  54505. shader: string;
  54506. };
  54507. }
  54508. declare module BABYLON {
  54509. /** @hidden */
  54510. export var pbrVertexDeclaration: {
  54511. name: string;
  54512. shader: string;
  54513. };
  54514. }
  54515. declare module BABYLON {
  54516. /** @hidden */
  54517. export var pbrVertexShader: {
  54518. name: string;
  54519. shader: string;
  54520. };
  54521. }
  54522. declare module BABYLON {
  54523. /**
  54524. * Manages the defines for the PBR Material.
  54525. * @hidden
  54526. */
  54527. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  54528. PBR: boolean;
  54529. NUM_SAMPLES: string;
  54530. REALTIME_FILTERING: boolean;
  54531. MAINUV1: boolean;
  54532. MAINUV2: boolean;
  54533. UV1: boolean;
  54534. UV2: boolean;
  54535. ALBEDO: boolean;
  54536. GAMMAALBEDO: boolean;
  54537. ALBEDODIRECTUV: number;
  54538. VERTEXCOLOR: boolean;
  54539. AMBIENT: boolean;
  54540. AMBIENTDIRECTUV: number;
  54541. AMBIENTINGRAYSCALE: boolean;
  54542. OPACITY: boolean;
  54543. VERTEXALPHA: boolean;
  54544. OPACITYDIRECTUV: number;
  54545. OPACITYRGB: boolean;
  54546. ALPHATEST: boolean;
  54547. DEPTHPREPASS: boolean;
  54548. ALPHABLEND: boolean;
  54549. ALPHAFROMALBEDO: boolean;
  54550. ALPHATESTVALUE: string;
  54551. SPECULAROVERALPHA: boolean;
  54552. RADIANCEOVERALPHA: boolean;
  54553. ALPHAFRESNEL: boolean;
  54554. LINEARALPHAFRESNEL: boolean;
  54555. PREMULTIPLYALPHA: boolean;
  54556. EMISSIVE: boolean;
  54557. EMISSIVEDIRECTUV: number;
  54558. REFLECTIVITY: boolean;
  54559. REFLECTIVITYDIRECTUV: number;
  54560. SPECULARTERM: boolean;
  54561. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54562. MICROSURFACEAUTOMATIC: boolean;
  54563. LODBASEDMICROSFURACE: boolean;
  54564. MICROSURFACEMAP: boolean;
  54565. MICROSURFACEMAPDIRECTUV: number;
  54566. METALLICWORKFLOW: boolean;
  54567. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54568. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54569. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54570. AOSTOREINMETALMAPRED: boolean;
  54571. METALLIC_REFLECTANCE: boolean;
  54572. METALLIC_REFLECTANCEDIRECTUV: number;
  54573. ENVIRONMENTBRDF: boolean;
  54574. ENVIRONMENTBRDF_RGBD: boolean;
  54575. NORMAL: boolean;
  54576. TANGENT: boolean;
  54577. BUMP: boolean;
  54578. BUMPDIRECTUV: number;
  54579. OBJECTSPACE_NORMALMAP: boolean;
  54580. PARALLAX: boolean;
  54581. PARALLAXOCCLUSION: boolean;
  54582. NORMALXYSCALE: boolean;
  54583. LIGHTMAP: boolean;
  54584. LIGHTMAPDIRECTUV: number;
  54585. USELIGHTMAPASSHADOWMAP: boolean;
  54586. GAMMALIGHTMAP: boolean;
  54587. RGBDLIGHTMAP: boolean;
  54588. REFLECTION: boolean;
  54589. REFLECTIONMAP_3D: boolean;
  54590. REFLECTIONMAP_SPHERICAL: boolean;
  54591. REFLECTIONMAP_PLANAR: boolean;
  54592. REFLECTIONMAP_CUBIC: boolean;
  54593. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  54594. REFLECTIONMAP_PROJECTION: boolean;
  54595. REFLECTIONMAP_SKYBOX: boolean;
  54596. REFLECTIONMAP_EXPLICIT: boolean;
  54597. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  54598. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  54599. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  54600. INVERTCUBICMAP: boolean;
  54601. USESPHERICALFROMREFLECTIONMAP: boolean;
  54602. USEIRRADIANCEMAP: boolean;
  54603. SPHERICAL_HARMONICS: boolean;
  54604. USESPHERICALINVERTEX: boolean;
  54605. REFLECTIONMAP_OPPOSITEZ: boolean;
  54606. LODINREFLECTIONALPHA: boolean;
  54607. GAMMAREFLECTION: boolean;
  54608. RGBDREFLECTION: boolean;
  54609. LINEARSPECULARREFLECTION: boolean;
  54610. RADIANCEOCCLUSION: boolean;
  54611. HORIZONOCCLUSION: boolean;
  54612. INSTANCES: boolean;
  54613. THIN_INSTANCES: boolean;
  54614. NUM_BONE_INFLUENCERS: number;
  54615. BonesPerMesh: number;
  54616. BONETEXTURE: boolean;
  54617. NONUNIFORMSCALING: boolean;
  54618. MORPHTARGETS: boolean;
  54619. MORPHTARGETS_NORMAL: boolean;
  54620. MORPHTARGETS_TANGENT: boolean;
  54621. MORPHTARGETS_UV: boolean;
  54622. NUM_MORPH_INFLUENCERS: number;
  54623. IMAGEPROCESSING: boolean;
  54624. VIGNETTE: boolean;
  54625. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54626. VIGNETTEBLENDMODEOPAQUE: boolean;
  54627. TONEMAPPING: boolean;
  54628. TONEMAPPING_ACES: boolean;
  54629. CONTRAST: boolean;
  54630. COLORCURVES: boolean;
  54631. COLORGRADING: boolean;
  54632. COLORGRADING3D: boolean;
  54633. SAMPLER3DGREENDEPTH: boolean;
  54634. SAMPLER3DBGRMAP: boolean;
  54635. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54636. EXPOSURE: boolean;
  54637. MULTIVIEW: boolean;
  54638. USEPHYSICALLIGHTFALLOFF: boolean;
  54639. USEGLTFLIGHTFALLOFF: boolean;
  54640. TWOSIDEDLIGHTING: boolean;
  54641. SHADOWFLOAT: boolean;
  54642. CLIPPLANE: boolean;
  54643. CLIPPLANE2: boolean;
  54644. CLIPPLANE3: boolean;
  54645. CLIPPLANE4: boolean;
  54646. CLIPPLANE5: boolean;
  54647. CLIPPLANE6: boolean;
  54648. POINTSIZE: boolean;
  54649. FOG: boolean;
  54650. LOGARITHMICDEPTH: boolean;
  54651. FORCENORMALFORWARD: boolean;
  54652. SPECULARAA: boolean;
  54653. CLEARCOAT: boolean;
  54654. CLEARCOAT_DEFAULTIOR: boolean;
  54655. CLEARCOAT_TEXTURE: boolean;
  54656. CLEARCOAT_TEXTUREDIRECTUV: number;
  54657. CLEARCOAT_BUMP: boolean;
  54658. CLEARCOAT_BUMPDIRECTUV: number;
  54659. CLEARCOAT_TINT: boolean;
  54660. CLEARCOAT_TINT_TEXTURE: boolean;
  54661. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54662. ANISOTROPIC: boolean;
  54663. ANISOTROPIC_TEXTURE: boolean;
  54664. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54665. BRDF_V_HEIGHT_CORRELATED: boolean;
  54666. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54667. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54668. SHEEN: boolean;
  54669. SHEEN_TEXTURE: boolean;
  54670. SHEEN_TEXTUREDIRECTUV: number;
  54671. SHEEN_LINKWITHALBEDO: boolean;
  54672. SHEEN_ROUGHNESS: boolean;
  54673. SHEEN_ALBEDOSCALING: boolean;
  54674. SUBSURFACE: boolean;
  54675. SS_REFRACTION: boolean;
  54676. SS_TRANSLUCENCY: boolean;
  54677. SS_SCATERRING: boolean;
  54678. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54679. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54680. SS_REFRACTIONMAP_3D: boolean;
  54681. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54682. SS_LODINREFRACTIONALPHA: boolean;
  54683. SS_GAMMAREFRACTION: boolean;
  54684. SS_RGBDREFRACTION: boolean;
  54685. SS_LINEARSPECULARREFRACTION: boolean;
  54686. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54687. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54688. UNLIT: boolean;
  54689. DEBUGMODE: number;
  54690. /**
  54691. * Initializes the PBR Material defines.
  54692. */
  54693. constructor();
  54694. /**
  54695. * Resets the PBR Material defines.
  54696. */
  54697. reset(): void;
  54698. }
  54699. /**
  54700. * The Physically based material base class of BJS.
  54701. *
  54702. * This offers the main features of a standard PBR material.
  54703. * For more information, please refer to the documentation :
  54704. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54705. */
  54706. export abstract class PBRBaseMaterial extends PushMaterial {
  54707. /**
  54708. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54709. */
  54710. static readonly PBRMATERIAL_OPAQUE: number;
  54711. /**
  54712. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54713. */
  54714. static readonly PBRMATERIAL_ALPHATEST: number;
  54715. /**
  54716. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54717. */
  54718. static readonly PBRMATERIAL_ALPHABLEND: number;
  54719. /**
  54720. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54721. * They are also discarded below the alpha cutoff threshold to improve performances.
  54722. */
  54723. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54724. /**
  54725. * Defines the default value of how much AO map is occluding the analytical lights
  54726. * (point spot...).
  54727. */
  54728. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54729. /**
  54730. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54731. */
  54732. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54733. /**
  54734. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54735. * to enhance interoperability with other engines.
  54736. */
  54737. static readonly LIGHTFALLOFF_GLTF: number;
  54738. /**
  54739. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54740. * to enhance interoperability with other materials.
  54741. */
  54742. static readonly LIGHTFALLOFF_STANDARD: number;
  54743. /**
  54744. * Intensity of the direct lights e.g. the four lights available in your scene.
  54745. * This impacts both the direct diffuse and specular highlights.
  54746. */
  54747. protected _directIntensity: number;
  54748. /**
  54749. * Intensity of the emissive part of the material.
  54750. * This helps controlling the emissive effect without modifying the emissive color.
  54751. */
  54752. protected _emissiveIntensity: number;
  54753. /**
  54754. * Intensity of the environment e.g. how much the environment will light the object
  54755. * either through harmonics for rough material or through the refelction for shiny ones.
  54756. */
  54757. protected _environmentIntensity: number;
  54758. /**
  54759. * This is a special control allowing the reduction of the specular highlights coming from the
  54760. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54761. */
  54762. protected _specularIntensity: number;
  54763. /**
  54764. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  54765. */
  54766. private _lightingInfos;
  54767. /**
  54768. * Debug Control allowing disabling the bump map on this material.
  54769. */
  54770. protected _disableBumpMap: boolean;
  54771. /**
  54772. * AKA Diffuse Texture in standard nomenclature.
  54773. */
  54774. protected _albedoTexture: Nullable<BaseTexture>;
  54775. /**
  54776. * AKA Occlusion Texture in other nomenclature.
  54777. */
  54778. protected _ambientTexture: Nullable<BaseTexture>;
  54779. /**
  54780. * AKA Occlusion Texture Intensity in other nomenclature.
  54781. */
  54782. protected _ambientTextureStrength: number;
  54783. /**
  54784. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54785. * 1 means it completely occludes it
  54786. * 0 mean it has no impact
  54787. */
  54788. protected _ambientTextureImpactOnAnalyticalLights: number;
  54789. /**
  54790. * Stores the alpha values in a texture.
  54791. */
  54792. protected _opacityTexture: Nullable<BaseTexture>;
  54793. /**
  54794. * Stores the reflection values in a texture.
  54795. */
  54796. protected _reflectionTexture: Nullable<BaseTexture>;
  54797. /**
  54798. * Stores the emissive values in a texture.
  54799. */
  54800. protected _emissiveTexture: Nullable<BaseTexture>;
  54801. /**
  54802. * AKA Specular texture in other nomenclature.
  54803. */
  54804. protected _reflectivityTexture: Nullable<BaseTexture>;
  54805. /**
  54806. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54807. */
  54808. protected _metallicTexture: Nullable<BaseTexture>;
  54809. /**
  54810. * Specifies the metallic scalar of the metallic/roughness workflow.
  54811. * Can also be used to scale the metalness values of the metallic texture.
  54812. */
  54813. protected _metallic: Nullable<number>;
  54814. /**
  54815. * Specifies the roughness scalar of the metallic/roughness workflow.
  54816. * Can also be used to scale the roughness values of the metallic texture.
  54817. */
  54818. protected _roughness: Nullable<number>;
  54819. /**
  54820. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  54821. * By default the indexOfrefraction is used to compute F0;
  54822. *
  54823. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  54824. *
  54825. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  54826. * F90 = metallicReflectanceColor;
  54827. */
  54828. protected _metallicF0Factor: number;
  54829. /**
  54830. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  54831. * By default the F90 is always 1;
  54832. *
  54833. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  54834. *
  54835. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  54836. * F90 = metallicReflectanceColor;
  54837. */
  54838. protected _metallicReflectanceColor: Color3;
  54839. /**
  54840. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  54841. * This is multiply against the scalar values defined in the material.
  54842. */
  54843. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  54844. /**
  54845. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54846. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54847. */
  54848. protected _microSurfaceTexture: Nullable<BaseTexture>;
  54849. /**
  54850. * Stores surface normal data used to displace a mesh in a texture.
  54851. */
  54852. protected _bumpTexture: Nullable<BaseTexture>;
  54853. /**
  54854. * Stores the pre-calculated light information of a mesh in a texture.
  54855. */
  54856. protected _lightmapTexture: Nullable<BaseTexture>;
  54857. /**
  54858. * The color of a material in ambient lighting.
  54859. */
  54860. protected _ambientColor: Color3;
  54861. /**
  54862. * AKA Diffuse Color in other nomenclature.
  54863. */
  54864. protected _albedoColor: Color3;
  54865. /**
  54866. * AKA Specular Color in other nomenclature.
  54867. */
  54868. protected _reflectivityColor: Color3;
  54869. /**
  54870. * The color applied when light is reflected from a material.
  54871. */
  54872. protected _reflectionColor: Color3;
  54873. /**
  54874. * The color applied when light is emitted from a material.
  54875. */
  54876. protected _emissiveColor: Color3;
  54877. /**
  54878. * AKA Glossiness in other nomenclature.
  54879. */
  54880. protected _microSurface: number;
  54881. /**
  54882. * Specifies that the material will use the light map as a show map.
  54883. */
  54884. protected _useLightmapAsShadowmap: boolean;
  54885. /**
  54886. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54887. * makes the reflect vector face the model (under horizon).
  54888. */
  54889. protected _useHorizonOcclusion: boolean;
  54890. /**
  54891. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54892. * too much the area relying on ambient texture to define their ambient occlusion.
  54893. */
  54894. protected _useRadianceOcclusion: boolean;
  54895. /**
  54896. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54897. */
  54898. protected _useAlphaFromAlbedoTexture: boolean;
  54899. /**
  54900. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  54901. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54902. */
  54903. protected _useSpecularOverAlpha: boolean;
  54904. /**
  54905. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54906. */
  54907. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54908. /**
  54909. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54910. */
  54911. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  54912. /**
  54913. * Specifies if the metallic texture contains the roughness information in its green channel.
  54914. */
  54915. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54916. /**
  54917. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54918. */
  54919. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54920. /**
  54921. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54922. */
  54923. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54924. /**
  54925. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54926. */
  54927. protected _useAmbientInGrayScale: boolean;
  54928. /**
  54929. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54930. * The material will try to infer what glossiness each pixel should be.
  54931. */
  54932. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54933. /**
  54934. * Defines the falloff type used in this material.
  54935. * It by default is Physical.
  54936. */
  54937. protected _lightFalloff: number;
  54938. /**
  54939. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54940. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54941. */
  54942. protected _useRadianceOverAlpha: boolean;
  54943. /**
  54944. * Allows using an object space normal map (instead of tangent space).
  54945. */
  54946. protected _useObjectSpaceNormalMap: boolean;
  54947. /**
  54948. * Allows using the bump map in parallax mode.
  54949. */
  54950. protected _useParallax: boolean;
  54951. /**
  54952. * Allows using the bump map in parallax occlusion mode.
  54953. */
  54954. protected _useParallaxOcclusion: boolean;
  54955. /**
  54956. * Controls the scale bias of the parallax mode.
  54957. */
  54958. protected _parallaxScaleBias: number;
  54959. /**
  54960. * If sets to true, disables all the lights affecting the material.
  54961. */
  54962. protected _disableLighting: boolean;
  54963. /**
  54964. * Number of Simultaneous lights allowed on the material.
  54965. */
  54966. protected _maxSimultaneousLights: number;
  54967. /**
  54968. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54969. */
  54970. protected _invertNormalMapX: boolean;
  54971. /**
  54972. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54973. */
  54974. protected _invertNormalMapY: boolean;
  54975. /**
  54976. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54977. */
  54978. protected _twoSidedLighting: boolean;
  54979. /**
  54980. * Defines the alpha limits in alpha test mode.
  54981. */
  54982. protected _alphaCutOff: number;
  54983. /**
  54984. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54985. */
  54986. protected _forceAlphaTest: boolean;
  54987. /**
  54988. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54989. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54990. */
  54991. protected _useAlphaFresnel: boolean;
  54992. /**
  54993. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54994. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54995. */
  54996. protected _useLinearAlphaFresnel: boolean;
  54997. /**
  54998. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54999. * from cos thetav and roughness:
  55000. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  55001. */
  55002. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  55003. /**
  55004. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55005. */
  55006. protected _forceIrradianceInFragment: boolean;
  55007. private _realTimeFiltering;
  55008. /**
  55009. * Enables realtime filtering on the texture.
  55010. */
  55011. get realTimeFiltering(): boolean;
  55012. set realTimeFiltering(b: boolean);
  55013. private _realTimeFilteringQuality;
  55014. /**
  55015. * Quality switch for realtime filtering
  55016. */
  55017. get realTimeFilteringQuality(): number;
  55018. set realTimeFilteringQuality(n: number);
  55019. /**
  55020. * Force normal to face away from face.
  55021. */
  55022. protected _forceNormalForward: boolean;
  55023. /**
  55024. * Enables specular anti aliasing in the PBR shader.
  55025. * It will both interacts on the Geometry for analytical and IBL lighting.
  55026. * It also prefilter the roughness map based on the bump values.
  55027. */
  55028. protected _enableSpecularAntiAliasing: boolean;
  55029. /**
  55030. * Default configuration related to image processing available in the PBR Material.
  55031. */
  55032. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55033. /**
  55034. * Keep track of the image processing observer to allow dispose and replace.
  55035. */
  55036. private _imageProcessingObserver;
  55037. /**
  55038. * Attaches a new image processing configuration to the PBR Material.
  55039. * @param configuration
  55040. */
  55041. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55042. /**
  55043. * Stores the available render targets.
  55044. */
  55045. private _renderTargets;
  55046. /**
  55047. * Sets the global ambient color for the material used in lighting calculations.
  55048. */
  55049. private _globalAmbientColor;
  55050. /**
  55051. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55052. */
  55053. private _useLogarithmicDepth;
  55054. /**
  55055. * If set to true, no lighting calculations will be applied.
  55056. */
  55057. private _unlit;
  55058. private _debugMode;
  55059. /**
  55060. * @hidden
  55061. * This is reserved for the inspector.
  55062. * Defines the material debug mode.
  55063. * It helps seeing only some components of the material while troubleshooting.
  55064. */
  55065. debugMode: number;
  55066. /**
  55067. * @hidden
  55068. * This is reserved for the inspector.
  55069. * Specify from where on screen the debug mode should start.
  55070. * The value goes from -1 (full screen) to 1 (not visible)
  55071. * It helps with side by side comparison against the final render
  55072. * This defaults to -1
  55073. */
  55074. private debugLimit;
  55075. /**
  55076. * @hidden
  55077. * This is reserved for the inspector.
  55078. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55079. * You can use the factor to better multiply the final value.
  55080. */
  55081. private debugFactor;
  55082. /**
  55083. * Defines the clear coat layer parameters for the material.
  55084. */
  55085. readonly clearCoat: PBRClearCoatConfiguration;
  55086. /**
  55087. * Defines the anisotropic parameters for the material.
  55088. */
  55089. readonly anisotropy: PBRAnisotropicConfiguration;
  55090. /**
  55091. * Defines the BRDF parameters for the material.
  55092. */
  55093. readonly brdf: PBRBRDFConfiguration;
  55094. /**
  55095. * Defines the Sheen parameters for the material.
  55096. */
  55097. readonly sheen: PBRSheenConfiguration;
  55098. /**
  55099. * Defines the SubSurface parameters for the material.
  55100. */
  55101. readonly subSurface: PBRSubSurfaceConfiguration;
  55102. protected _rebuildInParallel: boolean;
  55103. /**
  55104. * Instantiates a new PBRMaterial instance.
  55105. *
  55106. * @param name The material name
  55107. * @param scene The scene the material will be use in.
  55108. */
  55109. constructor(name: string, scene: Scene);
  55110. /**
  55111. * Gets a boolean indicating that current material needs to register RTT
  55112. */
  55113. get hasRenderTargetTextures(): boolean;
  55114. /**
  55115. * Gets the name of the material class.
  55116. */
  55117. getClassName(): string;
  55118. /**
  55119. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55120. */
  55121. get useLogarithmicDepth(): boolean;
  55122. /**
  55123. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55124. */
  55125. set useLogarithmicDepth(value: boolean);
  55126. /**
  55127. * Returns true if alpha blending should be disabled.
  55128. */
  55129. protected get _disableAlphaBlending(): boolean;
  55130. /**
  55131. * Specifies whether or not this material should be rendered in alpha blend mode.
  55132. */
  55133. needAlphaBlending(): boolean;
  55134. /**
  55135. * Specifies whether or not this material should be rendered in alpha test mode.
  55136. */
  55137. needAlphaTesting(): boolean;
  55138. /**
  55139. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55140. */
  55141. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55142. /**
  55143. * Gets the texture used for the alpha test.
  55144. */
  55145. getAlphaTestTexture(): Nullable<BaseTexture>;
  55146. /**
  55147. * Specifies that the submesh is ready to be used.
  55148. * @param mesh - BJS mesh.
  55149. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55150. * @param useInstances - Specifies that instances should be used.
  55151. * @returns - boolean indicating that the submesh is ready or not.
  55152. */
  55153. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55154. /**
  55155. * Specifies if the material uses metallic roughness workflow.
  55156. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55157. */
  55158. isMetallicWorkflow(): boolean;
  55159. private _prepareEffect;
  55160. private _prepareDefines;
  55161. /**
  55162. * Force shader compilation
  55163. */
  55164. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55165. /**
  55166. * Initializes the uniform buffer layout for the shader.
  55167. */
  55168. buildUniformLayout(): void;
  55169. /**
  55170. * Unbinds the material from the mesh
  55171. */
  55172. unbind(): void;
  55173. /**
  55174. * Binds the submesh data.
  55175. * @param world - The world matrix.
  55176. * @param mesh - The BJS mesh.
  55177. * @param subMesh - A submesh of the BJS mesh.
  55178. */
  55179. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55180. /**
  55181. * Returns the animatable textures.
  55182. * @returns - Array of animatable textures.
  55183. */
  55184. getAnimatables(): IAnimatable[];
  55185. /**
  55186. * Returns the texture used for reflections.
  55187. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55188. */
  55189. private _getReflectionTexture;
  55190. /**
  55191. * Returns an array of the actively used textures.
  55192. * @returns - Array of BaseTextures
  55193. */
  55194. getActiveTextures(): BaseTexture[];
  55195. /**
  55196. * Checks to see if a texture is used in the material.
  55197. * @param texture - Base texture to use.
  55198. * @returns - Boolean specifying if a texture is used in the material.
  55199. */
  55200. hasTexture(texture: BaseTexture): boolean;
  55201. /**
  55202. * Disposes the resources of the material.
  55203. * @param forceDisposeEffect - Forces the disposal of effects.
  55204. * @param forceDisposeTextures - Forces the disposal of all textures.
  55205. */
  55206. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55207. }
  55208. }
  55209. declare module BABYLON {
  55210. /**
  55211. * The Physically based material of BJS.
  55212. *
  55213. * This offers the main features of a standard PBR material.
  55214. * For more information, please refer to the documentation :
  55215. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55216. */
  55217. export class PBRMaterial extends PBRBaseMaterial {
  55218. /**
  55219. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55220. */
  55221. static readonly PBRMATERIAL_OPAQUE: number;
  55222. /**
  55223. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55224. */
  55225. static readonly PBRMATERIAL_ALPHATEST: number;
  55226. /**
  55227. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55228. */
  55229. static readonly PBRMATERIAL_ALPHABLEND: number;
  55230. /**
  55231. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55232. * They are also discarded below the alpha cutoff threshold to improve performances.
  55233. */
  55234. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55235. /**
  55236. * Defines the default value of how much AO map is occluding the analytical lights
  55237. * (point spot...).
  55238. */
  55239. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55240. /**
  55241. * Intensity of the direct lights e.g. the four lights available in your scene.
  55242. * This impacts both the direct diffuse and specular highlights.
  55243. */
  55244. directIntensity: number;
  55245. /**
  55246. * Intensity of the emissive part of the material.
  55247. * This helps controlling the emissive effect without modifying the emissive color.
  55248. */
  55249. emissiveIntensity: number;
  55250. /**
  55251. * Intensity of the environment e.g. how much the environment will light the object
  55252. * either through harmonics for rough material or through the refelction for shiny ones.
  55253. */
  55254. environmentIntensity: number;
  55255. /**
  55256. * This is a special control allowing the reduction of the specular highlights coming from the
  55257. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55258. */
  55259. specularIntensity: number;
  55260. /**
  55261. * Debug Control allowing disabling the bump map on this material.
  55262. */
  55263. disableBumpMap: boolean;
  55264. /**
  55265. * AKA Diffuse Texture in standard nomenclature.
  55266. */
  55267. albedoTexture: BaseTexture;
  55268. /**
  55269. * AKA Occlusion Texture in other nomenclature.
  55270. */
  55271. ambientTexture: BaseTexture;
  55272. /**
  55273. * AKA Occlusion Texture Intensity in other nomenclature.
  55274. */
  55275. ambientTextureStrength: number;
  55276. /**
  55277. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55278. * 1 means it completely occludes it
  55279. * 0 mean it has no impact
  55280. */
  55281. ambientTextureImpactOnAnalyticalLights: number;
  55282. /**
  55283. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55284. */
  55285. opacityTexture: BaseTexture;
  55286. /**
  55287. * Stores the reflection values in a texture.
  55288. */
  55289. reflectionTexture: Nullable<BaseTexture>;
  55290. /**
  55291. * Stores the emissive values in a texture.
  55292. */
  55293. emissiveTexture: BaseTexture;
  55294. /**
  55295. * AKA Specular texture in other nomenclature.
  55296. */
  55297. reflectivityTexture: BaseTexture;
  55298. /**
  55299. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55300. */
  55301. metallicTexture: BaseTexture;
  55302. /**
  55303. * Specifies the metallic scalar of the metallic/roughness workflow.
  55304. * Can also be used to scale the metalness values of the metallic texture.
  55305. */
  55306. metallic: Nullable<number>;
  55307. /**
  55308. * Specifies the roughness scalar of the metallic/roughness workflow.
  55309. * Can also be used to scale the roughness values of the metallic texture.
  55310. */
  55311. roughness: Nullable<number>;
  55312. /**
  55313. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55314. * By default the indexOfrefraction is used to compute F0;
  55315. *
  55316. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55317. *
  55318. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55319. * F90 = metallicReflectanceColor;
  55320. */
  55321. metallicF0Factor: number;
  55322. /**
  55323. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55324. * By default the F90 is always 1;
  55325. *
  55326. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55327. *
  55328. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55329. * F90 = metallicReflectanceColor;
  55330. */
  55331. metallicReflectanceColor: Color3;
  55332. /**
  55333. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55334. * This is multiply against the scalar values defined in the material.
  55335. */
  55336. metallicReflectanceTexture: Nullable<BaseTexture>;
  55337. /**
  55338. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55339. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55340. */
  55341. microSurfaceTexture: BaseTexture;
  55342. /**
  55343. * Stores surface normal data used to displace a mesh in a texture.
  55344. */
  55345. bumpTexture: BaseTexture;
  55346. /**
  55347. * Stores the pre-calculated light information of a mesh in a texture.
  55348. */
  55349. lightmapTexture: BaseTexture;
  55350. /**
  55351. * Stores the refracted light information in a texture.
  55352. */
  55353. get refractionTexture(): Nullable<BaseTexture>;
  55354. set refractionTexture(value: Nullable<BaseTexture>);
  55355. /**
  55356. * The color of a material in ambient lighting.
  55357. */
  55358. ambientColor: Color3;
  55359. /**
  55360. * AKA Diffuse Color in other nomenclature.
  55361. */
  55362. albedoColor: Color3;
  55363. /**
  55364. * AKA Specular Color in other nomenclature.
  55365. */
  55366. reflectivityColor: Color3;
  55367. /**
  55368. * The color reflected from the material.
  55369. */
  55370. reflectionColor: Color3;
  55371. /**
  55372. * The color emitted from the material.
  55373. */
  55374. emissiveColor: Color3;
  55375. /**
  55376. * AKA Glossiness in other nomenclature.
  55377. */
  55378. microSurface: number;
  55379. /**
  55380. * Index of refraction of the material base layer.
  55381. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55382. *
  55383. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55384. *
  55385. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55386. */
  55387. get indexOfRefraction(): number;
  55388. set indexOfRefraction(value: number);
  55389. /**
  55390. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55391. */
  55392. get invertRefractionY(): boolean;
  55393. set invertRefractionY(value: boolean);
  55394. /**
  55395. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55396. * Materials half opaque for instance using refraction could benefit from this control.
  55397. */
  55398. get linkRefractionWithTransparency(): boolean;
  55399. set linkRefractionWithTransparency(value: boolean);
  55400. /**
  55401. * If true, the light map contains occlusion information instead of lighting info.
  55402. */
  55403. useLightmapAsShadowmap: boolean;
  55404. /**
  55405. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55406. */
  55407. useAlphaFromAlbedoTexture: boolean;
  55408. /**
  55409. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55410. */
  55411. forceAlphaTest: boolean;
  55412. /**
  55413. * Defines the alpha limits in alpha test mode.
  55414. */
  55415. alphaCutOff: number;
  55416. /**
  55417. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55418. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55419. */
  55420. useSpecularOverAlpha: boolean;
  55421. /**
  55422. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55423. */
  55424. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55425. /**
  55426. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55427. */
  55428. useRoughnessFromMetallicTextureAlpha: boolean;
  55429. /**
  55430. * Specifies if the metallic texture contains the roughness information in its green channel.
  55431. */
  55432. useRoughnessFromMetallicTextureGreen: boolean;
  55433. /**
  55434. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55435. */
  55436. useMetallnessFromMetallicTextureBlue: boolean;
  55437. /**
  55438. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55439. */
  55440. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55441. /**
  55442. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55443. */
  55444. useAmbientInGrayScale: boolean;
  55445. /**
  55446. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55447. * The material will try to infer what glossiness each pixel should be.
  55448. */
  55449. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55450. /**
  55451. * BJS is using an harcoded light falloff based on a manually sets up range.
  55452. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55453. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55454. */
  55455. get usePhysicalLightFalloff(): boolean;
  55456. /**
  55457. * BJS is using an harcoded light falloff based on a manually sets up range.
  55458. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55459. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55460. */
  55461. set usePhysicalLightFalloff(value: boolean);
  55462. /**
  55463. * In order to support the falloff compatibility with gltf, a special mode has been added
  55464. * to reproduce the gltf light falloff.
  55465. */
  55466. get useGLTFLightFalloff(): boolean;
  55467. /**
  55468. * In order to support the falloff compatibility with gltf, a special mode has been added
  55469. * to reproduce the gltf light falloff.
  55470. */
  55471. set useGLTFLightFalloff(value: boolean);
  55472. /**
  55473. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55474. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55475. */
  55476. useRadianceOverAlpha: boolean;
  55477. /**
  55478. * Allows using an object space normal map (instead of tangent space).
  55479. */
  55480. useObjectSpaceNormalMap: boolean;
  55481. /**
  55482. * Allows using the bump map in parallax mode.
  55483. */
  55484. useParallax: boolean;
  55485. /**
  55486. * Allows using the bump map in parallax occlusion mode.
  55487. */
  55488. useParallaxOcclusion: boolean;
  55489. /**
  55490. * Controls the scale bias of the parallax mode.
  55491. */
  55492. parallaxScaleBias: number;
  55493. /**
  55494. * If sets to true, disables all the lights affecting the material.
  55495. */
  55496. disableLighting: boolean;
  55497. /**
  55498. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55499. */
  55500. forceIrradianceInFragment: boolean;
  55501. /**
  55502. * Number of Simultaneous lights allowed on the material.
  55503. */
  55504. maxSimultaneousLights: number;
  55505. /**
  55506. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55507. */
  55508. invertNormalMapX: boolean;
  55509. /**
  55510. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55511. */
  55512. invertNormalMapY: boolean;
  55513. /**
  55514. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55515. */
  55516. twoSidedLighting: boolean;
  55517. /**
  55518. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55519. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55520. */
  55521. useAlphaFresnel: boolean;
  55522. /**
  55523. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55524. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55525. */
  55526. useLinearAlphaFresnel: boolean;
  55527. /**
  55528. * Let user defines the brdf lookup texture used for IBL.
  55529. * A default 8bit version is embedded but you could point at :
  55530. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55531. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55532. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55533. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55534. */
  55535. environmentBRDFTexture: Nullable<BaseTexture>;
  55536. /**
  55537. * Force normal to face away from face.
  55538. */
  55539. forceNormalForward: boolean;
  55540. /**
  55541. * Enables specular anti aliasing in the PBR shader.
  55542. * It will both interacts on the Geometry for analytical and IBL lighting.
  55543. * It also prefilter the roughness map based on the bump values.
  55544. */
  55545. enableSpecularAntiAliasing: boolean;
  55546. /**
  55547. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55548. * makes the reflect vector face the model (under horizon).
  55549. */
  55550. useHorizonOcclusion: boolean;
  55551. /**
  55552. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55553. * too much the area relying on ambient texture to define their ambient occlusion.
  55554. */
  55555. useRadianceOcclusion: boolean;
  55556. /**
  55557. * If set to true, no lighting calculations will be applied.
  55558. */
  55559. unlit: boolean;
  55560. /**
  55561. * Gets the image processing configuration used either in this material.
  55562. */
  55563. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55564. /**
  55565. * Sets the Default image processing configuration used either in the this material.
  55566. *
  55567. * If sets to null, the scene one is in use.
  55568. */
  55569. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55570. /**
  55571. * Gets wether the color curves effect is enabled.
  55572. */
  55573. get cameraColorCurvesEnabled(): boolean;
  55574. /**
  55575. * Sets wether the color curves effect is enabled.
  55576. */
  55577. set cameraColorCurvesEnabled(value: boolean);
  55578. /**
  55579. * Gets wether the color grading effect is enabled.
  55580. */
  55581. get cameraColorGradingEnabled(): boolean;
  55582. /**
  55583. * Gets wether the color grading effect is enabled.
  55584. */
  55585. set cameraColorGradingEnabled(value: boolean);
  55586. /**
  55587. * Gets wether tonemapping is enabled or not.
  55588. */
  55589. get cameraToneMappingEnabled(): boolean;
  55590. /**
  55591. * Sets wether tonemapping is enabled or not
  55592. */
  55593. set cameraToneMappingEnabled(value: boolean);
  55594. /**
  55595. * The camera exposure used on this material.
  55596. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55597. * This corresponds to a photographic exposure.
  55598. */
  55599. get cameraExposure(): number;
  55600. /**
  55601. * The camera exposure used on this material.
  55602. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55603. * This corresponds to a photographic exposure.
  55604. */
  55605. set cameraExposure(value: number);
  55606. /**
  55607. * Gets The camera contrast used on this material.
  55608. */
  55609. get cameraContrast(): number;
  55610. /**
  55611. * Sets The camera contrast used on this material.
  55612. */
  55613. set cameraContrast(value: number);
  55614. /**
  55615. * Gets the Color Grading 2D Lookup Texture.
  55616. */
  55617. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55618. /**
  55619. * Sets the Color Grading 2D Lookup Texture.
  55620. */
  55621. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55622. /**
  55623. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55624. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55625. * 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;
  55626. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55627. */
  55628. get cameraColorCurves(): Nullable<ColorCurves>;
  55629. /**
  55630. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55631. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55632. * 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;
  55633. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55634. */
  55635. set cameraColorCurves(value: Nullable<ColorCurves>);
  55636. /**
  55637. * Instantiates a new PBRMaterial instance.
  55638. *
  55639. * @param name The material name
  55640. * @param scene The scene the material will be use in.
  55641. */
  55642. constructor(name: string, scene: Scene);
  55643. /**
  55644. * Returns the name of this material class.
  55645. */
  55646. getClassName(): string;
  55647. /**
  55648. * Makes a duplicate of the current material.
  55649. * @param name - name to use for the new material.
  55650. */
  55651. clone(name: string): PBRMaterial;
  55652. /**
  55653. * Serializes this PBR Material.
  55654. * @returns - An object with the serialized material.
  55655. */
  55656. serialize(): any;
  55657. /**
  55658. * Parses a PBR Material from a serialized object.
  55659. * @param source - Serialized object.
  55660. * @param scene - BJS scene instance.
  55661. * @param rootUrl - url for the scene object
  55662. * @returns - PBRMaterial
  55663. */
  55664. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55665. }
  55666. }
  55667. declare module BABYLON {
  55668. /**
  55669. * Direct draw surface info
  55670. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55671. */
  55672. export interface DDSInfo {
  55673. /**
  55674. * Width of the texture
  55675. */
  55676. width: number;
  55677. /**
  55678. * Width of the texture
  55679. */
  55680. height: number;
  55681. /**
  55682. * Number of Mipmaps for the texture
  55683. * @see https://en.wikipedia.org/wiki/Mipmap
  55684. */
  55685. mipmapCount: number;
  55686. /**
  55687. * If the textures format is a known fourCC format
  55688. * @see https://www.fourcc.org/
  55689. */
  55690. isFourCC: boolean;
  55691. /**
  55692. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55693. */
  55694. isRGB: boolean;
  55695. /**
  55696. * If the texture is a lumincance format
  55697. */
  55698. isLuminance: boolean;
  55699. /**
  55700. * If this is a cube texture
  55701. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55702. */
  55703. isCube: boolean;
  55704. /**
  55705. * If the texture is a compressed format eg. FOURCC_DXT1
  55706. */
  55707. isCompressed: boolean;
  55708. /**
  55709. * The dxgiFormat of the texture
  55710. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55711. */
  55712. dxgiFormat: number;
  55713. /**
  55714. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55715. */
  55716. textureType: number;
  55717. /**
  55718. * Sphericle polynomial created for the dds texture
  55719. */
  55720. sphericalPolynomial?: SphericalPolynomial;
  55721. }
  55722. /**
  55723. * Class used to provide DDS decompression tools
  55724. */
  55725. export class DDSTools {
  55726. /**
  55727. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55728. */
  55729. static StoreLODInAlphaChannel: boolean;
  55730. /**
  55731. * Gets DDS information from an array buffer
  55732. * @param data defines the array buffer view to read data from
  55733. * @returns the DDS information
  55734. */
  55735. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55736. private static _FloatView;
  55737. private static _Int32View;
  55738. private static _ToHalfFloat;
  55739. private static _FromHalfFloat;
  55740. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55741. private static _GetHalfFloatRGBAArrayBuffer;
  55742. private static _GetFloatRGBAArrayBuffer;
  55743. private static _GetFloatAsUIntRGBAArrayBuffer;
  55744. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55745. private static _GetRGBAArrayBuffer;
  55746. private static _ExtractLongWordOrder;
  55747. private static _GetRGBArrayBuffer;
  55748. private static _GetLuminanceArrayBuffer;
  55749. /**
  55750. * Uploads DDS Levels to a Babylon Texture
  55751. * @hidden
  55752. */
  55753. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55754. }
  55755. interface ThinEngine {
  55756. /**
  55757. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  55758. * @param rootUrl defines the url where the file to load is located
  55759. * @param scene defines the current scene
  55760. * @param lodScale defines scale to apply to the mip map selection
  55761. * @param lodOffset defines offset to apply to the mip map selection
  55762. * @param onLoad defines an optional callback raised when the texture is loaded
  55763. * @param onError defines an optional callback raised if there is an issue to load the texture
  55764. * @param format defines the format of the data
  55765. * @param forcedExtension defines the extension to use to pick the right loader
  55766. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  55767. * @returns the cube texture as an InternalTexture
  55768. */
  55769. 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;
  55770. }
  55771. }
  55772. declare module BABYLON {
  55773. /**
  55774. * Implementation of the DDS Texture Loader.
  55775. * @hidden
  55776. */
  55777. export class _DDSTextureLoader implements IInternalTextureLoader {
  55778. /**
  55779. * Defines wether the loader supports cascade loading the different faces.
  55780. */
  55781. readonly supportCascades: boolean;
  55782. /**
  55783. * This returns if the loader support the current file information.
  55784. * @param extension defines the file extension of the file being loaded
  55785. * @returns true if the loader can load the specified file
  55786. */
  55787. canLoad(extension: string): boolean;
  55788. /**
  55789. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55790. * @param data contains the texture data
  55791. * @param texture defines the BabylonJS internal texture
  55792. * @param createPolynomials will be true if polynomials have been requested
  55793. * @param onLoad defines the callback to trigger once the texture is ready
  55794. * @param onError defines the callback to trigger in case of error
  55795. */
  55796. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55797. /**
  55798. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55799. * @param data contains the texture data
  55800. * @param texture defines the BabylonJS internal texture
  55801. * @param callback defines the method to call once ready to upload
  55802. */
  55803. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55804. }
  55805. }
  55806. declare module BABYLON {
  55807. /**
  55808. * Implementation of the ENV Texture Loader.
  55809. * @hidden
  55810. */
  55811. export class _ENVTextureLoader implements IInternalTextureLoader {
  55812. /**
  55813. * Defines wether the loader supports cascade loading the different faces.
  55814. */
  55815. readonly supportCascades: boolean;
  55816. /**
  55817. * This returns if the loader support the current file information.
  55818. * @param extension defines the file extension of the file being loaded
  55819. * @returns true if the loader can load the specified file
  55820. */
  55821. canLoad(extension: string): boolean;
  55822. /**
  55823. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55824. * @param data contains the texture data
  55825. * @param texture defines the BabylonJS internal texture
  55826. * @param createPolynomials will be true if polynomials have been requested
  55827. * @param onLoad defines the callback to trigger once the texture is ready
  55828. * @param onError defines the callback to trigger in case of error
  55829. */
  55830. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55831. /**
  55832. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55833. * @param data contains the texture data
  55834. * @param texture defines the BabylonJS internal texture
  55835. * @param callback defines the method to call once ready to upload
  55836. */
  55837. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55838. }
  55839. }
  55840. declare module BABYLON {
  55841. /**
  55842. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55843. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55844. */
  55845. export class KhronosTextureContainer {
  55846. /** contents of the KTX container file */
  55847. data: ArrayBufferView;
  55848. private static HEADER_LEN;
  55849. private static COMPRESSED_2D;
  55850. private static COMPRESSED_3D;
  55851. private static TEX_2D;
  55852. private static TEX_3D;
  55853. /**
  55854. * Gets the openGL type
  55855. */
  55856. glType: number;
  55857. /**
  55858. * Gets the openGL type size
  55859. */
  55860. glTypeSize: number;
  55861. /**
  55862. * Gets the openGL format
  55863. */
  55864. glFormat: number;
  55865. /**
  55866. * Gets the openGL internal format
  55867. */
  55868. glInternalFormat: number;
  55869. /**
  55870. * Gets the base internal format
  55871. */
  55872. glBaseInternalFormat: number;
  55873. /**
  55874. * Gets image width in pixel
  55875. */
  55876. pixelWidth: number;
  55877. /**
  55878. * Gets image height in pixel
  55879. */
  55880. pixelHeight: number;
  55881. /**
  55882. * Gets image depth in pixels
  55883. */
  55884. pixelDepth: number;
  55885. /**
  55886. * Gets the number of array elements
  55887. */
  55888. numberOfArrayElements: number;
  55889. /**
  55890. * Gets the number of faces
  55891. */
  55892. numberOfFaces: number;
  55893. /**
  55894. * Gets the number of mipmap levels
  55895. */
  55896. numberOfMipmapLevels: number;
  55897. /**
  55898. * Gets the bytes of key value data
  55899. */
  55900. bytesOfKeyValueData: number;
  55901. /**
  55902. * Gets the load type
  55903. */
  55904. loadType: number;
  55905. /**
  55906. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  55907. */
  55908. isInvalid: boolean;
  55909. /**
  55910. * Creates a new KhronosTextureContainer
  55911. * @param data contents of the KTX container file
  55912. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  55913. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  55914. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  55915. */
  55916. constructor(
  55917. /** contents of the KTX container file */
  55918. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55919. /**
  55920. * Uploads KTX content to a Babylon Texture.
  55921. * It is assumed that the texture has already been created & is currently bound
  55922. * @hidden
  55923. */
  55924. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55925. private _upload2DCompressedLevels;
  55926. /**
  55927. * Checks if the given data starts with a KTX file identifier.
  55928. * @param data the data to check
  55929. * @returns true if the data is a KTX file or false otherwise
  55930. */
  55931. static IsValid(data: ArrayBufferView): boolean;
  55932. }
  55933. }
  55934. declare module BABYLON {
  55935. /**
  55936. * Class for loading KTX2 files
  55937. * !!! Experimental Extension Subject to Changes !!!
  55938. * @hidden
  55939. */
  55940. export class KhronosTextureContainer2 {
  55941. private static _ModulePromise;
  55942. private static _TranscodeFormat;
  55943. constructor(engine: ThinEngine);
  55944. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55945. private _determineTranscodeFormat;
  55946. /**
  55947. * Checks if the given data starts with a KTX2 file identifier.
  55948. * @param data the data to check
  55949. * @returns true if the data is a KTX2 file or false otherwise
  55950. */
  55951. static IsValid(data: ArrayBufferView): boolean;
  55952. }
  55953. }
  55954. declare module BABYLON {
  55955. /**
  55956. * Implementation of the KTX Texture Loader.
  55957. * @hidden
  55958. */
  55959. export class _KTXTextureLoader implements IInternalTextureLoader {
  55960. /**
  55961. * Defines wether the loader supports cascade loading the different faces.
  55962. */
  55963. readonly supportCascades: boolean;
  55964. /**
  55965. * This returns if the loader support the current file information.
  55966. * @param extension defines the file extension of the file being loaded
  55967. * @returns true if the loader can load the specified file
  55968. */
  55969. canLoad(extension: string): boolean;
  55970. /**
  55971. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55972. * @param data contains the texture data
  55973. * @param texture defines the BabylonJS internal texture
  55974. * @param createPolynomials will be true if polynomials have been requested
  55975. * @param onLoad defines the callback to trigger once the texture is ready
  55976. * @param onError defines the callback to trigger in case of error
  55977. */
  55978. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55979. /**
  55980. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55981. * @param data contains the texture data
  55982. * @param texture defines the BabylonJS internal texture
  55983. * @param callback defines the method to call once ready to upload
  55984. */
  55985. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55986. }
  55987. }
  55988. declare module BABYLON {
  55989. /** @hidden */
  55990. export var _forceSceneHelpersToBundle: boolean;
  55991. interface Scene {
  55992. /**
  55993. * Creates a default light for the scene.
  55994. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55995. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55996. */
  55997. createDefaultLight(replace?: boolean): void;
  55998. /**
  55999. * Creates a default camera for the scene.
  56000. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  56001. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56002. * @param replace has default false, when true replaces the active camera in the scene
  56003. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  56004. */
  56005. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56006. /**
  56007. * Creates a default camera and a default light.
  56008. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  56009. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56010. * @param replace has the default false, when true replaces the active camera/light in the scene
  56011. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56012. */
  56013. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56014. /**
  56015. * Creates a new sky box
  56016. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56017. * @param environmentTexture defines the texture to use as environment texture
  56018. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56019. * @param scale defines the overall scale of the skybox
  56020. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56021. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56022. * @returns a new mesh holding the sky box
  56023. */
  56024. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56025. /**
  56026. * Creates a new environment
  56027. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56028. * @param options defines the options you can use to configure the environment
  56029. * @returns the new EnvironmentHelper
  56030. */
  56031. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56032. /**
  56033. * Creates a new VREXperienceHelper
  56034. * @see http://doc.babylonjs.com/how_to/webvr_helper
  56035. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56036. * @returns a new VREXperienceHelper
  56037. */
  56038. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56039. /**
  56040. * Creates a new WebXRDefaultExperience
  56041. * @see http://doc.babylonjs.com/how_to/webxr
  56042. * @param options experience options
  56043. * @returns a promise for a new WebXRDefaultExperience
  56044. */
  56045. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56046. }
  56047. }
  56048. declare module BABYLON {
  56049. /**
  56050. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56051. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56052. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56053. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56054. */
  56055. export class VideoDome extends TransformNode {
  56056. /**
  56057. * Define the video source as a Monoscopic panoramic 360 video.
  56058. */
  56059. static readonly MODE_MONOSCOPIC: number;
  56060. /**
  56061. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56062. */
  56063. static readonly MODE_TOPBOTTOM: number;
  56064. /**
  56065. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56066. */
  56067. static readonly MODE_SIDEBYSIDE: number;
  56068. private _halfDome;
  56069. private _useDirectMapping;
  56070. /**
  56071. * The video texture being displayed on the sphere
  56072. */
  56073. protected _videoTexture: VideoTexture;
  56074. /**
  56075. * Gets the video texture being displayed on the sphere
  56076. */
  56077. get videoTexture(): VideoTexture;
  56078. /**
  56079. * The skybox material
  56080. */
  56081. protected _material: BackgroundMaterial;
  56082. /**
  56083. * The surface used for the skybox
  56084. */
  56085. protected _mesh: Mesh;
  56086. /**
  56087. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56088. */
  56089. private _halfDomeMask;
  56090. /**
  56091. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56092. * Also see the options.resolution property.
  56093. */
  56094. get fovMultiplier(): number;
  56095. set fovMultiplier(value: number);
  56096. private _videoMode;
  56097. /**
  56098. * Gets or set the current video mode for the video. It can be:
  56099. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56100. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56101. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56102. */
  56103. get videoMode(): number;
  56104. set videoMode(value: number);
  56105. /**
  56106. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56107. *
  56108. */
  56109. get halfDome(): boolean;
  56110. /**
  56111. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56112. */
  56113. set halfDome(enabled: boolean);
  56114. /**
  56115. * Oberserver used in Stereoscopic VR Mode.
  56116. */
  56117. private _onBeforeCameraRenderObserver;
  56118. /**
  56119. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56120. * @param name Element's name, child elements will append suffixes for their own names.
  56121. * @param urlsOrVideo defines the url(s) or the video element to use
  56122. * @param options An object containing optional or exposed sub element properties
  56123. */
  56124. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56125. resolution?: number;
  56126. clickToPlay?: boolean;
  56127. autoPlay?: boolean;
  56128. loop?: boolean;
  56129. size?: number;
  56130. poster?: string;
  56131. faceForward?: boolean;
  56132. useDirectMapping?: boolean;
  56133. halfDomeMode?: boolean;
  56134. }, scene: Scene);
  56135. private _changeVideoMode;
  56136. /**
  56137. * Releases resources associated with this node.
  56138. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56139. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56140. */
  56141. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56142. }
  56143. }
  56144. declare module BABYLON {
  56145. /**
  56146. * This class can be used to get instrumentation data from a Babylon engine
  56147. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56148. */
  56149. export class EngineInstrumentation implements IDisposable {
  56150. /**
  56151. * Define the instrumented engine.
  56152. */
  56153. engine: Engine;
  56154. private _captureGPUFrameTime;
  56155. private _gpuFrameTimeToken;
  56156. private _gpuFrameTime;
  56157. private _captureShaderCompilationTime;
  56158. private _shaderCompilationTime;
  56159. private _onBeginFrameObserver;
  56160. private _onEndFrameObserver;
  56161. private _onBeforeShaderCompilationObserver;
  56162. private _onAfterShaderCompilationObserver;
  56163. /**
  56164. * Gets the perf counter used for GPU frame time
  56165. */
  56166. get gpuFrameTimeCounter(): PerfCounter;
  56167. /**
  56168. * Gets the GPU frame time capture status
  56169. */
  56170. get captureGPUFrameTime(): boolean;
  56171. /**
  56172. * Enable or disable the GPU frame time capture
  56173. */
  56174. set captureGPUFrameTime(value: boolean);
  56175. /**
  56176. * Gets the perf counter used for shader compilation time
  56177. */
  56178. get shaderCompilationTimeCounter(): PerfCounter;
  56179. /**
  56180. * Gets the shader compilation time capture status
  56181. */
  56182. get captureShaderCompilationTime(): boolean;
  56183. /**
  56184. * Enable or disable the shader compilation time capture
  56185. */
  56186. set captureShaderCompilationTime(value: boolean);
  56187. /**
  56188. * Instantiates a new engine instrumentation.
  56189. * This class can be used to get instrumentation data from a Babylon engine
  56190. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56191. * @param engine Defines the engine to instrument
  56192. */
  56193. constructor(
  56194. /**
  56195. * Define the instrumented engine.
  56196. */
  56197. engine: Engine);
  56198. /**
  56199. * Dispose and release associated resources.
  56200. */
  56201. dispose(): void;
  56202. }
  56203. }
  56204. declare module BABYLON {
  56205. /**
  56206. * This class can be used to get instrumentation data from a Babylon engine
  56207. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56208. */
  56209. export class SceneInstrumentation implements IDisposable {
  56210. /**
  56211. * Defines the scene to instrument
  56212. */
  56213. scene: Scene;
  56214. private _captureActiveMeshesEvaluationTime;
  56215. private _activeMeshesEvaluationTime;
  56216. private _captureRenderTargetsRenderTime;
  56217. private _renderTargetsRenderTime;
  56218. private _captureFrameTime;
  56219. private _frameTime;
  56220. private _captureRenderTime;
  56221. private _renderTime;
  56222. private _captureInterFrameTime;
  56223. private _interFrameTime;
  56224. private _captureParticlesRenderTime;
  56225. private _particlesRenderTime;
  56226. private _captureSpritesRenderTime;
  56227. private _spritesRenderTime;
  56228. private _capturePhysicsTime;
  56229. private _physicsTime;
  56230. private _captureAnimationsTime;
  56231. private _animationsTime;
  56232. private _captureCameraRenderTime;
  56233. private _cameraRenderTime;
  56234. private _onBeforeActiveMeshesEvaluationObserver;
  56235. private _onAfterActiveMeshesEvaluationObserver;
  56236. private _onBeforeRenderTargetsRenderObserver;
  56237. private _onAfterRenderTargetsRenderObserver;
  56238. private _onAfterRenderObserver;
  56239. private _onBeforeDrawPhaseObserver;
  56240. private _onAfterDrawPhaseObserver;
  56241. private _onBeforeAnimationsObserver;
  56242. private _onBeforeParticlesRenderingObserver;
  56243. private _onAfterParticlesRenderingObserver;
  56244. private _onBeforeSpritesRenderingObserver;
  56245. private _onAfterSpritesRenderingObserver;
  56246. private _onBeforePhysicsObserver;
  56247. private _onAfterPhysicsObserver;
  56248. private _onAfterAnimationsObserver;
  56249. private _onBeforeCameraRenderObserver;
  56250. private _onAfterCameraRenderObserver;
  56251. /**
  56252. * Gets the perf counter used for active meshes evaluation time
  56253. */
  56254. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56255. /**
  56256. * Gets the active meshes evaluation time capture status
  56257. */
  56258. get captureActiveMeshesEvaluationTime(): boolean;
  56259. /**
  56260. * Enable or disable the active meshes evaluation time capture
  56261. */
  56262. set captureActiveMeshesEvaluationTime(value: boolean);
  56263. /**
  56264. * Gets the perf counter used for render targets render time
  56265. */
  56266. get renderTargetsRenderTimeCounter(): PerfCounter;
  56267. /**
  56268. * Gets the render targets render time capture status
  56269. */
  56270. get captureRenderTargetsRenderTime(): boolean;
  56271. /**
  56272. * Enable or disable the render targets render time capture
  56273. */
  56274. set captureRenderTargetsRenderTime(value: boolean);
  56275. /**
  56276. * Gets the perf counter used for particles render time
  56277. */
  56278. get particlesRenderTimeCounter(): PerfCounter;
  56279. /**
  56280. * Gets the particles render time capture status
  56281. */
  56282. get captureParticlesRenderTime(): boolean;
  56283. /**
  56284. * Enable or disable the particles render time capture
  56285. */
  56286. set captureParticlesRenderTime(value: boolean);
  56287. /**
  56288. * Gets the perf counter used for sprites render time
  56289. */
  56290. get spritesRenderTimeCounter(): PerfCounter;
  56291. /**
  56292. * Gets the sprites render time capture status
  56293. */
  56294. get captureSpritesRenderTime(): boolean;
  56295. /**
  56296. * Enable or disable the sprites render time capture
  56297. */
  56298. set captureSpritesRenderTime(value: boolean);
  56299. /**
  56300. * Gets the perf counter used for physics time
  56301. */
  56302. get physicsTimeCounter(): PerfCounter;
  56303. /**
  56304. * Gets the physics time capture status
  56305. */
  56306. get capturePhysicsTime(): boolean;
  56307. /**
  56308. * Enable or disable the physics time capture
  56309. */
  56310. set capturePhysicsTime(value: boolean);
  56311. /**
  56312. * Gets the perf counter used for animations time
  56313. */
  56314. get animationsTimeCounter(): PerfCounter;
  56315. /**
  56316. * Gets the animations time capture status
  56317. */
  56318. get captureAnimationsTime(): boolean;
  56319. /**
  56320. * Enable or disable the animations time capture
  56321. */
  56322. set captureAnimationsTime(value: boolean);
  56323. /**
  56324. * Gets the perf counter used for frame time capture
  56325. */
  56326. get frameTimeCounter(): PerfCounter;
  56327. /**
  56328. * Gets the frame time capture status
  56329. */
  56330. get captureFrameTime(): boolean;
  56331. /**
  56332. * Enable or disable the frame time capture
  56333. */
  56334. set captureFrameTime(value: boolean);
  56335. /**
  56336. * Gets the perf counter used for inter-frames time capture
  56337. */
  56338. get interFrameTimeCounter(): PerfCounter;
  56339. /**
  56340. * Gets the inter-frames time capture status
  56341. */
  56342. get captureInterFrameTime(): boolean;
  56343. /**
  56344. * Enable or disable the inter-frames time capture
  56345. */
  56346. set captureInterFrameTime(value: boolean);
  56347. /**
  56348. * Gets the perf counter used for render time capture
  56349. */
  56350. get renderTimeCounter(): PerfCounter;
  56351. /**
  56352. * Gets the render time capture status
  56353. */
  56354. get captureRenderTime(): boolean;
  56355. /**
  56356. * Enable or disable the render time capture
  56357. */
  56358. set captureRenderTime(value: boolean);
  56359. /**
  56360. * Gets the perf counter used for camera render time capture
  56361. */
  56362. get cameraRenderTimeCounter(): PerfCounter;
  56363. /**
  56364. * Gets the camera render time capture status
  56365. */
  56366. get captureCameraRenderTime(): boolean;
  56367. /**
  56368. * Enable or disable the camera render time capture
  56369. */
  56370. set captureCameraRenderTime(value: boolean);
  56371. /**
  56372. * Gets the perf counter used for draw calls
  56373. */
  56374. get drawCallsCounter(): PerfCounter;
  56375. /**
  56376. * Instantiates a new scene instrumentation.
  56377. * This class can be used to get instrumentation data from a Babylon engine
  56378. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56379. * @param scene Defines the scene to instrument
  56380. */
  56381. constructor(
  56382. /**
  56383. * Defines the scene to instrument
  56384. */
  56385. scene: Scene);
  56386. /**
  56387. * Dispose and release associated resources.
  56388. */
  56389. dispose(): void;
  56390. }
  56391. }
  56392. declare module BABYLON {
  56393. /** @hidden */
  56394. export var glowMapGenerationPixelShader: {
  56395. name: string;
  56396. shader: string;
  56397. };
  56398. }
  56399. declare module BABYLON {
  56400. /** @hidden */
  56401. export var glowMapGenerationVertexShader: {
  56402. name: string;
  56403. shader: string;
  56404. };
  56405. }
  56406. declare module BABYLON {
  56407. /**
  56408. * Effect layer options. This helps customizing the behaviour
  56409. * of the effect layer.
  56410. */
  56411. export interface IEffectLayerOptions {
  56412. /**
  56413. * Multiplication factor apply to the canvas size to compute the render target size
  56414. * used to generated the objects (the smaller the faster).
  56415. */
  56416. mainTextureRatio: number;
  56417. /**
  56418. * Enforces a fixed size texture to ensure effect stability across devices.
  56419. */
  56420. mainTextureFixedSize?: number;
  56421. /**
  56422. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56423. */
  56424. alphaBlendingMode: number;
  56425. /**
  56426. * The camera attached to the layer.
  56427. */
  56428. camera: Nullable<Camera>;
  56429. /**
  56430. * The rendering group to draw the layer in.
  56431. */
  56432. renderingGroupId: number;
  56433. }
  56434. /**
  56435. * The effect layer Helps adding post process effect blended with the main pass.
  56436. *
  56437. * This can be for instance use to generate glow or higlight effects on the scene.
  56438. *
  56439. * The effect layer class can not be used directly and is intented to inherited from to be
  56440. * customized per effects.
  56441. */
  56442. export abstract class EffectLayer {
  56443. private _vertexBuffers;
  56444. private _indexBuffer;
  56445. private _cachedDefines;
  56446. private _effectLayerMapGenerationEffect;
  56447. private _effectLayerOptions;
  56448. private _mergeEffect;
  56449. protected _scene: Scene;
  56450. protected _engine: Engine;
  56451. protected _maxSize: number;
  56452. protected _mainTextureDesiredSize: ISize;
  56453. protected _mainTexture: RenderTargetTexture;
  56454. protected _shouldRender: boolean;
  56455. protected _postProcesses: PostProcess[];
  56456. protected _textures: BaseTexture[];
  56457. protected _emissiveTextureAndColor: {
  56458. texture: Nullable<BaseTexture>;
  56459. color: Color4;
  56460. };
  56461. /**
  56462. * The name of the layer
  56463. */
  56464. name: string;
  56465. /**
  56466. * The clear color of the texture used to generate the glow map.
  56467. */
  56468. neutralColor: Color4;
  56469. /**
  56470. * Specifies whether the highlight layer is enabled or not.
  56471. */
  56472. isEnabled: boolean;
  56473. /**
  56474. * Gets the camera attached to the layer.
  56475. */
  56476. get camera(): Nullable<Camera>;
  56477. /**
  56478. * Gets the rendering group id the layer should render in.
  56479. */
  56480. get renderingGroupId(): number;
  56481. set renderingGroupId(renderingGroupId: number);
  56482. /**
  56483. * An event triggered when the effect layer has been disposed.
  56484. */
  56485. onDisposeObservable: Observable<EffectLayer>;
  56486. /**
  56487. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56488. */
  56489. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56490. /**
  56491. * An event triggered when the generated texture is being merged in the scene.
  56492. */
  56493. onBeforeComposeObservable: Observable<EffectLayer>;
  56494. /**
  56495. * An event triggered when the mesh is rendered into the effect render target.
  56496. */
  56497. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56498. /**
  56499. * An event triggered after the mesh has been rendered into the effect render target.
  56500. */
  56501. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56502. /**
  56503. * An event triggered when the generated texture has been merged in the scene.
  56504. */
  56505. onAfterComposeObservable: Observable<EffectLayer>;
  56506. /**
  56507. * An event triggered when the efffect layer changes its size.
  56508. */
  56509. onSizeChangedObservable: Observable<EffectLayer>;
  56510. /** @hidden */
  56511. static _SceneComponentInitialization: (scene: Scene) => void;
  56512. /**
  56513. * Instantiates a new effect Layer and references it in the scene.
  56514. * @param name The name of the layer
  56515. * @param scene The scene to use the layer in
  56516. */
  56517. constructor(
  56518. /** The Friendly of the effect in the scene */
  56519. name: string, scene: Scene);
  56520. /**
  56521. * Get the effect name of the layer.
  56522. * @return The effect name
  56523. */
  56524. abstract getEffectName(): string;
  56525. /**
  56526. * Checks for the readiness of the element composing the layer.
  56527. * @param subMesh the mesh to check for
  56528. * @param useInstances specify whether or not to use instances to render the mesh
  56529. * @return true if ready otherwise, false
  56530. */
  56531. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56532. /**
  56533. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56534. * @returns true if the effect requires stencil during the main canvas render pass.
  56535. */
  56536. abstract needStencil(): boolean;
  56537. /**
  56538. * Create the merge effect. This is the shader use to blit the information back
  56539. * to the main canvas at the end of the scene rendering.
  56540. * @returns The effect containing the shader used to merge the effect on the main canvas
  56541. */
  56542. protected abstract _createMergeEffect(): Effect;
  56543. /**
  56544. * Creates the render target textures and post processes used in the effect layer.
  56545. */
  56546. protected abstract _createTextureAndPostProcesses(): void;
  56547. /**
  56548. * Implementation specific of rendering the generating effect on the main canvas.
  56549. * @param effect The effect used to render through
  56550. */
  56551. protected abstract _internalRender(effect: Effect): void;
  56552. /**
  56553. * Sets the required values for both the emissive texture and and the main color.
  56554. */
  56555. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56556. /**
  56557. * Free any resources and references associated to a mesh.
  56558. * Internal use
  56559. * @param mesh The mesh to free.
  56560. */
  56561. abstract _disposeMesh(mesh: Mesh): void;
  56562. /**
  56563. * Serializes this layer (Glow or Highlight for example)
  56564. * @returns a serialized layer object
  56565. */
  56566. abstract serialize?(): any;
  56567. /**
  56568. * Initializes the effect layer with the required options.
  56569. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56570. */
  56571. protected _init(options: Partial<IEffectLayerOptions>): void;
  56572. /**
  56573. * Generates the index buffer of the full screen quad blending to the main canvas.
  56574. */
  56575. private _generateIndexBuffer;
  56576. /**
  56577. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56578. */
  56579. private _generateVertexBuffer;
  56580. /**
  56581. * Sets the main texture desired size which is the closest power of two
  56582. * of the engine canvas size.
  56583. */
  56584. private _setMainTextureSize;
  56585. /**
  56586. * Creates the main texture for the effect layer.
  56587. */
  56588. protected _createMainTexture(): void;
  56589. /**
  56590. * Adds specific effects defines.
  56591. * @param defines The defines to add specifics to.
  56592. */
  56593. protected _addCustomEffectDefines(defines: string[]): void;
  56594. /**
  56595. * Checks for the readiness of the element composing the layer.
  56596. * @param subMesh the mesh to check for
  56597. * @param useInstances specify whether or not to use instances to render the mesh
  56598. * @param emissiveTexture the associated emissive texture used to generate the glow
  56599. * @return true if ready otherwise, false
  56600. */
  56601. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56602. /**
  56603. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56604. */
  56605. render(): void;
  56606. /**
  56607. * Determine if a given mesh will be used in the current effect.
  56608. * @param mesh mesh to test
  56609. * @returns true if the mesh will be used
  56610. */
  56611. hasMesh(mesh: AbstractMesh): boolean;
  56612. /**
  56613. * Returns true if the layer contains information to display, otherwise false.
  56614. * @returns true if the glow layer should be rendered
  56615. */
  56616. shouldRender(): boolean;
  56617. /**
  56618. * Returns true if the mesh should render, otherwise false.
  56619. * @param mesh The mesh to render
  56620. * @returns true if it should render otherwise false
  56621. */
  56622. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56623. /**
  56624. * Returns true if the mesh can be rendered, otherwise false.
  56625. * @param mesh The mesh to render
  56626. * @param material The material used on the mesh
  56627. * @returns true if it can be rendered otherwise false
  56628. */
  56629. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56630. /**
  56631. * Returns true if the mesh should render, otherwise false.
  56632. * @param mesh The mesh to render
  56633. * @returns true if it should render otherwise false
  56634. */
  56635. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56636. /**
  56637. * Renders the submesh passed in parameter to the generation map.
  56638. */
  56639. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56640. /**
  56641. * Defines whether the current material of the mesh should be use to render the effect.
  56642. * @param mesh defines the current mesh to render
  56643. */
  56644. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56645. /**
  56646. * Rebuild the required buffers.
  56647. * @hidden Internal use only.
  56648. */
  56649. _rebuild(): void;
  56650. /**
  56651. * Dispose only the render target textures and post process.
  56652. */
  56653. private _disposeTextureAndPostProcesses;
  56654. /**
  56655. * Dispose the highlight layer and free resources.
  56656. */
  56657. dispose(): void;
  56658. /**
  56659. * Gets the class name of the effect layer
  56660. * @returns the string with the class name of the effect layer
  56661. */
  56662. getClassName(): string;
  56663. /**
  56664. * Creates an effect layer from parsed effect layer data
  56665. * @param parsedEffectLayer defines effect layer data
  56666. * @param scene defines the current scene
  56667. * @param rootUrl defines the root URL containing the effect layer information
  56668. * @returns a parsed effect Layer
  56669. */
  56670. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56671. }
  56672. }
  56673. declare module BABYLON {
  56674. interface AbstractScene {
  56675. /**
  56676. * The list of effect layers (highlights/glow) added to the scene
  56677. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56678. * @see http://doc.babylonjs.com/how_to/glow_layer
  56679. */
  56680. effectLayers: Array<EffectLayer>;
  56681. /**
  56682. * Removes the given effect layer from this scene.
  56683. * @param toRemove defines the effect layer to remove
  56684. * @returns the index of the removed effect layer
  56685. */
  56686. removeEffectLayer(toRemove: EffectLayer): number;
  56687. /**
  56688. * Adds the given effect layer to this scene
  56689. * @param newEffectLayer defines the effect layer to add
  56690. */
  56691. addEffectLayer(newEffectLayer: EffectLayer): void;
  56692. }
  56693. /**
  56694. * Defines the layer scene component responsible to manage any effect layers
  56695. * in a given scene.
  56696. */
  56697. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56698. /**
  56699. * The component name helpfull to identify the component in the list of scene components.
  56700. */
  56701. readonly name: string;
  56702. /**
  56703. * The scene the component belongs to.
  56704. */
  56705. scene: Scene;
  56706. private _engine;
  56707. private _renderEffects;
  56708. private _needStencil;
  56709. private _previousStencilState;
  56710. /**
  56711. * Creates a new instance of the component for the given scene
  56712. * @param scene Defines the scene to register the component in
  56713. */
  56714. constructor(scene: Scene);
  56715. /**
  56716. * Registers the component in a given scene
  56717. */
  56718. register(): void;
  56719. /**
  56720. * Rebuilds the elements related to this component in case of
  56721. * context lost for instance.
  56722. */
  56723. rebuild(): void;
  56724. /**
  56725. * Serializes the component data to the specified json object
  56726. * @param serializationObject The object to serialize to
  56727. */
  56728. serialize(serializationObject: any): void;
  56729. /**
  56730. * Adds all the elements from the container to the scene
  56731. * @param container the container holding the elements
  56732. */
  56733. addFromContainer(container: AbstractScene): void;
  56734. /**
  56735. * Removes all the elements in the container from the scene
  56736. * @param container contains the elements to remove
  56737. * @param dispose if the removed element should be disposed (default: false)
  56738. */
  56739. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56740. /**
  56741. * Disposes the component and the associated ressources.
  56742. */
  56743. dispose(): void;
  56744. private _isReadyForMesh;
  56745. private _renderMainTexture;
  56746. private _setStencil;
  56747. private _setStencilBack;
  56748. private _draw;
  56749. private _drawCamera;
  56750. private _drawRenderingGroup;
  56751. }
  56752. }
  56753. declare module BABYLON {
  56754. /** @hidden */
  56755. export var glowMapMergePixelShader: {
  56756. name: string;
  56757. shader: string;
  56758. };
  56759. }
  56760. declare module BABYLON {
  56761. /** @hidden */
  56762. export var glowMapMergeVertexShader: {
  56763. name: string;
  56764. shader: string;
  56765. };
  56766. }
  56767. declare module BABYLON {
  56768. interface AbstractScene {
  56769. /**
  56770. * Return a the first highlight layer of the scene with a given name.
  56771. * @param name The name of the highlight layer to look for.
  56772. * @return The highlight layer if found otherwise null.
  56773. */
  56774. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  56775. }
  56776. /**
  56777. * Glow layer options. This helps customizing the behaviour
  56778. * of the glow layer.
  56779. */
  56780. export interface IGlowLayerOptions {
  56781. /**
  56782. * Multiplication factor apply to the canvas size to compute the render target size
  56783. * used to generated the glowing objects (the smaller the faster).
  56784. */
  56785. mainTextureRatio: number;
  56786. /**
  56787. * Enforces a fixed size texture to ensure resize independant blur.
  56788. */
  56789. mainTextureFixedSize?: number;
  56790. /**
  56791. * How big is the kernel of the blur texture.
  56792. */
  56793. blurKernelSize: number;
  56794. /**
  56795. * The camera attached to the layer.
  56796. */
  56797. camera: Nullable<Camera>;
  56798. /**
  56799. * Enable MSAA by chosing the number of samples.
  56800. */
  56801. mainTextureSamples?: number;
  56802. /**
  56803. * The rendering group to draw the layer in.
  56804. */
  56805. renderingGroupId: number;
  56806. }
  56807. /**
  56808. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  56809. *
  56810. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  56811. *
  56812. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  56813. */
  56814. export class GlowLayer extends EffectLayer {
  56815. /**
  56816. * Effect Name of the layer.
  56817. */
  56818. static readonly EffectName: string;
  56819. /**
  56820. * The default blur kernel size used for the glow.
  56821. */
  56822. static DefaultBlurKernelSize: number;
  56823. /**
  56824. * The default texture size ratio used for the glow.
  56825. */
  56826. static DefaultTextureRatio: number;
  56827. /**
  56828. * Sets the kernel size of the blur.
  56829. */
  56830. set blurKernelSize(value: number);
  56831. /**
  56832. * Gets the kernel size of the blur.
  56833. */
  56834. get blurKernelSize(): number;
  56835. /**
  56836. * Sets the glow intensity.
  56837. */
  56838. set intensity(value: number);
  56839. /**
  56840. * Gets the glow intensity.
  56841. */
  56842. get intensity(): number;
  56843. private _options;
  56844. private _intensity;
  56845. private _horizontalBlurPostprocess1;
  56846. private _verticalBlurPostprocess1;
  56847. private _horizontalBlurPostprocess2;
  56848. private _verticalBlurPostprocess2;
  56849. private _blurTexture1;
  56850. private _blurTexture2;
  56851. private _postProcesses1;
  56852. private _postProcesses2;
  56853. private _includedOnlyMeshes;
  56854. private _excludedMeshes;
  56855. private _meshesUsingTheirOwnMaterials;
  56856. /**
  56857. * Callback used to let the user override the color selection on a per mesh basis
  56858. */
  56859. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56860. /**
  56861. * Callback used to let the user override the texture selection on a per mesh basis
  56862. */
  56863. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56864. /**
  56865. * Instantiates a new glow Layer and references it to the scene.
  56866. * @param name The name of the layer
  56867. * @param scene The scene to use the layer in
  56868. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56869. */
  56870. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56871. /**
  56872. * Get the effect name of the layer.
  56873. * @return The effect name
  56874. */
  56875. getEffectName(): string;
  56876. /**
  56877. * Create the merge effect. This is the shader use to blit the information back
  56878. * to the main canvas at the end of the scene rendering.
  56879. */
  56880. protected _createMergeEffect(): Effect;
  56881. /**
  56882. * Creates the render target textures and post processes used in the glow layer.
  56883. */
  56884. protected _createTextureAndPostProcesses(): void;
  56885. /**
  56886. * Checks for the readiness of the element composing the layer.
  56887. * @param subMesh the mesh to check for
  56888. * @param useInstances specify wether or not to use instances to render the mesh
  56889. * @param emissiveTexture the associated emissive texture used to generate the glow
  56890. * @return true if ready otherwise, false
  56891. */
  56892. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56893. /**
  56894. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56895. */
  56896. needStencil(): boolean;
  56897. /**
  56898. * Returns true if the mesh can be rendered, otherwise false.
  56899. * @param mesh The mesh to render
  56900. * @param material The material used on the mesh
  56901. * @returns true if it can be rendered otherwise false
  56902. */
  56903. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56904. /**
  56905. * Implementation specific of rendering the generating effect on the main canvas.
  56906. * @param effect The effect used to render through
  56907. */
  56908. protected _internalRender(effect: Effect): void;
  56909. /**
  56910. * Sets the required values for both the emissive texture and and the main color.
  56911. */
  56912. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56913. /**
  56914. * Returns true if the mesh should render, otherwise false.
  56915. * @param mesh The mesh to render
  56916. * @returns true if it should render otherwise false
  56917. */
  56918. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56919. /**
  56920. * Adds specific effects defines.
  56921. * @param defines The defines to add specifics to.
  56922. */
  56923. protected _addCustomEffectDefines(defines: string[]): void;
  56924. /**
  56925. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56926. * @param mesh The mesh to exclude from the glow layer
  56927. */
  56928. addExcludedMesh(mesh: Mesh): void;
  56929. /**
  56930. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56931. * @param mesh The mesh to remove
  56932. */
  56933. removeExcludedMesh(mesh: Mesh): void;
  56934. /**
  56935. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56936. * @param mesh The mesh to include in the glow layer
  56937. */
  56938. addIncludedOnlyMesh(mesh: Mesh): void;
  56939. /**
  56940. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56941. * @param mesh The mesh to remove
  56942. */
  56943. removeIncludedOnlyMesh(mesh: Mesh): void;
  56944. /**
  56945. * Determine if a given mesh will be used in the glow layer
  56946. * @param mesh The mesh to test
  56947. * @returns true if the mesh will be highlighted by the current glow layer
  56948. */
  56949. hasMesh(mesh: AbstractMesh): boolean;
  56950. /**
  56951. * Defines whether the current material of the mesh should be use to render the effect.
  56952. * @param mesh defines the current mesh to render
  56953. */
  56954. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56955. /**
  56956. * Add a mesh to be rendered through its own material and not with emissive only.
  56957. * @param mesh The mesh for which we need to use its material
  56958. */
  56959. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56960. /**
  56961. * Remove a mesh from being rendered through its own material and not with emissive only.
  56962. * @param mesh The mesh for which we need to not use its material
  56963. */
  56964. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56965. /**
  56966. * Free any resources and references associated to a mesh.
  56967. * Internal use
  56968. * @param mesh The mesh to free.
  56969. * @hidden
  56970. */
  56971. _disposeMesh(mesh: Mesh): void;
  56972. /**
  56973. * Gets the class name of the effect layer
  56974. * @returns the string with the class name of the effect layer
  56975. */
  56976. getClassName(): string;
  56977. /**
  56978. * Serializes this glow layer
  56979. * @returns a serialized glow layer object
  56980. */
  56981. serialize(): any;
  56982. /**
  56983. * Creates a Glow Layer from parsed glow layer data
  56984. * @param parsedGlowLayer defines glow layer data
  56985. * @param scene defines the current scene
  56986. * @param rootUrl defines the root URL containing the glow layer information
  56987. * @returns a parsed Glow Layer
  56988. */
  56989. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56990. }
  56991. }
  56992. declare module BABYLON {
  56993. /** @hidden */
  56994. export var glowBlurPostProcessPixelShader: {
  56995. name: string;
  56996. shader: string;
  56997. };
  56998. }
  56999. declare module BABYLON {
  57000. interface AbstractScene {
  57001. /**
  57002. * Return a the first highlight layer of the scene with a given name.
  57003. * @param name The name of the highlight layer to look for.
  57004. * @return The highlight layer if found otherwise null.
  57005. */
  57006. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  57007. }
  57008. /**
  57009. * Highlight layer options. This helps customizing the behaviour
  57010. * of the highlight layer.
  57011. */
  57012. export interface IHighlightLayerOptions {
  57013. /**
  57014. * Multiplication factor apply to the canvas size to compute the render target size
  57015. * used to generated the glowing objects (the smaller the faster).
  57016. */
  57017. mainTextureRatio: number;
  57018. /**
  57019. * Enforces a fixed size texture to ensure resize independant blur.
  57020. */
  57021. mainTextureFixedSize?: number;
  57022. /**
  57023. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57024. * of the picture to blur (the smaller the faster).
  57025. */
  57026. blurTextureSizeRatio: number;
  57027. /**
  57028. * How big in texel of the blur texture is the vertical blur.
  57029. */
  57030. blurVerticalSize: number;
  57031. /**
  57032. * How big in texel of the blur texture is the horizontal blur.
  57033. */
  57034. blurHorizontalSize: number;
  57035. /**
  57036. * Alpha blending mode used to apply the blur. Default is combine.
  57037. */
  57038. alphaBlendingMode: number;
  57039. /**
  57040. * The camera attached to the layer.
  57041. */
  57042. camera: Nullable<Camera>;
  57043. /**
  57044. * Should we display highlight as a solid stroke?
  57045. */
  57046. isStroke?: boolean;
  57047. /**
  57048. * The rendering group to draw the layer in.
  57049. */
  57050. renderingGroupId: number;
  57051. }
  57052. /**
  57053. * The highlight layer Helps adding a glow effect around a mesh.
  57054. *
  57055. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57056. * glowy meshes to your scene.
  57057. *
  57058. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57059. */
  57060. export class HighlightLayer extends EffectLayer {
  57061. name: string;
  57062. /**
  57063. * Effect Name of the highlight layer.
  57064. */
  57065. static readonly EffectName: string;
  57066. /**
  57067. * The neutral color used during the preparation of the glow effect.
  57068. * This is black by default as the blend operation is a blend operation.
  57069. */
  57070. static NeutralColor: Color4;
  57071. /**
  57072. * Stencil value used for glowing meshes.
  57073. */
  57074. static GlowingMeshStencilReference: number;
  57075. /**
  57076. * Stencil value used for the other meshes in the scene.
  57077. */
  57078. static NormalMeshStencilReference: number;
  57079. /**
  57080. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57081. */
  57082. innerGlow: boolean;
  57083. /**
  57084. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57085. */
  57086. outerGlow: boolean;
  57087. /**
  57088. * Specifies the horizontal size of the blur.
  57089. */
  57090. set blurHorizontalSize(value: number);
  57091. /**
  57092. * Specifies the vertical size of the blur.
  57093. */
  57094. set blurVerticalSize(value: number);
  57095. /**
  57096. * Gets the horizontal size of the blur.
  57097. */
  57098. get blurHorizontalSize(): number;
  57099. /**
  57100. * Gets the vertical size of the blur.
  57101. */
  57102. get blurVerticalSize(): number;
  57103. /**
  57104. * An event triggered when the highlight layer is being blurred.
  57105. */
  57106. onBeforeBlurObservable: Observable<HighlightLayer>;
  57107. /**
  57108. * An event triggered when the highlight layer has been blurred.
  57109. */
  57110. onAfterBlurObservable: Observable<HighlightLayer>;
  57111. private _instanceGlowingMeshStencilReference;
  57112. private _options;
  57113. private _downSamplePostprocess;
  57114. private _horizontalBlurPostprocess;
  57115. private _verticalBlurPostprocess;
  57116. private _blurTexture;
  57117. private _meshes;
  57118. private _excludedMeshes;
  57119. /**
  57120. * Instantiates a new highlight Layer and references it to the scene..
  57121. * @param name The name of the layer
  57122. * @param scene The scene to use the layer in
  57123. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57124. */
  57125. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57126. /**
  57127. * Get the effect name of the layer.
  57128. * @return The effect name
  57129. */
  57130. getEffectName(): string;
  57131. /**
  57132. * Create the merge effect. This is the shader use to blit the information back
  57133. * to the main canvas at the end of the scene rendering.
  57134. */
  57135. protected _createMergeEffect(): Effect;
  57136. /**
  57137. * Creates the render target textures and post processes used in the highlight layer.
  57138. */
  57139. protected _createTextureAndPostProcesses(): void;
  57140. /**
  57141. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57142. */
  57143. needStencil(): boolean;
  57144. /**
  57145. * Checks for the readiness of the element composing the layer.
  57146. * @param subMesh the mesh to check for
  57147. * @param useInstances specify wether or not to use instances to render the mesh
  57148. * @param emissiveTexture the associated emissive texture used to generate the glow
  57149. * @return true if ready otherwise, false
  57150. */
  57151. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57152. /**
  57153. * Implementation specific of rendering the generating effect on the main canvas.
  57154. * @param effect The effect used to render through
  57155. */
  57156. protected _internalRender(effect: Effect): void;
  57157. /**
  57158. * Returns true if the layer contains information to display, otherwise false.
  57159. */
  57160. shouldRender(): boolean;
  57161. /**
  57162. * Returns true if the mesh should render, otherwise false.
  57163. * @param mesh The mesh to render
  57164. * @returns true if it should render otherwise false
  57165. */
  57166. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57167. /**
  57168. * Adds specific effects defines.
  57169. * @param defines The defines to add specifics to.
  57170. */
  57171. protected _addCustomEffectDefines(defines: string[]): void;
  57172. /**
  57173. * Sets the required values for both the emissive texture and and the main color.
  57174. */
  57175. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57176. /**
  57177. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57178. * @param mesh The mesh to exclude from the highlight layer
  57179. */
  57180. addExcludedMesh(mesh: Mesh): void;
  57181. /**
  57182. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57183. * @param mesh The mesh to highlight
  57184. */
  57185. removeExcludedMesh(mesh: Mesh): void;
  57186. /**
  57187. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57188. * @param mesh mesh to test
  57189. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57190. */
  57191. hasMesh(mesh: AbstractMesh): boolean;
  57192. /**
  57193. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57194. * @param mesh The mesh to highlight
  57195. * @param color The color of the highlight
  57196. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57197. */
  57198. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57199. /**
  57200. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57201. * @param mesh The mesh to highlight
  57202. */
  57203. removeMesh(mesh: Mesh): void;
  57204. /**
  57205. * Remove all the meshes currently referenced in the highlight layer
  57206. */
  57207. removeAllMeshes(): void;
  57208. /**
  57209. * Force the stencil to the normal expected value for none glowing parts
  57210. */
  57211. private _defaultStencilReference;
  57212. /**
  57213. * Free any resources and references associated to a mesh.
  57214. * Internal use
  57215. * @param mesh The mesh to free.
  57216. * @hidden
  57217. */
  57218. _disposeMesh(mesh: Mesh): void;
  57219. /**
  57220. * Dispose the highlight layer and free resources.
  57221. */
  57222. dispose(): void;
  57223. /**
  57224. * Gets the class name of the effect layer
  57225. * @returns the string with the class name of the effect layer
  57226. */
  57227. getClassName(): string;
  57228. /**
  57229. * Serializes this Highlight layer
  57230. * @returns a serialized Highlight layer object
  57231. */
  57232. serialize(): any;
  57233. /**
  57234. * Creates a Highlight layer from parsed Highlight layer data
  57235. * @param parsedHightlightLayer defines the Highlight layer data
  57236. * @param scene defines the current scene
  57237. * @param rootUrl defines the root URL containing the Highlight layer information
  57238. * @returns a parsed Highlight layer
  57239. */
  57240. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57241. }
  57242. }
  57243. declare module BABYLON {
  57244. interface AbstractScene {
  57245. /**
  57246. * The list of layers (background and foreground) of the scene
  57247. */
  57248. layers: Array<Layer>;
  57249. }
  57250. /**
  57251. * Defines the layer scene component responsible to manage any layers
  57252. * in a given scene.
  57253. */
  57254. export class LayerSceneComponent implements ISceneComponent {
  57255. /**
  57256. * The component name helpfull to identify the component in the list of scene components.
  57257. */
  57258. readonly name: string;
  57259. /**
  57260. * The scene the component belongs to.
  57261. */
  57262. scene: Scene;
  57263. private _engine;
  57264. /**
  57265. * Creates a new instance of the component for the given scene
  57266. * @param scene Defines the scene to register the component in
  57267. */
  57268. constructor(scene: Scene);
  57269. /**
  57270. * Registers the component in a given scene
  57271. */
  57272. register(): void;
  57273. /**
  57274. * Rebuilds the elements related to this component in case of
  57275. * context lost for instance.
  57276. */
  57277. rebuild(): void;
  57278. /**
  57279. * Disposes the component and the associated ressources.
  57280. */
  57281. dispose(): void;
  57282. private _draw;
  57283. private _drawCameraPredicate;
  57284. private _drawCameraBackground;
  57285. private _drawCameraForeground;
  57286. private _drawRenderTargetPredicate;
  57287. private _drawRenderTargetBackground;
  57288. private _drawRenderTargetForeground;
  57289. /**
  57290. * Adds all the elements from the container to the scene
  57291. * @param container the container holding the elements
  57292. */
  57293. addFromContainer(container: AbstractScene): void;
  57294. /**
  57295. * Removes all the elements in the container from the scene
  57296. * @param container contains the elements to remove
  57297. * @param dispose if the removed element should be disposed (default: false)
  57298. */
  57299. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57300. }
  57301. }
  57302. declare module BABYLON {
  57303. /** @hidden */
  57304. export var layerPixelShader: {
  57305. name: string;
  57306. shader: string;
  57307. };
  57308. }
  57309. declare module BABYLON {
  57310. /** @hidden */
  57311. export var layerVertexShader: {
  57312. name: string;
  57313. shader: string;
  57314. };
  57315. }
  57316. declare module BABYLON {
  57317. /**
  57318. * This represents a full screen 2d layer.
  57319. * This can be useful to display a picture in the background of your scene for instance.
  57320. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57321. */
  57322. export class Layer {
  57323. /**
  57324. * Define the name of the layer.
  57325. */
  57326. name: string;
  57327. /**
  57328. * Define the texture the layer should display.
  57329. */
  57330. texture: Nullable<Texture>;
  57331. /**
  57332. * Is the layer in background or foreground.
  57333. */
  57334. isBackground: boolean;
  57335. /**
  57336. * Define the color of the layer (instead of texture).
  57337. */
  57338. color: Color4;
  57339. /**
  57340. * Define the scale of the layer in order to zoom in out of the texture.
  57341. */
  57342. scale: Vector2;
  57343. /**
  57344. * Define an offset for the layer in order to shift the texture.
  57345. */
  57346. offset: Vector2;
  57347. /**
  57348. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57349. */
  57350. alphaBlendingMode: number;
  57351. /**
  57352. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57353. * Alpha test will not mix with the background color in case of transparency.
  57354. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57355. */
  57356. alphaTest: boolean;
  57357. /**
  57358. * Define a mask to restrict the layer to only some of the scene cameras.
  57359. */
  57360. layerMask: number;
  57361. /**
  57362. * Define the list of render target the layer is visible into.
  57363. */
  57364. renderTargetTextures: RenderTargetTexture[];
  57365. /**
  57366. * Define if the layer is only used in renderTarget or if it also
  57367. * renders in the main frame buffer of the canvas.
  57368. */
  57369. renderOnlyInRenderTargetTextures: boolean;
  57370. private _scene;
  57371. private _vertexBuffers;
  57372. private _indexBuffer;
  57373. private _effect;
  57374. private _previousDefines;
  57375. /**
  57376. * An event triggered when the layer is disposed.
  57377. */
  57378. onDisposeObservable: Observable<Layer>;
  57379. private _onDisposeObserver;
  57380. /**
  57381. * Back compatibility with callback before the onDisposeObservable existed.
  57382. * The set callback will be triggered when the layer has been disposed.
  57383. */
  57384. set onDispose(callback: () => void);
  57385. /**
  57386. * An event triggered before rendering the scene
  57387. */
  57388. onBeforeRenderObservable: Observable<Layer>;
  57389. private _onBeforeRenderObserver;
  57390. /**
  57391. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57392. * The set callback will be triggered just before rendering the layer.
  57393. */
  57394. set onBeforeRender(callback: () => void);
  57395. /**
  57396. * An event triggered after rendering the scene
  57397. */
  57398. onAfterRenderObservable: Observable<Layer>;
  57399. private _onAfterRenderObserver;
  57400. /**
  57401. * Back compatibility with callback before the onAfterRenderObservable existed.
  57402. * The set callback will be triggered just after rendering the layer.
  57403. */
  57404. set onAfterRender(callback: () => void);
  57405. /**
  57406. * Instantiates a new layer.
  57407. * This represents a full screen 2d layer.
  57408. * This can be useful to display a picture in the background of your scene for instance.
  57409. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57410. * @param name Define the name of the layer in the scene
  57411. * @param imgUrl Define the url of the texture to display in the layer
  57412. * @param scene Define the scene the layer belongs to
  57413. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57414. * @param color Defines a color for the layer
  57415. */
  57416. constructor(
  57417. /**
  57418. * Define the name of the layer.
  57419. */
  57420. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57421. private _createIndexBuffer;
  57422. /** @hidden */
  57423. _rebuild(): void;
  57424. /**
  57425. * Renders the layer in the scene.
  57426. */
  57427. render(): void;
  57428. /**
  57429. * Disposes and releases the associated ressources.
  57430. */
  57431. dispose(): void;
  57432. }
  57433. }
  57434. declare module BABYLON {
  57435. /** @hidden */
  57436. export var lensFlarePixelShader: {
  57437. name: string;
  57438. shader: string;
  57439. };
  57440. }
  57441. declare module BABYLON {
  57442. /** @hidden */
  57443. export var lensFlareVertexShader: {
  57444. name: string;
  57445. shader: string;
  57446. };
  57447. }
  57448. declare module BABYLON {
  57449. /**
  57450. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57451. * It is usually composed of several `lensFlare`.
  57452. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57453. */
  57454. export class LensFlareSystem {
  57455. /**
  57456. * Define the name of the lens flare system
  57457. */
  57458. name: string;
  57459. /**
  57460. * List of lens flares used in this system.
  57461. */
  57462. lensFlares: LensFlare[];
  57463. /**
  57464. * Define a limit from the border the lens flare can be visible.
  57465. */
  57466. borderLimit: number;
  57467. /**
  57468. * Define a viewport border we do not want to see the lens flare in.
  57469. */
  57470. viewportBorder: number;
  57471. /**
  57472. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57473. */
  57474. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57475. /**
  57476. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57477. */
  57478. layerMask: number;
  57479. /**
  57480. * Define the id of the lens flare system in the scene.
  57481. * (equal to name by default)
  57482. */
  57483. id: string;
  57484. private _scene;
  57485. private _emitter;
  57486. private _vertexBuffers;
  57487. private _indexBuffer;
  57488. private _effect;
  57489. private _positionX;
  57490. private _positionY;
  57491. private _isEnabled;
  57492. /** @hidden */
  57493. static _SceneComponentInitialization: (scene: Scene) => void;
  57494. /**
  57495. * Instantiates a lens flare system.
  57496. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57497. * It is usually composed of several `lensFlare`.
  57498. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57499. * @param name Define the name of the lens flare system in the scene
  57500. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57501. * @param scene Define the scene the lens flare system belongs to
  57502. */
  57503. constructor(
  57504. /**
  57505. * Define the name of the lens flare system
  57506. */
  57507. name: string, emitter: any, scene: Scene);
  57508. /**
  57509. * Define if the lens flare system is enabled.
  57510. */
  57511. get isEnabled(): boolean;
  57512. set isEnabled(value: boolean);
  57513. /**
  57514. * Get the scene the effects belongs to.
  57515. * @returns the scene holding the lens flare system
  57516. */
  57517. getScene(): Scene;
  57518. /**
  57519. * Get the emitter of the lens flare system.
  57520. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57521. * @returns the emitter of the lens flare system
  57522. */
  57523. getEmitter(): any;
  57524. /**
  57525. * Set the emitter of the lens flare system.
  57526. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57527. * @param newEmitter Define the new emitter of the system
  57528. */
  57529. setEmitter(newEmitter: any): void;
  57530. /**
  57531. * Get the lens flare system emitter position.
  57532. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57533. * @returns the position
  57534. */
  57535. getEmitterPosition(): Vector3;
  57536. /**
  57537. * @hidden
  57538. */
  57539. computeEffectivePosition(globalViewport: Viewport): boolean;
  57540. /** @hidden */
  57541. _isVisible(): boolean;
  57542. /**
  57543. * @hidden
  57544. */
  57545. render(): boolean;
  57546. /**
  57547. * Dispose and release the lens flare with its associated resources.
  57548. */
  57549. dispose(): void;
  57550. /**
  57551. * Parse a lens flare system from a JSON repressentation
  57552. * @param parsedLensFlareSystem Define the JSON to parse
  57553. * @param scene Define the scene the parsed system should be instantiated in
  57554. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57555. * @returns the parsed system
  57556. */
  57557. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57558. /**
  57559. * Serialize the current Lens Flare System into a JSON representation.
  57560. * @returns the serialized JSON
  57561. */
  57562. serialize(): any;
  57563. }
  57564. }
  57565. declare module BABYLON {
  57566. /**
  57567. * This represents one of the lens effect in a `lensFlareSystem`.
  57568. * It controls one of the indiviual texture used in the effect.
  57569. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57570. */
  57571. export class LensFlare {
  57572. /**
  57573. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57574. */
  57575. size: number;
  57576. /**
  57577. * 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.
  57578. */
  57579. position: number;
  57580. /**
  57581. * Define the lens color.
  57582. */
  57583. color: Color3;
  57584. /**
  57585. * Define the lens texture.
  57586. */
  57587. texture: Nullable<Texture>;
  57588. /**
  57589. * Define the alpha mode to render this particular lens.
  57590. */
  57591. alphaMode: number;
  57592. private _system;
  57593. /**
  57594. * Creates a new Lens Flare.
  57595. * This represents one of the lens effect in a `lensFlareSystem`.
  57596. * It controls one of the indiviual texture used in the effect.
  57597. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57598. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57599. * @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.
  57600. * @param color Define the lens color
  57601. * @param imgUrl Define the lens texture url
  57602. * @param system Define the `lensFlareSystem` this flare is part of
  57603. * @returns The newly created Lens Flare
  57604. */
  57605. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57606. /**
  57607. * Instantiates a new Lens Flare.
  57608. * This represents one of the lens effect in a `lensFlareSystem`.
  57609. * It controls one of the indiviual texture used in the effect.
  57610. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57611. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57612. * @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.
  57613. * @param color Define the lens color
  57614. * @param imgUrl Define the lens texture url
  57615. * @param system Define the `lensFlareSystem` this flare is part of
  57616. */
  57617. constructor(
  57618. /**
  57619. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57620. */
  57621. size: number,
  57622. /**
  57623. * 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.
  57624. */
  57625. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57626. /**
  57627. * Dispose and release the lens flare with its associated resources.
  57628. */
  57629. dispose(): void;
  57630. }
  57631. }
  57632. declare module BABYLON {
  57633. interface AbstractScene {
  57634. /**
  57635. * The list of lens flare system added to the scene
  57636. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57637. */
  57638. lensFlareSystems: Array<LensFlareSystem>;
  57639. /**
  57640. * Removes the given lens flare system from this scene.
  57641. * @param toRemove The lens flare system to remove
  57642. * @returns The index of the removed lens flare system
  57643. */
  57644. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57645. /**
  57646. * Adds the given lens flare system to this scene
  57647. * @param newLensFlareSystem The lens flare system to add
  57648. */
  57649. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57650. /**
  57651. * Gets a lens flare system using its name
  57652. * @param name defines the name to look for
  57653. * @returns the lens flare system or null if not found
  57654. */
  57655. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57656. /**
  57657. * Gets a lens flare system using its id
  57658. * @param id defines the id to look for
  57659. * @returns the lens flare system or null if not found
  57660. */
  57661. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57662. }
  57663. /**
  57664. * Defines the lens flare scene component responsible to manage any lens flares
  57665. * in a given scene.
  57666. */
  57667. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57668. /**
  57669. * The component name helpfull to identify the component in the list of scene components.
  57670. */
  57671. readonly name: string;
  57672. /**
  57673. * The scene the component belongs to.
  57674. */
  57675. scene: Scene;
  57676. /**
  57677. * Creates a new instance of the component for the given scene
  57678. * @param scene Defines the scene to register the component in
  57679. */
  57680. constructor(scene: Scene);
  57681. /**
  57682. * Registers the component in a given scene
  57683. */
  57684. register(): void;
  57685. /**
  57686. * Rebuilds the elements related to this component in case of
  57687. * context lost for instance.
  57688. */
  57689. rebuild(): void;
  57690. /**
  57691. * Adds all the elements from the container to the scene
  57692. * @param container the container holding the elements
  57693. */
  57694. addFromContainer(container: AbstractScene): void;
  57695. /**
  57696. * Removes all the elements in the container from the scene
  57697. * @param container contains the elements to remove
  57698. * @param dispose if the removed element should be disposed (default: false)
  57699. */
  57700. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57701. /**
  57702. * Serializes the component data to the specified json object
  57703. * @param serializationObject The object to serialize to
  57704. */
  57705. serialize(serializationObject: any): void;
  57706. /**
  57707. * Disposes the component and the associated ressources.
  57708. */
  57709. dispose(): void;
  57710. private _draw;
  57711. }
  57712. }
  57713. declare module BABYLON {
  57714. /** @hidden */
  57715. export var depthPixelShader: {
  57716. name: string;
  57717. shader: string;
  57718. };
  57719. }
  57720. declare module BABYLON {
  57721. /** @hidden */
  57722. export var depthVertexShader: {
  57723. name: string;
  57724. shader: string;
  57725. };
  57726. }
  57727. declare module BABYLON {
  57728. /**
  57729. * This represents a depth renderer in Babylon.
  57730. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57731. */
  57732. export class DepthRenderer {
  57733. private _scene;
  57734. private _depthMap;
  57735. private _effect;
  57736. private readonly _storeNonLinearDepth;
  57737. private readonly _clearColor;
  57738. /** Get if the depth renderer is using packed depth or not */
  57739. readonly isPacked: boolean;
  57740. private _cachedDefines;
  57741. private _camera;
  57742. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57743. enabled: boolean;
  57744. /**
  57745. * Specifiess that the depth renderer will only be used within
  57746. * the camera it is created for.
  57747. * This can help forcing its rendering during the camera processing.
  57748. */
  57749. useOnlyInActiveCamera: boolean;
  57750. /** @hidden */
  57751. static _SceneComponentInitialization: (scene: Scene) => void;
  57752. /**
  57753. * Instantiates a depth renderer
  57754. * @param scene The scene the renderer belongs to
  57755. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57756. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57757. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57758. */
  57759. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57760. /**
  57761. * Creates the depth rendering effect and checks if the effect is ready.
  57762. * @param subMesh The submesh to be used to render the depth map of
  57763. * @param useInstances If multiple world instances should be used
  57764. * @returns if the depth renderer is ready to render the depth map
  57765. */
  57766. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57767. /**
  57768. * Gets the texture which the depth map will be written to.
  57769. * @returns The depth map texture
  57770. */
  57771. getDepthMap(): RenderTargetTexture;
  57772. /**
  57773. * Disposes of the depth renderer.
  57774. */
  57775. dispose(): void;
  57776. }
  57777. }
  57778. declare module BABYLON {
  57779. /** @hidden */
  57780. export var minmaxReduxPixelShader: {
  57781. name: string;
  57782. shader: string;
  57783. };
  57784. }
  57785. declare module BABYLON {
  57786. /**
  57787. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57788. * and maximum values from all values of the texture.
  57789. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57790. * The source values are read from the red channel of the texture.
  57791. */
  57792. export class MinMaxReducer {
  57793. /**
  57794. * Observable triggered when the computation has been performed
  57795. */
  57796. onAfterReductionPerformed: Observable<{
  57797. min: number;
  57798. max: number;
  57799. }>;
  57800. protected _camera: Camera;
  57801. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57802. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57803. protected _postProcessManager: PostProcessManager;
  57804. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57805. protected _forceFullscreenViewport: boolean;
  57806. /**
  57807. * Creates a min/max reducer
  57808. * @param camera The camera to use for the post processes
  57809. */
  57810. constructor(camera: Camera);
  57811. /**
  57812. * Gets the texture used to read the values from.
  57813. */
  57814. get sourceTexture(): Nullable<RenderTargetTexture>;
  57815. /**
  57816. * Sets the source texture to read the values from.
  57817. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57818. * because in such textures '1' value must not be taken into account to compute the maximum
  57819. * as this value is used to clear the texture.
  57820. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57821. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57822. * @param depthRedux Indicates if the texture is a depth texture or not
  57823. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57824. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57825. */
  57826. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57827. /**
  57828. * Defines the refresh rate of the computation.
  57829. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57830. */
  57831. get refreshRate(): number;
  57832. set refreshRate(value: number);
  57833. protected _activated: boolean;
  57834. /**
  57835. * Gets the activation status of the reducer
  57836. */
  57837. get activated(): boolean;
  57838. /**
  57839. * Activates the reduction computation.
  57840. * When activated, the observers registered in onAfterReductionPerformed are
  57841. * called after the compuation is performed
  57842. */
  57843. activate(): void;
  57844. /**
  57845. * Deactivates the reduction computation.
  57846. */
  57847. deactivate(): void;
  57848. /**
  57849. * Disposes the min/max reducer
  57850. * @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.
  57851. */
  57852. dispose(disposeAll?: boolean): void;
  57853. }
  57854. }
  57855. declare module BABYLON {
  57856. /**
  57857. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57858. */
  57859. export class DepthReducer extends MinMaxReducer {
  57860. private _depthRenderer;
  57861. private _depthRendererId;
  57862. /**
  57863. * Gets the depth renderer used for the computation.
  57864. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57865. */
  57866. get depthRenderer(): Nullable<DepthRenderer>;
  57867. /**
  57868. * Creates a depth reducer
  57869. * @param camera The camera used to render the depth texture
  57870. */
  57871. constructor(camera: Camera);
  57872. /**
  57873. * Sets the depth renderer to use to generate the depth map
  57874. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57875. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57876. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57877. */
  57878. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57879. /** @hidden */
  57880. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57881. /**
  57882. * Activates the reduction computation.
  57883. * When activated, the observers registered in onAfterReductionPerformed are
  57884. * called after the compuation is performed
  57885. */
  57886. activate(): void;
  57887. /**
  57888. * Deactivates the reduction computation.
  57889. */
  57890. deactivate(): void;
  57891. /**
  57892. * Disposes the depth reducer
  57893. * @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.
  57894. */
  57895. dispose(disposeAll?: boolean): void;
  57896. }
  57897. }
  57898. declare module BABYLON {
  57899. /**
  57900. * A CSM implementation allowing casting shadows on large scenes.
  57901. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57902. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57903. */
  57904. export class CascadedShadowGenerator extends ShadowGenerator {
  57905. private static readonly frustumCornersNDCSpace;
  57906. /**
  57907. * Name of the CSM class
  57908. */
  57909. static CLASSNAME: string;
  57910. /**
  57911. * Defines the default number of cascades used by the CSM.
  57912. */
  57913. static readonly DEFAULT_CASCADES_COUNT: number;
  57914. /**
  57915. * Defines the minimum number of cascades used by the CSM.
  57916. */
  57917. static readonly MIN_CASCADES_COUNT: number;
  57918. /**
  57919. * Defines the maximum number of cascades used by the CSM.
  57920. */
  57921. static readonly MAX_CASCADES_COUNT: number;
  57922. protected _validateFilter(filter: number): number;
  57923. /**
  57924. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57925. */
  57926. penumbraDarkness: number;
  57927. private _numCascades;
  57928. /**
  57929. * Gets or set the number of cascades used by the CSM.
  57930. */
  57931. get numCascades(): number;
  57932. set numCascades(value: number);
  57933. /**
  57934. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57935. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  57936. */
  57937. stabilizeCascades: boolean;
  57938. private _freezeShadowCastersBoundingInfo;
  57939. private _freezeShadowCastersBoundingInfoObservable;
  57940. /**
  57941. * Enables or disables the shadow casters bounding info computation.
  57942. * If your shadow casters don't move, you can disable this feature.
  57943. * If it is enabled, the bounding box computation is done every frame.
  57944. */
  57945. get freezeShadowCastersBoundingInfo(): boolean;
  57946. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57947. private _scbiMin;
  57948. private _scbiMax;
  57949. protected _computeShadowCastersBoundingInfo(): void;
  57950. protected _shadowCastersBoundingInfo: BoundingInfo;
  57951. /**
  57952. * Gets or sets the shadow casters bounding info.
  57953. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57954. * so that the system won't overwrite the bounds you provide
  57955. */
  57956. get shadowCastersBoundingInfo(): BoundingInfo;
  57957. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57958. protected _breaksAreDirty: boolean;
  57959. protected _minDistance: number;
  57960. protected _maxDistance: number;
  57961. /**
  57962. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57963. *
  57964. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57965. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57966. * @param min minimal distance for the breaks (default to 0.)
  57967. * @param max maximal distance for the breaks (default to 1.)
  57968. */
  57969. setMinMaxDistance(min: number, max: number): void;
  57970. /** Gets the minimal distance used in the cascade break computation */
  57971. get minDistance(): number;
  57972. /** Gets the maximal distance used in the cascade break computation */
  57973. get maxDistance(): number;
  57974. /**
  57975. * Gets the class name of that object
  57976. * @returns "CascadedShadowGenerator"
  57977. */
  57978. getClassName(): string;
  57979. private _cascadeMinExtents;
  57980. private _cascadeMaxExtents;
  57981. /**
  57982. * Gets a cascade minimum extents
  57983. * @param cascadeIndex index of the cascade
  57984. * @returns the minimum cascade extents
  57985. */
  57986. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57987. /**
  57988. * Gets a cascade maximum extents
  57989. * @param cascadeIndex index of the cascade
  57990. * @returns the maximum cascade extents
  57991. */
  57992. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57993. private _cascades;
  57994. private _currentLayer;
  57995. private _viewSpaceFrustumsZ;
  57996. private _viewMatrices;
  57997. private _projectionMatrices;
  57998. private _transformMatrices;
  57999. private _transformMatricesAsArray;
  58000. private _frustumLengths;
  58001. private _lightSizeUVCorrection;
  58002. private _depthCorrection;
  58003. private _frustumCornersWorldSpace;
  58004. private _frustumCenter;
  58005. private _shadowCameraPos;
  58006. private _shadowMaxZ;
  58007. /**
  58008. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  58009. * It defaults to camera.maxZ
  58010. */
  58011. get shadowMaxZ(): number;
  58012. /**
  58013. * Sets the shadow max z distance.
  58014. */
  58015. set shadowMaxZ(value: number);
  58016. protected _debug: boolean;
  58017. /**
  58018. * Gets or sets the debug flag.
  58019. * When enabled, the cascades are materialized by different colors on the screen.
  58020. */
  58021. get debug(): boolean;
  58022. set debug(dbg: boolean);
  58023. private _depthClamp;
  58024. /**
  58025. * Gets or sets the depth clamping value.
  58026. *
  58027. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58028. * to account for the shadow casters far away.
  58029. *
  58030. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58031. */
  58032. get depthClamp(): boolean;
  58033. set depthClamp(value: boolean);
  58034. private _cascadeBlendPercentage;
  58035. /**
  58036. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58037. * It defaults to 0.1 (10% blending).
  58038. */
  58039. get cascadeBlendPercentage(): number;
  58040. set cascadeBlendPercentage(value: number);
  58041. private _lambda;
  58042. /**
  58043. * Gets or set the lambda parameter.
  58044. * This parameter is used to split the camera frustum and create the cascades.
  58045. * 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.
  58046. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58047. */
  58048. get lambda(): number;
  58049. set lambda(value: number);
  58050. /**
  58051. * Gets the view matrix corresponding to a given cascade
  58052. * @param cascadeNum cascade to retrieve the view matrix from
  58053. * @returns the cascade view matrix
  58054. */
  58055. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58056. /**
  58057. * Gets the projection matrix corresponding to a given cascade
  58058. * @param cascadeNum cascade to retrieve the projection matrix from
  58059. * @returns the cascade projection matrix
  58060. */
  58061. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58062. /**
  58063. * Gets the transformation matrix corresponding to a given cascade
  58064. * @param cascadeNum cascade to retrieve the transformation matrix from
  58065. * @returns the cascade transformation matrix
  58066. */
  58067. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58068. private _depthRenderer;
  58069. /**
  58070. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58071. *
  58072. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58073. *
  58074. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58075. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58076. * @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
  58077. */
  58078. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58079. private _depthReducer;
  58080. private _autoCalcDepthBounds;
  58081. /**
  58082. * Gets or sets the autoCalcDepthBounds property.
  58083. *
  58084. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58085. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58086. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58087. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58088. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58089. */
  58090. get autoCalcDepthBounds(): boolean;
  58091. set autoCalcDepthBounds(value: boolean);
  58092. /**
  58093. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58094. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58095. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58096. * for setting the refresh rate on the renderer yourself!
  58097. */
  58098. get autoCalcDepthBoundsRefreshRate(): number;
  58099. set autoCalcDepthBoundsRefreshRate(value: number);
  58100. /**
  58101. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58102. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58103. * you change the camera near/far planes!
  58104. */
  58105. splitFrustum(): void;
  58106. private _splitFrustum;
  58107. private _computeMatrices;
  58108. private _computeFrustumInWorldSpace;
  58109. private _computeCascadeFrustum;
  58110. /**
  58111. * Support test.
  58112. */
  58113. static get IsSupported(): boolean;
  58114. /** @hidden */
  58115. static _SceneComponentInitialization: (scene: Scene) => void;
  58116. /**
  58117. * Creates a Cascaded Shadow Generator object.
  58118. * A ShadowGenerator is the required tool to use the shadows.
  58119. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58120. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58121. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58122. * @param light The directional light object generating the shadows.
  58123. * @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.
  58124. */
  58125. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58126. protected _initializeGenerator(): void;
  58127. protected _createTargetRenderTexture(): void;
  58128. protected _initializeShadowMap(): void;
  58129. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58130. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58131. /**
  58132. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58133. * @param defines Defines of the material we want to update
  58134. * @param lightIndex Index of the light in the enabled light list of the material
  58135. */
  58136. prepareDefines(defines: any, lightIndex: number): void;
  58137. /**
  58138. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58139. * defined in the generator but impacting the effect).
  58140. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58141. * @param effect The effect we are binfing the information for
  58142. */
  58143. bindShadowLight(lightIndex: string, effect: Effect): void;
  58144. /**
  58145. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58146. * (eq to view projection * shadow projection matrices)
  58147. * @returns The transform matrix used to create the shadow map
  58148. */
  58149. getTransformMatrix(): Matrix;
  58150. /**
  58151. * Disposes the ShadowGenerator.
  58152. * Returns nothing.
  58153. */
  58154. dispose(): void;
  58155. /**
  58156. * Serializes the shadow generator setup to a json object.
  58157. * @returns The serialized JSON object
  58158. */
  58159. serialize(): any;
  58160. /**
  58161. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58162. * @param parsedShadowGenerator The JSON object to parse
  58163. * @param scene The scene to create the shadow map for
  58164. * @returns The parsed shadow generator
  58165. */
  58166. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58167. }
  58168. }
  58169. declare module BABYLON {
  58170. /**
  58171. * Defines the shadow generator component responsible to manage any shadow generators
  58172. * in a given scene.
  58173. */
  58174. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58175. /**
  58176. * The component name helpfull to identify the component in the list of scene components.
  58177. */
  58178. readonly name: string;
  58179. /**
  58180. * The scene the component belongs to.
  58181. */
  58182. scene: Scene;
  58183. /**
  58184. * Creates a new instance of the component for the given scene
  58185. * @param scene Defines the scene to register the component in
  58186. */
  58187. constructor(scene: Scene);
  58188. /**
  58189. * Registers the component in a given scene
  58190. */
  58191. register(): void;
  58192. /**
  58193. * Rebuilds the elements related to this component in case of
  58194. * context lost for instance.
  58195. */
  58196. rebuild(): void;
  58197. /**
  58198. * Serializes the component data to the specified json object
  58199. * @param serializationObject The object to serialize to
  58200. */
  58201. serialize(serializationObject: any): void;
  58202. /**
  58203. * Adds all the elements from the container to the scene
  58204. * @param container the container holding the elements
  58205. */
  58206. addFromContainer(container: AbstractScene): void;
  58207. /**
  58208. * Removes all the elements in the container from the scene
  58209. * @param container contains the elements to remove
  58210. * @param dispose if the removed element should be disposed (default: false)
  58211. */
  58212. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58213. /**
  58214. * Rebuilds the elements related to this component in case of
  58215. * context lost for instance.
  58216. */
  58217. dispose(): void;
  58218. private _gatherRenderTargets;
  58219. }
  58220. }
  58221. declare module BABYLON {
  58222. /**
  58223. * A point light is a light defined by an unique point in world space.
  58224. * The light is emitted in every direction from this point.
  58225. * A good example of a point light is a standard light bulb.
  58226. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58227. */
  58228. export class PointLight extends ShadowLight {
  58229. private _shadowAngle;
  58230. /**
  58231. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58232. * This specifies what angle the shadow will use to be created.
  58233. *
  58234. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58235. */
  58236. get shadowAngle(): number;
  58237. /**
  58238. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58239. * This specifies what angle the shadow will use to be created.
  58240. *
  58241. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58242. */
  58243. set shadowAngle(value: number);
  58244. /**
  58245. * Gets the direction if it has been set.
  58246. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58247. */
  58248. get direction(): Vector3;
  58249. /**
  58250. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58251. */
  58252. set direction(value: Vector3);
  58253. /**
  58254. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58255. * A PointLight emits the light in every direction.
  58256. * It can cast shadows.
  58257. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58258. * ```javascript
  58259. * var pointLight = new PointLight("pl", camera.position, scene);
  58260. * ```
  58261. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58262. * @param name The light friendly name
  58263. * @param position The position of the point light in the scene
  58264. * @param scene The scene the lights belongs to
  58265. */
  58266. constructor(name: string, position: Vector3, scene: Scene);
  58267. /**
  58268. * Returns the string "PointLight"
  58269. * @returns the class name
  58270. */
  58271. getClassName(): string;
  58272. /**
  58273. * Returns the integer 0.
  58274. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58275. */
  58276. getTypeID(): number;
  58277. /**
  58278. * Specifies wether or not the shadowmap should be a cube texture.
  58279. * @returns true if the shadowmap needs to be a cube texture.
  58280. */
  58281. needCube(): boolean;
  58282. /**
  58283. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58284. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58285. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58286. */
  58287. getShadowDirection(faceIndex?: number): Vector3;
  58288. /**
  58289. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58290. * - fov = PI / 2
  58291. * - aspect ratio : 1.0
  58292. * - z-near and far equal to the active camera minZ and maxZ.
  58293. * Returns the PointLight.
  58294. */
  58295. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58296. protected _buildUniformLayout(): void;
  58297. /**
  58298. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58299. * @param effect The effect to update
  58300. * @param lightIndex The index of the light in the effect to update
  58301. * @returns The point light
  58302. */
  58303. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58304. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58305. /**
  58306. * Prepares the list of defines specific to the light type.
  58307. * @param defines the list of defines
  58308. * @param lightIndex defines the index of the light for the effect
  58309. */
  58310. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58311. }
  58312. }
  58313. declare module BABYLON {
  58314. /**
  58315. * Header information of HDR texture files.
  58316. */
  58317. export interface HDRInfo {
  58318. /**
  58319. * The height of the texture in pixels.
  58320. */
  58321. height: number;
  58322. /**
  58323. * The width of the texture in pixels.
  58324. */
  58325. width: number;
  58326. /**
  58327. * The index of the beginning of the data in the binary file.
  58328. */
  58329. dataPosition: number;
  58330. }
  58331. /**
  58332. * This groups tools to convert HDR texture to native colors array.
  58333. */
  58334. export class HDRTools {
  58335. private static Ldexp;
  58336. private static Rgbe2float;
  58337. private static readStringLine;
  58338. /**
  58339. * Reads header information from an RGBE texture stored in a native array.
  58340. * More information on this format are available here:
  58341. * https://en.wikipedia.org/wiki/RGBE_image_format
  58342. *
  58343. * @param uint8array The binary file stored in native array.
  58344. * @return The header information.
  58345. */
  58346. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58347. /**
  58348. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58349. * This RGBE texture needs to store the information as a panorama.
  58350. *
  58351. * More information on this format are available here:
  58352. * https://en.wikipedia.org/wiki/RGBE_image_format
  58353. *
  58354. * @param buffer The binary file stored in an array buffer.
  58355. * @param size The expected size of the extracted cubemap.
  58356. * @return The Cube Map information.
  58357. */
  58358. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58359. /**
  58360. * Returns the pixels data extracted from an RGBE texture.
  58361. * This pixels will be stored left to right up to down in the R G B order in one array.
  58362. *
  58363. * More information on this format are available here:
  58364. * https://en.wikipedia.org/wiki/RGBE_image_format
  58365. *
  58366. * @param uint8array The binary file stored in an array buffer.
  58367. * @param hdrInfo The header information of the file.
  58368. * @return The pixels data in RGB right to left up to down order.
  58369. */
  58370. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58371. private static RGBE_ReadPixels_RLE;
  58372. }
  58373. }
  58374. declare module BABYLON {
  58375. /**
  58376. * Effect Render Options
  58377. */
  58378. export interface IEffectRendererOptions {
  58379. /**
  58380. * Defines the vertices positions.
  58381. */
  58382. positions?: number[];
  58383. /**
  58384. * Defines the indices.
  58385. */
  58386. indices?: number[];
  58387. }
  58388. /**
  58389. * Helper class to render one or more effects.
  58390. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58391. */
  58392. export class EffectRenderer {
  58393. private engine;
  58394. private static _DefaultOptions;
  58395. private _vertexBuffers;
  58396. private _indexBuffer;
  58397. private _fullscreenViewport;
  58398. /**
  58399. * Creates an effect renderer
  58400. * @param engine the engine to use for rendering
  58401. * @param options defines the options of the effect renderer
  58402. */
  58403. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58404. /**
  58405. * Sets the current viewport in normalized coordinates 0-1
  58406. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58407. */
  58408. setViewport(viewport?: Viewport): void;
  58409. /**
  58410. * Binds the embedded attributes buffer to the effect.
  58411. * @param effect Defines the effect to bind the attributes for
  58412. */
  58413. bindBuffers(effect: Effect): void;
  58414. /**
  58415. * Sets the current effect wrapper to use during draw.
  58416. * The effect needs to be ready before calling this api.
  58417. * This also sets the default full screen position attribute.
  58418. * @param effectWrapper Defines the effect to draw with
  58419. */
  58420. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58421. /**
  58422. * Restores engine states
  58423. */
  58424. restoreStates(): void;
  58425. /**
  58426. * Draws a full screen quad.
  58427. */
  58428. draw(): void;
  58429. private isRenderTargetTexture;
  58430. /**
  58431. * renders one or more effects to a specified texture
  58432. * @param effectWrapper the effect to renderer
  58433. * @param outputTexture texture to draw to, if null it will render to the screen.
  58434. */
  58435. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58436. /**
  58437. * Disposes of the effect renderer
  58438. */
  58439. dispose(): void;
  58440. }
  58441. /**
  58442. * Options to create an EffectWrapper
  58443. */
  58444. interface EffectWrapperCreationOptions {
  58445. /**
  58446. * Engine to use to create the effect
  58447. */
  58448. engine: ThinEngine;
  58449. /**
  58450. * Fragment shader for the effect
  58451. */
  58452. fragmentShader: string;
  58453. /**
  58454. * Use the shader store instead of direct source code
  58455. */
  58456. useShaderStore?: boolean;
  58457. /**
  58458. * Vertex shader for the effect
  58459. */
  58460. vertexShader?: string;
  58461. /**
  58462. * Attributes to use in the shader
  58463. */
  58464. attributeNames?: Array<string>;
  58465. /**
  58466. * Uniforms to use in the shader
  58467. */
  58468. uniformNames?: Array<string>;
  58469. /**
  58470. * Texture sampler names to use in the shader
  58471. */
  58472. samplerNames?: Array<string>;
  58473. /**
  58474. * Defines to use in the shader
  58475. */
  58476. defines?: Array<string>;
  58477. /**
  58478. * Callback when effect is compiled
  58479. */
  58480. onCompiled?: Nullable<(effect: Effect) => void>;
  58481. /**
  58482. * The friendly name of the effect displayed in Spector.
  58483. */
  58484. name?: string;
  58485. }
  58486. /**
  58487. * Wraps an effect to be used for rendering
  58488. */
  58489. export class EffectWrapper {
  58490. /**
  58491. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58492. */
  58493. onApplyObservable: Observable<{}>;
  58494. /**
  58495. * The underlying effect
  58496. */
  58497. effect: Effect;
  58498. /**
  58499. * Creates an effect to be renderer
  58500. * @param creationOptions options to create the effect
  58501. */
  58502. constructor(creationOptions: EffectWrapperCreationOptions);
  58503. /**
  58504. * Disposes of the effect wrapper
  58505. */
  58506. dispose(): void;
  58507. }
  58508. }
  58509. declare module BABYLON {
  58510. /** @hidden */
  58511. export var hdrFilteringVertexShader: {
  58512. name: string;
  58513. shader: string;
  58514. };
  58515. }
  58516. declare module BABYLON {
  58517. /** @hidden */
  58518. export var hdrFilteringPixelShader: {
  58519. name: string;
  58520. shader: string;
  58521. };
  58522. }
  58523. declare module BABYLON {
  58524. /**
  58525. * Options for texture filtering
  58526. */
  58527. interface IHDRFilteringOptions {
  58528. /**
  58529. * Scales pixel intensity for the input HDR map.
  58530. */
  58531. hdrScale?: number;
  58532. /**
  58533. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58534. */
  58535. quality?: number;
  58536. }
  58537. /**
  58538. * Filters HDR maps to get correct renderings of PBR reflections
  58539. */
  58540. export class HDRFiltering {
  58541. private _engine;
  58542. private _effectRenderer;
  58543. private _effectWrapper;
  58544. private _lodGenerationOffset;
  58545. private _lodGenerationScale;
  58546. /**
  58547. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58548. * you care about baking speed.
  58549. */
  58550. quality: number;
  58551. /**
  58552. * Scales pixel intensity for the input HDR map.
  58553. */
  58554. hdrScale: number;
  58555. /**
  58556. * Instantiates HDR filter for reflection maps
  58557. *
  58558. * @param engine Thin engine
  58559. * @param options Options
  58560. */
  58561. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58562. private _createRenderTarget;
  58563. private _prefilterInternal;
  58564. private _createEffect;
  58565. /**
  58566. * Get a value indicating if the filter is ready to be used
  58567. * @param texture Texture to filter
  58568. * @returns true if the filter is ready
  58569. */
  58570. isReady(texture: BaseTexture): boolean;
  58571. /**
  58572. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58573. * Prefiltering will be invoked at the end of next rendering pass.
  58574. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58575. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58576. * @param texture Texture to filter
  58577. * @param onFinished Callback when filtering is done
  58578. * @return Promise called when prefiltering is done
  58579. */
  58580. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  58581. }
  58582. }
  58583. declare module BABYLON {
  58584. /**
  58585. * This represents a texture coming from an HDR input.
  58586. *
  58587. * The only supported format is currently panorama picture stored in RGBE format.
  58588. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58589. */
  58590. export class HDRCubeTexture extends BaseTexture {
  58591. private static _facesMapping;
  58592. private _generateHarmonics;
  58593. private _noMipmap;
  58594. private _prefilterOnLoad;
  58595. private _textureMatrix;
  58596. private _size;
  58597. private _onLoad;
  58598. private _onError;
  58599. /**
  58600. * The texture URL.
  58601. */
  58602. url: string;
  58603. /**
  58604. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58605. */
  58606. coordinatesMode: number;
  58607. protected _isBlocking: boolean;
  58608. /**
  58609. * Sets wether or not the texture is blocking during loading.
  58610. */
  58611. set isBlocking(value: boolean);
  58612. /**
  58613. * Gets wether or not the texture is blocking during loading.
  58614. */
  58615. get isBlocking(): boolean;
  58616. protected _rotationY: number;
  58617. /**
  58618. * Sets texture matrix rotation angle around Y axis in radians.
  58619. */
  58620. set rotationY(value: number);
  58621. /**
  58622. * Gets texture matrix rotation angle around Y axis radians.
  58623. */
  58624. get rotationY(): number;
  58625. /**
  58626. * Gets or sets the center of the bounding box associated with the cube texture
  58627. * It must define where the camera used to render the texture was set
  58628. */
  58629. boundingBoxPosition: Vector3;
  58630. private _boundingBoxSize;
  58631. /**
  58632. * Gets or sets the size of the bounding box associated with the cube texture
  58633. * When defined, the cubemap will switch to local mode
  58634. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58635. * @example https://www.babylonjs-playground.com/#RNASML
  58636. */
  58637. set boundingBoxSize(value: Vector3);
  58638. get boundingBoxSize(): Vector3;
  58639. /**
  58640. * Instantiates an HDRTexture from the following parameters.
  58641. *
  58642. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58643. * @param sceneOrEngine The scene or engine the texture will be used in
  58644. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58645. * @param noMipmap Forces to not generate the mipmap if true
  58646. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58647. * @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)
  58648. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  58649. */
  58650. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, prefilterOnLoad?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58651. /**
  58652. * Get the current class name of the texture useful for serialization or dynamic coding.
  58653. * @returns "HDRCubeTexture"
  58654. */
  58655. getClassName(): string;
  58656. /**
  58657. * Occurs when the file is raw .hdr file.
  58658. */
  58659. private loadTexture;
  58660. clone(): HDRCubeTexture;
  58661. delayLoad(): void;
  58662. /**
  58663. * Get the texture reflection matrix used to rotate/transform the reflection.
  58664. * @returns the reflection matrix
  58665. */
  58666. getReflectionTextureMatrix(): Matrix;
  58667. /**
  58668. * Set the texture reflection matrix used to rotate/transform the reflection.
  58669. * @param value Define the reflection matrix to set
  58670. */
  58671. setReflectionTextureMatrix(value: Matrix): void;
  58672. /**
  58673. * Parses a JSON representation of an HDR Texture in order to create the texture
  58674. * @param parsedTexture Define the JSON representation
  58675. * @param scene Define the scene the texture should be created in
  58676. * @param rootUrl Define the root url in case we need to load relative dependencies
  58677. * @returns the newly created texture after parsing
  58678. */
  58679. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58680. serialize(): any;
  58681. }
  58682. }
  58683. declare module BABYLON {
  58684. /**
  58685. * Class used to control physics engine
  58686. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58687. */
  58688. export class PhysicsEngine implements IPhysicsEngine {
  58689. private _physicsPlugin;
  58690. /**
  58691. * Global value used to control the smallest number supported by the simulation
  58692. */
  58693. static Epsilon: number;
  58694. private _impostors;
  58695. private _joints;
  58696. private _subTimeStep;
  58697. /**
  58698. * Gets the gravity vector used by the simulation
  58699. */
  58700. gravity: Vector3;
  58701. /**
  58702. * Factory used to create the default physics plugin.
  58703. * @returns The default physics plugin
  58704. */
  58705. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58706. /**
  58707. * Creates a new Physics Engine
  58708. * @param gravity defines the gravity vector used by the simulation
  58709. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58710. */
  58711. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58712. /**
  58713. * Sets the gravity vector used by the simulation
  58714. * @param gravity defines the gravity vector to use
  58715. */
  58716. setGravity(gravity: Vector3): void;
  58717. /**
  58718. * Set the time step of the physics engine.
  58719. * Default is 1/60.
  58720. * To slow it down, enter 1/600 for example.
  58721. * To speed it up, 1/30
  58722. * @param newTimeStep defines the new timestep to apply to this world.
  58723. */
  58724. setTimeStep(newTimeStep?: number): void;
  58725. /**
  58726. * Get the time step of the physics engine.
  58727. * @returns the current time step
  58728. */
  58729. getTimeStep(): number;
  58730. /**
  58731. * Set the sub time step of the physics engine.
  58732. * Default is 0 meaning there is no sub steps
  58733. * To increase physics resolution precision, set a small value (like 1 ms)
  58734. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58735. */
  58736. setSubTimeStep(subTimeStep?: number): void;
  58737. /**
  58738. * Get the sub time step of the physics engine.
  58739. * @returns the current sub time step
  58740. */
  58741. getSubTimeStep(): number;
  58742. /**
  58743. * Release all resources
  58744. */
  58745. dispose(): void;
  58746. /**
  58747. * Gets the name of the current physics plugin
  58748. * @returns the name of the plugin
  58749. */
  58750. getPhysicsPluginName(): string;
  58751. /**
  58752. * Adding a new impostor for the impostor tracking.
  58753. * This will be done by the impostor itself.
  58754. * @param impostor the impostor to add
  58755. */
  58756. addImpostor(impostor: PhysicsImpostor): void;
  58757. /**
  58758. * Remove an impostor from the engine.
  58759. * This impostor and its mesh will not longer be updated by the physics engine.
  58760. * @param impostor the impostor to remove
  58761. */
  58762. removeImpostor(impostor: PhysicsImpostor): void;
  58763. /**
  58764. * Add a joint to the physics engine
  58765. * @param mainImpostor defines the main impostor to which the joint is added.
  58766. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  58767. * @param joint defines the joint that will connect both impostors.
  58768. */
  58769. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58770. /**
  58771. * Removes a joint from the simulation
  58772. * @param mainImpostor defines the impostor used with the joint
  58773. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  58774. * @param joint defines the joint to remove
  58775. */
  58776. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58777. /**
  58778. * Called by the scene. No need to call it.
  58779. * @param delta defines the timespam between frames
  58780. */
  58781. _step(delta: number): void;
  58782. /**
  58783. * Gets the current plugin used to run the simulation
  58784. * @returns current plugin
  58785. */
  58786. getPhysicsPlugin(): IPhysicsEnginePlugin;
  58787. /**
  58788. * Gets the list of physic impostors
  58789. * @returns an array of PhysicsImpostor
  58790. */
  58791. getImpostors(): Array<PhysicsImpostor>;
  58792. /**
  58793. * Gets the impostor for a physics enabled object
  58794. * @param object defines the object impersonated by the impostor
  58795. * @returns the PhysicsImpostor or null if not found
  58796. */
  58797. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  58798. /**
  58799. * Gets the impostor for a physics body object
  58800. * @param body defines physics body used by the impostor
  58801. * @returns the PhysicsImpostor or null if not found
  58802. */
  58803. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  58804. /**
  58805. * Does a raycast in the physics world
  58806. * @param from when should the ray start?
  58807. * @param to when should the ray end?
  58808. * @returns PhysicsRaycastResult
  58809. */
  58810. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58811. }
  58812. }
  58813. declare module BABYLON {
  58814. /** @hidden */
  58815. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  58816. private _useDeltaForWorldStep;
  58817. world: any;
  58818. name: string;
  58819. private _physicsMaterials;
  58820. private _fixedTimeStep;
  58821. private _cannonRaycastResult;
  58822. private _raycastResult;
  58823. private _physicsBodysToRemoveAfterStep;
  58824. private _firstFrame;
  58825. BJSCANNON: any;
  58826. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  58827. setGravity(gravity: Vector3): void;
  58828. setTimeStep(timeStep: number): void;
  58829. getTimeStep(): number;
  58830. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58831. private _removeMarkedPhysicsBodiesFromWorld;
  58832. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58833. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58834. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58835. private _processChildMeshes;
  58836. removePhysicsBody(impostor: PhysicsImpostor): void;
  58837. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58838. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58839. private _addMaterial;
  58840. private _checkWithEpsilon;
  58841. private _createShape;
  58842. private _createHeightmap;
  58843. private _minus90X;
  58844. private _plus90X;
  58845. private _tmpPosition;
  58846. private _tmpDeltaPosition;
  58847. private _tmpUnityRotation;
  58848. private _updatePhysicsBodyTransformation;
  58849. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58850. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58851. isSupported(): boolean;
  58852. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58853. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58854. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58855. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58856. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58857. getBodyMass(impostor: PhysicsImpostor): number;
  58858. getBodyFriction(impostor: PhysicsImpostor): number;
  58859. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58860. getBodyRestitution(impostor: PhysicsImpostor): number;
  58861. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58862. sleepBody(impostor: PhysicsImpostor): void;
  58863. wakeUpBody(impostor: PhysicsImpostor): void;
  58864. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  58865. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58866. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58867. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58868. getRadius(impostor: PhysicsImpostor): number;
  58869. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58870. dispose(): void;
  58871. private _extendNamespace;
  58872. /**
  58873. * Does a raycast in the physics world
  58874. * @param from when should the ray start?
  58875. * @param to when should the ray end?
  58876. * @returns PhysicsRaycastResult
  58877. */
  58878. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58879. }
  58880. }
  58881. declare module BABYLON {
  58882. /** @hidden */
  58883. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  58884. private _useDeltaForWorldStep;
  58885. world: any;
  58886. name: string;
  58887. BJSOIMO: any;
  58888. private _raycastResult;
  58889. private _fixedTimeStep;
  58890. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  58891. setGravity(gravity: Vector3): void;
  58892. setTimeStep(timeStep: number): void;
  58893. getTimeStep(): number;
  58894. private _tmpImpostorsArray;
  58895. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58896. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58897. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58898. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58899. private _tmpPositionVector;
  58900. removePhysicsBody(impostor: PhysicsImpostor): void;
  58901. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58902. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58903. isSupported(): boolean;
  58904. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58905. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58906. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58907. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58908. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58909. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58910. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58911. getBodyMass(impostor: PhysicsImpostor): number;
  58912. getBodyFriction(impostor: PhysicsImpostor): number;
  58913. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58914. getBodyRestitution(impostor: PhysicsImpostor): number;
  58915. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58916. sleepBody(impostor: PhysicsImpostor): void;
  58917. wakeUpBody(impostor: PhysicsImpostor): void;
  58918. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58919. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58920. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58921. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58922. getRadius(impostor: PhysicsImpostor): number;
  58923. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58924. dispose(): void;
  58925. /**
  58926. * Does a raycast in the physics world
  58927. * @param from when should the ray start?
  58928. * @param to when should the ray end?
  58929. * @returns PhysicsRaycastResult
  58930. */
  58931. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58932. }
  58933. }
  58934. declare module BABYLON {
  58935. /**
  58936. * Class containing static functions to help procedurally build meshes
  58937. */
  58938. export class RibbonBuilder {
  58939. /**
  58940. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58941. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58942. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58943. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58944. * * 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
  58945. * * 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
  58946. * * 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
  58947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58948. * * 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
  58949. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58950. * * 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
  58951. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58952. * * 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
  58953. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58955. * @param name defines the name of the mesh
  58956. * @param options defines the options used to create the mesh
  58957. * @param scene defines the hosting scene
  58958. * @returns the ribbon mesh
  58959. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58960. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58961. */
  58962. static CreateRibbon(name: string, options: {
  58963. pathArray: Vector3[][];
  58964. closeArray?: boolean;
  58965. closePath?: boolean;
  58966. offset?: number;
  58967. updatable?: boolean;
  58968. sideOrientation?: number;
  58969. frontUVs?: Vector4;
  58970. backUVs?: Vector4;
  58971. instance?: Mesh;
  58972. invertUV?: boolean;
  58973. uvs?: Vector2[];
  58974. colors?: Color4[];
  58975. }, scene?: Nullable<Scene>): Mesh;
  58976. }
  58977. }
  58978. declare module BABYLON {
  58979. /**
  58980. * Class containing static functions to help procedurally build meshes
  58981. */
  58982. export class ShapeBuilder {
  58983. /**
  58984. * 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.
  58985. * * 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.
  58986. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58987. * * 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.
  58988. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58989. * * 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
  58990. * * 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
  58991. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58993. * * 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
  58994. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58996. * @param name defines the name of the mesh
  58997. * @param options defines the options used to create the mesh
  58998. * @param scene defines the hosting scene
  58999. * @returns the extruded shape mesh
  59000. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59001. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59002. */
  59003. static ExtrudeShape(name: string, options: {
  59004. shape: Vector3[];
  59005. path: Vector3[];
  59006. scale?: number;
  59007. rotation?: number;
  59008. cap?: number;
  59009. updatable?: boolean;
  59010. sideOrientation?: number;
  59011. frontUVs?: Vector4;
  59012. backUVs?: Vector4;
  59013. instance?: Mesh;
  59014. invertUV?: boolean;
  59015. }, scene?: Nullable<Scene>): Mesh;
  59016. /**
  59017. * Creates an custom extruded shape mesh.
  59018. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59019. * * 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.
  59020. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59021. * * 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
  59022. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59023. * * 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
  59024. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59025. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59026. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59027. * * 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
  59028. * * 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
  59029. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59031. * * 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
  59032. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59034. * @param name defines the name of the mesh
  59035. * @param options defines the options used to create the mesh
  59036. * @param scene defines the hosting scene
  59037. * @returns the custom extruded shape mesh
  59038. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59039. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59040. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59041. */
  59042. static ExtrudeShapeCustom(name: string, options: {
  59043. shape: Vector3[];
  59044. path: Vector3[];
  59045. scaleFunction?: any;
  59046. rotationFunction?: any;
  59047. ribbonCloseArray?: boolean;
  59048. ribbonClosePath?: boolean;
  59049. cap?: number;
  59050. updatable?: boolean;
  59051. sideOrientation?: number;
  59052. frontUVs?: Vector4;
  59053. backUVs?: Vector4;
  59054. instance?: Mesh;
  59055. invertUV?: boolean;
  59056. }, scene?: Nullable<Scene>): Mesh;
  59057. private static _ExtrudeShapeGeneric;
  59058. }
  59059. }
  59060. declare module BABYLON {
  59061. /**
  59062. * AmmoJS Physics plugin
  59063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59064. * @see https://github.com/kripken/ammo.js/
  59065. */
  59066. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59067. private _useDeltaForWorldStep;
  59068. /**
  59069. * Reference to the Ammo library
  59070. */
  59071. bjsAMMO: any;
  59072. /**
  59073. * Created ammoJS world which physics bodies are added to
  59074. */
  59075. world: any;
  59076. /**
  59077. * Name of the plugin
  59078. */
  59079. name: string;
  59080. private _timeStep;
  59081. private _fixedTimeStep;
  59082. private _maxSteps;
  59083. private _tmpQuaternion;
  59084. private _tmpAmmoTransform;
  59085. private _tmpAmmoQuaternion;
  59086. private _tmpAmmoConcreteContactResultCallback;
  59087. private _collisionConfiguration;
  59088. private _dispatcher;
  59089. private _overlappingPairCache;
  59090. private _solver;
  59091. private _softBodySolver;
  59092. private _tmpAmmoVectorA;
  59093. private _tmpAmmoVectorB;
  59094. private _tmpAmmoVectorC;
  59095. private _tmpAmmoVectorD;
  59096. private _tmpContactCallbackResult;
  59097. private _tmpAmmoVectorRCA;
  59098. private _tmpAmmoVectorRCB;
  59099. private _raycastResult;
  59100. private static readonly DISABLE_COLLISION_FLAG;
  59101. private static readonly KINEMATIC_FLAG;
  59102. private static readonly DISABLE_DEACTIVATION_FLAG;
  59103. /**
  59104. * Initializes the ammoJS plugin
  59105. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59106. * @param ammoInjection can be used to inject your own ammo reference
  59107. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59108. */
  59109. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59110. /**
  59111. * Sets the gravity of the physics world (m/(s^2))
  59112. * @param gravity Gravity to set
  59113. */
  59114. setGravity(gravity: Vector3): void;
  59115. /**
  59116. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59117. * @param timeStep timestep to use in seconds
  59118. */
  59119. setTimeStep(timeStep: number): void;
  59120. /**
  59121. * 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)
  59122. * @param fixedTimeStep fixedTimeStep to use in seconds
  59123. */
  59124. setFixedTimeStep(fixedTimeStep: number): void;
  59125. /**
  59126. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59127. * @param maxSteps the maximum number of steps by the physics engine per frame
  59128. */
  59129. setMaxSteps(maxSteps: number): void;
  59130. /**
  59131. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59132. * @returns the current timestep in seconds
  59133. */
  59134. getTimeStep(): number;
  59135. /**
  59136. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59137. */
  59138. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59139. private _isImpostorInContact;
  59140. private _isImpostorPairInContact;
  59141. private _stepSimulation;
  59142. /**
  59143. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59144. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59145. * After the step the babylon meshes are set to the position of the physics imposters
  59146. * @param delta amount of time to step forward
  59147. * @param impostors array of imposters to update before/after the step
  59148. */
  59149. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59150. /**
  59151. * Update babylon mesh to match physics world object
  59152. * @param impostor imposter to match
  59153. */
  59154. private _afterSoftStep;
  59155. /**
  59156. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59157. * @param impostor imposter to match
  59158. */
  59159. private _ropeStep;
  59160. /**
  59161. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59162. * @param impostor imposter to match
  59163. */
  59164. private _softbodyOrClothStep;
  59165. private _tmpMatrix;
  59166. /**
  59167. * Applies an impulse on the imposter
  59168. * @param impostor imposter to apply impulse to
  59169. * @param force amount of force to be applied to the imposter
  59170. * @param contactPoint the location to apply the impulse on the imposter
  59171. */
  59172. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59173. /**
  59174. * Applies a force on the imposter
  59175. * @param impostor imposter to apply force
  59176. * @param force amount of force to be applied to the imposter
  59177. * @param contactPoint the location to apply the force on the imposter
  59178. */
  59179. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59180. /**
  59181. * Creates a physics body using the plugin
  59182. * @param impostor the imposter to create the physics body on
  59183. */
  59184. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59185. /**
  59186. * Removes the physics body from the imposter and disposes of the body's memory
  59187. * @param impostor imposter to remove the physics body from
  59188. */
  59189. removePhysicsBody(impostor: PhysicsImpostor): void;
  59190. /**
  59191. * Generates a joint
  59192. * @param impostorJoint the imposter joint to create the joint with
  59193. */
  59194. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59195. /**
  59196. * Removes a joint
  59197. * @param impostorJoint the imposter joint to remove the joint from
  59198. */
  59199. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59200. private _addMeshVerts;
  59201. /**
  59202. * Initialise the soft body vertices to match its object's (mesh) vertices
  59203. * Softbody vertices (nodes) are in world space and to match this
  59204. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59205. * @param impostor to create the softbody for
  59206. */
  59207. private _softVertexData;
  59208. /**
  59209. * Create an impostor's soft body
  59210. * @param impostor to create the softbody for
  59211. */
  59212. private _createSoftbody;
  59213. /**
  59214. * Create cloth for an impostor
  59215. * @param impostor to create the softbody for
  59216. */
  59217. private _createCloth;
  59218. /**
  59219. * Create rope for an impostor
  59220. * @param impostor to create the softbody for
  59221. */
  59222. private _createRope;
  59223. /**
  59224. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59225. * @param impostor to create the custom physics shape for
  59226. */
  59227. private _createCustom;
  59228. private _addHullVerts;
  59229. private _createShape;
  59230. /**
  59231. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59232. * @param impostor imposter containing the physics body and babylon object
  59233. */
  59234. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59235. /**
  59236. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59237. * @param impostor imposter containing the physics body and babylon object
  59238. * @param newPosition new position
  59239. * @param newRotation new rotation
  59240. */
  59241. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59242. /**
  59243. * If this plugin is supported
  59244. * @returns true if its supported
  59245. */
  59246. isSupported(): boolean;
  59247. /**
  59248. * Sets the linear velocity of the physics body
  59249. * @param impostor imposter to set the velocity on
  59250. * @param velocity velocity to set
  59251. */
  59252. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59253. /**
  59254. * Sets the angular velocity of the physics body
  59255. * @param impostor imposter to set the velocity on
  59256. * @param velocity velocity to set
  59257. */
  59258. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59259. /**
  59260. * gets the linear velocity
  59261. * @param impostor imposter to get linear velocity from
  59262. * @returns linear velocity
  59263. */
  59264. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59265. /**
  59266. * gets the angular velocity
  59267. * @param impostor imposter to get angular velocity from
  59268. * @returns angular velocity
  59269. */
  59270. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59271. /**
  59272. * Sets the mass of physics body
  59273. * @param impostor imposter to set the mass on
  59274. * @param mass mass to set
  59275. */
  59276. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59277. /**
  59278. * Gets the mass of the physics body
  59279. * @param impostor imposter to get the mass from
  59280. * @returns mass
  59281. */
  59282. getBodyMass(impostor: PhysicsImpostor): number;
  59283. /**
  59284. * Gets friction of the impostor
  59285. * @param impostor impostor to get friction from
  59286. * @returns friction value
  59287. */
  59288. getBodyFriction(impostor: PhysicsImpostor): number;
  59289. /**
  59290. * Sets friction of the impostor
  59291. * @param impostor impostor to set friction on
  59292. * @param friction friction value
  59293. */
  59294. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59295. /**
  59296. * Gets restitution of the impostor
  59297. * @param impostor impostor to get restitution from
  59298. * @returns restitution value
  59299. */
  59300. getBodyRestitution(impostor: PhysicsImpostor): number;
  59301. /**
  59302. * Sets resitution of the impostor
  59303. * @param impostor impostor to set resitution on
  59304. * @param restitution resitution value
  59305. */
  59306. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59307. /**
  59308. * Gets pressure inside the impostor
  59309. * @param impostor impostor to get pressure from
  59310. * @returns pressure value
  59311. */
  59312. getBodyPressure(impostor: PhysicsImpostor): number;
  59313. /**
  59314. * Sets pressure inside a soft body impostor
  59315. * Cloth and rope must remain 0 pressure
  59316. * @param impostor impostor to set pressure on
  59317. * @param pressure pressure value
  59318. */
  59319. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59320. /**
  59321. * Gets stiffness of the impostor
  59322. * @param impostor impostor to get stiffness from
  59323. * @returns pressure value
  59324. */
  59325. getBodyStiffness(impostor: PhysicsImpostor): number;
  59326. /**
  59327. * Sets stiffness of the impostor
  59328. * @param impostor impostor to set stiffness on
  59329. * @param stiffness stiffness value from 0 to 1
  59330. */
  59331. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59332. /**
  59333. * Gets velocityIterations of the impostor
  59334. * @param impostor impostor to get velocity iterations from
  59335. * @returns velocityIterations value
  59336. */
  59337. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59338. /**
  59339. * Sets velocityIterations of the impostor
  59340. * @param impostor impostor to set velocity iterations on
  59341. * @param velocityIterations velocityIterations value
  59342. */
  59343. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59344. /**
  59345. * Gets positionIterations of the impostor
  59346. * @param impostor impostor to get position iterations from
  59347. * @returns positionIterations value
  59348. */
  59349. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59350. /**
  59351. * Sets positionIterations of the impostor
  59352. * @param impostor impostor to set position on
  59353. * @param positionIterations positionIterations value
  59354. */
  59355. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59356. /**
  59357. * Append an anchor to a cloth object
  59358. * @param impostor is the cloth impostor to add anchor to
  59359. * @param otherImpostor is the rigid impostor to anchor to
  59360. * @param width ratio across width from 0 to 1
  59361. * @param height ratio up height from 0 to 1
  59362. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59363. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59364. */
  59365. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59366. /**
  59367. * Append an hook to a rope object
  59368. * @param impostor is the rope impostor to add hook to
  59369. * @param otherImpostor is the rigid impostor to hook to
  59370. * @param length ratio along the rope from 0 to 1
  59371. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59372. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59373. */
  59374. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59375. /**
  59376. * Sleeps the physics body and stops it from being active
  59377. * @param impostor impostor to sleep
  59378. */
  59379. sleepBody(impostor: PhysicsImpostor): void;
  59380. /**
  59381. * Activates the physics body
  59382. * @param impostor impostor to activate
  59383. */
  59384. wakeUpBody(impostor: PhysicsImpostor): void;
  59385. /**
  59386. * Updates the distance parameters of the joint
  59387. * @param joint joint to update
  59388. * @param maxDistance maximum distance of the joint
  59389. * @param minDistance minimum distance of the joint
  59390. */
  59391. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59392. /**
  59393. * Sets a motor on the joint
  59394. * @param joint joint to set motor on
  59395. * @param speed speed of the motor
  59396. * @param maxForce maximum force of the motor
  59397. * @param motorIndex index of the motor
  59398. */
  59399. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59400. /**
  59401. * Sets the motors limit
  59402. * @param joint joint to set limit on
  59403. * @param upperLimit upper limit
  59404. * @param lowerLimit lower limit
  59405. */
  59406. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59407. /**
  59408. * Syncs the position and rotation of a mesh with the impostor
  59409. * @param mesh mesh to sync
  59410. * @param impostor impostor to update the mesh with
  59411. */
  59412. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59413. /**
  59414. * Gets the radius of the impostor
  59415. * @param impostor impostor to get radius from
  59416. * @returns the radius
  59417. */
  59418. getRadius(impostor: PhysicsImpostor): number;
  59419. /**
  59420. * Gets the box size of the impostor
  59421. * @param impostor impostor to get box size from
  59422. * @param result the resulting box size
  59423. */
  59424. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59425. /**
  59426. * Disposes of the impostor
  59427. */
  59428. dispose(): void;
  59429. /**
  59430. * Does a raycast in the physics world
  59431. * @param from when should the ray start?
  59432. * @param to when should the ray end?
  59433. * @returns PhysicsRaycastResult
  59434. */
  59435. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59436. }
  59437. }
  59438. declare module BABYLON {
  59439. interface AbstractScene {
  59440. /**
  59441. * The list of reflection probes added to the scene
  59442. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59443. */
  59444. reflectionProbes: Array<ReflectionProbe>;
  59445. /**
  59446. * Removes the given reflection probe from this scene.
  59447. * @param toRemove The reflection probe to remove
  59448. * @returns The index of the removed reflection probe
  59449. */
  59450. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59451. /**
  59452. * Adds the given reflection probe to this scene.
  59453. * @param newReflectionProbe The reflection probe to add
  59454. */
  59455. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59456. }
  59457. /**
  59458. * Class used to generate realtime reflection / refraction cube textures
  59459. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59460. */
  59461. export class ReflectionProbe {
  59462. /** defines the name of the probe */
  59463. name: string;
  59464. private _scene;
  59465. private _renderTargetTexture;
  59466. private _projectionMatrix;
  59467. private _viewMatrix;
  59468. private _target;
  59469. private _add;
  59470. private _attachedMesh;
  59471. private _invertYAxis;
  59472. /** Gets or sets probe position (center of the cube map) */
  59473. position: Vector3;
  59474. /**
  59475. * Creates a new reflection probe
  59476. * @param name defines the name of the probe
  59477. * @param size defines the texture resolution (for each face)
  59478. * @param scene defines the hosting scene
  59479. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59480. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59481. */
  59482. constructor(
  59483. /** defines the name of the probe */
  59484. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59485. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59486. get samples(): number;
  59487. set samples(value: number);
  59488. /** Gets or sets the refresh rate to use (on every frame by default) */
  59489. get refreshRate(): number;
  59490. set refreshRate(value: number);
  59491. /**
  59492. * Gets the hosting scene
  59493. * @returns a Scene
  59494. */
  59495. getScene(): Scene;
  59496. /** Gets the internal CubeTexture used to render to */
  59497. get cubeTexture(): RenderTargetTexture;
  59498. /** Gets the list of meshes to render */
  59499. get renderList(): Nullable<AbstractMesh[]>;
  59500. /**
  59501. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59502. * @param mesh defines the mesh to attach to
  59503. */
  59504. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59505. /**
  59506. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59507. * @param renderingGroupId The rendering group id corresponding to its index
  59508. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59509. */
  59510. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59511. /**
  59512. * Clean all associated resources
  59513. */
  59514. dispose(): void;
  59515. /**
  59516. * Converts the reflection probe information to a readable string for debug purpose.
  59517. * @param fullDetails Supports for multiple levels of logging within scene loading
  59518. * @returns the human readable reflection probe info
  59519. */
  59520. toString(fullDetails?: boolean): string;
  59521. /**
  59522. * Get the class name of the relfection probe.
  59523. * @returns "ReflectionProbe"
  59524. */
  59525. getClassName(): string;
  59526. /**
  59527. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59528. * @returns The JSON representation of the texture
  59529. */
  59530. serialize(): any;
  59531. /**
  59532. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59533. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59534. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59535. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59536. * @returns The parsed reflection probe if successful
  59537. */
  59538. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59539. }
  59540. }
  59541. declare module BABYLON {
  59542. /** @hidden */
  59543. export var _BabylonLoaderRegistered: boolean;
  59544. /**
  59545. * Helps setting up some configuration for the babylon file loader.
  59546. */
  59547. export class BabylonFileLoaderConfiguration {
  59548. /**
  59549. * The loader does not allow injecting custom physix engine into the plugins.
  59550. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59551. * So you could set this variable to your engine import to make it work.
  59552. */
  59553. static LoaderInjectedPhysicsEngine: any;
  59554. }
  59555. }
  59556. declare module BABYLON {
  59557. /**
  59558. * The Physically based simple base material of BJS.
  59559. *
  59560. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59561. * It is used as the base class for both the specGloss and metalRough conventions.
  59562. */
  59563. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59564. /**
  59565. * Number of Simultaneous lights allowed on the material.
  59566. */
  59567. maxSimultaneousLights: number;
  59568. /**
  59569. * If sets to true, disables all the lights affecting the material.
  59570. */
  59571. disableLighting: boolean;
  59572. /**
  59573. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59574. */
  59575. environmentTexture: BaseTexture;
  59576. /**
  59577. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59578. */
  59579. invertNormalMapX: boolean;
  59580. /**
  59581. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59582. */
  59583. invertNormalMapY: boolean;
  59584. /**
  59585. * Normal map used in the model.
  59586. */
  59587. normalTexture: BaseTexture;
  59588. /**
  59589. * Emissivie color used to self-illuminate the model.
  59590. */
  59591. emissiveColor: Color3;
  59592. /**
  59593. * Emissivie texture used to self-illuminate the model.
  59594. */
  59595. emissiveTexture: BaseTexture;
  59596. /**
  59597. * Occlusion Channel Strenght.
  59598. */
  59599. occlusionStrength: number;
  59600. /**
  59601. * Occlusion Texture of the material (adding extra occlusion effects).
  59602. */
  59603. occlusionTexture: BaseTexture;
  59604. /**
  59605. * Defines the alpha limits in alpha test mode.
  59606. */
  59607. alphaCutOff: number;
  59608. /**
  59609. * Gets the current double sided mode.
  59610. */
  59611. get doubleSided(): boolean;
  59612. /**
  59613. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59614. */
  59615. set doubleSided(value: boolean);
  59616. /**
  59617. * Stores the pre-calculated light information of a mesh in a texture.
  59618. */
  59619. lightmapTexture: BaseTexture;
  59620. /**
  59621. * If true, the light map contains occlusion information instead of lighting info.
  59622. */
  59623. useLightmapAsShadowmap: boolean;
  59624. /**
  59625. * Instantiates a new PBRMaterial instance.
  59626. *
  59627. * @param name The material name
  59628. * @param scene The scene the material will be use in.
  59629. */
  59630. constructor(name: string, scene: Scene);
  59631. getClassName(): string;
  59632. }
  59633. }
  59634. declare module BABYLON {
  59635. /**
  59636. * The PBR material of BJS following the metal roughness convention.
  59637. *
  59638. * This fits to the PBR convention in the GLTF definition:
  59639. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59640. */
  59641. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59642. /**
  59643. * The base color has two different interpretations depending on the value of metalness.
  59644. * When the material is a metal, the base color is the specific measured reflectance value
  59645. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59646. * of the material.
  59647. */
  59648. baseColor: Color3;
  59649. /**
  59650. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59651. * well as opacity information in the alpha channel.
  59652. */
  59653. baseTexture: BaseTexture;
  59654. /**
  59655. * Specifies the metallic scalar value of the material.
  59656. * Can also be used to scale the metalness values of the metallic texture.
  59657. */
  59658. metallic: number;
  59659. /**
  59660. * Specifies the roughness scalar value of the material.
  59661. * Can also be used to scale the roughness values of the metallic texture.
  59662. */
  59663. roughness: number;
  59664. /**
  59665. * Texture containing both the metallic value in the B channel and the
  59666. * roughness value in the G channel to keep better precision.
  59667. */
  59668. metallicRoughnessTexture: BaseTexture;
  59669. /**
  59670. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59671. *
  59672. * @param name The material name
  59673. * @param scene The scene the material will be use in.
  59674. */
  59675. constructor(name: string, scene: Scene);
  59676. /**
  59677. * Return the currrent class name of the material.
  59678. */
  59679. getClassName(): string;
  59680. /**
  59681. * Makes a duplicate of the current material.
  59682. * @param name - name to use for the new material.
  59683. */
  59684. clone(name: string): PBRMetallicRoughnessMaterial;
  59685. /**
  59686. * Serialize the material to a parsable JSON object.
  59687. */
  59688. serialize(): any;
  59689. /**
  59690. * Parses a JSON object correponding to the serialize function.
  59691. */
  59692. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59693. }
  59694. }
  59695. declare module BABYLON {
  59696. /**
  59697. * The PBR material of BJS following the specular glossiness convention.
  59698. *
  59699. * This fits to the PBR convention in the GLTF definition:
  59700. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59701. */
  59702. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59703. /**
  59704. * Specifies the diffuse color of the material.
  59705. */
  59706. diffuseColor: Color3;
  59707. /**
  59708. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59709. * channel.
  59710. */
  59711. diffuseTexture: BaseTexture;
  59712. /**
  59713. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59714. */
  59715. specularColor: Color3;
  59716. /**
  59717. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59718. */
  59719. glossiness: number;
  59720. /**
  59721. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59722. */
  59723. specularGlossinessTexture: BaseTexture;
  59724. /**
  59725. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59726. *
  59727. * @param name The material name
  59728. * @param scene The scene the material will be use in.
  59729. */
  59730. constructor(name: string, scene: Scene);
  59731. /**
  59732. * Return the currrent class name of the material.
  59733. */
  59734. getClassName(): string;
  59735. /**
  59736. * Makes a duplicate of the current material.
  59737. * @param name - name to use for the new material.
  59738. */
  59739. clone(name: string): PBRSpecularGlossinessMaterial;
  59740. /**
  59741. * Serialize the material to a parsable JSON object.
  59742. */
  59743. serialize(): any;
  59744. /**
  59745. * Parses a JSON object correponding to the serialize function.
  59746. */
  59747. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59748. }
  59749. }
  59750. declare module BABYLON {
  59751. /**
  59752. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59753. * It can help converting any input color in a desired output one. This can then be used to create effects
  59754. * from sepia, black and white to sixties or futuristic rendering...
  59755. *
  59756. * The only supported format is currently 3dl.
  59757. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59758. */
  59759. export class ColorGradingTexture extends BaseTexture {
  59760. /**
  59761. * The texture URL.
  59762. */
  59763. url: string;
  59764. /**
  59765. * Empty line regex stored for GC.
  59766. */
  59767. private static _noneEmptyLineRegex;
  59768. private _textureMatrix;
  59769. private _onLoad;
  59770. /**
  59771. * Instantiates a ColorGradingTexture from the following parameters.
  59772. *
  59773. * @param url The location of the color gradind data (currently only supporting 3dl)
  59774. * @param sceneOrEngine The scene or engine the texture will be used in
  59775. * @param onLoad defines a callback triggered when the texture has been loaded
  59776. */
  59777. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  59778. /**
  59779. * Fires the onload event from the constructor if requested.
  59780. */
  59781. private _triggerOnLoad;
  59782. /**
  59783. * Returns the texture matrix used in most of the material.
  59784. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59785. */
  59786. getTextureMatrix(): Matrix;
  59787. /**
  59788. * Occurs when the file being loaded is a .3dl LUT file.
  59789. */
  59790. private load3dlTexture;
  59791. /**
  59792. * Starts the loading process of the texture.
  59793. */
  59794. private loadTexture;
  59795. /**
  59796. * Clones the color gradind texture.
  59797. */
  59798. clone(): ColorGradingTexture;
  59799. /**
  59800. * Called during delayed load for textures.
  59801. */
  59802. delayLoad(): void;
  59803. /**
  59804. * Parses a color grading texture serialized by Babylon.
  59805. * @param parsedTexture The texture information being parsedTexture
  59806. * @param scene The scene to load the texture in
  59807. * @param rootUrl The root url of the data assets to load
  59808. * @return A color gradind texture
  59809. */
  59810. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  59811. /**
  59812. * Serializes the LUT texture to json format.
  59813. */
  59814. serialize(): any;
  59815. }
  59816. }
  59817. declare module BABYLON {
  59818. /**
  59819. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59820. */
  59821. export class EquiRectangularCubeTexture extends BaseTexture {
  59822. /** The six faces of the cube. */
  59823. private static _FacesMapping;
  59824. private _noMipmap;
  59825. private _onLoad;
  59826. private _onError;
  59827. /** The size of the cubemap. */
  59828. private _size;
  59829. /** The buffer of the image. */
  59830. private _buffer;
  59831. /** The width of the input image. */
  59832. private _width;
  59833. /** The height of the input image. */
  59834. private _height;
  59835. /** The URL to the image. */
  59836. url: string;
  59837. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59838. coordinatesMode: number;
  59839. /**
  59840. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59841. * @param url The location of the image
  59842. * @param scene The scene the texture will be used in
  59843. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59844. * @param noMipmap Forces to not generate the mipmap if true
  59845. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59846. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59847. * @param onLoad — defines a callback called when texture is loaded
  59848. * @param onError — defines a callback called if there is an error
  59849. */
  59850. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59851. /**
  59852. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59853. */
  59854. private loadImage;
  59855. /**
  59856. * Convert the image buffer into a cubemap and create a CubeTexture.
  59857. */
  59858. private loadTexture;
  59859. /**
  59860. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59861. * @param buffer The ArrayBuffer that should be converted.
  59862. * @returns The buffer as Float32Array.
  59863. */
  59864. private getFloat32ArrayFromArrayBuffer;
  59865. /**
  59866. * Get the current class name of the texture useful for serialization or dynamic coding.
  59867. * @returns "EquiRectangularCubeTexture"
  59868. */
  59869. getClassName(): string;
  59870. /**
  59871. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59872. * @returns A clone of the current EquiRectangularCubeTexture.
  59873. */
  59874. clone(): EquiRectangularCubeTexture;
  59875. }
  59876. }
  59877. declare module BABYLON {
  59878. /**
  59879. * Defines the options related to the creation of an HtmlElementTexture
  59880. */
  59881. export interface IHtmlElementTextureOptions {
  59882. /**
  59883. * Defines wether mip maps should be created or not.
  59884. */
  59885. generateMipMaps?: boolean;
  59886. /**
  59887. * Defines the sampling mode of the texture.
  59888. */
  59889. samplingMode?: number;
  59890. /**
  59891. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59892. */
  59893. engine: Nullable<ThinEngine>;
  59894. /**
  59895. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59896. */
  59897. scene: Nullable<Scene>;
  59898. }
  59899. /**
  59900. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59901. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59902. * is automatically managed.
  59903. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59904. * in your application.
  59905. *
  59906. * As the update is not automatic, you need to call them manually.
  59907. */
  59908. export class HtmlElementTexture extends BaseTexture {
  59909. /**
  59910. * The texture URL.
  59911. */
  59912. element: HTMLVideoElement | HTMLCanvasElement;
  59913. private static readonly DefaultOptions;
  59914. private _textureMatrix;
  59915. private _isVideo;
  59916. private _generateMipMaps;
  59917. private _samplingMode;
  59918. /**
  59919. * Instantiates a HtmlElementTexture from the following parameters.
  59920. *
  59921. * @param name Defines the name of the texture
  59922. * @param element Defines the video or canvas the texture is filled with
  59923. * @param options Defines the other none mandatory texture creation options
  59924. */
  59925. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59926. private _createInternalTexture;
  59927. /**
  59928. * Returns the texture matrix used in most of the material.
  59929. */
  59930. getTextureMatrix(): Matrix;
  59931. /**
  59932. * Updates the content of the texture.
  59933. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59934. */
  59935. update(invertY?: Nullable<boolean>): void;
  59936. }
  59937. }
  59938. declare module BABYLON {
  59939. /**
  59940. * Based on jsTGALoader - Javascript loader for TGA file
  59941. * By Vincent Thibault
  59942. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59943. */
  59944. export class TGATools {
  59945. private static _TYPE_INDEXED;
  59946. private static _TYPE_RGB;
  59947. private static _TYPE_GREY;
  59948. private static _TYPE_RLE_INDEXED;
  59949. private static _TYPE_RLE_RGB;
  59950. private static _TYPE_RLE_GREY;
  59951. private static _ORIGIN_MASK;
  59952. private static _ORIGIN_SHIFT;
  59953. private static _ORIGIN_BL;
  59954. private static _ORIGIN_BR;
  59955. private static _ORIGIN_UL;
  59956. private static _ORIGIN_UR;
  59957. /**
  59958. * Gets the header of a TGA file
  59959. * @param data defines the TGA data
  59960. * @returns the header
  59961. */
  59962. static GetTGAHeader(data: Uint8Array): any;
  59963. /**
  59964. * Uploads TGA content to a Babylon Texture
  59965. * @hidden
  59966. */
  59967. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59968. /** @hidden */
  59969. 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;
  59970. /** @hidden */
  59971. 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;
  59972. /** @hidden */
  59973. 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;
  59974. /** @hidden */
  59975. 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;
  59976. /** @hidden */
  59977. 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;
  59978. /** @hidden */
  59979. 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;
  59980. }
  59981. }
  59982. declare module BABYLON {
  59983. /**
  59984. * Implementation of the TGA Texture Loader.
  59985. * @hidden
  59986. */
  59987. export class _TGATextureLoader implements IInternalTextureLoader {
  59988. /**
  59989. * Defines wether the loader supports cascade loading the different faces.
  59990. */
  59991. readonly supportCascades: boolean;
  59992. /**
  59993. * This returns if the loader support the current file information.
  59994. * @param extension defines the file extension of the file being loaded
  59995. * @returns true if the loader can load the specified file
  59996. */
  59997. canLoad(extension: string): boolean;
  59998. /**
  59999. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60000. * @param data contains the texture data
  60001. * @param texture defines the BabylonJS internal texture
  60002. * @param createPolynomials will be true if polynomials have been requested
  60003. * @param onLoad defines the callback to trigger once the texture is ready
  60004. * @param onError defines the callback to trigger in case of error
  60005. */
  60006. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60007. /**
  60008. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60009. * @param data contains the texture data
  60010. * @param texture defines the BabylonJS internal texture
  60011. * @param callback defines the method to call once ready to upload
  60012. */
  60013. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60014. }
  60015. }
  60016. declare module BABYLON {
  60017. /**
  60018. * Info about the .basis files
  60019. */
  60020. class BasisFileInfo {
  60021. /**
  60022. * If the file has alpha
  60023. */
  60024. hasAlpha: boolean;
  60025. /**
  60026. * Info about each image of the basis file
  60027. */
  60028. images: Array<{
  60029. levels: Array<{
  60030. width: number;
  60031. height: number;
  60032. transcodedPixels: ArrayBufferView;
  60033. }>;
  60034. }>;
  60035. }
  60036. /**
  60037. * Result of transcoding a basis file
  60038. */
  60039. class TranscodeResult {
  60040. /**
  60041. * Info about the .basis file
  60042. */
  60043. fileInfo: BasisFileInfo;
  60044. /**
  60045. * Format to use when loading the file
  60046. */
  60047. format: number;
  60048. }
  60049. /**
  60050. * Configuration options for the Basis transcoder
  60051. */
  60052. export class BasisTranscodeConfiguration {
  60053. /**
  60054. * Supported compression formats used to determine the supported output format of the transcoder
  60055. */
  60056. supportedCompressionFormats?: {
  60057. /**
  60058. * etc1 compression format
  60059. */
  60060. etc1?: boolean;
  60061. /**
  60062. * s3tc compression format
  60063. */
  60064. s3tc?: boolean;
  60065. /**
  60066. * pvrtc compression format
  60067. */
  60068. pvrtc?: boolean;
  60069. /**
  60070. * etc2 compression format
  60071. */
  60072. etc2?: boolean;
  60073. };
  60074. /**
  60075. * If mipmap levels should be loaded for transcoded images (Default: true)
  60076. */
  60077. loadMipmapLevels?: boolean;
  60078. /**
  60079. * Index of a single image to load (Default: all images)
  60080. */
  60081. loadSingleImage?: number;
  60082. }
  60083. /**
  60084. * Used to load .Basis files
  60085. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60086. */
  60087. export class BasisTools {
  60088. private static _IgnoreSupportedFormats;
  60089. /**
  60090. * URL to use when loading the basis transcoder
  60091. */
  60092. static JSModuleURL: string;
  60093. /**
  60094. * URL to use when loading the wasm module for the transcoder
  60095. */
  60096. static WasmModuleURL: string;
  60097. /**
  60098. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60099. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60100. * @returns internal format corresponding to the Basis format
  60101. */
  60102. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60103. private static _WorkerPromise;
  60104. private static _Worker;
  60105. private static _actionId;
  60106. private static _CreateWorkerAsync;
  60107. /**
  60108. * Transcodes a loaded image file to compressed pixel data
  60109. * @param data image data to transcode
  60110. * @param config configuration options for the transcoding
  60111. * @returns a promise resulting in the transcoded image
  60112. */
  60113. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60114. /**
  60115. * Loads a texture from the transcode result
  60116. * @param texture texture load to
  60117. * @param transcodeResult the result of transcoding the basis file to load from
  60118. */
  60119. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60120. }
  60121. }
  60122. declare module BABYLON {
  60123. /**
  60124. * Loader for .basis file format
  60125. */
  60126. export class _BasisTextureLoader implements IInternalTextureLoader {
  60127. /**
  60128. * Defines whether the loader supports cascade loading the different faces.
  60129. */
  60130. readonly supportCascades: boolean;
  60131. /**
  60132. * This returns if the loader support the current file information.
  60133. * @param extension defines the file extension of the file being loaded
  60134. * @returns true if the loader can load the specified file
  60135. */
  60136. canLoad(extension: string): boolean;
  60137. /**
  60138. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60139. * @param data contains the texture data
  60140. * @param texture defines the BabylonJS internal texture
  60141. * @param createPolynomials will be true if polynomials have been requested
  60142. * @param onLoad defines the callback to trigger once the texture is ready
  60143. * @param onError defines the callback to trigger in case of error
  60144. */
  60145. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60146. /**
  60147. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60148. * @param data contains the texture data
  60149. * @param texture defines the BabylonJS internal texture
  60150. * @param callback defines the method to call once ready to upload
  60151. */
  60152. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60153. }
  60154. }
  60155. declare module BABYLON {
  60156. /**
  60157. * Defines the basic options interface of a TexturePacker Frame
  60158. */
  60159. export interface ITexturePackerFrame {
  60160. /**
  60161. * The frame ID
  60162. */
  60163. id: number;
  60164. /**
  60165. * The frames Scale
  60166. */
  60167. scale: Vector2;
  60168. /**
  60169. * The Frames offset
  60170. */
  60171. offset: Vector2;
  60172. }
  60173. /**
  60174. * This is a support class for frame Data on texture packer sets.
  60175. */
  60176. export class TexturePackerFrame implements ITexturePackerFrame {
  60177. /**
  60178. * The frame ID
  60179. */
  60180. id: number;
  60181. /**
  60182. * The frames Scale
  60183. */
  60184. scale: Vector2;
  60185. /**
  60186. * The Frames offset
  60187. */
  60188. offset: Vector2;
  60189. /**
  60190. * Initializes a texture package frame.
  60191. * @param id The numerical frame identifier
  60192. * @param scale Scalar Vector2 for UV frame
  60193. * @param offset Vector2 for the frame position in UV units.
  60194. * @returns TexturePackerFrame
  60195. */
  60196. constructor(id: number, scale: Vector2, offset: Vector2);
  60197. }
  60198. }
  60199. declare module BABYLON {
  60200. /**
  60201. * Defines the basic options interface of a TexturePacker
  60202. */
  60203. export interface ITexturePackerOptions {
  60204. /**
  60205. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60206. */
  60207. map?: string[];
  60208. /**
  60209. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60210. */
  60211. uvsIn?: string;
  60212. /**
  60213. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60214. */
  60215. uvsOut?: string;
  60216. /**
  60217. * number representing the layout style. Defaults to LAYOUT_STRIP
  60218. */
  60219. layout?: number;
  60220. /**
  60221. * number of columns if using custom column count layout(2). This defaults to 4.
  60222. */
  60223. colnum?: number;
  60224. /**
  60225. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60226. */
  60227. updateInputMeshes?: boolean;
  60228. /**
  60229. * boolean flag to dispose all the source textures. Defaults to true.
  60230. */
  60231. disposeSources?: boolean;
  60232. /**
  60233. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60234. */
  60235. fillBlanks?: boolean;
  60236. /**
  60237. * string value representing the context fill style color. Defaults to 'black'.
  60238. */
  60239. customFillColor?: string;
  60240. /**
  60241. * Width and Height Value of each Frame in the TexturePacker Sets
  60242. */
  60243. frameSize?: number;
  60244. /**
  60245. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60246. */
  60247. paddingRatio?: number;
  60248. /**
  60249. * Number that declares the fill method for the padding gutter.
  60250. */
  60251. paddingMode?: number;
  60252. /**
  60253. * If in SUBUV_COLOR padding mode what color to use.
  60254. */
  60255. paddingColor?: Color3 | Color4;
  60256. }
  60257. /**
  60258. * Defines the basic interface of a TexturePacker JSON File
  60259. */
  60260. export interface ITexturePackerJSON {
  60261. /**
  60262. * The frame ID
  60263. */
  60264. name: string;
  60265. /**
  60266. * The base64 channel data
  60267. */
  60268. sets: any;
  60269. /**
  60270. * The options of the Packer
  60271. */
  60272. options: ITexturePackerOptions;
  60273. /**
  60274. * The frame data of the Packer
  60275. */
  60276. frames: Array<number>;
  60277. }
  60278. /**
  60279. * This is a support class that generates a series of packed texture sets.
  60280. * @see https://doc.babylonjs.com/babylon101/materials
  60281. */
  60282. export class TexturePacker {
  60283. /** Packer Layout Constant 0 */
  60284. static readonly LAYOUT_STRIP: number;
  60285. /** Packer Layout Constant 1 */
  60286. static readonly LAYOUT_POWER2: number;
  60287. /** Packer Layout Constant 2 */
  60288. static readonly LAYOUT_COLNUM: number;
  60289. /** Packer Layout Constant 0 */
  60290. static readonly SUBUV_WRAP: number;
  60291. /** Packer Layout Constant 1 */
  60292. static readonly SUBUV_EXTEND: number;
  60293. /** Packer Layout Constant 2 */
  60294. static readonly SUBUV_COLOR: number;
  60295. /** The Name of the Texture Package */
  60296. name: string;
  60297. /** The scene scope of the TexturePacker */
  60298. scene: Scene;
  60299. /** The Meshes to target */
  60300. meshes: AbstractMesh[];
  60301. /** Arguments passed with the Constructor */
  60302. options: ITexturePackerOptions;
  60303. /** The promise that is started upon initialization */
  60304. promise: Nullable<Promise<TexturePacker | string>>;
  60305. /** The Container object for the channel sets that are generated */
  60306. sets: object;
  60307. /** The Container array for the frames that are generated */
  60308. frames: TexturePackerFrame[];
  60309. /** The expected number of textures the system is parsing. */
  60310. private _expecting;
  60311. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60312. private _paddingValue;
  60313. /**
  60314. * Initializes a texture package series from an array of meshes or a single mesh.
  60315. * @param name The name of the package
  60316. * @param meshes The target meshes to compose the package from
  60317. * @param options The arguments that texture packer should follow while building.
  60318. * @param scene The scene which the textures are scoped to.
  60319. * @returns TexturePacker
  60320. */
  60321. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60322. /**
  60323. * Starts the package process
  60324. * @param resolve The promises resolution function
  60325. * @returns TexturePacker
  60326. */
  60327. private _createFrames;
  60328. /**
  60329. * Calculates the Size of the Channel Sets
  60330. * @returns Vector2
  60331. */
  60332. private _calculateSize;
  60333. /**
  60334. * Calculates the UV data for the frames.
  60335. * @param baseSize the base frameSize
  60336. * @param padding the base frame padding
  60337. * @param dtSize size of the Dynamic Texture for that channel
  60338. * @param dtUnits is 1/dtSize
  60339. * @param update flag to update the input meshes
  60340. */
  60341. private _calculateMeshUVFrames;
  60342. /**
  60343. * Calculates the frames Offset.
  60344. * @param index of the frame
  60345. * @returns Vector2
  60346. */
  60347. private _getFrameOffset;
  60348. /**
  60349. * Updates a Mesh to the frame data
  60350. * @param mesh that is the target
  60351. * @param frameID or the frame index
  60352. */
  60353. private _updateMeshUV;
  60354. /**
  60355. * Updates a Meshes materials to use the texture packer channels
  60356. * @param m is the mesh to target
  60357. * @param force all channels on the packer to be set.
  60358. */
  60359. private _updateTextureReferences;
  60360. /**
  60361. * Public method to set a Mesh to a frame
  60362. * @param m that is the target
  60363. * @param frameID or the frame index
  60364. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60365. */
  60366. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60367. /**
  60368. * Starts the async promise to compile the texture packer.
  60369. * @returns Promise<void>
  60370. */
  60371. processAsync(): Promise<void>;
  60372. /**
  60373. * Disposes all textures associated with this packer
  60374. */
  60375. dispose(): void;
  60376. /**
  60377. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60378. * @param imageType is the image type to use.
  60379. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60380. */
  60381. download(imageType?: string, quality?: number): void;
  60382. /**
  60383. * Public method to load a texturePacker JSON file.
  60384. * @param data of the JSON file in string format.
  60385. */
  60386. updateFromJSON(data: string): void;
  60387. }
  60388. }
  60389. declare module BABYLON {
  60390. /**
  60391. * 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.
  60392. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60393. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60394. */
  60395. export class CustomProceduralTexture extends ProceduralTexture {
  60396. private _animate;
  60397. private _time;
  60398. private _config;
  60399. private _texturePath;
  60400. /**
  60401. * Instantiates a new Custom Procedural Texture.
  60402. * 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.
  60403. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60404. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60405. * @param name Define the name of the texture
  60406. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60407. * @param size Define the size of the texture to create
  60408. * @param scene Define the scene the texture belongs to
  60409. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60410. * @param generateMipMaps Define if the texture should creates mip maps or not
  60411. */
  60412. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60413. private _loadJson;
  60414. /**
  60415. * Is the texture ready to be used ? (rendered at least once)
  60416. * @returns true if ready, otherwise, false.
  60417. */
  60418. isReady(): boolean;
  60419. /**
  60420. * Render the texture to its associated render target.
  60421. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60422. */
  60423. render(useCameraPostProcess?: boolean): void;
  60424. /**
  60425. * Update the list of dependant textures samplers in the shader.
  60426. */
  60427. updateTextures(): void;
  60428. /**
  60429. * Update the uniform values of the procedural texture in the shader.
  60430. */
  60431. updateShaderUniforms(): void;
  60432. /**
  60433. * Define if the texture animates or not.
  60434. */
  60435. get animate(): boolean;
  60436. set animate(value: boolean);
  60437. }
  60438. }
  60439. declare module BABYLON {
  60440. /** @hidden */
  60441. export var noisePixelShader: {
  60442. name: string;
  60443. shader: string;
  60444. };
  60445. }
  60446. declare module BABYLON {
  60447. /**
  60448. * Class used to generate noise procedural textures
  60449. */
  60450. export class NoiseProceduralTexture extends ProceduralTexture {
  60451. private _time;
  60452. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60453. brightness: number;
  60454. /** Defines the number of octaves to process */
  60455. octaves: number;
  60456. /** Defines the level of persistence (0.8 by default) */
  60457. persistence: number;
  60458. /** Gets or sets animation speed factor (default is 1) */
  60459. animationSpeedFactor: number;
  60460. /**
  60461. * Creates a new NoiseProceduralTexture
  60462. * @param name defines the name fo the texture
  60463. * @param size defines the size of the texture (default is 256)
  60464. * @param scene defines the hosting scene
  60465. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60466. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60467. */
  60468. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60469. private _updateShaderUniforms;
  60470. protected _getDefines(): string;
  60471. /** Generate the current state of the procedural texture */
  60472. render(useCameraPostProcess?: boolean): void;
  60473. /**
  60474. * Serializes this noise procedural texture
  60475. * @returns a serialized noise procedural texture object
  60476. */
  60477. serialize(): any;
  60478. /**
  60479. * Clone the texture.
  60480. * @returns the cloned texture
  60481. */
  60482. clone(): NoiseProceduralTexture;
  60483. /**
  60484. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60485. * @param parsedTexture defines parsed texture data
  60486. * @param scene defines the current scene
  60487. * @param rootUrl defines the root URL containing noise procedural texture information
  60488. * @returns a parsed NoiseProceduralTexture
  60489. */
  60490. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60491. }
  60492. }
  60493. declare module BABYLON {
  60494. /**
  60495. * Raw cube texture where the raw buffers are passed in
  60496. */
  60497. export class RawCubeTexture extends CubeTexture {
  60498. /**
  60499. * Creates a cube texture where the raw buffers are passed in.
  60500. * @param scene defines the scene the texture is attached to
  60501. * @param data defines the array of data to use to create each face
  60502. * @param size defines the size of the textures
  60503. * @param format defines the format of the data
  60504. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60505. * @param generateMipMaps defines if the engine should generate the mip levels
  60506. * @param invertY defines if data must be stored with Y axis inverted
  60507. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60508. * @param compression defines the compression used (null by default)
  60509. */
  60510. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60511. /**
  60512. * Updates the raw cube texture.
  60513. * @param data defines the data to store
  60514. * @param format defines the data format
  60515. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60516. * @param invertY defines if data must be stored with Y axis inverted
  60517. * @param compression defines the compression used (null by default)
  60518. * @param level defines which level of the texture to update
  60519. */
  60520. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60521. /**
  60522. * Updates a raw cube texture with RGBD encoded data.
  60523. * @param data defines the array of data [mipmap][face] to use to create each face
  60524. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60525. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60526. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60527. * @returns a promsie that resolves when the operation is complete
  60528. */
  60529. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60530. /**
  60531. * Clones the raw cube texture.
  60532. * @return a new cube texture
  60533. */
  60534. clone(): CubeTexture;
  60535. /** @hidden */
  60536. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60537. }
  60538. }
  60539. declare module BABYLON {
  60540. /**
  60541. * Class used to store 2D array textures containing user data
  60542. */
  60543. export class RawTexture2DArray extends Texture {
  60544. /** Gets or sets the texture format to use */
  60545. format: number;
  60546. /**
  60547. * Create a new RawTexture2DArray
  60548. * @param data defines the data of the texture
  60549. * @param width defines the width of the texture
  60550. * @param height defines the height of the texture
  60551. * @param depth defines the number of layers of the texture
  60552. * @param format defines the texture format to use
  60553. * @param scene defines the hosting scene
  60554. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60555. * @param invertY defines if texture must be stored with Y axis inverted
  60556. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60557. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60558. */
  60559. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60560. /** Gets or sets the texture format to use */
  60561. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60562. /**
  60563. * Update the texture with new data
  60564. * @param data defines the data to store in the texture
  60565. */
  60566. update(data: ArrayBufferView): void;
  60567. }
  60568. }
  60569. declare module BABYLON {
  60570. /**
  60571. * Class used to store 3D textures containing user data
  60572. */
  60573. export class RawTexture3D extends Texture {
  60574. /** Gets or sets the texture format to use */
  60575. format: number;
  60576. /**
  60577. * Create a new RawTexture3D
  60578. * @param data defines the data of the texture
  60579. * @param width defines the width of the texture
  60580. * @param height defines the height of the texture
  60581. * @param depth defines the depth of the texture
  60582. * @param format defines the texture format to use
  60583. * @param scene defines the hosting scene
  60584. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60585. * @param invertY defines if texture must be stored with Y axis inverted
  60586. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60587. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60588. */
  60589. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60590. /** Gets or sets the texture format to use */
  60591. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60592. /**
  60593. * Update the texture with new data
  60594. * @param data defines the data to store in the texture
  60595. */
  60596. update(data: ArrayBufferView): void;
  60597. }
  60598. }
  60599. declare module BABYLON {
  60600. /**
  60601. * Creates a refraction texture used by refraction channel of the standard material.
  60602. * It is like a mirror but to see through a material.
  60603. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60604. */
  60605. export class RefractionTexture extends RenderTargetTexture {
  60606. /**
  60607. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  60608. * 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.
  60609. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60610. */
  60611. refractionPlane: Plane;
  60612. /**
  60613. * Define how deep under the surface we should see.
  60614. */
  60615. depth: number;
  60616. /**
  60617. * Creates a refraction texture used by refraction channel of the standard material.
  60618. * It is like a mirror but to see through a material.
  60619. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60620. * @param name Define the texture name
  60621. * @param size Define the size of the underlying texture
  60622. * @param scene Define the scene the refraction belongs to
  60623. * @param generateMipMaps Define if we need to generate mips level for the refraction
  60624. */
  60625. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  60626. /**
  60627. * Clone the refraction texture.
  60628. * @returns the cloned texture
  60629. */
  60630. clone(): RefractionTexture;
  60631. /**
  60632. * Serialize the texture to a JSON representation you could use in Parse later on
  60633. * @returns the serialized JSON representation
  60634. */
  60635. serialize(): any;
  60636. }
  60637. }
  60638. declare module BABYLON {
  60639. /**
  60640. * Block used to add support for vertex skinning (bones)
  60641. */
  60642. export class BonesBlock extends NodeMaterialBlock {
  60643. /**
  60644. * Creates a new BonesBlock
  60645. * @param name defines the block name
  60646. */
  60647. constructor(name: string);
  60648. /**
  60649. * Initialize the block and prepare the context for build
  60650. * @param state defines the state that will be used for the build
  60651. */
  60652. initialize(state: NodeMaterialBuildState): void;
  60653. /**
  60654. * Gets the current class name
  60655. * @returns the class name
  60656. */
  60657. getClassName(): string;
  60658. /**
  60659. * Gets the matrix indices input component
  60660. */
  60661. get matricesIndices(): NodeMaterialConnectionPoint;
  60662. /**
  60663. * Gets the matrix weights input component
  60664. */
  60665. get matricesWeights(): NodeMaterialConnectionPoint;
  60666. /**
  60667. * Gets the extra matrix indices input component
  60668. */
  60669. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60670. /**
  60671. * Gets the extra matrix weights input component
  60672. */
  60673. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60674. /**
  60675. * Gets the world input component
  60676. */
  60677. get world(): NodeMaterialConnectionPoint;
  60678. /**
  60679. * Gets the output component
  60680. */
  60681. get output(): NodeMaterialConnectionPoint;
  60682. autoConfigure(material: NodeMaterial): void;
  60683. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60684. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60685. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60686. protected _buildBlock(state: NodeMaterialBuildState): this;
  60687. }
  60688. }
  60689. declare module BABYLON {
  60690. /**
  60691. * Block used to add support for instances
  60692. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60693. */
  60694. export class InstancesBlock extends NodeMaterialBlock {
  60695. /**
  60696. * Creates a new InstancesBlock
  60697. * @param name defines the block name
  60698. */
  60699. constructor(name: string);
  60700. /**
  60701. * Gets the current class name
  60702. * @returns the class name
  60703. */
  60704. getClassName(): string;
  60705. /**
  60706. * Gets the first world row input component
  60707. */
  60708. get world0(): NodeMaterialConnectionPoint;
  60709. /**
  60710. * Gets the second world row input component
  60711. */
  60712. get world1(): NodeMaterialConnectionPoint;
  60713. /**
  60714. * Gets the third world row input component
  60715. */
  60716. get world2(): NodeMaterialConnectionPoint;
  60717. /**
  60718. * Gets the forth world row input component
  60719. */
  60720. get world3(): NodeMaterialConnectionPoint;
  60721. /**
  60722. * Gets the world input component
  60723. */
  60724. get world(): NodeMaterialConnectionPoint;
  60725. /**
  60726. * Gets the output component
  60727. */
  60728. get output(): NodeMaterialConnectionPoint;
  60729. /**
  60730. * Gets the isntanceID component
  60731. */
  60732. get instanceID(): NodeMaterialConnectionPoint;
  60733. autoConfigure(material: NodeMaterial): void;
  60734. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  60735. protected _buildBlock(state: NodeMaterialBuildState): this;
  60736. }
  60737. }
  60738. declare module BABYLON {
  60739. /**
  60740. * Block used to add morph targets support to vertex shader
  60741. */
  60742. export class MorphTargetsBlock extends NodeMaterialBlock {
  60743. private _repeatableContentAnchor;
  60744. /**
  60745. * Create a new MorphTargetsBlock
  60746. * @param name defines the block name
  60747. */
  60748. constructor(name: string);
  60749. /**
  60750. * Gets the current class name
  60751. * @returns the class name
  60752. */
  60753. getClassName(): string;
  60754. /**
  60755. * Gets the position input component
  60756. */
  60757. get position(): NodeMaterialConnectionPoint;
  60758. /**
  60759. * Gets the normal input component
  60760. */
  60761. get normal(): NodeMaterialConnectionPoint;
  60762. /**
  60763. * Gets the tangent input component
  60764. */
  60765. get tangent(): NodeMaterialConnectionPoint;
  60766. /**
  60767. * Gets the tangent input component
  60768. */
  60769. get uv(): NodeMaterialConnectionPoint;
  60770. /**
  60771. * Gets the position output component
  60772. */
  60773. get positionOutput(): NodeMaterialConnectionPoint;
  60774. /**
  60775. * Gets the normal output component
  60776. */
  60777. get normalOutput(): NodeMaterialConnectionPoint;
  60778. /**
  60779. * Gets the tangent output component
  60780. */
  60781. get tangentOutput(): NodeMaterialConnectionPoint;
  60782. /**
  60783. * Gets the tangent output component
  60784. */
  60785. get uvOutput(): NodeMaterialConnectionPoint;
  60786. initialize(state: NodeMaterialBuildState): void;
  60787. autoConfigure(material: NodeMaterial): void;
  60788. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60789. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60790. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60791. protected _buildBlock(state: NodeMaterialBuildState): this;
  60792. }
  60793. }
  60794. declare module BABYLON {
  60795. /**
  60796. * Block used to get data information from a light
  60797. */
  60798. export class LightInformationBlock extends NodeMaterialBlock {
  60799. private _lightDataUniformName;
  60800. private _lightColorUniformName;
  60801. private _lightTypeDefineName;
  60802. /**
  60803. * Gets or sets the light associated with this block
  60804. */
  60805. light: Nullable<Light>;
  60806. /**
  60807. * Creates a new LightInformationBlock
  60808. * @param name defines the block name
  60809. */
  60810. constructor(name: string);
  60811. /**
  60812. * Gets the current class name
  60813. * @returns the class name
  60814. */
  60815. getClassName(): string;
  60816. /**
  60817. * Gets the world position input component
  60818. */
  60819. get worldPosition(): NodeMaterialConnectionPoint;
  60820. /**
  60821. * Gets the direction output component
  60822. */
  60823. get direction(): NodeMaterialConnectionPoint;
  60824. /**
  60825. * Gets the direction output component
  60826. */
  60827. get color(): NodeMaterialConnectionPoint;
  60828. /**
  60829. * Gets the direction output component
  60830. */
  60831. get intensity(): NodeMaterialConnectionPoint;
  60832. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60833. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60834. protected _buildBlock(state: NodeMaterialBuildState): this;
  60835. serialize(): any;
  60836. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60837. }
  60838. }
  60839. declare module BABYLON {
  60840. /**
  60841. * Block used to add image processing support to fragment shader
  60842. */
  60843. export class ImageProcessingBlock extends NodeMaterialBlock {
  60844. /**
  60845. * Create a new ImageProcessingBlock
  60846. * @param name defines the block name
  60847. */
  60848. constructor(name: string);
  60849. /**
  60850. * Gets the current class name
  60851. * @returns the class name
  60852. */
  60853. getClassName(): string;
  60854. /**
  60855. * Gets the color input component
  60856. */
  60857. get color(): NodeMaterialConnectionPoint;
  60858. /**
  60859. * Gets the output component
  60860. */
  60861. get output(): NodeMaterialConnectionPoint;
  60862. /**
  60863. * Initialize the block and prepare the context for build
  60864. * @param state defines the state that will be used for the build
  60865. */
  60866. initialize(state: NodeMaterialBuildState): void;
  60867. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  60868. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60869. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60870. protected _buildBlock(state: NodeMaterialBuildState): this;
  60871. }
  60872. }
  60873. declare module BABYLON {
  60874. /**
  60875. * Block used to pertub normals based on a normal map
  60876. */
  60877. export class PerturbNormalBlock extends NodeMaterialBlock {
  60878. private _tangentSpaceParameterName;
  60879. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60880. invertX: boolean;
  60881. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  60882. invertY: boolean;
  60883. /**
  60884. * Create a new PerturbNormalBlock
  60885. * @param name defines the block name
  60886. */
  60887. constructor(name: string);
  60888. /**
  60889. * Gets the current class name
  60890. * @returns the class name
  60891. */
  60892. getClassName(): string;
  60893. /**
  60894. * Gets the world position input component
  60895. */
  60896. get worldPosition(): NodeMaterialConnectionPoint;
  60897. /**
  60898. * Gets the world normal input component
  60899. */
  60900. get worldNormal(): NodeMaterialConnectionPoint;
  60901. /**
  60902. * Gets the world tangent input component
  60903. */
  60904. get worldTangent(): NodeMaterialConnectionPoint;
  60905. /**
  60906. * Gets the uv input component
  60907. */
  60908. get uv(): NodeMaterialConnectionPoint;
  60909. /**
  60910. * Gets the normal map color input component
  60911. */
  60912. get normalMapColor(): NodeMaterialConnectionPoint;
  60913. /**
  60914. * Gets the strength input component
  60915. */
  60916. get strength(): NodeMaterialConnectionPoint;
  60917. /**
  60918. * Gets the output component
  60919. */
  60920. get output(): NodeMaterialConnectionPoint;
  60921. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60922. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60923. autoConfigure(material: NodeMaterial): void;
  60924. protected _buildBlock(state: NodeMaterialBuildState): this;
  60925. protected _dumpPropertiesCode(): string;
  60926. serialize(): any;
  60927. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60928. }
  60929. }
  60930. declare module BABYLON {
  60931. /**
  60932. * Block used to discard a pixel if a value is smaller than a cutoff
  60933. */
  60934. export class DiscardBlock extends NodeMaterialBlock {
  60935. /**
  60936. * Create a new DiscardBlock
  60937. * @param name defines the block name
  60938. */
  60939. constructor(name: string);
  60940. /**
  60941. * Gets the current class name
  60942. * @returns the class name
  60943. */
  60944. getClassName(): string;
  60945. /**
  60946. * Gets the color input component
  60947. */
  60948. get value(): NodeMaterialConnectionPoint;
  60949. /**
  60950. * Gets the cutoff input component
  60951. */
  60952. get cutoff(): NodeMaterialConnectionPoint;
  60953. protected _buildBlock(state: NodeMaterialBuildState): this;
  60954. }
  60955. }
  60956. declare module BABYLON {
  60957. /**
  60958. * Block used to test if the fragment shader is front facing
  60959. */
  60960. export class FrontFacingBlock extends NodeMaterialBlock {
  60961. /**
  60962. * Creates a new FrontFacingBlock
  60963. * @param name defines the block name
  60964. */
  60965. constructor(name: string);
  60966. /**
  60967. * Gets the current class name
  60968. * @returns the class name
  60969. */
  60970. getClassName(): string;
  60971. /**
  60972. * Gets the output component
  60973. */
  60974. get output(): NodeMaterialConnectionPoint;
  60975. protected _buildBlock(state: NodeMaterialBuildState): this;
  60976. }
  60977. }
  60978. declare module BABYLON {
  60979. /**
  60980. * Block used to get the derivative value on x and y of a given input
  60981. */
  60982. export class DerivativeBlock extends NodeMaterialBlock {
  60983. /**
  60984. * Create a new DerivativeBlock
  60985. * @param name defines the block name
  60986. */
  60987. constructor(name: string);
  60988. /**
  60989. * Gets the current class name
  60990. * @returns the class name
  60991. */
  60992. getClassName(): string;
  60993. /**
  60994. * Gets the input component
  60995. */
  60996. get input(): NodeMaterialConnectionPoint;
  60997. /**
  60998. * Gets the derivative output on x
  60999. */
  61000. get dx(): NodeMaterialConnectionPoint;
  61001. /**
  61002. * Gets the derivative output on y
  61003. */
  61004. get dy(): NodeMaterialConnectionPoint;
  61005. protected _buildBlock(state: NodeMaterialBuildState): this;
  61006. }
  61007. }
  61008. declare module BABYLON {
  61009. /**
  61010. * Block used to add support for scene fog
  61011. */
  61012. export class FogBlock extends NodeMaterialBlock {
  61013. private _fogDistanceName;
  61014. private _fogParameters;
  61015. /**
  61016. * Create a new FogBlock
  61017. * @param name defines the block name
  61018. */
  61019. constructor(name: string);
  61020. /**
  61021. * Gets the current class name
  61022. * @returns the class name
  61023. */
  61024. getClassName(): string;
  61025. /**
  61026. * Gets the world position input component
  61027. */
  61028. get worldPosition(): NodeMaterialConnectionPoint;
  61029. /**
  61030. * Gets the view input component
  61031. */
  61032. get view(): NodeMaterialConnectionPoint;
  61033. /**
  61034. * Gets the color input component
  61035. */
  61036. get input(): NodeMaterialConnectionPoint;
  61037. /**
  61038. * Gets the fog color input component
  61039. */
  61040. get fogColor(): NodeMaterialConnectionPoint;
  61041. /**
  61042. * Gets the output component
  61043. */
  61044. get output(): NodeMaterialConnectionPoint;
  61045. autoConfigure(material: NodeMaterial): void;
  61046. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61047. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61048. protected _buildBlock(state: NodeMaterialBuildState): this;
  61049. }
  61050. }
  61051. declare module BABYLON {
  61052. /**
  61053. * Block used to add light in the fragment shader
  61054. */
  61055. export class LightBlock extends NodeMaterialBlock {
  61056. private _lightId;
  61057. /**
  61058. * Gets or sets the light associated with this block
  61059. */
  61060. light: Nullable<Light>;
  61061. /**
  61062. * Create a new LightBlock
  61063. * @param name defines the block name
  61064. */
  61065. constructor(name: string);
  61066. /**
  61067. * Gets the current class name
  61068. * @returns the class name
  61069. */
  61070. getClassName(): string;
  61071. /**
  61072. * Gets the world position input component
  61073. */
  61074. get worldPosition(): NodeMaterialConnectionPoint;
  61075. /**
  61076. * Gets the world normal input component
  61077. */
  61078. get worldNormal(): NodeMaterialConnectionPoint;
  61079. /**
  61080. * Gets the camera (or eye) position component
  61081. */
  61082. get cameraPosition(): NodeMaterialConnectionPoint;
  61083. /**
  61084. * Gets the glossiness component
  61085. */
  61086. get glossiness(): NodeMaterialConnectionPoint;
  61087. /**
  61088. * Gets the glossinness power component
  61089. */
  61090. get glossPower(): NodeMaterialConnectionPoint;
  61091. /**
  61092. * Gets the diffuse color component
  61093. */
  61094. get diffuseColor(): NodeMaterialConnectionPoint;
  61095. /**
  61096. * Gets the specular color component
  61097. */
  61098. get specularColor(): NodeMaterialConnectionPoint;
  61099. /**
  61100. * Gets the diffuse output component
  61101. */
  61102. get diffuseOutput(): NodeMaterialConnectionPoint;
  61103. /**
  61104. * Gets the specular output component
  61105. */
  61106. get specularOutput(): NodeMaterialConnectionPoint;
  61107. /**
  61108. * Gets the shadow output component
  61109. */
  61110. get shadow(): NodeMaterialConnectionPoint;
  61111. autoConfigure(material: NodeMaterial): void;
  61112. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61113. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61114. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61115. private _injectVertexCode;
  61116. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61117. serialize(): any;
  61118. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61119. }
  61120. }
  61121. declare module BABYLON {
  61122. /**
  61123. * Block used to read a reflection texture from a sampler
  61124. */
  61125. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61126. /**
  61127. * Create a new ReflectionTextureBlock
  61128. * @param name defines the block name
  61129. */
  61130. constructor(name: string);
  61131. /**
  61132. * Gets the current class name
  61133. * @returns the class name
  61134. */
  61135. getClassName(): string;
  61136. /**
  61137. * Gets the world position input component
  61138. */
  61139. get position(): NodeMaterialConnectionPoint;
  61140. /**
  61141. * Gets the world position input component
  61142. */
  61143. get worldPosition(): NodeMaterialConnectionPoint;
  61144. /**
  61145. * Gets the world normal input component
  61146. */
  61147. get worldNormal(): NodeMaterialConnectionPoint;
  61148. /**
  61149. * Gets the world input component
  61150. */
  61151. get world(): NodeMaterialConnectionPoint;
  61152. /**
  61153. * Gets the camera (or eye) position component
  61154. */
  61155. get cameraPosition(): NodeMaterialConnectionPoint;
  61156. /**
  61157. * Gets the view input component
  61158. */
  61159. get view(): NodeMaterialConnectionPoint;
  61160. /**
  61161. * Gets the rgb output component
  61162. */
  61163. get rgb(): NodeMaterialConnectionPoint;
  61164. /**
  61165. * Gets the r output component
  61166. */
  61167. get r(): NodeMaterialConnectionPoint;
  61168. /**
  61169. * Gets the g output component
  61170. */
  61171. get g(): NodeMaterialConnectionPoint;
  61172. /**
  61173. * Gets the b output component
  61174. */
  61175. get b(): NodeMaterialConnectionPoint;
  61176. autoConfigure(material: NodeMaterial): void;
  61177. protected _buildBlock(state: NodeMaterialBuildState): this;
  61178. }
  61179. }
  61180. declare module BABYLON {
  61181. /**
  61182. * Block used to add 2 vectors
  61183. */
  61184. export class AddBlock extends NodeMaterialBlock {
  61185. /**
  61186. * Creates a new AddBlock
  61187. * @param name defines the block name
  61188. */
  61189. constructor(name: string);
  61190. /**
  61191. * Gets the current class name
  61192. * @returns the class name
  61193. */
  61194. getClassName(): string;
  61195. /**
  61196. * Gets the left operand input component
  61197. */
  61198. get left(): NodeMaterialConnectionPoint;
  61199. /**
  61200. * Gets the right operand input component
  61201. */
  61202. get right(): NodeMaterialConnectionPoint;
  61203. /**
  61204. * Gets the output component
  61205. */
  61206. get output(): NodeMaterialConnectionPoint;
  61207. protected _buildBlock(state: NodeMaterialBuildState): this;
  61208. }
  61209. }
  61210. declare module BABYLON {
  61211. /**
  61212. * Block used to scale a vector by a float
  61213. */
  61214. export class ScaleBlock extends NodeMaterialBlock {
  61215. /**
  61216. * Creates a new ScaleBlock
  61217. * @param name defines the block name
  61218. */
  61219. constructor(name: string);
  61220. /**
  61221. * Gets the current class name
  61222. * @returns the class name
  61223. */
  61224. getClassName(): string;
  61225. /**
  61226. * Gets the input component
  61227. */
  61228. get input(): NodeMaterialConnectionPoint;
  61229. /**
  61230. * Gets the factor input component
  61231. */
  61232. get factor(): NodeMaterialConnectionPoint;
  61233. /**
  61234. * Gets the output component
  61235. */
  61236. get output(): NodeMaterialConnectionPoint;
  61237. protected _buildBlock(state: NodeMaterialBuildState): this;
  61238. }
  61239. }
  61240. declare module BABYLON {
  61241. /**
  61242. * Block used to clamp a float
  61243. */
  61244. export class ClampBlock extends NodeMaterialBlock {
  61245. /** Gets or sets the minimum range */
  61246. minimum: number;
  61247. /** Gets or sets the maximum range */
  61248. maximum: number;
  61249. /**
  61250. * Creates a new ClampBlock
  61251. * @param name defines the block name
  61252. */
  61253. constructor(name: string);
  61254. /**
  61255. * Gets the current class name
  61256. * @returns the class name
  61257. */
  61258. getClassName(): string;
  61259. /**
  61260. * Gets the value input component
  61261. */
  61262. get value(): NodeMaterialConnectionPoint;
  61263. /**
  61264. * Gets the output component
  61265. */
  61266. get output(): NodeMaterialConnectionPoint;
  61267. protected _buildBlock(state: NodeMaterialBuildState): this;
  61268. protected _dumpPropertiesCode(): string;
  61269. serialize(): any;
  61270. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61271. }
  61272. }
  61273. declare module BABYLON {
  61274. /**
  61275. * Block used to apply a cross product between 2 vectors
  61276. */
  61277. export class CrossBlock extends NodeMaterialBlock {
  61278. /**
  61279. * Creates a new CrossBlock
  61280. * @param name defines the block name
  61281. */
  61282. constructor(name: string);
  61283. /**
  61284. * Gets the current class name
  61285. * @returns the class name
  61286. */
  61287. getClassName(): string;
  61288. /**
  61289. * Gets the left operand input component
  61290. */
  61291. get left(): NodeMaterialConnectionPoint;
  61292. /**
  61293. * Gets the right operand input component
  61294. */
  61295. get right(): NodeMaterialConnectionPoint;
  61296. /**
  61297. * Gets the output component
  61298. */
  61299. get output(): NodeMaterialConnectionPoint;
  61300. protected _buildBlock(state: NodeMaterialBuildState): this;
  61301. }
  61302. }
  61303. declare module BABYLON {
  61304. /**
  61305. * Block used to apply a dot product between 2 vectors
  61306. */
  61307. export class DotBlock extends NodeMaterialBlock {
  61308. /**
  61309. * Creates a new DotBlock
  61310. * @param name defines the block name
  61311. */
  61312. constructor(name: string);
  61313. /**
  61314. * Gets the current class name
  61315. * @returns the class name
  61316. */
  61317. getClassName(): string;
  61318. /**
  61319. * Gets the left operand input component
  61320. */
  61321. get left(): NodeMaterialConnectionPoint;
  61322. /**
  61323. * Gets the right operand input component
  61324. */
  61325. get right(): NodeMaterialConnectionPoint;
  61326. /**
  61327. * Gets the output component
  61328. */
  61329. get output(): NodeMaterialConnectionPoint;
  61330. protected _buildBlock(state: NodeMaterialBuildState): this;
  61331. }
  61332. }
  61333. declare module BABYLON {
  61334. /**
  61335. * Block used to normalize a vector
  61336. */
  61337. export class NormalizeBlock extends NodeMaterialBlock {
  61338. /**
  61339. * Creates a new NormalizeBlock
  61340. * @param name defines the block name
  61341. */
  61342. constructor(name: string);
  61343. /**
  61344. * Gets the current class name
  61345. * @returns the class name
  61346. */
  61347. getClassName(): string;
  61348. /**
  61349. * Gets the input component
  61350. */
  61351. get input(): NodeMaterialConnectionPoint;
  61352. /**
  61353. * Gets the output component
  61354. */
  61355. get output(): NodeMaterialConnectionPoint;
  61356. protected _buildBlock(state: NodeMaterialBuildState): this;
  61357. }
  61358. }
  61359. declare module BABYLON {
  61360. /**
  61361. * Operations supported by the Trigonometry block
  61362. */
  61363. export enum TrigonometryBlockOperations {
  61364. /** Cos */
  61365. Cos = 0,
  61366. /** Sin */
  61367. Sin = 1,
  61368. /** Abs */
  61369. Abs = 2,
  61370. /** Exp */
  61371. Exp = 3,
  61372. /** Exp2 */
  61373. Exp2 = 4,
  61374. /** Round */
  61375. Round = 5,
  61376. /** Floor */
  61377. Floor = 6,
  61378. /** Ceiling */
  61379. Ceiling = 7,
  61380. /** Square root */
  61381. Sqrt = 8,
  61382. /** Log */
  61383. Log = 9,
  61384. /** Tangent */
  61385. Tan = 10,
  61386. /** Arc tangent */
  61387. ArcTan = 11,
  61388. /** Arc cosinus */
  61389. ArcCos = 12,
  61390. /** Arc sinus */
  61391. ArcSin = 13,
  61392. /** Fraction */
  61393. Fract = 14,
  61394. /** Sign */
  61395. Sign = 15,
  61396. /** To radians (from degrees) */
  61397. Radians = 16,
  61398. /** To degrees (from radians) */
  61399. Degrees = 17
  61400. }
  61401. /**
  61402. * Block used to apply trigonometry operation to floats
  61403. */
  61404. export class TrigonometryBlock extends NodeMaterialBlock {
  61405. /**
  61406. * Gets or sets the operation applied by the block
  61407. */
  61408. operation: TrigonometryBlockOperations;
  61409. /**
  61410. * Creates a new TrigonometryBlock
  61411. * @param name defines the block name
  61412. */
  61413. constructor(name: string);
  61414. /**
  61415. * Gets the current class name
  61416. * @returns the class name
  61417. */
  61418. getClassName(): string;
  61419. /**
  61420. * Gets the input component
  61421. */
  61422. get input(): NodeMaterialConnectionPoint;
  61423. /**
  61424. * Gets the output component
  61425. */
  61426. get output(): NodeMaterialConnectionPoint;
  61427. protected _buildBlock(state: NodeMaterialBuildState): this;
  61428. serialize(): any;
  61429. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61430. protected _dumpPropertiesCode(): string;
  61431. }
  61432. }
  61433. declare module BABYLON {
  61434. /**
  61435. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61436. */
  61437. export class ColorMergerBlock extends NodeMaterialBlock {
  61438. /**
  61439. * Create a new ColorMergerBlock
  61440. * @param name defines the block name
  61441. */
  61442. constructor(name: string);
  61443. /**
  61444. * Gets the current class name
  61445. * @returns the class name
  61446. */
  61447. getClassName(): string;
  61448. /**
  61449. * Gets the rgb component (input)
  61450. */
  61451. get rgbIn(): NodeMaterialConnectionPoint;
  61452. /**
  61453. * Gets the r component (input)
  61454. */
  61455. get r(): NodeMaterialConnectionPoint;
  61456. /**
  61457. * Gets the g component (input)
  61458. */
  61459. get g(): NodeMaterialConnectionPoint;
  61460. /**
  61461. * Gets the b component (input)
  61462. */
  61463. get b(): NodeMaterialConnectionPoint;
  61464. /**
  61465. * Gets the a component (input)
  61466. */
  61467. get a(): NodeMaterialConnectionPoint;
  61468. /**
  61469. * Gets the rgba component (output)
  61470. */
  61471. get rgba(): NodeMaterialConnectionPoint;
  61472. /**
  61473. * Gets the rgb component (output)
  61474. */
  61475. get rgbOut(): NodeMaterialConnectionPoint;
  61476. /**
  61477. * Gets the rgb component (output)
  61478. * @deprecated Please use rgbOut instead.
  61479. */
  61480. get rgb(): NodeMaterialConnectionPoint;
  61481. protected _buildBlock(state: NodeMaterialBuildState): this;
  61482. }
  61483. }
  61484. declare module BABYLON {
  61485. /**
  61486. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61487. */
  61488. export class VectorSplitterBlock extends NodeMaterialBlock {
  61489. /**
  61490. * Create a new VectorSplitterBlock
  61491. * @param name defines the block name
  61492. */
  61493. constructor(name: string);
  61494. /**
  61495. * Gets the current class name
  61496. * @returns the class name
  61497. */
  61498. getClassName(): string;
  61499. /**
  61500. * Gets the xyzw component (input)
  61501. */
  61502. get xyzw(): NodeMaterialConnectionPoint;
  61503. /**
  61504. * Gets the xyz component (input)
  61505. */
  61506. get xyzIn(): NodeMaterialConnectionPoint;
  61507. /**
  61508. * Gets the xy component (input)
  61509. */
  61510. get xyIn(): NodeMaterialConnectionPoint;
  61511. /**
  61512. * Gets the xyz component (output)
  61513. */
  61514. get xyzOut(): NodeMaterialConnectionPoint;
  61515. /**
  61516. * Gets the xy component (output)
  61517. */
  61518. get xyOut(): NodeMaterialConnectionPoint;
  61519. /**
  61520. * Gets the x component (output)
  61521. */
  61522. get x(): NodeMaterialConnectionPoint;
  61523. /**
  61524. * Gets the y component (output)
  61525. */
  61526. get y(): NodeMaterialConnectionPoint;
  61527. /**
  61528. * Gets the z component (output)
  61529. */
  61530. get z(): NodeMaterialConnectionPoint;
  61531. /**
  61532. * Gets the w component (output)
  61533. */
  61534. get w(): NodeMaterialConnectionPoint;
  61535. protected _inputRename(name: string): string;
  61536. protected _outputRename(name: string): string;
  61537. protected _buildBlock(state: NodeMaterialBuildState): this;
  61538. }
  61539. }
  61540. declare module BABYLON {
  61541. /**
  61542. * Block used to lerp between 2 values
  61543. */
  61544. export class LerpBlock extends NodeMaterialBlock {
  61545. /**
  61546. * Creates a new LerpBlock
  61547. * @param name defines the block name
  61548. */
  61549. constructor(name: string);
  61550. /**
  61551. * Gets the current class name
  61552. * @returns the class name
  61553. */
  61554. getClassName(): string;
  61555. /**
  61556. * Gets the left operand input component
  61557. */
  61558. get left(): NodeMaterialConnectionPoint;
  61559. /**
  61560. * Gets the right operand input component
  61561. */
  61562. get right(): NodeMaterialConnectionPoint;
  61563. /**
  61564. * Gets the gradient operand input component
  61565. */
  61566. get gradient(): NodeMaterialConnectionPoint;
  61567. /**
  61568. * Gets the output component
  61569. */
  61570. get output(): NodeMaterialConnectionPoint;
  61571. protected _buildBlock(state: NodeMaterialBuildState): this;
  61572. }
  61573. }
  61574. declare module BABYLON {
  61575. /**
  61576. * Block used to divide 2 vectors
  61577. */
  61578. export class DivideBlock extends NodeMaterialBlock {
  61579. /**
  61580. * Creates a new DivideBlock
  61581. * @param name defines the block name
  61582. */
  61583. constructor(name: string);
  61584. /**
  61585. * Gets the current class name
  61586. * @returns the class name
  61587. */
  61588. getClassName(): string;
  61589. /**
  61590. * Gets the left operand input component
  61591. */
  61592. get left(): NodeMaterialConnectionPoint;
  61593. /**
  61594. * Gets the right operand input component
  61595. */
  61596. get right(): NodeMaterialConnectionPoint;
  61597. /**
  61598. * Gets the output component
  61599. */
  61600. get output(): NodeMaterialConnectionPoint;
  61601. protected _buildBlock(state: NodeMaterialBuildState): this;
  61602. }
  61603. }
  61604. declare module BABYLON {
  61605. /**
  61606. * Block used to subtract 2 vectors
  61607. */
  61608. export class SubtractBlock extends NodeMaterialBlock {
  61609. /**
  61610. * Creates a new SubtractBlock
  61611. * @param name defines the block name
  61612. */
  61613. constructor(name: string);
  61614. /**
  61615. * Gets the current class name
  61616. * @returns the class name
  61617. */
  61618. getClassName(): string;
  61619. /**
  61620. * Gets the left operand input component
  61621. */
  61622. get left(): NodeMaterialConnectionPoint;
  61623. /**
  61624. * Gets the right operand input component
  61625. */
  61626. get right(): NodeMaterialConnectionPoint;
  61627. /**
  61628. * Gets the output component
  61629. */
  61630. get output(): NodeMaterialConnectionPoint;
  61631. protected _buildBlock(state: NodeMaterialBuildState): this;
  61632. }
  61633. }
  61634. declare module BABYLON {
  61635. /**
  61636. * Block used to step a value
  61637. */
  61638. export class StepBlock extends NodeMaterialBlock {
  61639. /**
  61640. * Creates a new StepBlock
  61641. * @param name defines the block name
  61642. */
  61643. constructor(name: string);
  61644. /**
  61645. * Gets the current class name
  61646. * @returns the class name
  61647. */
  61648. getClassName(): string;
  61649. /**
  61650. * Gets the value operand input component
  61651. */
  61652. get value(): NodeMaterialConnectionPoint;
  61653. /**
  61654. * Gets the edge operand input component
  61655. */
  61656. get edge(): NodeMaterialConnectionPoint;
  61657. /**
  61658. * Gets the output component
  61659. */
  61660. get output(): NodeMaterialConnectionPoint;
  61661. protected _buildBlock(state: NodeMaterialBuildState): this;
  61662. }
  61663. }
  61664. declare module BABYLON {
  61665. /**
  61666. * Block used to get the opposite (1 - x) of a value
  61667. */
  61668. export class OneMinusBlock extends NodeMaterialBlock {
  61669. /**
  61670. * Creates a new OneMinusBlock
  61671. * @param name defines the block name
  61672. */
  61673. constructor(name: string);
  61674. /**
  61675. * Gets the current class name
  61676. * @returns the class name
  61677. */
  61678. getClassName(): string;
  61679. /**
  61680. * Gets the input component
  61681. */
  61682. get input(): NodeMaterialConnectionPoint;
  61683. /**
  61684. * Gets the output component
  61685. */
  61686. get output(): NodeMaterialConnectionPoint;
  61687. protected _buildBlock(state: NodeMaterialBuildState): this;
  61688. }
  61689. }
  61690. declare module BABYLON {
  61691. /**
  61692. * Block used to get the view direction
  61693. */
  61694. export class ViewDirectionBlock extends NodeMaterialBlock {
  61695. /**
  61696. * Creates a new ViewDirectionBlock
  61697. * @param name defines the block name
  61698. */
  61699. constructor(name: string);
  61700. /**
  61701. * Gets the current class name
  61702. * @returns the class name
  61703. */
  61704. getClassName(): string;
  61705. /**
  61706. * Gets the world position component
  61707. */
  61708. get worldPosition(): NodeMaterialConnectionPoint;
  61709. /**
  61710. * Gets the camera position component
  61711. */
  61712. get cameraPosition(): NodeMaterialConnectionPoint;
  61713. /**
  61714. * Gets the output component
  61715. */
  61716. get output(): NodeMaterialConnectionPoint;
  61717. autoConfigure(material: NodeMaterial): void;
  61718. protected _buildBlock(state: NodeMaterialBuildState): this;
  61719. }
  61720. }
  61721. declare module BABYLON {
  61722. /**
  61723. * Block used to compute fresnel value
  61724. */
  61725. export class FresnelBlock extends NodeMaterialBlock {
  61726. /**
  61727. * Create a new FresnelBlock
  61728. * @param name defines the block name
  61729. */
  61730. constructor(name: string);
  61731. /**
  61732. * Gets the current class name
  61733. * @returns the class name
  61734. */
  61735. getClassName(): string;
  61736. /**
  61737. * Gets the world normal input component
  61738. */
  61739. get worldNormal(): NodeMaterialConnectionPoint;
  61740. /**
  61741. * Gets the view direction input component
  61742. */
  61743. get viewDirection(): NodeMaterialConnectionPoint;
  61744. /**
  61745. * Gets the bias input component
  61746. */
  61747. get bias(): NodeMaterialConnectionPoint;
  61748. /**
  61749. * Gets the camera (or eye) position component
  61750. */
  61751. get power(): NodeMaterialConnectionPoint;
  61752. /**
  61753. * Gets the fresnel output component
  61754. */
  61755. get fresnel(): NodeMaterialConnectionPoint;
  61756. autoConfigure(material: NodeMaterial): void;
  61757. protected _buildBlock(state: NodeMaterialBuildState): this;
  61758. }
  61759. }
  61760. declare module BABYLON {
  61761. /**
  61762. * Block used to get the max of 2 values
  61763. */
  61764. export class MaxBlock extends NodeMaterialBlock {
  61765. /**
  61766. * Creates a new MaxBlock
  61767. * @param name defines the block name
  61768. */
  61769. constructor(name: string);
  61770. /**
  61771. * Gets the current class name
  61772. * @returns the class name
  61773. */
  61774. getClassName(): string;
  61775. /**
  61776. * Gets the left operand input component
  61777. */
  61778. get left(): NodeMaterialConnectionPoint;
  61779. /**
  61780. * Gets the right operand input component
  61781. */
  61782. get right(): NodeMaterialConnectionPoint;
  61783. /**
  61784. * Gets the output component
  61785. */
  61786. get output(): NodeMaterialConnectionPoint;
  61787. protected _buildBlock(state: NodeMaterialBuildState): this;
  61788. }
  61789. }
  61790. declare module BABYLON {
  61791. /**
  61792. * Block used to get the min of 2 values
  61793. */
  61794. export class MinBlock extends NodeMaterialBlock {
  61795. /**
  61796. * Creates a new MinBlock
  61797. * @param name defines the block name
  61798. */
  61799. constructor(name: string);
  61800. /**
  61801. * Gets the current class name
  61802. * @returns the class name
  61803. */
  61804. getClassName(): string;
  61805. /**
  61806. * Gets the left operand input component
  61807. */
  61808. get left(): NodeMaterialConnectionPoint;
  61809. /**
  61810. * Gets the right operand input component
  61811. */
  61812. get right(): NodeMaterialConnectionPoint;
  61813. /**
  61814. * Gets the output component
  61815. */
  61816. get output(): NodeMaterialConnectionPoint;
  61817. protected _buildBlock(state: NodeMaterialBuildState): this;
  61818. }
  61819. }
  61820. declare module BABYLON {
  61821. /**
  61822. * Block used to get the distance between 2 values
  61823. */
  61824. export class DistanceBlock extends NodeMaterialBlock {
  61825. /**
  61826. * Creates a new DistanceBlock
  61827. * @param name defines the block name
  61828. */
  61829. constructor(name: string);
  61830. /**
  61831. * Gets the current class name
  61832. * @returns the class name
  61833. */
  61834. getClassName(): string;
  61835. /**
  61836. * Gets the left operand input component
  61837. */
  61838. get left(): NodeMaterialConnectionPoint;
  61839. /**
  61840. * Gets the right operand input component
  61841. */
  61842. get right(): NodeMaterialConnectionPoint;
  61843. /**
  61844. * Gets the output component
  61845. */
  61846. get output(): NodeMaterialConnectionPoint;
  61847. protected _buildBlock(state: NodeMaterialBuildState): this;
  61848. }
  61849. }
  61850. declare module BABYLON {
  61851. /**
  61852. * Block used to get the length of a vector
  61853. */
  61854. export class LengthBlock extends NodeMaterialBlock {
  61855. /**
  61856. * Creates a new LengthBlock
  61857. * @param name defines the block name
  61858. */
  61859. constructor(name: string);
  61860. /**
  61861. * Gets the current class name
  61862. * @returns the class name
  61863. */
  61864. getClassName(): string;
  61865. /**
  61866. * Gets the value input component
  61867. */
  61868. get value(): NodeMaterialConnectionPoint;
  61869. /**
  61870. * Gets the output component
  61871. */
  61872. get output(): NodeMaterialConnectionPoint;
  61873. protected _buildBlock(state: NodeMaterialBuildState): this;
  61874. }
  61875. }
  61876. declare module BABYLON {
  61877. /**
  61878. * Block used to get negative version of a value (i.e. x * -1)
  61879. */
  61880. export class NegateBlock extends NodeMaterialBlock {
  61881. /**
  61882. * Creates a new NegateBlock
  61883. * @param name defines the block name
  61884. */
  61885. constructor(name: string);
  61886. /**
  61887. * Gets the current class name
  61888. * @returns the class name
  61889. */
  61890. getClassName(): string;
  61891. /**
  61892. * Gets the value input component
  61893. */
  61894. get value(): NodeMaterialConnectionPoint;
  61895. /**
  61896. * Gets the output component
  61897. */
  61898. get output(): NodeMaterialConnectionPoint;
  61899. protected _buildBlock(state: NodeMaterialBuildState): this;
  61900. }
  61901. }
  61902. declare module BABYLON {
  61903. /**
  61904. * Block used to get the value of the first parameter raised to the power of the second
  61905. */
  61906. export class PowBlock extends NodeMaterialBlock {
  61907. /**
  61908. * Creates a new PowBlock
  61909. * @param name defines the block name
  61910. */
  61911. constructor(name: string);
  61912. /**
  61913. * Gets the current class name
  61914. * @returns the class name
  61915. */
  61916. getClassName(): string;
  61917. /**
  61918. * Gets the value operand input component
  61919. */
  61920. get value(): NodeMaterialConnectionPoint;
  61921. /**
  61922. * Gets the power operand input component
  61923. */
  61924. get power(): NodeMaterialConnectionPoint;
  61925. /**
  61926. * Gets the output component
  61927. */
  61928. get output(): NodeMaterialConnectionPoint;
  61929. protected _buildBlock(state: NodeMaterialBuildState): this;
  61930. }
  61931. }
  61932. declare module BABYLON {
  61933. /**
  61934. * Block used to get a random number
  61935. */
  61936. export class RandomNumberBlock extends NodeMaterialBlock {
  61937. /**
  61938. * Creates a new RandomNumberBlock
  61939. * @param name defines the block name
  61940. */
  61941. constructor(name: string);
  61942. /**
  61943. * Gets the current class name
  61944. * @returns the class name
  61945. */
  61946. getClassName(): string;
  61947. /**
  61948. * Gets the seed input component
  61949. */
  61950. get seed(): NodeMaterialConnectionPoint;
  61951. /**
  61952. * Gets the output component
  61953. */
  61954. get output(): NodeMaterialConnectionPoint;
  61955. protected _buildBlock(state: NodeMaterialBuildState): this;
  61956. }
  61957. }
  61958. declare module BABYLON {
  61959. /**
  61960. * Block used to compute arc tangent of 2 values
  61961. */
  61962. export class ArcTan2Block extends NodeMaterialBlock {
  61963. /**
  61964. * Creates a new ArcTan2Block
  61965. * @param name defines the block name
  61966. */
  61967. constructor(name: string);
  61968. /**
  61969. * Gets the current class name
  61970. * @returns the class name
  61971. */
  61972. getClassName(): string;
  61973. /**
  61974. * Gets the x operand input component
  61975. */
  61976. get x(): NodeMaterialConnectionPoint;
  61977. /**
  61978. * Gets the y operand input component
  61979. */
  61980. get y(): NodeMaterialConnectionPoint;
  61981. /**
  61982. * Gets the output component
  61983. */
  61984. get output(): NodeMaterialConnectionPoint;
  61985. protected _buildBlock(state: NodeMaterialBuildState): this;
  61986. }
  61987. }
  61988. declare module BABYLON {
  61989. /**
  61990. * Block used to smooth step a value
  61991. */
  61992. export class SmoothStepBlock extends NodeMaterialBlock {
  61993. /**
  61994. * Creates a new SmoothStepBlock
  61995. * @param name defines the block name
  61996. */
  61997. constructor(name: string);
  61998. /**
  61999. * Gets the current class name
  62000. * @returns the class name
  62001. */
  62002. getClassName(): string;
  62003. /**
  62004. * Gets the value operand input component
  62005. */
  62006. get value(): NodeMaterialConnectionPoint;
  62007. /**
  62008. * Gets the first edge operand input component
  62009. */
  62010. get edge0(): NodeMaterialConnectionPoint;
  62011. /**
  62012. * Gets the second edge operand input component
  62013. */
  62014. get edge1(): NodeMaterialConnectionPoint;
  62015. /**
  62016. * Gets the output component
  62017. */
  62018. get output(): NodeMaterialConnectionPoint;
  62019. protected _buildBlock(state: NodeMaterialBuildState): this;
  62020. }
  62021. }
  62022. declare module BABYLON {
  62023. /**
  62024. * Block used to get the reciprocal (1 / x) of a value
  62025. */
  62026. export class ReciprocalBlock extends NodeMaterialBlock {
  62027. /**
  62028. * Creates a new ReciprocalBlock
  62029. * @param name defines the block name
  62030. */
  62031. constructor(name: string);
  62032. /**
  62033. * Gets the current class name
  62034. * @returns the class name
  62035. */
  62036. getClassName(): string;
  62037. /**
  62038. * Gets the input component
  62039. */
  62040. get input(): NodeMaterialConnectionPoint;
  62041. /**
  62042. * Gets the output component
  62043. */
  62044. get output(): NodeMaterialConnectionPoint;
  62045. protected _buildBlock(state: NodeMaterialBuildState): this;
  62046. }
  62047. }
  62048. declare module BABYLON {
  62049. /**
  62050. * Block used to replace a color by another one
  62051. */
  62052. export class ReplaceColorBlock extends NodeMaterialBlock {
  62053. /**
  62054. * Creates a new ReplaceColorBlock
  62055. * @param name defines the block name
  62056. */
  62057. constructor(name: string);
  62058. /**
  62059. * Gets the current class name
  62060. * @returns the class name
  62061. */
  62062. getClassName(): string;
  62063. /**
  62064. * Gets the value input component
  62065. */
  62066. get value(): NodeMaterialConnectionPoint;
  62067. /**
  62068. * Gets the reference input component
  62069. */
  62070. get reference(): NodeMaterialConnectionPoint;
  62071. /**
  62072. * Gets the distance input component
  62073. */
  62074. get distance(): NodeMaterialConnectionPoint;
  62075. /**
  62076. * Gets the replacement input component
  62077. */
  62078. get replacement(): NodeMaterialConnectionPoint;
  62079. /**
  62080. * Gets the output component
  62081. */
  62082. get output(): NodeMaterialConnectionPoint;
  62083. protected _buildBlock(state: NodeMaterialBuildState): this;
  62084. }
  62085. }
  62086. declare module BABYLON {
  62087. /**
  62088. * Block used to posterize a value
  62089. * @see https://en.wikipedia.org/wiki/Posterization
  62090. */
  62091. export class PosterizeBlock extends NodeMaterialBlock {
  62092. /**
  62093. * Creates a new PosterizeBlock
  62094. * @param name defines the block name
  62095. */
  62096. constructor(name: string);
  62097. /**
  62098. * Gets the current class name
  62099. * @returns the class name
  62100. */
  62101. getClassName(): string;
  62102. /**
  62103. * Gets the value input component
  62104. */
  62105. get value(): NodeMaterialConnectionPoint;
  62106. /**
  62107. * Gets the steps input component
  62108. */
  62109. get steps(): NodeMaterialConnectionPoint;
  62110. /**
  62111. * Gets the output component
  62112. */
  62113. get output(): NodeMaterialConnectionPoint;
  62114. protected _buildBlock(state: NodeMaterialBuildState): this;
  62115. }
  62116. }
  62117. declare module BABYLON {
  62118. /**
  62119. * Operations supported by the Wave block
  62120. */
  62121. export enum WaveBlockKind {
  62122. /** SawTooth */
  62123. SawTooth = 0,
  62124. /** Square */
  62125. Square = 1,
  62126. /** Triangle */
  62127. Triangle = 2
  62128. }
  62129. /**
  62130. * Block used to apply wave operation to floats
  62131. */
  62132. export class WaveBlock extends NodeMaterialBlock {
  62133. /**
  62134. * Gets or sets the kibnd of wave to be applied by the block
  62135. */
  62136. kind: WaveBlockKind;
  62137. /**
  62138. * Creates a new WaveBlock
  62139. * @param name defines the block name
  62140. */
  62141. constructor(name: string);
  62142. /**
  62143. * Gets the current class name
  62144. * @returns the class name
  62145. */
  62146. getClassName(): string;
  62147. /**
  62148. * Gets the input component
  62149. */
  62150. get input(): NodeMaterialConnectionPoint;
  62151. /**
  62152. * Gets the output component
  62153. */
  62154. get output(): NodeMaterialConnectionPoint;
  62155. protected _buildBlock(state: NodeMaterialBuildState): this;
  62156. serialize(): any;
  62157. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62158. }
  62159. }
  62160. declare module BABYLON {
  62161. /**
  62162. * Class used to store a color step for the GradientBlock
  62163. */
  62164. export class GradientBlockColorStep {
  62165. /**
  62166. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62167. */
  62168. step: number;
  62169. /**
  62170. * Gets or sets the color associated with this step
  62171. */
  62172. color: Color3;
  62173. /**
  62174. * Creates a new GradientBlockColorStep
  62175. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62176. * @param color defines the color associated with this step
  62177. */
  62178. constructor(
  62179. /**
  62180. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62181. */
  62182. step: number,
  62183. /**
  62184. * Gets or sets the color associated with this step
  62185. */
  62186. color: Color3);
  62187. }
  62188. /**
  62189. * Block used to return a color from a gradient based on an input value between 0 and 1
  62190. */
  62191. export class GradientBlock extends NodeMaterialBlock {
  62192. /**
  62193. * Gets or sets the list of color steps
  62194. */
  62195. colorSteps: GradientBlockColorStep[];
  62196. /**
  62197. * Creates a new GradientBlock
  62198. * @param name defines the block name
  62199. */
  62200. constructor(name: string);
  62201. /**
  62202. * Gets the current class name
  62203. * @returns the class name
  62204. */
  62205. getClassName(): string;
  62206. /**
  62207. * Gets the gradient input component
  62208. */
  62209. get gradient(): NodeMaterialConnectionPoint;
  62210. /**
  62211. * Gets the output component
  62212. */
  62213. get output(): NodeMaterialConnectionPoint;
  62214. private _writeColorConstant;
  62215. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62216. serialize(): any;
  62217. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62218. protected _dumpPropertiesCode(): string;
  62219. }
  62220. }
  62221. declare module BABYLON {
  62222. /**
  62223. * Block used to normalize lerp between 2 values
  62224. */
  62225. export class NLerpBlock extends NodeMaterialBlock {
  62226. /**
  62227. * Creates a new NLerpBlock
  62228. * @param name defines the block name
  62229. */
  62230. constructor(name: string);
  62231. /**
  62232. * Gets the current class name
  62233. * @returns the class name
  62234. */
  62235. getClassName(): string;
  62236. /**
  62237. * Gets the left operand input component
  62238. */
  62239. get left(): NodeMaterialConnectionPoint;
  62240. /**
  62241. * Gets the right operand input component
  62242. */
  62243. get right(): NodeMaterialConnectionPoint;
  62244. /**
  62245. * Gets the gradient operand input component
  62246. */
  62247. get gradient(): NodeMaterialConnectionPoint;
  62248. /**
  62249. * Gets the output component
  62250. */
  62251. get output(): NodeMaterialConnectionPoint;
  62252. protected _buildBlock(state: NodeMaterialBuildState): this;
  62253. }
  62254. }
  62255. declare module BABYLON {
  62256. /**
  62257. * block used to Generate a Worley Noise 3D Noise Pattern
  62258. */
  62259. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62260. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62261. manhattanDistance: boolean;
  62262. /**
  62263. * Creates a new WorleyNoise3DBlock
  62264. * @param name defines the block name
  62265. */
  62266. constructor(name: string);
  62267. /**
  62268. * Gets the current class name
  62269. * @returns the class name
  62270. */
  62271. getClassName(): string;
  62272. /**
  62273. * Gets the seed input component
  62274. */
  62275. get seed(): NodeMaterialConnectionPoint;
  62276. /**
  62277. * Gets the jitter input component
  62278. */
  62279. get jitter(): NodeMaterialConnectionPoint;
  62280. /**
  62281. * Gets the output component
  62282. */
  62283. get output(): NodeMaterialConnectionPoint;
  62284. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62285. /**
  62286. * Exposes the properties to the UI?
  62287. */
  62288. protected _dumpPropertiesCode(): string;
  62289. /**
  62290. * Exposes the properties to the Seralize?
  62291. */
  62292. serialize(): any;
  62293. /**
  62294. * Exposes the properties to the deseralize?
  62295. */
  62296. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62297. }
  62298. }
  62299. declare module BABYLON {
  62300. /**
  62301. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62302. */
  62303. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62304. /**
  62305. * Creates a new SimplexPerlin3DBlock
  62306. * @param name defines the block name
  62307. */
  62308. constructor(name: string);
  62309. /**
  62310. * Gets the current class name
  62311. * @returns the class name
  62312. */
  62313. getClassName(): string;
  62314. /**
  62315. * Gets the seed operand input component
  62316. */
  62317. get seed(): NodeMaterialConnectionPoint;
  62318. /**
  62319. * Gets the output component
  62320. */
  62321. get output(): NodeMaterialConnectionPoint;
  62322. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62323. }
  62324. }
  62325. declare module BABYLON {
  62326. /**
  62327. * Block used to blend normals
  62328. */
  62329. export class NormalBlendBlock extends NodeMaterialBlock {
  62330. /**
  62331. * Creates a new NormalBlendBlock
  62332. * @param name defines the block name
  62333. */
  62334. constructor(name: string);
  62335. /**
  62336. * Gets the current class name
  62337. * @returns the class name
  62338. */
  62339. getClassName(): string;
  62340. /**
  62341. * Gets the first input component
  62342. */
  62343. get normalMap0(): NodeMaterialConnectionPoint;
  62344. /**
  62345. * Gets the second input component
  62346. */
  62347. get normalMap1(): NodeMaterialConnectionPoint;
  62348. /**
  62349. * Gets the output component
  62350. */
  62351. get output(): NodeMaterialConnectionPoint;
  62352. protected _buildBlock(state: NodeMaterialBuildState): this;
  62353. }
  62354. }
  62355. declare module BABYLON {
  62356. /**
  62357. * Block used to rotate a 2d vector by a given angle
  62358. */
  62359. export class Rotate2dBlock extends NodeMaterialBlock {
  62360. /**
  62361. * Creates a new Rotate2dBlock
  62362. * @param name defines the block name
  62363. */
  62364. constructor(name: string);
  62365. /**
  62366. * Gets the current class name
  62367. * @returns the class name
  62368. */
  62369. getClassName(): string;
  62370. /**
  62371. * Gets the input vector
  62372. */
  62373. get input(): NodeMaterialConnectionPoint;
  62374. /**
  62375. * Gets the input angle
  62376. */
  62377. get angle(): NodeMaterialConnectionPoint;
  62378. /**
  62379. * Gets the output component
  62380. */
  62381. get output(): NodeMaterialConnectionPoint;
  62382. autoConfigure(material: NodeMaterial): void;
  62383. protected _buildBlock(state: NodeMaterialBuildState): this;
  62384. }
  62385. }
  62386. declare module BABYLON {
  62387. /**
  62388. * Block used to get the reflected vector from a direction and a normal
  62389. */
  62390. export class ReflectBlock extends NodeMaterialBlock {
  62391. /**
  62392. * Creates a new ReflectBlock
  62393. * @param name defines the block name
  62394. */
  62395. constructor(name: string);
  62396. /**
  62397. * Gets the current class name
  62398. * @returns the class name
  62399. */
  62400. getClassName(): string;
  62401. /**
  62402. * Gets the incident component
  62403. */
  62404. get incident(): NodeMaterialConnectionPoint;
  62405. /**
  62406. * Gets the normal component
  62407. */
  62408. get normal(): NodeMaterialConnectionPoint;
  62409. /**
  62410. * Gets the output component
  62411. */
  62412. get output(): NodeMaterialConnectionPoint;
  62413. protected _buildBlock(state: NodeMaterialBuildState): this;
  62414. }
  62415. }
  62416. declare module BABYLON {
  62417. /**
  62418. * Block used to get the refracted vector from a direction and a normal
  62419. */
  62420. export class RefractBlock extends NodeMaterialBlock {
  62421. /**
  62422. * Creates a new RefractBlock
  62423. * @param name defines the block name
  62424. */
  62425. constructor(name: string);
  62426. /**
  62427. * Gets the current class name
  62428. * @returns the class name
  62429. */
  62430. getClassName(): string;
  62431. /**
  62432. * Gets the incident component
  62433. */
  62434. get incident(): NodeMaterialConnectionPoint;
  62435. /**
  62436. * Gets the normal component
  62437. */
  62438. get normal(): NodeMaterialConnectionPoint;
  62439. /**
  62440. * Gets the index of refraction component
  62441. */
  62442. get ior(): NodeMaterialConnectionPoint;
  62443. /**
  62444. * Gets the output component
  62445. */
  62446. get output(): NodeMaterialConnectionPoint;
  62447. protected _buildBlock(state: NodeMaterialBuildState): this;
  62448. }
  62449. }
  62450. declare module BABYLON {
  62451. /**
  62452. * Block used to desaturate a color
  62453. */
  62454. export class DesaturateBlock extends NodeMaterialBlock {
  62455. /**
  62456. * Creates a new DesaturateBlock
  62457. * @param name defines the block name
  62458. */
  62459. constructor(name: string);
  62460. /**
  62461. * Gets the current class name
  62462. * @returns the class name
  62463. */
  62464. getClassName(): string;
  62465. /**
  62466. * Gets the color operand input component
  62467. */
  62468. get color(): NodeMaterialConnectionPoint;
  62469. /**
  62470. * Gets the level operand input component
  62471. */
  62472. get level(): NodeMaterialConnectionPoint;
  62473. /**
  62474. * Gets the output component
  62475. */
  62476. get output(): NodeMaterialConnectionPoint;
  62477. protected _buildBlock(state: NodeMaterialBuildState): this;
  62478. }
  62479. }
  62480. declare module BABYLON {
  62481. /**
  62482. * Block used to implement the ambient occlusion module of the PBR material
  62483. */
  62484. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62485. /**
  62486. * Create a new AmbientOcclusionBlock
  62487. * @param name defines the block name
  62488. */
  62489. constructor(name: string);
  62490. /**
  62491. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62492. */
  62493. useAmbientInGrayScale: boolean;
  62494. /**
  62495. * Initialize the block and prepare the context for build
  62496. * @param state defines the state that will be used for the build
  62497. */
  62498. initialize(state: NodeMaterialBuildState): void;
  62499. /**
  62500. * Gets the current class name
  62501. * @returns the class name
  62502. */
  62503. getClassName(): string;
  62504. /**
  62505. * Gets the texture input component
  62506. */
  62507. get texture(): NodeMaterialConnectionPoint;
  62508. /**
  62509. * Gets the texture intensity component
  62510. */
  62511. get intensity(): NodeMaterialConnectionPoint;
  62512. /**
  62513. * Gets the direct light intensity input component
  62514. */
  62515. get directLightIntensity(): NodeMaterialConnectionPoint;
  62516. /**
  62517. * Gets the ambient occlusion object output component
  62518. */
  62519. get ambientOcclusion(): NodeMaterialConnectionPoint;
  62520. /**
  62521. * Gets the main code of the block (fragment side)
  62522. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  62523. * @returns the shader code
  62524. */
  62525. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  62526. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62527. protected _buildBlock(state: NodeMaterialBuildState): this;
  62528. protected _dumpPropertiesCode(): string;
  62529. serialize(): any;
  62530. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62531. }
  62532. }
  62533. declare module BABYLON {
  62534. /**
  62535. * Block used to implement the reflection module of the PBR material
  62536. */
  62537. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  62538. /** @hidden */
  62539. _defineLODReflectionAlpha: string;
  62540. /** @hidden */
  62541. _defineLinearSpecularReflection: string;
  62542. private _vEnvironmentIrradianceName;
  62543. /** @hidden */
  62544. _vReflectionMicrosurfaceInfosName: string;
  62545. /** @hidden */
  62546. _vReflectionInfosName: string;
  62547. private _scene;
  62548. /**
  62549. * The three properties below are set by the main PBR block prior to calling methods of this class.
  62550. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62551. * It's less burden on the user side in the editor part.
  62552. */
  62553. /** @hidden */
  62554. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62555. /** @hidden */
  62556. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62557. /** @hidden */
  62558. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  62559. /**
  62560. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  62561. * diffuse part of the IBL.
  62562. */
  62563. useSphericalHarmonics: boolean;
  62564. /**
  62565. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  62566. */
  62567. forceIrradianceInFragment: boolean;
  62568. /**
  62569. * Create a new ReflectionBlock
  62570. * @param name defines the block name
  62571. */
  62572. constructor(name: string);
  62573. /**
  62574. * Gets the current class name
  62575. * @returns the class name
  62576. */
  62577. getClassName(): string;
  62578. /**
  62579. * Gets the position input component
  62580. */
  62581. get position(): NodeMaterialConnectionPoint;
  62582. /**
  62583. * Gets the world position input component
  62584. */
  62585. get worldPosition(): NodeMaterialConnectionPoint;
  62586. /**
  62587. * Gets the world normal input component
  62588. */
  62589. get worldNormal(): NodeMaterialConnectionPoint;
  62590. /**
  62591. * Gets the world input component
  62592. */
  62593. get world(): NodeMaterialConnectionPoint;
  62594. /**
  62595. * Gets the camera (or eye) position component
  62596. */
  62597. get cameraPosition(): NodeMaterialConnectionPoint;
  62598. /**
  62599. * Gets the view input component
  62600. */
  62601. get view(): NodeMaterialConnectionPoint;
  62602. /**
  62603. * Gets the color input component
  62604. */
  62605. get color(): NodeMaterialConnectionPoint;
  62606. /**
  62607. * Gets the reflection object output component
  62608. */
  62609. get reflection(): NodeMaterialConnectionPoint;
  62610. /**
  62611. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  62612. */
  62613. get hasTexture(): boolean;
  62614. /**
  62615. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  62616. */
  62617. get reflectionColor(): string;
  62618. protected _getTexture(): Nullable<BaseTexture>;
  62619. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62620. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62621. /**
  62622. * Gets the code to inject in the vertex shader
  62623. * @param state current state of the node material building
  62624. * @returns the shader code
  62625. */
  62626. handleVertexSide(state: NodeMaterialBuildState): string;
  62627. /**
  62628. * Gets the main code of the block (fragment side)
  62629. * @param state current state of the node material building
  62630. * @param normalVarName name of the existing variable corresponding to the normal
  62631. * @returns the shader code
  62632. */
  62633. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  62634. protected _buildBlock(state: NodeMaterialBuildState): this;
  62635. protected _dumpPropertiesCode(): string;
  62636. serialize(): any;
  62637. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62638. }
  62639. }
  62640. declare module BABYLON {
  62641. /**
  62642. * Block used to implement the sheen module of the PBR material
  62643. */
  62644. export class SheenBlock extends NodeMaterialBlock {
  62645. /**
  62646. * Create a new SheenBlock
  62647. * @param name defines the block name
  62648. */
  62649. constructor(name: string);
  62650. /**
  62651. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  62652. * It allows the strength of the sheen effect to not depend on the base color of the material,
  62653. * making it easier to setup and tweak the effect
  62654. */
  62655. albedoScaling: boolean;
  62656. /**
  62657. * Defines if the sheen is linked to the sheen color.
  62658. */
  62659. linkSheenWithAlbedo: boolean;
  62660. /**
  62661. * Initialize the block and prepare the context for build
  62662. * @param state defines the state that will be used for the build
  62663. */
  62664. initialize(state: NodeMaterialBuildState): void;
  62665. /**
  62666. * Gets the current class name
  62667. * @returns the class name
  62668. */
  62669. getClassName(): string;
  62670. /**
  62671. * Gets the intensity input component
  62672. */
  62673. get intensity(): NodeMaterialConnectionPoint;
  62674. /**
  62675. * Gets the color input component
  62676. */
  62677. get color(): NodeMaterialConnectionPoint;
  62678. /**
  62679. * Gets the roughness input component
  62680. */
  62681. get roughness(): NodeMaterialConnectionPoint;
  62682. /**
  62683. * Gets the texture input component
  62684. */
  62685. get texture(): NodeMaterialConnectionPoint;
  62686. /**
  62687. * Gets the sheen object output component
  62688. */
  62689. get sheen(): NodeMaterialConnectionPoint;
  62690. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62691. /**
  62692. * Gets the main code of the block (fragment side)
  62693. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62694. * @returns the shader code
  62695. */
  62696. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  62697. protected _buildBlock(state: NodeMaterialBuildState): this;
  62698. protected _dumpPropertiesCode(): string;
  62699. serialize(): any;
  62700. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62701. }
  62702. }
  62703. declare module BABYLON {
  62704. /**
  62705. * Block used to implement the reflectivity module of the PBR material
  62706. */
  62707. export class ReflectivityBlock extends NodeMaterialBlock {
  62708. /**
  62709. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  62710. */
  62711. useAmbientOcclusionFromMetallicTextureRed: boolean;
  62712. /**
  62713. * Specifies if the metallic texture contains the metallness information in its blue channel.
  62714. */
  62715. useMetallnessFromMetallicTextureBlue: boolean;
  62716. /**
  62717. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  62718. */
  62719. useRoughnessFromMetallicTextureAlpha: boolean;
  62720. /**
  62721. * Specifies if the metallic texture contains the roughness information in its green channel.
  62722. */
  62723. useRoughnessFromMetallicTextureGreen: boolean;
  62724. /**
  62725. * Create a new ReflectivityBlock
  62726. * @param name defines the block name
  62727. */
  62728. constructor(name: string);
  62729. /**
  62730. * Initialize the block and prepare the context for build
  62731. * @param state defines the state that will be used for the build
  62732. */
  62733. initialize(state: NodeMaterialBuildState): void;
  62734. /**
  62735. * Gets the current class name
  62736. * @returns the class name
  62737. */
  62738. getClassName(): string;
  62739. /**
  62740. * Gets the metallic input component
  62741. */
  62742. get metallic(): NodeMaterialConnectionPoint;
  62743. /**
  62744. * Gets the roughness input component
  62745. */
  62746. get roughness(): NodeMaterialConnectionPoint;
  62747. /**
  62748. * Gets the texture input component
  62749. */
  62750. get texture(): NodeMaterialConnectionPoint;
  62751. /**
  62752. * Gets the reflectivity object output component
  62753. */
  62754. get reflectivity(): NodeMaterialConnectionPoint;
  62755. /**
  62756. * Gets the main code of the block (fragment side)
  62757. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  62758. * @returns the shader code
  62759. */
  62760. getCode(aoIntensityVarName: string): string;
  62761. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62762. protected _buildBlock(state: NodeMaterialBuildState): this;
  62763. protected _dumpPropertiesCode(): string;
  62764. serialize(): any;
  62765. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62766. }
  62767. }
  62768. declare module BABYLON {
  62769. /**
  62770. * Block used to implement the anisotropy module of the PBR material
  62771. */
  62772. export class AnisotropyBlock extends NodeMaterialBlock {
  62773. /**
  62774. * The two properties below are set by the main PBR block prior to calling methods of this class.
  62775. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62776. * It's less burden on the user side in the editor part.
  62777. */
  62778. /** @hidden */
  62779. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62780. /** @hidden */
  62781. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62782. /**
  62783. * Create a new AnisotropyBlock
  62784. * @param name defines the block name
  62785. */
  62786. constructor(name: string);
  62787. /**
  62788. * Initialize the block and prepare the context for build
  62789. * @param state defines the state that will be used for the build
  62790. */
  62791. initialize(state: NodeMaterialBuildState): void;
  62792. /**
  62793. * Gets the current class name
  62794. * @returns the class name
  62795. */
  62796. getClassName(): string;
  62797. /**
  62798. * Gets the intensity input component
  62799. */
  62800. get intensity(): NodeMaterialConnectionPoint;
  62801. /**
  62802. * Gets the direction input component
  62803. */
  62804. get direction(): NodeMaterialConnectionPoint;
  62805. /**
  62806. * Gets the texture input component
  62807. */
  62808. get texture(): NodeMaterialConnectionPoint;
  62809. /**
  62810. * Gets the uv input component
  62811. */
  62812. get uv(): NodeMaterialConnectionPoint;
  62813. /**
  62814. * Gets the worldTangent input component
  62815. */
  62816. get worldTangent(): NodeMaterialConnectionPoint;
  62817. /**
  62818. * Gets the anisotropy object output component
  62819. */
  62820. get anisotropy(): NodeMaterialConnectionPoint;
  62821. private _generateTBNSpace;
  62822. /**
  62823. * Gets the main code of the block (fragment side)
  62824. * @param state current state of the node material building
  62825. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62826. * @returns the shader code
  62827. */
  62828. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  62829. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62830. protected _buildBlock(state: NodeMaterialBuildState): this;
  62831. }
  62832. }
  62833. declare module BABYLON {
  62834. /**
  62835. * Block used to implement the clear coat module of the PBR material
  62836. */
  62837. export class ClearCoatBlock extends NodeMaterialBlock {
  62838. private _scene;
  62839. /**
  62840. * Create a new ClearCoatBlock
  62841. * @param name defines the block name
  62842. */
  62843. constructor(name: string);
  62844. /**
  62845. * Initialize the block and prepare the context for build
  62846. * @param state defines the state that will be used for the build
  62847. */
  62848. initialize(state: NodeMaterialBuildState): void;
  62849. /**
  62850. * Gets the current class name
  62851. * @returns the class name
  62852. */
  62853. getClassName(): string;
  62854. /**
  62855. * Gets the intensity input component
  62856. */
  62857. get intensity(): NodeMaterialConnectionPoint;
  62858. /**
  62859. * Gets the roughness input component
  62860. */
  62861. get roughness(): NodeMaterialConnectionPoint;
  62862. /**
  62863. * Gets the ior input component
  62864. */
  62865. get ior(): NodeMaterialConnectionPoint;
  62866. /**
  62867. * Gets the texture input component
  62868. */
  62869. get texture(): NodeMaterialConnectionPoint;
  62870. /**
  62871. * Gets the bump texture input component
  62872. */
  62873. get bumpTexture(): NodeMaterialConnectionPoint;
  62874. /**
  62875. * Gets the uv input component
  62876. */
  62877. get uv(): NodeMaterialConnectionPoint;
  62878. /**
  62879. * Gets the tint color input component
  62880. */
  62881. get tintColor(): NodeMaterialConnectionPoint;
  62882. /**
  62883. * Gets the tint "at distance" input component
  62884. */
  62885. get tintAtDistance(): NodeMaterialConnectionPoint;
  62886. /**
  62887. * Gets the tint thickness input component
  62888. */
  62889. get tintThickness(): NodeMaterialConnectionPoint;
  62890. /**
  62891. * Gets the tint texture input component
  62892. */
  62893. get tintTexture(): NodeMaterialConnectionPoint;
  62894. /**
  62895. * Gets the world tangent input component
  62896. */
  62897. get worldTangent(): NodeMaterialConnectionPoint;
  62898. /**
  62899. * Gets the clear coat object output component
  62900. */
  62901. get clearcoat(): NodeMaterialConnectionPoint;
  62902. autoConfigure(material: NodeMaterial): void;
  62903. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62904. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62905. private _generateTBNSpace;
  62906. /**
  62907. * Gets the main code of the block (fragment side)
  62908. * @param state current state of the node material building
  62909. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  62910. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62911. * @param worldPosVarName name of the variable holding the world position
  62912. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62913. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  62914. * @param worldNormalVarName name of the variable holding the world normal
  62915. * @returns the shader code
  62916. */
  62917. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  62918. protected _buildBlock(state: NodeMaterialBuildState): this;
  62919. }
  62920. }
  62921. declare module BABYLON {
  62922. /**
  62923. * Block used to implement the sub surface module of the PBR material
  62924. */
  62925. export class SubSurfaceBlock extends NodeMaterialBlock {
  62926. /**
  62927. * Create a new SubSurfaceBlock
  62928. * @param name defines the block name
  62929. */
  62930. constructor(name: string);
  62931. /**
  62932. * Stores the intensity of the different subsurface effects in the thickness texture.
  62933. * * the green channel is the translucency intensity.
  62934. * * the blue channel is the scattering intensity.
  62935. * * the alpha channel is the refraction intensity.
  62936. */
  62937. useMaskFromThicknessTexture: boolean;
  62938. /**
  62939. * Initialize the block and prepare the context for build
  62940. * @param state defines the state that will be used for the build
  62941. */
  62942. initialize(state: NodeMaterialBuildState): void;
  62943. /**
  62944. * Gets the current class name
  62945. * @returns the class name
  62946. */
  62947. getClassName(): string;
  62948. /**
  62949. * Gets the min thickness input component
  62950. */
  62951. get minThickness(): NodeMaterialConnectionPoint;
  62952. /**
  62953. * Gets the max thickness input component
  62954. */
  62955. get maxThickness(): NodeMaterialConnectionPoint;
  62956. /**
  62957. * Gets the thickness texture component
  62958. */
  62959. get thicknessTexture(): NodeMaterialConnectionPoint;
  62960. /**
  62961. * Gets the tint color input component
  62962. */
  62963. get tintColor(): NodeMaterialConnectionPoint;
  62964. /**
  62965. * Gets the translucency intensity input component
  62966. */
  62967. get translucencyIntensity(): NodeMaterialConnectionPoint;
  62968. /**
  62969. * Gets the translucency diffusion distance input component
  62970. */
  62971. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  62972. /**
  62973. * Gets the refraction object parameters
  62974. */
  62975. get refraction(): NodeMaterialConnectionPoint;
  62976. /**
  62977. * Gets the sub surface object output component
  62978. */
  62979. get subsurface(): NodeMaterialConnectionPoint;
  62980. autoConfigure(material: NodeMaterial): void;
  62981. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62982. /**
  62983. * Gets the main code of the block (fragment side)
  62984. * @param state current state of the node material building
  62985. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  62986. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62987. * @param worldPosVarName name of the variable holding the world position
  62988. * @returns the shader code
  62989. */
  62990. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  62991. protected _buildBlock(state: NodeMaterialBuildState): this;
  62992. }
  62993. }
  62994. declare module BABYLON {
  62995. /**
  62996. * Block used to implement the PBR metallic/roughness model
  62997. */
  62998. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  62999. /**
  63000. * Gets or sets the light associated with this block
  63001. */
  63002. light: Nullable<Light>;
  63003. private _lightId;
  63004. private _scene;
  63005. private _environmentBRDFTexture;
  63006. private _environmentBrdfSamplerName;
  63007. private _vNormalWName;
  63008. private _invertNormalName;
  63009. /**
  63010. * Create a new ReflectionBlock
  63011. * @param name defines the block name
  63012. */
  63013. constructor(name: string);
  63014. /**
  63015. * Intensity of the direct lights e.g. the four lights available in your scene.
  63016. * This impacts both the direct diffuse and specular highlights.
  63017. */
  63018. directIntensity: number;
  63019. /**
  63020. * Intensity of the environment e.g. how much the environment will light the object
  63021. * either through harmonics for rough material or through the refelction for shiny ones.
  63022. */
  63023. environmentIntensity: number;
  63024. /**
  63025. * This is a special control allowing the reduction of the specular highlights coming from the
  63026. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63027. */
  63028. specularIntensity: number;
  63029. /**
  63030. * Defines the falloff type used in this material.
  63031. * It by default is Physical.
  63032. */
  63033. lightFalloff: number;
  63034. /**
  63035. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63036. */
  63037. useAlphaFromAlbedoTexture: boolean;
  63038. /**
  63039. * Specifies that alpha test should be used
  63040. */
  63041. useAlphaTest: boolean;
  63042. /**
  63043. * Defines the alpha limits in alpha test mode.
  63044. */
  63045. alphaTestCutoff: number;
  63046. /**
  63047. * Specifies that alpha blending should be used
  63048. */
  63049. useAlphaBlending: boolean;
  63050. /**
  63051. * Defines if the alpha value should be determined via the rgb values.
  63052. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63053. */
  63054. opacityRGB: boolean;
  63055. /**
  63056. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63057. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63058. */
  63059. useRadianceOverAlpha: boolean;
  63060. /**
  63061. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63062. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63063. */
  63064. useSpecularOverAlpha: boolean;
  63065. /**
  63066. * Enables specular anti aliasing in the PBR shader.
  63067. * It will both interacts on the Geometry for analytical and IBL lighting.
  63068. * It also prefilter the roughness map based on the bump values.
  63069. */
  63070. enableSpecularAntiAliasing: boolean;
  63071. /**
  63072. * Defines if the material uses energy conservation.
  63073. */
  63074. useEnergyConservation: boolean;
  63075. /**
  63076. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63077. * too much the area relying on ambient texture to define their ambient occlusion.
  63078. */
  63079. useRadianceOcclusion: boolean;
  63080. /**
  63081. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63082. * makes the reflect vector face the model (under horizon).
  63083. */
  63084. useHorizonOcclusion: boolean;
  63085. /**
  63086. * If set to true, no lighting calculations will be applied.
  63087. */
  63088. unlit: boolean;
  63089. /**
  63090. * Force normal to face away from face.
  63091. */
  63092. forceNormalForward: boolean;
  63093. /**
  63094. * Defines the material debug mode.
  63095. * It helps seeing only some components of the material while troubleshooting.
  63096. */
  63097. debugMode: number;
  63098. /**
  63099. * Specify from where on screen the debug mode should start.
  63100. * The value goes from -1 (full screen) to 1 (not visible)
  63101. * It helps with side by side comparison against the final render
  63102. * This defaults to 0
  63103. */
  63104. debugLimit: number;
  63105. /**
  63106. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63107. * You can use the factor to better multiply the final value.
  63108. */
  63109. debugFactor: number;
  63110. /**
  63111. * Initialize the block and prepare the context for build
  63112. * @param state defines the state that will be used for the build
  63113. */
  63114. initialize(state: NodeMaterialBuildState): void;
  63115. /**
  63116. * Gets the current class name
  63117. * @returns the class name
  63118. */
  63119. getClassName(): string;
  63120. /**
  63121. * Gets the world position input component
  63122. */
  63123. get worldPosition(): NodeMaterialConnectionPoint;
  63124. /**
  63125. * Gets the world normal input component
  63126. */
  63127. get worldNormal(): NodeMaterialConnectionPoint;
  63128. /**
  63129. * Gets the perturbed normal input component
  63130. */
  63131. get perturbedNormal(): NodeMaterialConnectionPoint;
  63132. /**
  63133. * Gets the camera position input component
  63134. */
  63135. get cameraPosition(): NodeMaterialConnectionPoint;
  63136. /**
  63137. * Gets the base color input component
  63138. */
  63139. get baseColor(): NodeMaterialConnectionPoint;
  63140. /**
  63141. * Gets the base texture input component
  63142. */
  63143. get baseTexture(): NodeMaterialConnectionPoint;
  63144. /**
  63145. * Gets the opacity texture input component
  63146. */
  63147. get opacityTexture(): NodeMaterialConnectionPoint;
  63148. /**
  63149. * Gets the ambient color input component
  63150. */
  63151. get ambientColor(): NodeMaterialConnectionPoint;
  63152. /**
  63153. * Gets the reflectivity object parameters
  63154. */
  63155. get reflectivity(): NodeMaterialConnectionPoint;
  63156. /**
  63157. * Gets the ambient occlusion object parameters
  63158. */
  63159. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63160. /**
  63161. * Gets the reflection object parameters
  63162. */
  63163. get reflection(): NodeMaterialConnectionPoint;
  63164. /**
  63165. * Gets the sheen object parameters
  63166. */
  63167. get sheen(): NodeMaterialConnectionPoint;
  63168. /**
  63169. * Gets the clear coat object parameters
  63170. */
  63171. get clearcoat(): NodeMaterialConnectionPoint;
  63172. /**
  63173. * Gets the sub surface object parameters
  63174. */
  63175. get subsurface(): NodeMaterialConnectionPoint;
  63176. /**
  63177. * Gets the anisotropy object parameters
  63178. */
  63179. get anisotropy(): NodeMaterialConnectionPoint;
  63180. /**
  63181. * Gets the ambient output component
  63182. */
  63183. get ambient(): NodeMaterialConnectionPoint;
  63184. /**
  63185. * Gets the diffuse output component
  63186. */
  63187. get diffuse(): NodeMaterialConnectionPoint;
  63188. /**
  63189. * Gets the specular output component
  63190. */
  63191. get specular(): NodeMaterialConnectionPoint;
  63192. /**
  63193. * Gets the sheen output component
  63194. */
  63195. get sheenDir(): NodeMaterialConnectionPoint;
  63196. /**
  63197. * Gets the clear coat output component
  63198. */
  63199. get clearcoatDir(): NodeMaterialConnectionPoint;
  63200. /**
  63201. * Gets the indirect diffuse output component
  63202. */
  63203. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63204. /**
  63205. * Gets the indirect specular output component
  63206. */
  63207. get specularIndirect(): NodeMaterialConnectionPoint;
  63208. /**
  63209. * Gets the indirect sheen output component
  63210. */
  63211. get sheenIndirect(): NodeMaterialConnectionPoint;
  63212. /**
  63213. * Gets the indirect clear coat output component
  63214. */
  63215. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63216. /**
  63217. * Gets the refraction output component
  63218. */
  63219. get refraction(): NodeMaterialConnectionPoint;
  63220. /**
  63221. * Gets the global lighting output component
  63222. */
  63223. get lighting(): NodeMaterialConnectionPoint;
  63224. /**
  63225. * Gets the shadow output component
  63226. */
  63227. get shadow(): NodeMaterialConnectionPoint;
  63228. /**
  63229. * Gets the alpha output component
  63230. */
  63231. get alpha(): NodeMaterialConnectionPoint;
  63232. autoConfigure(material: NodeMaterial): void;
  63233. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63234. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63235. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63236. private _injectVertexCode;
  63237. /**
  63238. * Gets the code corresponding to the albedo/opacity module
  63239. * @returns the shader code
  63240. */
  63241. getAlbedoOpacityCode(): string;
  63242. protected _buildBlock(state: NodeMaterialBuildState): this;
  63243. protected _dumpPropertiesCode(): string;
  63244. serialize(): any;
  63245. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63246. }
  63247. }
  63248. declare module BABYLON {
  63249. /**
  63250. * Block used to compute value of one parameter modulo another
  63251. */
  63252. export class ModBlock extends NodeMaterialBlock {
  63253. /**
  63254. * Creates a new ModBlock
  63255. * @param name defines the block name
  63256. */
  63257. constructor(name: string);
  63258. /**
  63259. * Gets the current class name
  63260. * @returns the class name
  63261. */
  63262. getClassName(): string;
  63263. /**
  63264. * Gets the left operand input component
  63265. */
  63266. get left(): NodeMaterialConnectionPoint;
  63267. /**
  63268. * Gets the right operand input component
  63269. */
  63270. get right(): NodeMaterialConnectionPoint;
  63271. /**
  63272. * Gets the output component
  63273. */
  63274. get output(): NodeMaterialConnectionPoint;
  63275. protected _buildBlock(state: NodeMaterialBuildState): this;
  63276. }
  63277. }
  63278. declare module BABYLON {
  63279. /**
  63280. * Helper class to push actions to a pool of workers.
  63281. */
  63282. export class WorkerPool implements IDisposable {
  63283. private _workerInfos;
  63284. private _pendingActions;
  63285. /**
  63286. * Constructor
  63287. * @param workers Array of workers to use for actions
  63288. */
  63289. constructor(workers: Array<Worker>);
  63290. /**
  63291. * Terminates all workers and clears any pending actions.
  63292. */
  63293. dispose(): void;
  63294. /**
  63295. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63296. * pended until a worker has completed its action.
  63297. * @param action The action to perform. Call onComplete when the action is complete.
  63298. */
  63299. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63300. private _execute;
  63301. }
  63302. }
  63303. declare module BABYLON {
  63304. /**
  63305. * Configuration for Draco compression
  63306. */
  63307. export interface IDracoCompressionConfiguration {
  63308. /**
  63309. * Configuration for the decoder.
  63310. */
  63311. decoder: {
  63312. /**
  63313. * The url to the WebAssembly module.
  63314. */
  63315. wasmUrl?: string;
  63316. /**
  63317. * The url to the WebAssembly binary.
  63318. */
  63319. wasmBinaryUrl?: string;
  63320. /**
  63321. * The url to the fallback JavaScript module.
  63322. */
  63323. fallbackUrl?: string;
  63324. };
  63325. }
  63326. /**
  63327. * Draco compression (https://google.github.io/draco/)
  63328. *
  63329. * This class wraps the Draco module.
  63330. *
  63331. * **Encoder**
  63332. *
  63333. * The encoder is not currently implemented.
  63334. *
  63335. * **Decoder**
  63336. *
  63337. * 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.
  63338. *
  63339. * To update the configuration, use the following code:
  63340. * ```javascript
  63341. * DracoCompression.Configuration = {
  63342. * decoder: {
  63343. * wasmUrl: "<url to the WebAssembly library>",
  63344. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63345. * fallbackUrl: "<url to the fallback JavaScript library>",
  63346. * }
  63347. * };
  63348. * ```
  63349. *
  63350. * 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.
  63351. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63352. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63353. *
  63354. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63355. * ```javascript
  63356. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63357. * ```
  63358. *
  63359. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63360. */
  63361. export class DracoCompression implements IDisposable {
  63362. private _workerPoolPromise?;
  63363. private _decoderModulePromise?;
  63364. /**
  63365. * The configuration. Defaults to the following urls:
  63366. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63367. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63368. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63369. */
  63370. static Configuration: IDracoCompressionConfiguration;
  63371. /**
  63372. * Returns true if the decoder configuration is available.
  63373. */
  63374. static get DecoderAvailable(): boolean;
  63375. /**
  63376. * Default number of workers to create when creating the draco compression object.
  63377. */
  63378. static DefaultNumWorkers: number;
  63379. private static GetDefaultNumWorkers;
  63380. private static _Default;
  63381. /**
  63382. * Default instance for the draco compression object.
  63383. */
  63384. static get Default(): DracoCompression;
  63385. /**
  63386. * Constructor
  63387. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63388. */
  63389. constructor(numWorkers?: number);
  63390. /**
  63391. * Stop all async operations and release resources.
  63392. */
  63393. dispose(): void;
  63394. /**
  63395. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63396. * @returns a promise that resolves when ready
  63397. */
  63398. whenReadyAsync(): Promise<void>;
  63399. /**
  63400. * Decode Draco compressed mesh data to vertex data.
  63401. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63402. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63403. * @returns A promise that resolves with the decoded vertex data
  63404. */
  63405. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63406. [kind: string]: number;
  63407. }): Promise<VertexData>;
  63408. }
  63409. }
  63410. declare module BABYLON {
  63411. /**
  63412. * Class for building Constructive Solid Geometry
  63413. */
  63414. export class CSG {
  63415. private polygons;
  63416. /**
  63417. * The world matrix
  63418. */
  63419. matrix: Matrix;
  63420. /**
  63421. * Stores the position
  63422. */
  63423. position: Vector3;
  63424. /**
  63425. * Stores the rotation
  63426. */
  63427. rotation: Vector3;
  63428. /**
  63429. * Stores the rotation quaternion
  63430. */
  63431. rotationQuaternion: Nullable<Quaternion>;
  63432. /**
  63433. * Stores the scaling vector
  63434. */
  63435. scaling: Vector3;
  63436. /**
  63437. * Convert the Mesh to CSG
  63438. * @param mesh The Mesh to convert to CSG
  63439. * @returns A new CSG from the Mesh
  63440. */
  63441. static FromMesh(mesh: Mesh): CSG;
  63442. /**
  63443. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63444. * @param polygons Polygons used to construct a CSG solid
  63445. */
  63446. private static FromPolygons;
  63447. /**
  63448. * Clones, or makes a deep copy, of the CSG
  63449. * @returns A new CSG
  63450. */
  63451. clone(): CSG;
  63452. /**
  63453. * Unions this CSG with another CSG
  63454. * @param csg The CSG to union against this CSG
  63455. * @returns The unioned CSG
  63456. */
  63457. union(csg: CSG): CSG;
  63458. /**
  63459. * Unions this CSG with another CSG in place
  63460. * @param csg The CSG to union against this CSG
  63461. */
  63462. unionInPlace(csg: CSG): void;
  63463. /**
  63464. * Subtracts this CSG with another CSG
  63465. * @param csg The CSG to subtract against this CSG
  63466. * @returns A new CSG
  63467. */
  63468. subtract(csg: CSG): CSG;
  63469. /**
  63470. * Subtracts this CSG with another CSG in place
  63471. * @param csg The CSG to subtact against this CSG
  63472. */
  63473. subtractInPlace(csg: CSG): void;
  63474. /**
  63475. * Intersect this CSG with another CSG
  63476. * @param csg The CSG to intersect against this CSG
  63477. * @returns A new CSG
  63478. */
  63479. intersect(csg: CSG): CSG;
  63480. /**
  63481. * Intersects this CSG with another CSG in place
  63482. * @param csg The CSG to intersect against this CSG
  63483. */
  63484. intersectInPlace(csg: CSG): void;
  63485. /**
  63486. * Return a new CSG solid with solid and empty space switched. This solid is
  63487. * not modified.
  63488. * @returns A new CSG solid with solid and empty space switched
  63489. */
  63490. inverse(): CSG;
  63491. /**
  63492. * Inverses the CSG in place
  63493. */
  63494. inverseInPlace(): void;
  63495. /**
  63496. * This is used to keep meshes transformations so they can be restored
  63497. * when we build back a Babylon Mesh
  63498. * NB : All CSG operations are performed in world coordinates
  63499. * @param csg The CSG to copy the transform attributes from
  63500. * @returns This CSG
  63501. */
  63502. copyTransformAttributes(csg: CSG): CSG;
  63503. /**
  63504. * Build Raw mesh from CSG
  63505. * Coordinates here are in world space
  63506. * @param name The name of the mesh geometry
  63507. * @param scene The Scene
  63508. * @param keepSubMeshes Specifies if the submeshes should be kept
  63509. * @returns A new Mesh
  63510. */
  63511. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63512. /**
  63513. * Build Mesh from CSG taking material and transforms into account
  63514. * @param name The name of the Mesh
  63515. * @param material The material of the Mesh
  63516. * @param scene The Scene
  63517. * @param keepSubMeshes Specifies if submeshes should be kept
  63518. * @returns The new Mesh
  63519. */
  63520. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63521. }
  63522. }
  63523. declare module BABYLON {
  63524. /**
  63525. * Class used to create a trail following a mesh
  63526. */
  63527. export class TrailMesh extends Mesh {
  63528. private _generator;
  63529. private _autoStart;
  63530. private _running;
  63531. private _diameter;
  63532. private _length;
  63533. private _sectionPolygonPointsCount;
  63534. private _sectionVectors;
  63535. private _sectionNormalVectors;
  63536. private _beforeRenderObserver;
  63537. /**
  63538. * @constructor
  63539. * @param name The value used by scene.getMeshByName() to do a lookup.
  63540. * @param generator The mesh or transform node to generate a trail.
  63541. * @param scene The scene to add this mesh to.
  63542. * @param diameter Diameter of trailing mesh. Default is 1.
  63543. * @param length Length of trailing mesh. Default is 60.
  63544. * @param autoStart Automatically start trailing mesh. Default true.
  63545. */
  63546. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63547. /**
  63548. * "TrailMesh"
  63549. * @returns "TrailMesh"
  63550. */
  63551. getClassName(): string;
  63552. private _createMesh;
  63553. /**
  63554. * Start trailing mesh.
  63555. */
  63556. start(): void;
  63557. /**
  63558. * Stop trailing mesh.
  63559. */
  63560. stop(): void;
  63561. /**
  63562. * Update trailing mesh geometry.
  63563. */
  63564. update(): void;
  63565. /**
  63566. * Returns a new TrailMesh object.
  63567. * @param name is a string, the name given to the new mesh
  63568. * @param newGenerator use new generator object for cloned trail mesh
  63569. * @returns a new mesh
  63570. */
  63571. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63572. /**
  63573. * Serializes this trail mesh
  63574. * @param serializationObject object to write serialization to
  63575. */
  63576. serialize(serializationObject: any): void;
  63577. /**
  63578. * Parses a serialized trail mesh
  63579. * @param parsedMesh the serialized mesh
  63580. * @param scene the scene to create the trail mesh in
  63581. * @returns the created trail mesh
  63582. */
  63583. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63584. }
  63585. }
  63586. declare module BABYLON {
  63587. /**
  63588. * Class containing static functions to help procedurally build meshes
  63589. */
  63590. export class TiledBoxBuilder {
  63591. /**
  63592. * Creates a box mesh
  63593. * 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)
  63594. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63596. * * 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
  63597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63598. * @param name defines the name of the mesh
  63599. * @param options defines the options used to create the mesh
  63600. * @param scene defines the hosting scene
  63601. * @returns the box mesh
  63602. */
  63603. static CreateTiledBox(name: string, options: {
  63604. pattern?: number;
  63605. width?: number;
  63606. height?: number;
  63607. depth?: number;
  63608. tileSize?: number;
  63609. tileWidth?: number;
  63610. tileHeight?: number;
  63611. alignHorizontal?: number;
  63612. alignVertical?: number;
  63613. faceUV?: Vector4[];
  63614. faceColors?: Color4[];
  63615. sideOrientation?: number;
  63616. updatable?: boolean;
  63617. }, scene?: Nullable<Scene>): Mesh;
  63618. }
  63619. }
  63620. declare module BABYLON {
  63621. /**
  63622. * Class containing static functions to help procedurally build meshes
  63623. */
  63624. export class TorusKnotBuilder {
  63625. /**
  63626. * Creates a torus knot mesh
  63627. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63628. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63629. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63630. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63632. * * 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
  63633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63634. * @param name defines the name of the mesh
  63635. * @param options defines the options used to create the mesh
  63636. * @param scene defines the hosting scene
  63637. * @returns the torus knot mesh
  63638. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63639. */
  63640. static CreateTorusKnot(name: string, options: {
  63641. radius?: number;
  63642. tube?: number;
  63643. radialSegments?: number;
  63644. tubularSegments?: number;
  63645. p?: number;
  63646. q?: number;
  63647. updatable?: boolean;
  63648. sideOrientation?: number;
  63649. frontUVs?: Vector4;
  63650. backUVs?: Vector4;
  63651. }, scene: any): Mesh;
  63652. }
  63653. }
  63654. declare module BABYLON {
  63655. /**
  63656. * Polygon
  63657. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63658. */
  63659. export class Polygon {
  63660. /**
  63661. * Creates a rectangle
  63662. * @param xmin bottom X coord
  63663. * @param ymin bottom Y coord
  63664. * @param xmax top X coord
  63665. * @param ymax top Y coord
  63666. * @returns points that make the resulting rectation
  63667. */
  63668. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63669. /**
  63670. * Creates a circle
  63671. * @param radius radius of circle
  63672. * @param cx scale in x
  63673. * @param cy scale in y
  63674. * @param numberOfSides number of sides that make up the circle
  63675. * @returns points that make the resulting circle
  63676. */
  63677. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63678. /**
  63679. * Creates a polygon from input string
  63680. * @param input Input polygon data
  63681. * @returns the parsed points
  63682. */
  63683. static Parse(input: string): Vector2[];
  63684. /**
  63685. * Starts building a polygon from x and y coordinates
  63686. * @param x x coordinate
  63687. * @param y y coordinate
  63688. * @returns the started path2
  63689. */
  63690. static StartingAt(x: number, y: number): Path2;
  63691. }
  63692. /**
  63693. * Builds a polygon
  63694. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63695. */
  63696. export class PolygonMeshBuilder {
  63697. private _points;
  63698. private _outlinepoints;
  63699. private _holes;
  63700. private _name;
  63701. private _scene;
  63702. private _epoints;
  63703. private _eholes;
  63704. private _addToepoint;
  63705. /**
  63706. * Babylon reference to the earcut plugin.
  63707. */
  63708. bjsEarcut: any;
  63709. /**
  63710. * Creates a PolygonMeshBuilder
  63711. * @param name name of the builder
  63712. * @param contours Path of the polygon
  63713. * @param scene scene to add to when creating the mesh
  63714. * @param earcutInjection can be used to inject your own earcut reference
  63715. */
  63716. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63717. /**
  63718. * Adds a whole within the polygon
  63719. * @param hole Array of points defining the hole
  63720. * @returns this
  63721. */
  63722. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63723. /**
  63724. * Creates the polygon
  63725. * @param updatable If the mesh should be updatable
  63726. * @param depth The depth of the mesh created
  63727. * @returns the created mesh
  63728. */
  63729. build(updatable?: boolean, depth?: number): Mesh;
  63730. /**
  63731. * Creates the polygon
  63732. * @param depth The depth of the mesh created
  63733. * @returns the created VertexData
  63734. */
  63735. buildVertexData(depth?: number): VertexData;
  63736. /**
  63737. * Adds a side to the polygon
  63738. * @param positions points that make the polygon
  63739. * @param normals normals of the polygon
  63740. * @param uvs uvs of the polygon
  63741. * @param indices indices of the polygon
  63742. * @param bounds bounds of the polygon
  63743. * @param points points of the polygon
  63744. * @param depth depth of the polygon
  63745. * @param flip flip of the polygon
  63746. */
  63747. private addSide;
  63748. }
  63749. }
  63750. declare module BABYLON {
  63751. /**
  63752. * Class containing static functions to help procedurally build meshes
  63753. */
  63754. export class PolygonBuilder {
  63755. /**
  63756. * Creates a polygon mesh
  63757. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63758. * * 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
  63759. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63761. * * 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)
  63762. * * Remember you can only change the shape positions, not their number when updating a polygon
  63763. * @param name defines the name of the mesh
  63764. * @param options defines the options used to create the mesh
  63765. * @param scene defines the hosting scene
  63766. * @param earcutInjection can be used to inject your own earcut reference
  63767. * @returns the polygon mesh
  63768. */
  63769. static CreatePolygon(name: string, options: {
  63770. shape: Vector3[];
  63771. holes?: Vector3[][];
  63772. depth?: number;
  63773. faceUV?: Vector4[];
  63774. faceColors?: Color4[];
  63775. updatable?: boolean;
  63776. sideOrientation?: number;
  63777. frontUVs?: Vector4;
  63778. backUVs?: Vector4;
  63779. wrap?: boolean;
  63780. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63781. /**
  63782. * Creates an extruded polygon mesh, with depth in the Y direction.
  63783. * * 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)
  63784. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63785. * @param name defines the name of the mesh
  63786. * @param options defines the options used to create the mesh
  63787. * @param scene defines the hosting scene
  63788. * @param earcutInjection can be used to inject your own earcut reference
  63789. * @returns the polygon mesh
  63790. */
  63791. static ExtrudePolygon(name: string, options: {
  63792. shape: Vector3[];
  63793. holes?: Vector3[][];
  63794. depth?: number;
  63795. faceUV?: Vector4[];
  63796. faceColors?: Color4[];
  63797. updatable?: boolean;
  63798. sideOrientation?: number;
  63799. frontUVs?: Vector4;
  63800. backUVs?: Vector4;
  63801. wrap?: boolean;
  63802. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63803. }
  63804. }
  63805. declare module BABYLON {
  63806. /**
  63807. * Class containing static functions to help procedurally build meshes
  63808. */
  63809. export class LatheBuilder {
  63810. /**
  63811. * Creates lathe mesh.
  63812. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63813. * * 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
  63814. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63815. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63816. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63817. * * 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
  63818. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63819. * * 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
  63820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63821. * * 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
  63822. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63824. * @param name defines the name of the mesh
  63825. * @param options defines the options used to create the mesh
  63826. * @param scene defines the hosting scene
  63827. * @returns the lathe mesh
  63828. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63829. */
  63830. static CreateLathe(name: string, options: {
  63831. shape: Vector3[];
  63832. radius?: number;
  63833. tessellation?: number;
  63834. clip?: number;
  63835. arc?: number;
  63836. closed?: boolean;
  63837. updatable?: boolean;
  63838. sideOrientation?: number;
  63839. frontUVs?: Vector4;
  63840. backUVs?: Vector4;
  63841. cap?: number;
  63842. invertUV?: boolean;
  63843. }, scene?: Nullable<Scene>): Mesh;
  63844. }
  63845. }
  63846. declare module BABYLON {
  63847. /**
  63848. * Class containing static functions to help procedurally build meshes
  63849. */
  63850. export class TiledPlaneBuilder {
  63851. /**
  63852. * Creates a tiled plane mesh
  63853. * * The parameter `pattern` will, depending on value, do nothing or
  63854. * * * flip (reflect about central vertical) alternate tiles across and up
  63855. * * * flip every tile on alternate rows
  63856. * * * rotate (180 degs) alternate tiles across and up
  63857. * * * rotate every tile on alternate rows
  63858. * * * flip and rotate alternate tiles across and up
  63859. * * * flip and rotate every tile on alternate rows
  63860. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63861. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63862. * * 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
  63863. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63864. * * 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)
  63865. * * 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)
  63866. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63867. * @param name defines the name of the mesh
  63868. * @param options defines the options used to create the mesh
  63869. * @param scene defines the hosting scene
  63870. * @returns the box mesh
  63871. */
  63872. static CreateTiledPlane(name: string, options: {
  63873. pattern?: number;
  63874. tileSize?: number;
  63875. tileWidth?: number;
  63876. tileHeight?: number;
  63877. size?: number;
  63878. width?: number;
  63879. height?: number;
  63880. alignHorizontal?: number;
  63881. alignVertical?: number;
  63882. sideOrientation?: number;
  63883. frontUVs?: Vector4;
  63884. backUVs?: Vector4;
  63885. updatable?: boolean;
  63886. }, scene?: Nullable<Scene>): Mesh;
  63887. }
  63888. }
  63889. declare module BABYLON {
  63890. /**
  63891. * Class containing static functions to help procedurally build meshes
  63892. */
  63893. export class TubeBuilder {
  63894. /**
  63895. * Creates a tube mesh.
  63896. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63897. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63898. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63899. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63900. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63901. * * 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)
  63902. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63903. * * 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
  63904. * * 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
  63905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63906. * * 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
  63907. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63909. * @param name defines the name of the mesh
  63910. * @param options defines the options used to create the mesh
  63911. * @param scene defines the hosting scene
  63912. * @returns the tube mesh
  63913. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63914. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63915. */
  63916. static CreateTube(name: string, options: {
  63917. path: Vector3[];
  63918. radius?: number;
  63919. tessellation?: number;
  63920. radiusFunction?: {
  63921. (i: number, distance: number): number;
  63922. };
  63923. cap?: number;
  63924. arc?: number;
  63925. updatable?: boolean;
  63926. sideOrientation?: number;
  63927. frontUVs?: Vector4;
  63928. backUVs?: Vector4;
  63929. instance?: Mesh;
  63930. invertUV?: boolean;
  63931. }, scene?: Nullable<Scene>): Mesh;
  63932. }
  63933. }
  63934. declare module BABYLON {
  63935. /**
  63936. * Class containing static functions to help procedurally build meshes
  63937. */
  63938. export class IcoSphereBuilder {
  63939. /**
  63940. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63941. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63942. * * 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`)
  63943. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63944. * * 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
  63945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63946. * * 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
  63947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63948. * @param name defines the name of the mesh
  63949. * @param options defines the options used to create the mesh
  63950. * @param scene defines the hosting scene
  63951. * @returns the icosahedron mesh
  63952. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63953. */
  63954. static CreateIcoSphere(name: string, options: {
  63955. radius?: number;
  63956. radiusX?: number;
  63957. radiusY?: number;
  63958. radiusZ?: number;
  63959. flat?: boolean;
  63960. subdivisions?: number;
  63961. sideOrientation?: number;
  63962. frontUVs?: Vector4;
  63963. backUVs?: Vector4;
  63964. updatable?: boolean;
  63965. }, scene?: Nullable<Scene>): Mesh;
  63966. }
  63967. }
  63968. declare module BABYLON {
  63969. /**
  63970. * Class containing static functions to help procedurally build meshes
  63971. */
  63972. export class DecalBuilder {
  63973. /**
  63974. * Creates a decal mesh.
  63975. * 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
  63976. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63977. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63978. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63979. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63980. * @param name defines the name of the mesh
  63981. * @param sourceMesh defines the mesh where the decal must be applied
  63982. * @param options defines the options used to create the mesh
  63983. * @param scene defines the hosting scene
  63984. * @returns the decal mesh
  63985. * @see https://doc.babylonjs.com/how_to/decals
  63986. */
  63987. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63988. position?: Vector3;
  63989. normal?: Vector3;
  63990. size?: Vector3;
  63991. angle?: number;
  63992. }): Mesh;
  63993. }
  63994. }
  63995. declare module BABYLON {
  63996. /**
  63997. * Class containing static functions to help procedurally build meshes
  63998. */
  63999. export class MeshBuilder {
  64000. /**
  64001. * Creates a box mesh
  64002. * * The parameter `size` sets the size (float) of each box side (default 1)
  64003. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64004. * * 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)
  64005. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64007. * * 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
  64008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64009. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64010. * @param name defines the name of the mesh
  64011. * @param options defines the options used to create the mesh
  64012. * @param scene defines the hosting scene
  64013. * @returns the box mesh
  64014. */
  64015. static CreateBox(name: string, options: {
  64016. size?: number;
  64017. width?: number;
  64018. height?: number;
  64019. depth?: number;
  64020. faceUV?: Vector4[];
  64021. faceColors?: Color4[];
  64022. sideOrientation?: number;
  64023. frontUVs?: Vector4;
  64024. backUVs?: Vector4;
  64025. wrap?: boolean;
  64026. topBaseAt?: number;
  64027. bottomBaseAt?: number;
  64028. updatable?: boolean;
  64029. }, scene?: Nullable<Scene>): Mesh;
  64030. /**
  64031. * Creates a tiled box mesh
  64032. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64034. * @param name defines the name of the mesh
  64035. * @param options defines the options used to create the mesh
  64036. * @param scene defines the hosting scene
  64037. * @returns the tiled box mesh
  64038. */
  64039. static CreateTiledBox(name: string, options: {
  64040. pattern?: number;
  64041. size?: number;
  64042. width?: number;
  64043. height?: number;
  64044. depth: number;
  64045. tileSize?: number;
  64046. tileWidth?: number;
  64047. tileHeight?: number;
  64048. faceUV?: Vector4[];
  64049. faceColors?: Color4[];
  64050. alignHorizontal?: number;
  64051. alignVertical?: number;
  64052. sideOrientation?: number;
  64053. updatable?: boolean;
  64054. }, scene?: Nullable<Scene>): Mesh;
  64055. /**
  64056. * Creates a sphere mesh
  64057. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64058. * * 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`)
  64059. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64060. * * 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
  64061. * * 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)
  64062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64063. * * 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
  64064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64065. * @param name defines the name of the mesh
  64066. * @param options defines the options used to create the mesh
  64067. * @param scene defines the hosting scene
  64068. * @returns the sphere mesh
  64069. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64070. */
  64071. static CreateSphere(name: string, options: {
  64072. segments?: number;
  64073. diameter?: number;
  64074. diameterX?: number;
  64075. diameterY?: number;
  64076. diameterZ?: number;
  64077. arc?: number;
  64078. slice?: number;
  64079. sideOrientation?: number;
  64080. frontUVs?: Vector4;
  64081. backUVs?: Vector4;
  64082. updatable?: boolean;
  64083. }, scene?: Nullable<Scene>): Mesh;
  64084. /**
  64085. * Creates a plane polygonal mesh. By default, this is a disc
  64086. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64087. * * 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
  64088. * * 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
  64089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64090. * * 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
  64091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64092. * @param name defines the name of the mesh
  64093. * @param options defines the options used to create the mesh
  64094. * @param scene defines the hosting scene
  64095. * @returns the plane polygonal mesh
  64096. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64097. */
  64098. static CreateDisc(name: string, options: {
  64099. radius?: number;
  64100. tessellation?: number;
  64101. arc?: number;
  64102. updatable?: boolean;
  64103. sideOrientation?: number;
  64104. frontUVs?: Vector4;
  64105. backUVs?: Vector4;
  64106. }, scene?: Nullable<Scene>): Mesh;
  64107. /**
  64108. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64109. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64110. * * 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`)
  64111. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64112. * * 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
  64113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64114. * * 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
  64115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64116. * @param name defines the name of the mesh
  64117. * @param options defines the options used to create the mesh
  64118. * @param scene defines the hosting scene
  64119. * @returns the icosahedron mesh
  64120. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64121. */
  64122. static CreateIcoSphere(name: string, options: {
  64123. radius?: number;
  64124. radiusX?: number;
  64125. radiusY?: number;
  64126. radiusZ?: number;
  64127. flat?: boolean;
  64128. subdivisions?: number;
  64129. sideOrientation?: number;
  64130. frontUVs?: Vector4;
  64131. backUVs?: Vector4;
  64132. updatable?: boolean;
  64133. }, scene?: Nullable<Scene>): Mesh;
  64134. /**
  64135. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64136. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64137. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64138. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64139. * * 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
  64140. * * 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
  64141. * * 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
  64142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64143. * * 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
  64144. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64145. * * 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
  64146. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64147. * * 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
  64148. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64150. * @param name defines the name of the mesh
  64151. * @param options defines the options used to create the mesh
  64152. * @param scene defines the hosting scene
  64153. * @returns the ribbon mesh
  64154. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64155. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64156. */
  64157. static CreateRibbon(name: string, options: {
  64158. pathArray: Vector3[][];
  64159. closeArray?: boolean;
  64160. closePath?: boolean;
  64161. offset?: number;
  64162. updatable?: boolean;
  64163. sideOrientation?: number;
  64164. frontUVs?: Vector4;
  64165. backUVs?: Vector4;
  64166. instance?: Mesh;
  64167. invertUV?: boolean;
  64168. uvs?: Vector2[];
  64169. colors?: Color4[];
  64170. }, scene?: Nullable<Scene>): Mesh;
  64171. /**
  64172. * Creates a cylinder or a cone mesh
  64173. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64174. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64175. * * 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.
  64176. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64177. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64178. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64179. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64180. * * 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).
  64181. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64182. * * 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).
  64183. * * 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
  64184. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64185. * * 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
  64186. * * 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.
  64187. * * If `enclose` is false, a ring surface is one element.
  64188. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64189. * * 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
  64190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64191. * * 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
  64192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64193. * @param name defines the name of the mesh
  64194. * @param options defines the options used to create the mesh
  64195. * @param scene defines the hosting scene
  64196. * @returns the cylinder mesh
  64197. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64198. */
  64199. static CreateCylinder(name: string, options: {
  64200. height?: number;
  64201. diameterTop?: number;
  64202. diameterBottom?: number;
  64203. diameter?: number;
  64204. tessellation?: number;
  64205. subdivisions?: number;
  64206. arc?: number;
  64207. faceColors?: Color4[];
  64208. faceUV?: Vector4[];
  64209. updatable?: boolean;
  64210. hasRings?: boolean;
  64211. enclose?: boolean;
  64212. cap?: number;
  64213. sideOrientation?: number;
  64214. frontUVs?: Vector4;
  64215. backUVs?: Vector4;
  64216. }, scene?: Nullable<Scene>): Mesh;
  64217. /**
  64218. * Creates a torus mesh
  64219. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64220. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64221. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64223. * * 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
  64224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64225. * @param name defines the name of the mesh
  64226. * @param options defines the options used to create the mesh
  64227. * @param scene defines the hosting scene
  64228. * @returns the torus mesh
  64229. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64230. */
  64231. static CreateTorus(name: string, options: {
  64232. diameter?: number;
  64233. thickness?: number;
  64234. tessellation?: number;
  64235. updatable?: boolean;
  64236. sideOrientation?: number;
  64237. frontUVs?: Vector4;
  64238. backUVs?: Vector4;
  64239. }, scene?: Nullable<Scene>): Mesh;
  64240. /**
  64241. * Creates a torus knot mesh
  64242. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64243. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64244. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64245. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64246. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64247. * * 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
  64248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64249. * @param name defines the name of the mesh
  64250. * @param options defines the options used to create the mesh
  64251. * @param scene defines the hosting scene
  64252. * @returns the torus knot mesh
  64253. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64254. */
  64255. static CreateTorusKnot(name: string, options: {
  64256. radius?: number;
  64257. tube?: number;
  64258. radialSegments?: number;
  64259. tubularSegments?: number;
  64260. p?: number;
  64261. q?: number;
  64262. updatable?: boolean;
  64263. sideOrientation?: number;
  64264. frontUVs?: Vector4;
  64265. backUVs?: Vector4;
  64266. }, scene?: Nullable<Scene>): Mesh;
  64267. /**
  64268. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64269. * * 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
  64270. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64271. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64272. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64273. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64274. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64275. * * 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
  64276. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64279. * @param name defines the name of the new line system
  64280. * @param options defines the options used to create the line system
  64281. * @param scene defines the hosting scene
  64282. * @returns a new line system mesh
  64283. */
  64284. static CreateLineSystem(name: string, options: {
  64285. lines: Vector3[][];
  64286. updatable?: boolean;
  64287. instance?: Nullable<LinesMesh>;
  64288. colors?: Nullable<Color4[][]>;
  64289. useVertexAlpha?: boolean;
  64290. }, scene: Nullable<Scene>): LinesMesh;
  64291. /**
  64292. * Creates a line mesh
  64293. * 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
  64294. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64295. * * The parameter `points` is an array successive Vector3
  64296. * * 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
  64297. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64298. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64299. * * When updating an instance, remember that only point positions can change, not the number of points
  64300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64301. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64302. * @param name defines the name of the new line system
  64303. * @param options defines the options used to create the line system
  64304. * @param scene defines the hosting scene
  64305. * @returns a new line mesh
  64306. */
  64307. static CreateLines(name: string, options: {
  64308. points: Vector3[];
  64309. updatable?: boolean;
  64310. instance?: Nullable<LinesMesh>;
  64311. colors?: Color4[];
  64312. useVertexAlpha?: boolean;
  64313. }, scene?: Nullable<Scene>): LinesMesh;
  64314. /**
  64315. * Creates a dashed line mesh
  64316. * * 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
  64317. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64318. * * The parameter `points` is an array successive Vector3
  64319. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64320. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64321. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64322. * * 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
  64323. * * When updating an instance, remember that only point positions can change, not the number of points
  64324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64325. * @param name defines the name of the mesh
  64326. * @param options defines the options used to create the mesh
  64327. * @param scene defines the hosting scene
  64328. * @returns the dashed line mesh
  64329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64330. */
  64331. static CreateDashedLines(name: string, options: {
  64332. points: Vector3[];
  64333. dashSize?: number;
  64334. gapSize?: number;
  64335. dashNb?: number;
  64336. updatable?: boolean;
  64337. instance?: LinesMesh;
  64338. }, scene?: Nullable<Scene>): LinesMesh;
  64339. /**
  64340. * 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.
  64341. * * 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.
  64342. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64343. * * 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.
  64344. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64345. * * 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
  64346. * * 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
  64347. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64349. * * 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
  64350. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64352. * @param name defines the name of the mesh
  64353. * @param options defines the options used to create the mesh
  64354. * @param scene defines the hosting scene
  64355. * @returns the extruded shape mesh
  64356. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64357. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64358. */
  64359. static ExtrudeShape(name: string, options: {
  64360. shape: Vector3[];
  64361. path: Vector3[];
  64362. scale?: number;
  64363. rotation?: number;
  64364. cap?: number;
  64365. updatable?: boolean;
  64366. sideOrientation?: number;
  64367. frontUVs?: Vector4;
  64368. backUVs?: Vector4;
  64369. instance?: Mesh;
  64370. invertUV?: boolean;
  64371. }, scene?: Nullable<Scene>): Mesh;
  64372. /**
  64373. * Creates an custom extruded shape mesh.
  64374. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64375. * * 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.
  64376. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64377. * * 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
  64378. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64379. * * 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
  64380. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64381. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64382. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64383. * * 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
  64384. * * 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
  64385. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64387. * * 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
  64388. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64390. * @param name defines the name of the mesh
  64391. * @param options defines the options used to create the mesh
  64392. * @param scene defines the hosting scene
  64393. * @returns the custom extruded shape mesh
  64394. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64395. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64396. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64397. */
  64398. static ExtrudeShapeCustom(name: string, options: {
  64399. shape: Vector3[];
  64400. path: Vector3[];
  64401. scaleFunction?: any;
  64402. rotationFunction?: any;
  64403. ribbonCloseArray?: boolean;
  64404. ribbonClosePath?: boolean;
  64405. cap?: number;
  64406. updatable?: boolean;
  64407. sideOrientation?: number;
  64408. frontUVs?: Vector4;
  64409. backUVs?: Vector4;
  64410. instance?: Mesh;
  64411. invertUV?: boolean;
  64412. }, scene?: Nullable<Scene>): Mesh;
  64413. /**
  64414. * Creates lathe mesh.
  64415. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64416. * * 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
  64417. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64418. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64419. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64420. * * 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
  64421. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64422. * * 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
  64423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64424. * * 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
  64425. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64427. * @param name defines the name of the mesh
  64428. * @param options defines the options used to create the mesh
  64429. * @param scene defines the hosting scene
  64430. * @returns the lathe mesh
  64431. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64432. */
  64433. static CreateLathe(name: string, options: {
  64434. shape: Vector3[];
  64435. radius?: number;
  64436. tessellation?: number;
  64437. clip?: number;
  64438. arc?: number;
  64439. closed?: boolean;
  64440. updatable?: boolean;
  64441. sideOrientation?: number;
  64442. frontUVs?: Vector4;
  64443. backUVs?: Vector4;
  64444. cap?: number;
  64445. invertUV?: boolean;
  64446. }, scene?: Nullable<Scene>): Mesh;
  64447. /**
  64448. * Creates a tiled plane mesh
  64449. * * You can set a limited pattern arrangement with the tiles
  64450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64451. * * 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
  64452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64453. * @param name defines the name of the mesh
  64454. * @param options defines the options used to create the mesh
  64455. * @param scene defines the hosting scene
  64456. * @returns the plane mesh
  64457. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64458. */
  64459. static CreateTiledPlane(name: string, options: {
  64460. pattern?: number;
  64461. tileSize?: number;
  64462. tileWidth?: number;
  64463. tileHeight?: number;
  64464. size?: number;
  64465. width?: number;
  64466. height?: number;
  64467. alignHorizontal?: number;
  64468. alignVertical?: number;
  64469. sideOrientation?: number;
  64470. frontUVs?: Vector4;
  64471. backUVs?: Vector4;
  64472. updatable?: boolean;
  64473. }, scene?: Nullable<Scene>): Mesh;
  64474. /**
  64475. * Creates a plane mesh
  64476. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64477. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64478. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64480. * * 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
  64481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64482. * @param name defines the name of the mesh
  64483. * @param options defines the options used to create the mesh
  64484. * @param scene defines the hosting scene
  64485. * @returns the plane mesh
  64486. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64487. */
  64488. static CreatePlane(name: string, options: {
  64489. size?: number;
  64490. width?: number;
  64491. height?: number;
  64492. sideOrientation?: number;
  64493. frontUVs?: Vector4;
  64494. backUVs?: Vector4;
  64495. updatable?: boolean;
  64496. sourcePlane?: Plane;
  64497. }, scene?: Nullable<Scene>): Mesh;
  64498. /**
  64499. * Creates a ground mesh
  64500. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64501. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64503. * @param name defines the name of the mesh
  64504. * @param options defines the options used to create the mesh
  64505. * @param scene defines the hosting scene
  64506. * @returns the ground mesh
  64507. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64508. */
  64509. static CreateGround(name: string, options: {
  64510. width?: number;
  64511. height?: number;
  64512. subdivisions?: number;
  64513. subdivisionsX?: number;
  64514. subdivisionsY?: number;
  64515. updatable?: boolean;
  64516. }, scene?: Nullable<Scene>): Mesh;
  64517. /**
  64518. * Creates a tiled ground mesh
  64519. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64520. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64521. * * 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
  64522. * * 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
  64523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64524. * @param name defines the name of the mesh
  64525. * @param options defines the options used to create the mesh
  64526. * @param scene defines the hosting scene
  64527. * @returns the tiled ground mesh
  64528. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64529. */
  64530. static CreateTiledGround(name: string, options: {
  64531. xmin: number;
  64532. zmin: number;
  64533. xmax: number;
  64534. zmax: number;
  64535. subdivisions?: {
  64536. w: number;
  64537. h: number;
  64538. };
  64539. precision?: {
  64540. w: number;
  64541. h: number;
  64542. };
  64543. updatable?: boolean;
  64544. }, scene?: Nullable<Scene>): Mesh;
  64545. /**
  64546. * Creates a ground mesh from a height map
  64547. * * The parameter `url` sets the URL of the height map image resource.
  64548. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64549. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64550. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64551. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64552. * * 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.
  64553. * * 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).
  64554. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64556. * @param name defines the name of the mesh
  64557. * @param url defines the url to the height map
  64558. * @param options defines the options used to create the mesh
  64559. * @param scene defines the hosting scene
  64560. * @returns the ground mesh
  64561. * @see https://doc.babylonjs.com/babylon101/height_map
  64562. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64563. */
  64564. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64565. width?: number;
  64566. height?: number;
  64567. subdivisions?: number;
  64568. minHeight?: number;
  64569. maxHeight?: number;
  64570. colorFilter?: Color3;
  64571. alphaFilter?: number;
  64572. updatable?: boolean;
  64573. onReady?: (mesh: GroundMesh) => void;
  64574. }, scene?: Nullable<Scene>): GroundMesh;
  64575. /**
  64576. * Creates a polygon mesh
  64577. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64578. * * 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
  64579. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64581. * * 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)
  64582. * * Remember you can only change the shape positions, not their number when updating a polygon
  64583. * @param name defines the name of the mesh
  64584. * @param options defines the options used to create the mesh
  64585. * @param scene defines the hosting scene
  64586. * @param earcutInjection can be used to inject your own earcut reference
  64587. * @returns the polygon mesh
  64588. */
  64589. static CreatePolygon(name: string, options: {
  64590. shape: Vector3[];
  64591. holes?: Vector3[][];
  64592. depth?: number;
  64593. faceUV?: Vector4[];
  64594. faceColors?: Color4[];
  64595. updatable?: boolean;
  64596. sideOrientation?: number;
  64597. frontUVs?: Vector4;
  64598. backUVs?: Vector4;
  64599. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64600. /**
  64601. * Creates an extruded polygon mesh, with depth in the Y direction.
  64602. * * 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)
  64603. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64604. * @param name defines the name of the mesh
  64605. * @param options defines the options used to create the mesh
  64606. * @param scene defines the hosting scene
  64607. * @param earcutInjection can be used to inject your own earcut reference
  64608. * @returns the polygon mesh
  64609. */
  64610. static ExtrudePolygon(name: string, options: {
  64611. shape: Vector3[];
  64612. holes?: Vector3[][];
  64613. depth?: number;
  64614. faceUV?: Vector4[];
  64615. faceColors?: Color4[];
  64616. updatable?: boolean;
  64617. sideOrientation?: number;
  64618. frontUVs?: Vector4;
  64619. backUVs?: Vector4;
  64620. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64621. /**
  64622. * Creates a tube mesh.
  64623. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64624. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64625. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64626. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64627. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64628. * * 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)
  64629. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64630. * * 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
  64631. * * 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
  64632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64633. * * 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
  64634. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64636. * @param name defines the name of the mesh
  64637. * @param options defines the options used to create the mesh
  64638. * @param scene defines the hosting scene
  64639. * @returns the tube mesh
  64640. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64641. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64642. */
  64643. static CreateTube(name: string, options: {
  64644. path: Vector3[];
  64645. radius?: number;
  64646. tessellation?: number;
  64647. radiusFunction?: {
  64648. (i: number, distance: number): number;
  64649. };
  64650. cap?: number;
  64651. arc?: number;
  64652. updatable?: boolean;
  64653. sideOrientation?: number;
  64654. frontUVs?: Vector4;
  64655. backUVs?: Vector4;
  64656. instance?: Mesh;
  64657. invertUV?: boolean;
  64658. }, scene?: Nullable<Scene>): Mesh;
  64659. /**
  64660. * Creates a polyhedron mesh
  64661. * * 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
  64662. * * The parameter `size` (positive float, default 1) sets the polygon size
  64663. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64664. * * 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`
  64665. * * 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
  64666. * * 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)`)
  64667. * * 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
  64668. * * 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
  64669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64670. * * 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
  64671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64672. * @param name defines the name of the mesh
  64673. * @param options defines the options used to create the mesh
  64674. * @param scene defines the hosting scene
  64675. * @returns the polyhedron mesh
  64676. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64677. */
  64678. static CreatePolyhedron(name: string, options: {
  64679. type?: number;
  64680. size?: number;
  64681. sizeX?: number;
  64682. sizeY?: number;
  64683. sizeZ?: number;
  64684. custom?: any;
  64685. faceUV?: Vector4[];
  64686. faceColors?: Color4[];
  64687. flat?: boolean;
  64688. updatable?: boolean;
  64689. sideOrientation?: number;
  64690. frontUVs?: Vector4;
  64691. backUVs?: Vector4;
  64692. }, scene?: Nullable<Scene>): Mesh;
  64693. /**
  64694. * Creates a decal mesh.
  64695. * 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
  64696. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64697. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64698. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64699. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64700. * @param name defines the name of the mesh
  64701. * @param sourceMesh defines the mesh where the decal must be applied
  64702. * @param options defines the options used to create the mesh
  64703. * @param scene defines the hosting scene
  64704. * @returns the decal mesh
  64705. * @see https://doc.babylonjs.com/how_to/decals
  64706. */
  64707. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64708. position?: Vector3;
  64709. normal?: Vector3;
  64710. size?: Vector3;
  64711. angle?: number;
  64712. }): Mesh;
  64713. }
  64714. }
  64715. declare module BABYLON {
  64716. /**
  64717. * A simplifier interface for future simplification implementations
  64718. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64719. */
  64720. export interface ISimplifier {
  64721. /**
  64722. * Simplification of a given mesh according to the given settings.
  64723. * Since this requires computation, it is assumed that the function runs async.
  64724. * @param settings The settings of the simplification, including quality and distance
  64725. * @param successCallback A callback that will be called after the mesh was simplified.
  64726. * @param errorCallback in case of an error, this callback will be called. optional.
  64727. */
  64728. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64729. }
  64730. /**
  64731. * Expected simplification settings.
  64732. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64733. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64734. */
  64735. export interface ISimplificationSettings {
  64736. /**
  64737. * Gets or sets the expected quality
  64738. */
  64739. quality: number;
  64740. /**
  64741. * Gets or sets the distance when this optimized version should be used
  64742. */
  64743. distance: number;
  64744. /**
  64745. * Gets an already optimized mesh
  64746. */
  64747. optimizeMesh?: boolean;
  64748. }
  64749. /**
  64750. * Class used to specify simplification options
  64751. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64752. */
  64753. export class SimplificationSettings implements ISimplificationSettings {
  64754. /** expected quality */
  64755. quality: number;
  64756. /** distance when this optimized version should be used */
  64757. distance: number;
  64758. /** already optimized mesh */
  64759. optimizeMesh?: boolean | undefined;
  64760. /**
  64761. * Creates a SimplificationSettings
  64762. * @param quality expected quality
  64763. * @param distance distance when this optimized version should be used
  64764. * @param optimizeMesh already optimized mesh
  64765. */
  64766. constructor(
  64767. /** expected quality */
  64768. quality: number,
  64769. /** distance when this optimized version should be used */
  64770. distance: number,
  64771. /** already optimized mesh */
  64772. optimizeMesh?: boolean | undefined);
  64773. }
  64774. /**
  64775. * Interface used to define a simplification task
  64776. */
  64777. export interface ISimplificationTask {
  64778. /**
  64779. * Array of settings
  64780. */
  64781. settings: Array<ISimplificationSettings>;
  64782. /**
  64783. * Simplification type
  64784. */
  64785. simplificationType: SimplificationType;
  64786. /**
  64787. * Mesh to simplify
  64788. */
  64789. mesh: Mesh;
  64790. /**
  64791. * Callback called on success
  64792. */
  64793. successCallback?: () => void;
  64794. /**
  64795. * Defines if parallel processing can be used
  64796. */
  64797. parallelProcessing: boolean;
  64798. }
  64799. /**
  64800. * Queue used to order the simplification tasks
  64801. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64802. */
  64803. export class SimplificationQueue {
  64804. private _simplificationArray;
  64805. /**
  64806. * Gets a boolean indicating that the process is still running
  64807. */
  64808. running: boolean;
  64809. /**
  64810. * Creates a new queue
  64811. */
  64812. constructor();
  64813. /**
  64814. * Adds a new simplification task
  64815. * @param task defines a task to add
  64816. */
  64817. addTask(task: ISimplificationTask): void;
  64818. /**
  64819. * Execute next task
  64820. */
  64821. executeNext(): void;
  64822. /**
  64823. * Execute a simplification task
  64824. * @param task defines the task to run
  64825. */
  64826. runSimplification(task: ISimplificationTask): void;
  64827. private getSimplifier;
  64828. }
  64829. /**
  64830. * The implemented types of simplification
  64831. * At the moment only Quadratic Error Decimation is implemented
  64832. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64833. */
  64834. export enum SimplificationType {
  64835. /** Quadratic error decimation */
  64836. QUADRATIC = 0
  64837. }
  64838. /**
  64839. * An implementation of the Quadratic Error simplification algorithm.
  64840. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  64841. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  64842. * @author RaananW
  64843. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64844. */
  64845. export class QuadraticErrorSimplification implements ISimplifier {
  64846. private _mesh;
  64847. private triangles;
  64848. private vertices;
  64849. private references;
  64850. private _reconstructedMesh;
  64851. /** Gets or sets the number pf sync interations */
  64852. syncIterations: number;
  64853. /** Gets or sets the aggressiveness of the simplifier */
  64854. aggressiveness: number;
  64855. /** Gets or sets the number of allowed iterations for decimation */
  64856. decimationIterations: number;
  64857. /** Gets or sets the espilon to use for bounding box computation */
  64858. boundingBoxEpsilon: number;
  64859. /**
  64860. * Creates a new QuadraticErrorSimplification
  64861. * @param _mesh defines the target mesh
  64862. */
  64863. constructor(_mesh: Mesh);
  64864. /**
  64865. * Simplification of a given mesh according to the given settings.
  64866. * Since this requires computation, it is assumed that the function runs async.
  64867. * @param settings The settings of the simplification, including quality and distance
  64868. * @param successCallback A callback that will be called after the mesh was simplified.
  64869. */
  64870. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  64871. private runDecimation;
  64872. private initWithMesh;
  64873. private init;
  64874. private reconstructMesh;
  64875. private initDecimatedMesh;
  64876. private isFlipped;
  64877. private updateTriangles;
  64878. private identifyBorder;
  64879. private updateMesh;
  64880. private vertexError;
  64881. private calculateError;
  64882. }
  64883. }
  64884. declare module BABYLON {
  64885. interface Scene {
  64886. /** @hidden (Backing field) */
  64887. _simplificationQueue: SimplificationQueue;
  64888. /**
  64889. * Gets or sets the simplification queue attached to the scene
  64890. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64891. */
  64892. simplificationQueue: SimplificationQueue;
  64893. }
  64894. interface Mesh {
  64895. /**
  64896. * Simplify the mesh according to the given array of settings.
  64897. * Function will return immediately and will simplify async
  64898. * @param settings a collection of simplification settings
  64899. * @param parallelProcessing should all levels calculate parallel or one after the other
  64900. * @param simplificationType the type of simplification to run
  64901. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64902. * @returns the current mesh
  64903. */
  64904. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64905. }
  64906. /**
  64907. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64908. * created in a scene
  64909. */
  64910. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64911. /**
  64912. * The component name helpfull to identify the component in the list of scene components.
  64913. */
  64914. readonly name: string;
  64915. /**
  64916. * The scene the component belongs to.
  64917. */
  64918. scene: Scene;
  64919. /**
  64920. * Creates a new instance of the component for the given scene
  64921. * @param scene Defines the scene to register the component in
  64922. */
  64923. constructor(scene: Scene);
  64924. /**
  64925. * Registers the component in a given scene
  64926. */
  64927. register(): void;
  64928. /**
  64929. * Rebuilds the elements related to this component in case of
  64930. * context lost for instance.
  64931. */
  64932. rebuild(): void;
  64933. /**
  64934. * Disposes the component and the associated ressources
  64935. */
  64936. dispose(): void;
  64937. private _beforeCameraUpdate;
  64938. }
  64939. }
  64940. declare module BABYLON {
  64941. interface Mesh {
  64942. /**
  64943. * Creates a new thin instance
  64944. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  64945. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  64946. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  64947. */
  64948. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  64949. /**
  64950. * Adds the transformation (matrix) of the current mesh as a thin instance
  64951. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  64952. * @returns the thin instance index number
  64953. */
  64954. thinInstanceAddSelf(refresh: boolean): number;
  64955. /**
  64956. * Registers a custom attribute to be used with thin instances
  64957. * @param kind name of the attribute
  64958. * @param stride size in floats of the attribute
  64959. */
  64960. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  64961. /**
  64962. * Sets the matrix of a thin instance
  64963. * @param index index of the thin instance
  64964. * @param matrix matrix to set
  64965. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  64966. */
  64967. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  64968. /**
  64969. * Sets the value of a custom attribute for a thin instance
  64970. * @param kind name of the attribute
  64971. * @param index index of the thin instance
  64972. * @param value value to set
  64973. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  64974. */
  64975. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  64976. /**
  64977. * Gets / sets the number of thin instances to display. Note that you can't set a number higher than what the underlying buffer can handle.
  64978. */
  64979. thinInstanceCount: number;
  64980. /**
  64981. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  64982. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  64983. * @param buffer buffer to set
  64984. * @param stride size in floats of each value of the buffer
  64985. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  64986. */
  64987. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  64988. /**
  64989. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  64990. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  64991. */
  64992. thinInstanceBufferUpdated(kind: string): void;
  64993. /**
  64994. * Refreshes the bounding info, taking into account all the thin instances defined
  64995. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  64996. */
  64997. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  64998. /** @hidden */
  64999. _thinInstanceInitializeUserStorage(): void;
  65000. /** @hidden */
  65001. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  65002. /** @hidden */
  65003. _userThinInstanceBuffersStorage: {
  65004. data: {
  65005. [key: string]: Float32Array;
  65006. };
  65007. sizes: {
  65008. [key: string]: number;
  65009. };
  65010. vertexBuffers: {
  65011. [key: string]: Nullable<VertexBuffer>;
  65012. };
  65013. strides: {
  65014. [key: string]: number;
  65015. };
  65016. };
  65017. }
  65018. }
  65019. declare module BABYLON {
  65020. /**
  65021. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65022. */
  65023. export interface INavigationEnginePlugin {
  65024. /**
  65025. * plugin name
  65026. */
  65027. name: string;
  65028. /**
  65029. * Creates a navigation mesh
  65030. * @param meshes array of all the geometry used to compute the navigatio mesh
  65031. * @param parameters bunch of parameters used to filter geometry
  65032. */
  65033. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65034. /**
  65035. * Create a navigation mesh debug mesh
  65036. * @param scene is where the mesh will be added
  65037. * @returns debug display mesh
  65038. */
  65039. createDebugNavMesh(scene: Scene): Mesh;
  65040. /**
  65041. * Get a navigation mesh constrained position, closest to the parameter position
  65042. * @param position world position
  65043. * @returns the closest point to position constrained by the navigation mesh
  65044. */
  65045. getClosestPoint(position: Vector3): Vector3;
  65046. /**
  65047. * Get a navigation mesh constrained position, closest to the parameter position
  65048. * @param position world position
  65049. * @param result output the closest point to position constrained by the navigation mesh
  65050. */
  65051. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65052. /**
  65053. * Get a navigation mesh constrained position, within a particular radius
  65054. * @param position world position
  65055. * @param maxRadius the maximum distance to the constrained world position
  65056. * @returns the closest point to position constrained by the navigation mesh
  65057. */
  65058. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65059. /**
  65060. * Get a navigation mesh constrained position, within a particular radius
  65061. * @param position world position
  65062. * @param maxRadius the maximum distance to the constrained world position
  65063. * @param result output the closest point to position constrained by the navigation mesh
  65064. */
  65065. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65066. /**
  65067. * Compute the final position from a segment made of destination-position
  65068. * @param position world position
  65069. * @param destination world position
  65070. * @returns the resulting point along the navmesh
  65071. */
  65072. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65073. /**
  65074. * Compute the final position from a segment made of destination-position
  65075. * @param position world position
  65076. * @param destination world position
  65077. * @param result output the resulting point along the navmesh
  65078. */
  65079. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65080. /**
  65081. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65082. * @param start world position
  65083. * @param end world position
  65084. * @returns array containing world position composing the path
  65085. */
  65086. computePath(start: Vector3, end: Vector3): Vector3[];
  65087. /**
  65088. * If this plugin is supported
  65089. * @returns true if plugin is supported
  65090. */
  65091. isSupported(): boolean;
  65092. /**
  65093. * Create a new Crowd so you can add agents
  65094. * @param maxAgents the maximum agent count in the crowd
  65095. * @param maxAgentRadius the maximum radius an agent can have
  65096. * @param scene to attach the crowd to
  65097. * @returns the crowd you can add agents to
  65098. */
  65099. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65100. /**
  65101. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65102. * The queries will try to find a solution within those bounds
  65103. * default is (1,1,1)
  65104. * @param extent x,y,z value that define the extent around the queries point of reference
  65105. */
  65106. setDefaultQueryExtent(extent: Vector3): void;
  65107. /**
  65108. * Get the Bounding box extent specified by setDefaultQueryExtent
  65109. * @returns the box extent values
  65110. */
  65111. getDefaultQueryExtent(): Vector3;
  65112. /**
  65113. * build the navmesh from a previously saved state using getNavmeshData
  65114. * @param data the Uint8Array returned by getNavmeshData
  65115. */
  65116. buildFromNavmeshData(data: Uint8Array): void;
  65117. /**
  65118. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65119. * @returns data the Uint8Array that can be saved and reused
  65120. */
  65121. getNavmeshData(): Uint8Array;
  65122. /**
  65123. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65124. * @param result output the box extent values
  65125. */
  65126. getDefaultQueryExtentToRef(result: Vector3): void;
  65127. /**
  65128. * Release all resources
  65129. */
  65130. dispose(): void;
  65131. }
  65132. /**
  65133. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65134. */
  65135. export interface ICrowd {
  65136. /**
  65137. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65138. * You can attach anything to that node. The node position is updated in the scene update tick.
  65139. * @param pos world position that will be constrained by the navigation mesh
  65140. * @param parameters agent parameters
  65141. * @param transform hooked to the agent that will be update by the scene
  65142. * @returns agent index
  65143. */
  65144. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65145. /**
  65146. * Returns the agent position in world space
  65147. * @param index agent index returned by addAgent
  65148. * @returns world space position
  65149. */
  65150. getAgentPosition(index: number): Vector3;
  65151. /**
  65152. * Gets the agent position result in world space
  65153. * @param index agent index returned by addAgent
  65154. * @param result output world space position
  65155. */
  65156. getAgentPositionToRef(index: number, result: Vector3): void;
  65157. /**
  65158. * Gets the agent velocity in world space
  65159. * @param index agent index returned by addAgent
  65160. * @returns world space velocity
  65161. */
  65162. getAgentVelocity(index: number): Vector3;
  65163. /**
  65164. * Gets the agent velocity result in world space
  65165. * @param index agent index returned by addAgent
  65166. * @param result output world space velocity
  65167. */
  65168. getAgentVelocityToRef(index: number, result: Vector3): void;
  65169. /**
  65170. * remove a particular agent previously created
  65171. * @param index agent index returned by addAgent
  65172. */
  65173. removeAgent(index: number): void;
  65174. /**
  65175. * get the list of all agents attached to this crowd
  65176. * @returns list of agent indices
  65177. */
  65178. getAgents(): number[];
  65179. /**
  65180. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65181. * @param deltaTime in seconds
  65182. */
  65183. update(deltaTime: number): void;
  65184. /**
  65185. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65186. * @param index agent index returned by addAgent
  65187. * @param destination targeted world position
  65188. */
  65189. agentGoto(index: number, destination: Vector3): void;
  65190. /**
  65191. * Teleport the agent to a new position
  65192. * @param index agent index returned by addAgent
  65193. * @param destination targeted world position
  65194. */
  65195. agentTeleport(index: number, destination: Vector3): void;
  65196. /**
  65197. * Update agent parameters
  65198. * @param index agent index returned by addAgent
  65199. * @param parameters agent parameters
  65200. */
  65201. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65202. /**
  65203. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65204. * The queries will try to find a solution within those bounds
  65205. * default is (1,1,1)
  65206. * @param extent x,y,z value that define the extent around the queries point of reference
  65207. */
  65208. setDefaultQueryExtent(extent: Vector3): void;
  65209. /**
  65210. * Get the Bounding box extent specified by setDefaultQueryExtent
  65211. * @returns the box extent values
  65212. */
  65213. getDefaultQueryExtent(): Vector3;
  65214. /**
  65215. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65216. * @param result output the box extent values
  65217. */
  65218. getDefaultQueryExtentToRef(result: Vector3): void;
  65219. /**
  65220. * Release all resources
  65221. */
  65222. dispose(): void;
  65223. }
  65224. /**
  65225. * Configures an agent
  65226. */
  65227. export interface IAgentParameters {
  65228. /**
  65229. * Agent radius. [Limit: >= 0]
  65230. */
  65231. radius: number;
  65232. /**
  65233. * Agent height. [Limit: > 0]
  65234. */
  65235. height: number;
  65236. /**
  65237. * Maximum allowed acceleration. [Limit: >= 0]
  65238. */
  65239. maxAcceleration: number;
  65240. /**
  65241. * Maximum allowed speed. [Limit: >= 0]
  65242. */
  65243. maxSpeed: number;
  65244. /**
  65245. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65246. */
  65247. collisionQueryRange: number;
  65248. /**
  65249. * The path visibility optimization range. [Limit: > 0]
  65250. */
  65251. pathOptimizationRange: number;
  65252. /**
  65253. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65254. */
  65255. separationWeight: number;
  65256. }
  65257. /**
  65258. * Configures the navigation mesh creation
  65259. */
  65260. export interface INavMeshParameters {
  65261. /**
  65262. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65263. */
  65264. cs: number;
  65265. /**
  65266. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65267. */
  65268. ch: number;
  65269. /**
  65270. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65271. */
  65272. walkableSlopeAngle: number;
  65273. /**
  65274. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65275. * be considered walkable. [Limit: >= 3] [Units: vx]
  65276. */
  65277. walkableHeight: number;
  65278. /**
  65279. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65280. */
  65281. walkableClimb: number;
  65282. /**
  65283. * The distance to erode/shrink the walkable area of the heightfield away from
  65284. * obstructions. [Limit: >=0] [Units: vx]
  65285. */
  65286. walkableRadius: number;
  65287. /**
  65288. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65289. */
  65290. maxEdgeLen: number;
  65291. /**
  65292. * The maximum distance a simplfied contour's border edges should deviate
  65293. * the original raw contour. [Limit: >=0] [Units: vx]
  65294. */
  65295. maxSimplificationError: number;
  65296. /**
  65297. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65298. */
  65299. minRegionArea: number;
  65300. /**
  65301. * Any regions with a span count smaller than this value will, if possible,
  65302. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65303. */
  65304. mergeRegionArea: number;
  65305. /**
  65306. * The maximum number of vertices allowed for polygons generated during the
  65307. * contour to polygon conversion process. [Limit: >= 3]
  65308. */
  65309. maxVertsPerPoly: number;
  65310. /**
  65311. * Sets the sampling distance to use when generating the detail mesh.
  65312. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65313. */
  65314. detailSampleDist: number;
  65315. /**
  65316. * The maximum distance the detail mesh surface should deviate from heightfield
  65317. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65318. */
  65319. detailSampleMaxError: number;
  65320. }
  65321. }
  65322. declare module BABYLON {
  65323. /**
  65324. * RecastJS navigation plugin
  65325. */
  65326. export class RecastJSPlugin implements INavigationEnginePlugin {
  65327. /**
  65328. * Reference to the Recast library
  65329. */
  65330. bjsRECAST: any;
  65331. /**
  65332. * plugin name
  65333. */
  65334. name: string;
  65335. /**
  65336. * the first navmesh created. We might extend this to support multiple navmeshes
  65337. */
  65338. navMesh: any;
  65339. /**
  65340. * Initializes the recastJS plugin
  65341. * @param recastInjection can be used to inject your own recast reference
  65342. */
  65343. constructor(recastInjection?: any);
  65344. /**
  65345. * Creates a navigation mesh
  65346. * @param meshes array of all the geometry used to compute the navigatio mesh
  65347. * @param parameters bunch of parameters used to filter geometry
  65348. */
  65349. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65350. /**
  65351. * Create a navigation mesh debug mesh
  65352. * @param scene is where the mesh will be added
  65353. * @returns debug display mesh
  65354. */
  65355. createDebugNavMesh(scene: Scene): Mesh;
  65356. /**
  65357. * Get a navigation mesh constrained position, closest to the parameter position
  65358. * @param position world position
  65359. * @returns the closest point to position constrained by the navigation mesh
  65360. */
  65361. getClosestPoint(position: Vector3): Vector3;
  65362. /**
  65363. * Get a navigation mesh constrained position, closest to the parameter position
  65364. * @param position world position
  65365. * @param result output the closest point to position constrained by the navigation mesh
  65366. */
  65367. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65368. /**
  65369. * Get a navigation mesh constrained position, within a particular radius
  65370. * @param position world position
  65371. * @param maxRadius the maximum distance to the constrained world position
  65372. * @returns the closest point to position constrained by the navigation mesh
  65373. */
  65374. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65375. /**
  65376. * Get a navigation mesh constrained position, within a particular radius
  65377. * @param position world position
  65378. * @param maxRadius the maximum distance to the constrained world position
  65379. * @param result output the closest point to position constrained by the navigation mesh
  65380. */
  65381. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65382. /**
  65383. * Compute the final position from a segment made of destination-position
  65384. * @param position world position
  65385. * @param destination world position
  65386. * @returns the resulting point along the navmesh
  65387. */
  65388. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65389. /**
  65390. * Compute the final position from a segment made of destination-position
  65391. * @param position world position
  65392. * @param destination world position
  65393. * @param result output the resulting point along the navmesh
  65394. */
  65395. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65396. /**
  65397. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65398. * @param start world position
  65399. * @param end world position
  65400. * @returns array containing world position composing the path
  65401. */
  65402. computePath(start: Vector3, end: Vector3): Vector3[];
  65403. /**
  65404. * Create a new Crowd so you can add agents
  65405. * @param maxAgents the maximum agent count in the crowd
  65406. * @param maxAgentRadius the maximum radius an agent can have
  65407. * @param scene to attach the crowd to
  65408. * @returns the crowd you can add agents to
  65409. */
  65410. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65411. /**
  65412. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65413. * The queries will try to find a solution within those bounds
  65414. * default is (1,1,1)
  65415. * @param extent x,y,z value that define the extent around the queries point of reference
  65416. */
  65417. setDefaultQueryExtent(extent: Vector3): void;
  65418. /**
  65419. * Get the Bounding box extent specified by setDefaultQueryExtent
  65420. * @returns the box extent values
  65421. */
  65422. getDefaultQueryExtent(): Vector3;
  65423. /**
  65424. * build the navmesh from a previously saved state using getNavmeshData
  65425. * @param data the Uint8Array returned by getNavmeshData
  65426. */
  65427. buildFromNavmeshData(data: Uint8Array): void;
  65428. /**
  65429. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65430. * @returns data the Uint8Array that can be saved and reused
  65431. */
  65432. getNavmeshData(): Uint8Array;
  65433. /**
  65434. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65435. * @param result output the box extent values
  65436. */
  65437. getDefaultQueryExtentToRef(result: Vector3): void;
  65438. /**
  65439. * Disposes
  65440. */
  65441. dispose(): void;
  65442. /**
  65443. * If this plugin is supported
  65444. * @returns true if plugin is supported
  65445. */
  65446. isSupported(): boolean;
  65447. }
  65448. /**
  65449. * Recast detour crowd implementation
  65450. */
  65451. export class RecastJSCrowd implements ICrowd {
  65452. /**
  65453. * Recast/detour plugin
  65454. */
  65455. bjsRECASTPlugin: RecastJSPlugin;
  65456. /**
  65457. * Link to the detour crowd
  65458. */
  65459. recastCrowd: any;
  65460. /**
  65461. * One transform per agent
  65462. */
  65463. transforms: TransformNode[];
  65464. /**
  65465. * All agents created
  65466. */
  65467. agents: number[];
  65468. /**
  65469. * Link to the scene is kept to unregister the crowd from the scene
  65470. */
  65471. private _scene;
  65472. /**
  65473. * Observer for crowd updates
  65474. */
  65475. private _onBeforeAnimationsObserver;
  65476. /**
  65477. * Constructor
  65478. * @param plugin recastJS plugin
  65479. * @param maxAgents the maximum agent count in the crowd
  65480. * @param maxAgentRadius the maximum radius an agent can have
  65481. * @param scene to attach the crowd to
  65482. * @returns the crowd you can add agents to
  65483. */
  65484. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65485. /**
  65486. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65487. * You can attach anything to that node. The node position is updated in the scene update tick.
  65488. * @param pos world position that will be constrained by the navigation mesh
  65489. * @param parameters agent parameters
  65490. * @param transform hooked to the agent that will be update by the scene
  65491. * @returns agent index
  65492. */
  65493. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65494. /**
  65495. * Returns the agent position in world space
  65496. * @param index agent index returned by addAgent
  65497. * @returns world space position
  65498. */
  65499. getAgentPosition(index: number): Vector3;
  65500. /**
  65501. * Returns the agent position result in world space
  65502. * @param index agent index returned by addAgent
  65503. * @param result output world space position
  65504. */
  65505. getAgentPositionToRef(index: number, result: Vector3): void;
  65506. /**
  65507. * Returns the agent velocity in world space
  65508. * @param index agent index returned by addAgent
  65509. * @returns world space velocity
  65510. */
  65511. getAgentVelocity(index: number): Vector3;
  65512. /**
  65513. * Returns the agent velocity result in world space
  65514. * @param index agent index returned by addAgent
  65515. * @param result output world space velocity
  65516. */
  65517. getAgentVelocityToRef(index: number, result: Vector3): void;
  65518. /**
  65519. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65520. * @param index agent index returned by addAgent
  65521. * @param destination targeted world position
  65522. */
  65523. agentGoto(index: number, destination: Vector3): void;
  65524. /**
  65525. * Teleport the agent to a new position
  65526. * @param index agent index returned by addAgent
  65527. * @param destination targeted world position
  65528. */
  65529. agentTeleport(index: number, destination: Vector3): void;
  65530. /**
  65531. * Update agent parameters
  65532. * @param index agent index returned by addAgent
  65533. * @param parameters agent parameters
  65534. */
  65535. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65536. /**
  65537. * remove a particular agent previously created
  65538. * @param index agent index returned by addAgent
  65539. */
  65540. removeAgent(index: number): void;
  65541. /**
  65542. * get the list of all agents attached to this crowd
  65543. * @returns list of agent indices
  65544. */
  65545. getAgents(): number[];
  65546. /**
  65547. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65548. * @param deltaTime in seconds
  65549. */
  65550. update(deltaTime: number): void;
  65551. /**
  65552. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65553. * The queries will try to find a solution within those bounds
  65554. * default is (1,1,1)
  65555. * @param extent x,y,z value that define the extent around the queries point of reference
  65556. */
  65557. setDefaultQueryExtent(extent: Vector3): void;
  65558. /**
  65559. * Get the Bounding box extent specified by setDefaultQueryExtent
  65560. * @returns the box extent values
  65561. */
  65562. getDefaultQueryExtent(): Vector3;
  65563. /**
  65564. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65565. * @param result output the box extent values
  65566. */
  65567. getDefaultQueryExtentToRef(result: Vector3): void;
  65568. /**
  65569. * Release all resources
  65570. */
  65571. dispose(): void;
  65572. }
  65573. }
  65574. declare module BABYLON {
  65575. /**
  65576. * Class used to enable access to IndexedDB
  65577. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65578. */
  65579. export class Database implements IOfflineProvider {
  65580. private _callbackManifestChecked;
  65581. private _currentSceneUrl;
  65582. private _db;
  65583. private _enableSceneOffline;
  65584. private _enableTexturesOffline;
  65585. private _manifestVersionFound;
  65586. private _mustUpdateRessources;
  65587. private _hasReachedQuota;
  65588. private _isSupported;
  65589. private _idbFactory;
  65590. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65591. private static IsUASupportingBlobStorage;
  65592. /**
  65593. * Gets a boolean indicating if Database storate is enabled (off by default)
  65594. */
  65595. static IDBStorageEnabled: boolean;
  65596. /**
  65597. * Gets a boolean indicating if scene must be saved in the database
  65598. */
  65599. get enableSceneOffline(): boolean;
  65600. /**
  65601. * Gets a boolean indicating if textures must be saved in the database
  65602. */
  65603. get enableTexturesOffline(): boolean;
  65604. /**
  65605. * Creates a new Database
  65606. * @param urlToScene defines the url to load the scene
  65607. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65608. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65609. */
  65610. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65611. private static _ParseURL;
  65612. private static _ReturnFullUrlLocation;
  65613. private _checkManifestFile;
  65614. /**
  65615. * Open the database and make it available
  65616. * @param successCallback defines the callback to call on success
  65617. * @param errorCallback defines the callback to call on error
  65618. */
  65619. open(successCallback: () => void, errorCallback: () => void): void;
  65620. /**
  65621. * Loads an image from the database
  65622. * @param url defines the url to load from
  65623. * @param image defines the target DOM image
  65624. */
  65625. loadImage(url: string, image: HTMLImageElement): void;
  65626. private _loadImageFromDBAsync;
  65627. private _saveImageIntoDBAsync;
  65628. private _checkVersionFromDB;
  65629. private _loadVersionFromDBAsync;
  65630. private _saveVersionIntoDBAsync;
  65631. /**
  65632. * Loads a file from database
  65633. * @param url defines the URL to load from
  65634. * @param sceneLoaded defines a callback to call on success
  65635. * @param progressCallBack defines a callback to call when progress changed
  65636. * @param errorCallback defines a callback to call on error
  65637. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65638. */
  65639. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65640. private _loadFileAsync;
  65641. private _saveFileAsync;
  65642. /**
  65643. * Validates if xhr data is correct
  65644. * @param xhr defines the request to validate
  65645. * @param dataType defines the expected data type
  65646. * @returns true if data is correct
  65647. */
  65648. private static _ValidateXHRData;
  65649. }
  65650. }
  65651. declare module BABYLON {
  65652. /** @hidden */
  65653. export var gpuUpdateParticlesPixelShader: {
  65654. name: string;
  65655. shader: string;
  65656. };
  65657. }
  65658. declare module BABYLON {
  65659. /** @hidden */
  65660. export var gpuUpdateParticlesVertexShader: {
  65661. name: string;
  65662. shader: string;
  65663. };
  65664. }
  65665. declare module BABYLON {
  65666. /** @hidden */
  65667. export var clipPlaneFragmentDeclaration2: {
  65668. name: string;
  65669. shader: string;
  65670. };
  65671. }
  65672. declare module BABYLON {
  65673. /** @hidden */
  65674. export var gpuRenderParticlesPixelShader: {
  65675. name: string;
  65676. shader: string;
  65677. };
  65678. }
  65679. declare module BABYLON {
  65680. /** @hidden */
  65681. export var clipPlaneVertexDeclaration2: {
  65682. name: string;
  65683. shader: string;
  65684. };
  65685. }
  65686. declare module BABYLON {
  65687. /** @hidden */
  65688. export var gpuRenderParticlesVertexShader: {
  65689. name: string;
  65690. shader: string;
  65691. };
  65692. }
  65693. declare module BABYLON {
  65694. /**
  65695. * This represents a GPU particle system in Babylon
  65696. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65697. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65698. */
  65699. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65700. /**
  65701. * The layer mask we are rendering the particles through.
  65702. */
  65703. layerMask: number;
  65704. private _capacity;
  65705. private _activeCount;
  65706. private _currentActiveCount;
  65707. private _accumulatedCount;
  65708. private _renderEffect;
  65709. private _updateEffect;
  65710. private _buffer0;
  65711. private _buffer1;
  65712. private _spriteBuffer;
  65713. private _updateVAO;
  65714. private _renderVAO;
  65715. private _targetIndex;
  65716. private _sourceBuffer;
  65717. private _targetBuffer;
  65718. private _engine;
  65719. private _currentRenderId;
  65720. private _started;
  65721. private _stopped;
  65722. private _timeDelta;
  65723. private _randomTexture;
  65724. private _randomTexture2;
  65725. private _attributesStrideSize;
  65726. private _updateEffectOptions;
  65727. private _randomTextureSize;
  65728. private _actualFrame;
  65729. private _customEffect;
  65730. private readonly _rawTextureWidth;
  65731. /**
  65732. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65733. */
  65734. static get IsSupported(): boolean;
  65735. /**
  65736. * An event triggered when the system is disposed.
  65737. */
  65738. onDisposeObservable: Observable<IParticleSystem>;
  65739. /**
  65740. * Gets the maximum number of particles active at the same time.
  65741. * @returns The max number of active particles.
  65742. */
  65743. getCapacity(): number;
  65744. /**
  65745. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65746. * to override the particles.
  65747. */
  65748. forceDepthWrite: boolean;
  65749. /**
  65750. * Gets or set the number of active particles
  65751. */
  65752. get activeParticleCount(): number;
  65753. set activeParticleCount(value: number);
  65754. private _preWarmDone;
  65755. /**
  65756. * Specifies if the particles are updated in emitter local space or world space.
  65757. */
  65758. isLocal: boolean;
  65759. /**
  65760. * Is this system ready to be used/rendered
  65761. * @return true if the system is ready
  65762. */
  65763. isReady(): boolean;
  65764. /**
  65765. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65766. * @returns True if it has been started, otherwise false.
  65767. */
  65768. isStarted(): boolean;
  65769. /**
  65770. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  65771. * @returns True if it has been stopped, otherwise false.
  65772. */
  65773. isStopped(): boolean;
  65774. /**
  65775. * Gets a boolean indicating that the system is stopping
  65776. * @returns true if the system is currently stopping
  65777. */
  65778. isStopping(): boolean;
  65779. /**
  65780. * Gets the number of particles active at the same time.
  65781. * @returns The number of active particles.
  65782. */
  65783. getActiveCount(): number;
  65784. /**
  65785. * Starts the particle system and begins to emit
  65786. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65787. */
  65788. start(delay?: number): void;
  65789. /**
  65790. * Stops the particle system.
  65791. */
  65792. stop(): void;
  65793. /**
  65794. * Remove all active particles
  65795. */
  65796. reset(): void;
  65797. /**
  65798. * Returns the string "GPUParticleSystem"
  65799. * @returns a string containing the class name
  65800. */
  65801. getClassName(): string;
  65802. /**
  65803. * Gets the custom effect used to render the particles
  65804. * @param blendMode Blend mode for which the effect should be retrieved
  65805. * @returns The effect
  65806. */
  65807. getCustomEffect(blendMode?: number): Nullable<Effect>;
  65808. /**
  65809. * Sets the custom effect used to render the particles
  65810. * @param effect The effect to set
  65811. * @param blendMode Blend mode for which the effect should be set
  65812. */
  65813. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  65814. /** @hidden */
  65815. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  65816. /**
  65817. * Observable that will be called just before the particles are drawn
  65818. */
  65819. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  65820. /**
  65821. * Gets the name of the particle vertex shader
  65822. */
  65823. get vertexShaderName(): string;
  65824. private _colorGradientsTexture;
  65825. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65826. /**
  65827. * Adds a new color gradient
  65828. * @param gradient defines the gradient to use (between 0 and 1)
  65829. * @param color1 defines the color to affect to the specified gradient
  65830. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65831. * @returns the current particle system
  65832. */
  65833. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65834. private _refreshColorGradient;
  65835. /** Force the system to rebuild all gradients that need to be resync */
  65836. forceRefreshGradients(): void;
  65837. /**
  65838. * Remove a specific color gradient
  65839. * @param gradient defines the gradient to remove
  65840. * @returns the current particle system
  65841. */
  65842. removeColorGradient(gradient: number): GPUParticleSystem;
  65843. private _angularSpeedGradientsTexture;
  65844. private _sizeGradientsTexture;
  65845. private _velocityGradientsTexture;
  65846. private _limitVelocityGradientsTexture;
  65847. private _dragGradientsTexture;
  65848. private _addFactorGradient;
  65849. /**
  65850. * Adds a new size gradient
  65851. * @param gradient defines the gradient to use (between 0 and 1)
  65852. * @param factor defines the size factor to affect to the specified gradient
  65853. * @returns the current particle system
  65854. */
  65855. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65856. /**
  65857. * Remove a specific size gradient
  65858. * @param gradient defines the gradient to remove
  65859. * @returns the current particle system
  65860. */
  65861. removeSizeGradient(gradient: number): GPUParticleSystem;
  65862. private _refreshFactorGradient;
  65863. /**
  65864. * Adds a new angular speed gradient
  65865. * @param gradient defines the gradient to use (between 0 and 1)
  65866. * @param factor defines the angular speed to affect to the specified gradient
  65867. * @returns the current particle system
  65868. */
  65869. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65870. /**
  65871. * Remove a specific angular speed gradient
  65872. * @param gradient defines the gradient to remove
  65873. * @returns the current particle system
  65874. */
  65875. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65876. /**
  65877. * Adds a new velocity gradient
  65878. * @param gradient defines the gradient to use (between 0 and 1)
  65879. * @param factor defines the velocity to affect to the specified gradient
  65880. * @returns the current particle system
  65881. */
  65882. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65883. /**
  65884. * Remove a specific velocity gradient
  65885. * @param gradient defines the gradient to remove
  65886. * @returns the current particle system
  65887. */
  65888. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65889. /**
  65890. * Adds a new limit velocity gradient
  65891. * @param gradient defines the gradient to use (between 0 and 1)
  65892. * @param factor defines the limit velocity value to affect to the specified gradient
  65893. * @returns the current particle system
  65894. */
  65895. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65896. /**
  65897. * Remove a specific limit velocity gradient
  65898. * @param gradient defines the gradient to remove
  65899. * @returns the current particle system
  65900. */
  65901. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65902. /**
  65903. * Adds a new drag gradient
  65904. * @param gradient defines the gradient to use (between 0 and 1)
  65905. * @param factor defines the drag value to affect to the specified gradient
  65906. * @returns the current particle system
  65907. */
  65908. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65909. /**
  65910. * Remove a specific drag gradient
  65911. * @param gradient defines the gradient to remove
  65912. * @returns the current particle system
  65913. */
  65914. removeDragGradient(gradient: number): GPUParticleSystem;
  65915. /**
  65916. * Not supported by GPUParticleSystem
  65917. * @param gradient defines the gradient to use (between 0 and 1)
  65918. * @param factor defines the emit rate value to affect to the specified gradient
  65919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65920. * @returns the current particle system
  65921. */
  65922. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65923. /**
  65924. * Not supported by GPUParticleSystem
  65925. * @param gradient defines the gradient to remove
  65926. * @returns the current particle system
  65927. */
  65928. removeEmitRateGradient(gradient: number): IParticleSystem;
  65929. /**
  65930. * Not supported by GPUParticleSystem
  65931. * @param gradient defines the gradient to use (between 0 and 1)
  65932. * @param factor defines the start size value to affect to the specified gradient
  65933. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65934. * @returns the current particle system
  65935. */
  65936. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65937. /**
  65938. * Not supported by GPUParticleSystem
  65939. * @param gradient defines the gradient to remove
  65940. * @returns the current particle system
  65941. */
  65942. removeStartSizeGradient(gradient: number): IParticleSystem;
  65943. /**
  65944. * Not supported by GPUParticleSystem
  65945. * @param gradient defines the gradient to use (between 0 and 1)
  65946. * @param min defines the color remap minimal range
  65947. * @param max defines the color remap maximal range
  65948. * @returns the current particle system
  65949. */
  65950. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65951. /**
  65952. * Not supported by GPUParticleSystem
  65953. * @param gradient defines the gradient to remove
  65954. * @returns the current particle system
  65955. */
  65956. removeColorRemapGradient(): IParticleSystem;
  65957. /**
  65958. * Not supported by GPUParticleSystem
  65959. * @param gradient defines the gradient to use (between 0 and 1)
  65960. * @param min defines the alpha remap minimal range
  65961. * @param max defines the alpha remap maximal range
  65962. * @returns the current particle system
  65963. */
  65964. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65965. /**
  65966. * Not supported by GPUParticleSystem
  65967. * @param gradient defines the gradient to remove
  65968. * @returns the current particle system
  65969. */
  65970. removeAlphaRemapGradient(): IParticleSystem;
  65971. /**
  65972. * Not supported by GPUParticleSystem
  65973. * @param gradient defines the gradient to use (between 0 and 1)
  65974. * @param color defines the color to affect to the specified gradient
  65975. * @returns the current particle system
  65976. */
  65977. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65978. /**
  65979. * Not supported by GPUParticleSystem
  65980. * @param gradient defines the gradient to remove
  65981. * @returns the current particle system
  65982. */
  65983. removeRampGradient(): IParticleSystem;
  65984. /**
  65985. * Not supported by GPUParticleSystem
  65986. * @returns the list of ramp gradients
  65987. */
  65988. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65989. /**
  65990. * Not supported by GPUParticleSystem
  65991. * Gets or sets a boolean indicating that ramp gradients must be used
  65992. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65993. */
  65994. get useRampGradients(): boolean;
  65995. set useRampGradients(value: boolean);
  65996. /**
  65997. * Not supported by GPUParticleSystem
  65998. * @param gradient defines the gradient to use (between 0 and 1)
  65999. * @param factor defines the life time factor to affect to the specified gradient
  66000. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66001. * @returns the current particle system
  66002. */
  66003. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66004. /**
  66005. * Not supported by GPUParticleSystem
  66006. * @param gradient defines the gradient to remove
  66007. * @returns the current particle system
  66008. */
  66009. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66010. /**
  66011. * Instantiates a GPU particle system.
  66012. * 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.
  66013. * @param name The name of the particle system
  66014. * @param options The options used to create the system
  66015. * @param scene The scene the particle system belongs to
  66016. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66017. * @param customEffect a custom effect used to change the way particles are rendered by default
  66018. */
  66019. constructor(name: string, options: Partial<{
  66020. capacity: number;
  66021. randomTextureSize: number;
  66022. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66023. protected _reset(): void;
  66024. private _createUpdateVAO;
  66025. private _createRenderVAO;
  66026. private _initialize;
  66027. /** @hidden */
  66028. _recreateUpdateEffect(): void;
  66029. private _getEffect;
  66030. /**
  66031. * Fill the defines array according to the current settings of the particle system
  66032. * @param defines Array to be updated
  66033. * @param blendMode blend mode to take into account when updating the array
  66034. */
  66035. fillDefines(defines: Array<string>, blendMode?: number): void;
  66036. /**
  66037. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66038. * @param uniforms Uniforms array to fill
  66039. * @param attributes Attributes array to fill
  66040. * @param samplers Samplers array to fill
  66041. */
  66042. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66043. /** @hidden */
  66044. _recreateRenderEffect(): Effect;
  66045. /**
  66046. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66047. * @param preWarm defines if we are in the pre-warmimg phase
  66048. */
  66049. animate(preWarm?: boolean): void;
  66050. private _createFactorGradientTexture;
  66051. private _createSizeGradientTexture;
  66052. private _createAngularSpeedGradientTexture;
  66053. private _createVelocityGradientTexture;
  66054. private _createLimitVelocityGradientTexture;
  66055. private _createDragGradientTexture;
  66056. private _createColorGradientTexture;
  66057. /**
  66058. * Renders the particle system in its current state
  66059. * @param preWarm defines if the system should only update the particles but not render them
  66060. * @returns the current number of particles
  66061. */
  66062. render(preWarm?: boolean): number;
  66063. /**
  66064. * Rebuilds the particle system
  66065. */
  66066. rebuild(): void;
  66067. private _releaseBuffers;
  66068. private _releaseVAOs;
  66069. /**
  66070. * Disposes the particle system and free the associated resources
  66071. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66072. */
  66073. dispose(disposeTexture?: boolean): void;
  66074. /**
  66075. * Clones the particle system.
  66076. * @param name The name of the cloned object
  66077. * @param newEmitter The new emitter to use
  66078. * @returns the cloned particle system
  66079. */
  66080. clone(name: string, newEmitter: any): GPUParticleSystem;
  66081. /**
  66082. * Serializes the particle system to a JSON object
  66083. * @param serializeTexture defines if the texture must be serialized as well
  66084. * @returns the JSON object
  66085. */
  66086. serialize(serializeTexture?: boolean): any;
  66087. /**
  66088. * Parses a JSON object to create a GPU particle system.
  66089. * @param parsedParticleSystem The JSON object to parse
  66090. * @param scene The scene to create the particle system in
  66091. * @param rootUrl The root url to use to load external dependencies like texture
  66092. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66093. * @returns the parsed GPU particle system
  66094. */
  66095. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66096. }
  66097. }
  66098. declare module BABYLON {
  66099. /**
  66100. * Represents a set of particle systems working together to create a specific effect
  66101. */
  66102. export class ParticleSystemSet implements IDisposable {
  66103. /**
  66104. * Gets or sets base Assets URL
  66105. */
  66106. static BaseAssetsUrl: string;
  66107. private _emitterCreationOptions;
  66108. private _emitterNode;
  66109. /**
  66110. * Gets the particle system list
  66111. */
  66112. systems: IParticleSystem[];
  66113. /**
  66114. * Gets the emitter node used with this set
  66115. */
  66116. get emitterNode(): Nullable<TransformNode>;
  66117. /**
  66118. * Creates a new emitter mesh as a sphere
  66119. * @param options defines the options used to create the sphere
  66120. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66121. * @param scene defines the hosting scene
  66122. */
  66123. setEmitterAsSphere(options: {
  66124. diameter: number;
  66125. segments: number;
  66126. color: Color3;
  66127. }, renderingGroupId: number, scene: Scene): void;
  66128. /**
  66129. * Starts all particle systems of the set
  66130. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66131. */
  66132. start(emitter?: AbstractMesh): void;
  66133. /**
  66134. * Release all associated resources
  66135. */
  66136. dispose(): void;
  66137. /**
  66138. * Serialize the set into a JSON compatible object
  66139. * @param serializeTexture defines if the texture must be serialized as well
  66140. * @returns a JSON compatible representation of the set
  66141. */
  66142. serialize(serializeTexture?: boolean): any;
  66143. /**
  66144. * Parse a new ParticleSystemSet from a serialized source
  66145. * @param data defines a JSON compatible representation of the set
  66146. * @param scene defines the hosting scene
  66147. * @param gpu defines if we want GPU particles or CPU particles
  66148. * @returns a new ParticleSystemSet
  66149. */
  66150. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66151. }
  66152. }
  66153. declare module BABYLON {
  66154. /**
  66155. * This class is made for on one-liner static method to help creating particle system set.
  66156. */
  66157. export class ParticleHelper {
  66158. /**
  66159. * Gets or sets base Assets URL
  66160. */
  66161. static BaseAssetsUrl: string;
  66162. /** Define the Url to load snippets */
  66163. static SnippetUrl: string;
  66164. /**
  66165. * Create a default particle system that you can tweak
  66166. * @param emitter defines the emitter to use
  66167. * @param capacity defines the system capacity (default is 500 particles)
  66168. * @param scene defines the hosting scene
  66169. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66170. * @returns the new Particle system
  66171. */
  66172. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66173. /**
  66174. * This is the main static method (one-liner) of this helper to create different particle systems
  66175. * @param type This string represents the type to the particle system to create
  66176. * @param scene The scene where the particle system should live
  66177. * @param gpu If the system will use gpu
  66178. * @returns the ParticleSystemSet created
  66179. */
  66180. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66181. /**
  66182. * Static function used to export a particle system to a ParticleSystemSet variable.
  66183. * Please note that the emitter shape is not exported
  66184. * @param systems defines the particle systems to export
  66185. * @returns the created particle system set
  66186. */
  66187. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66188. /**
  66189. * Creates a particle system from a snippet saved in a remote file
  66190. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66191. * @param url defines the url to load from
  66192. * @param scene defines the hosting scene
  66193. * @param gpu If the system will use gpu
  66194. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66195. * @returns a promise that will resolve to the new particle system
  66196. */
  66197. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66198. /**
  66199. * Creates a particle system from a snippet saved by the particle system editor
  66200. * @param snippetId defines the snippet to load
  66201. * @param scene defines the hosting scene
  66202. * @param gpu If the system will use gpu
  66203. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66204. * @returns a promise that will resolve to the new particle system
  66205. */
  66206. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66207. }
  66208. }
  66209. declare module BABYLON {
  66210. interface Engine {
  66211. /**
  66212. * Create an effect to use with particle systems.
  66213. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66214. * the particle system for which you want to create a custom effect in the last parameter
  66215. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66216. * @param uniformsNames defines a list of attribute names
  66217. * @param samplers defines an array of string used to represent textures
  66218. * @param defines defines the string containing the defines to use to compile the shaders
  66219. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66220. * @param onCompiled defines a function to call when the effect creation is successful
  66221. * @param onError defines a function to call when the effect creation has failed
  66222. * @param particleSystem the particle system you want to create the effect for
  66223. * @returns the new Effect
  66224. */
  66225. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66226. }
  66227. interface Mesh {
  66228. /**
  66229. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66230. * @returns an array of IParticleSystem
  66231. */
  66232. getEmittedParticleSystems(): IParticleSystem[];
  66233. /**
  66234. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66235. * @returns an array of IParticleSystem
  66236. */
  66237. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66238. }
  66239. }
  66240. declare module BABYLON {
  66241. /** Defines the 4 color options */
  66242. export enum PointColor {
  66243. /** color value */
  66244. Color = 2,
  66245. /** uv value */
  66246. UV = 1,
  66247. /** random value */
  66248. Random = 0,
  66249. /** stated value */
  66250. Stated = 3
  66251. }
  66252. /**
  66253. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66254. * 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.
  66255. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66256. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66257. *
  66258. * Full documentation here : TO BE ENTERED
  66259. */
  66260. export class PointsCloudSystem implements IDisposable {
  66261. /**
  66262. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66263. * Example : var p = SPS.particles[i];
  66264. */
  66265. particles: CloudPoint[];
  66266. /**
  66267. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66268. */
  66269. nbParticles: number;
  66270. /**
  66271. * This a counter for your own usage. It's not set by any SPS functions.
  66272. */
  66273. counter: number;
  66274. /**
  66275. * The PCS name. This name is also given to the underlying mesh.
  66276. */
  66277. name: string;
  66278. /**
  66279. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66280. */
  66281. mesh: Mesh;
  66282. /**
  66283. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66284. * Please read :
  66285. */
  66286. vars: any;
  66287. /**
  66288. * @hidden
  66289. */
  66290. _size: number;
  66291. private _scene;
  66292. private _promises;
  66293. private _positions;
  66294. private _indices;
  66295. private _normals;
  66296. private _colors;
  66297. private _uvs;
  66298. private _indices32;
  66299. private _positions32;
  66300. private _colors32;
  66301. private _uvs32;
  66302. private _updatable;
  66303. private _isVisibilityBoxLocked;
  66304. private _alwaysVisible;
  66305. private _groups;
  66306. private _groupCounter;
  66307. private _computeParticleColor;
  66308. private _computeParticleTexture;
  66309. private _computeParticleRotation;
  66310. private _computeBoundingBox;
  66311. private _isReady;
  66312. /**
  66313. * Creates a PCS (Points Cloud System) object
  66314. * @param name (String) is the PCS name, this will be the underlying mesh name
  66315. * @param pointSize (number) is the size for each point
  66316. * @param scene (Scene) is the scene in which the PCS is added
  66317. * @param options defines the options of the PCS e.g.
  66318. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66319. */
  66320. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66321. updatable?: boolean;
  66322. });
  66323. /**
  66324. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66325. * If no points were added to the PCS, the returned mesh is just a single point.
  66326. * @returns a promise for the created mesh
  66327. */
  66328. buildMeshAsync(): Promise<Mesh>;
  66329. /**
  66330. * @hidden
  66331. */
  66332. private _buildMesh;
  66333. private _addParticle;
  66334. private _randomUnitVector;
  66335. private _getColorIndicesForCoord;
  66336. private _setPointsColorOrUV;
  66337. private _colorFromTexture;
  66338. private _calculateDensity;
  66339. /**
  66340. * Adds points to the PCS in random positions within a unit sphere
  66341. * @param nb (positive integer) the number of particles to be created from this model
  66342. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66343. * @returns the number of groups in the system
  66344. */
  66345. addPoints(nb: number, pointFunction?: any): number;
  66346. /**
  66347. * Adds points to the PCS from the surface of the model shape
  66348. * @param mesh is any Mesh object that will be used as a surface model for the points
  66349. * @param nb (positive integer) the number of particles to be created from this model
  66350. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66351. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66352. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66353. * @returns the number of groups in the system
  66354. */
  66355. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66356. /**
  66357. * Adds points to the PCS inside the model shape
  66358. * @param mesh is any Mesh object that will be used as a surface model for the points
  66359. * @param nb (positive integer) the number of particles to be created from this model
  66360. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66361. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66362. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66363. * @returns the number of groups in the system
  66364. */
  66365. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66366. /**
  66367. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66368. * This method calls `updateParticle()` for each particle of the SPS.
  66369. * For an animated SPS, it is usually called within the render loop.
  66370. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66371. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66372. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66373. * @returns the PCS.
  66374. */
  66375. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66376. /**
  66377. * Disposes the PCS.
  66378. */
  66379. dispose(): void;
  66380. /**
  66381. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66382. * doc :
  66383. * @returns the PCS.
  66384. */
  66385. refreshVisibleSize(): PointsCloudSystem;
  66386. /**
  66387. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66388. * @param size the size (float) of the visibility box
  66389. * note : this doesn't lock the PCS mesh bounding box.
  66390. * doc :
  66391. */
  66392. setVisibilityBox(size: number): void;
  66393. /**
  66394. * Gets whether the PCS is always visible or not
  66395. * doc :
  66396. */
  66397. get isAlwaysVisible(): boolean;
  66398. /**
  66399. * Sets the PCS as always visible or not
  66400. * doc :
  66401. */
  66402. set isAlwaysVisible(val: boolean);
  66403. /**
  66404. * Tells to `setParticles()` to compute the particle rotations or not
  66405. * Default value : false. The PCS is faster when it's set to false
  66406. * Note : particle rotations are only applied to parent particles
  66407. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66408. */
  66409. set computeParticleRotation(val: boolean);
  66410. /**
  66411. * Tells to `setParticles()` to compute the particle colors or not.
  66412. * Default value : true. The PCS is faster when it's set to false.
  66413. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66414. */
  66415. set computeParticleColor(val: boolean);
  66416. set computeParticleTexture(val: boolean);
  66417. /**
  66418. * Gets if `setParticles()` computes the particle colors or not.
  66419. * Default value : false. The PCS is faster when it's set to false.
  66420. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66421. */
  66422. get computeParticleColor(): boolean;
  66423. /**
  66424. * Gets if `setParticles()` computes the particle textures or not.
  66425. * Default value : false. The PCS is faster when it's set to false.
  66426. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66427. */
  66428. get computeParticleTexture(): boolean;
  66429. /**
  66430. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66431. */
  66432. set computeBoundingBox(val: boolean);
  66433. /**
  66434. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66435. */
  66436. get computeBoundingBox(): boolean;
  66437. /**
  66438. * This function does nothing. It may be overwritten to set all the particle first values.
  66439. * The PCS doesn't call this function, you may have to call it by your own.
  66440. * doc :
  66441. */
  66442. initParticles(): void;
  66443. /**
  66444. * This function does nothing. It may be overwritten to recycle a particle
  66445. * The PCS doesn't call this function, you can to call it
  66446. * doc :
  66447. * @param particle The particle to recycle
  66448. * @returns the recycled particle
  66449. */
  66450. recycleParticle(particle: CloudPoint): CloudPoint;
  66451. /**
  66452. * Updates a particle : this function should be overwritten by the user.
  66453. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66454. * doc :
  66455. * @example : just set a particle position or velocity and recycle conditions
  66456. * @param particle The particle to update
  66457. * @returns the updated particle
  66458. */
  66459. updateParticle(particle: CloudPoint): CloudPoint;
  66460. /**
  66461. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66462. * This does nothing and may be overwritten by the user.
  66463. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66464. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66465. * @param update the boolean update value actually passed to setParticles()
  66466. */
  66467. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66468. /**
  66469. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66470. * This will be passed three parameters.
  66471. * This does nothing and may be overwritten by the user.
  66472. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66473. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66474. * @param update the boolean update value actually passed to setParticles()
  66475. */
  66476. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66477. }
  66478. }
  66479. declare module BABYLON {
  66480. /**
  66481. * Represents one particle of a points cloud system.
  66482. */
  66483. export class CloudPoint {
  66484. /**
  66485. * particle global index
  66486. */
  66487. idx: number;
  66488. /**
  66489. * The color of the particle
  66490. */
  66491. color: Nullable<Color4>;
  66492. /**
  66493. * The world space position of the particle.
  66494. */
  66495. position: Vector3;
  66496. /**
  66497. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66498. */
  66499. rotation: Vector3;
  66500. /**
  66501. * The world space rotation quaternion of the particle.
  66502. */
  66503. rotationQuaternion: Nullable<Quaternion>;
  66504. /**
  66505. * The uv of the particle.
  66506. */
  66507. uv: Nullable<Vector2>;
  66508. /**
  66509. * The current speed of the particle.
  66510. */
  66511. velocity: Vector3;
  66512. /**
  66513. * The pivot point in the particle local space.
  66514. */
  66515. pivot: Vector3;
  66516. /**
  66517. * Must the particle be translated from its pivot point in its local space ?
  66518. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66519. * Default : false
  66520. */
  66521. translateFromPivot: boolean;
  66522. /**
  66523. * Index of this particle in the global "positions" array (Internal use)
  66524. * @hidden
  66525. */
  66526. _pos: number;
  66527. /**
  66528. * @hidden Index of this particle in the global "indices" array (Internal use)
  66529. */
  66530. _ind: number;
  66531. /**
  66532. * Group this particle belongs to
  66533. */
  66534. _group: PointsGroup;
  66535. /**
  66536. * Group id of this particle
  66537. */
  66538. groupId: number;
  66539. /**
  66540. * Index of the particle in its group id (Internal use)
  66541. */
  66542. idxInGroup: number;
  66543. /**
  66544. * @hidden Particle BoundingInfo object (Internal use)
  66545. */
  66546. _boundingInfo: BoundingInfo;
  66547. /**
  66548. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66549. */
  66550. _pcs: PointsCloudSystem;
  66551. /**
  66552. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66553. */
  66554. _stillInvisible: boolean;
  66555. /**
  66556. * @hidden Last computed particle rotation matrix
  66557. */
  66558. _rotationMatrix: number[];
  66559. /**
  66560. * Parent particle Id, if any.
  66561. * Default null.
  66562. */
  66563. parentId: Nullable<number>;
  66564. /**
  66565. * @hidden Internal global position in the PCS.
  66566. */
  66567. _globalPosition: Vector3;
  66568. /**
  66569. * Creates a Point Cloud object.
  66570. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66571. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66572. * @param group (PointsGroup) is the group the particle belongs to
  66573. * @param groupId (integer) is the group identifier in the PCS.
  66574. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66575. * @param pcs defines the PCS it is associated to
  66576. */
  66577. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66578. /**
  66579. * get point size
  66580. */
  66581. get size(): Vector3;
  66582. /**
  66583. * Set point size
  66584. */
  66585. set size(scale: Vector3);
  66586. /**
  66587. * Legacy support, changed quaternion to rotationQuaternion
  66588. */
  66589. get quaternion(): Nullable<Quaternion>;
  66590. /**
  66591. * Legacy support, changed quaternion to rotationQuaternion
  66592. */
  66593. set quaternion(q: Nullable<Quaternion>);
  66594. /**
  66595. * Returns a boolean. True if the particle intersects a mesh, else false
  66596. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66597. * @param target is the object (point or mesh) what the intersection is computed against
  66598. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66599. * @returns true if it intersects
  66600. */
  66601. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66602. /**
  66603. * get the rotation matrix of the particle
  66604. * @hidden
  66605. */
  66606. getRotationMatrix(m: Matrix): void;
  66607. }
  66608. /**
  66609. * Represents a group of points in a points cloud system
  66610. * * PCS internal tool, don't use it manually.
  66611. */
  66612. export class PointsGroup {
  66613. /**
  66614. * The group id
  66615. * @hidden
  66616. */
  66617. groupID: number;
  66618. /**
  66619. * image data for group (internal use)
  66620. * @hidden
  66621. */
  66622. _groupImageData: Nullable<ArrayBufferView>;
  66623. /**
  66624. * Image Width (internal use)
  66625. * @hidden
  66626. */
  66627. _groupImgWidth: number;
  66628. /**
  66629. * Image Height (internal use)
  66630. * @hidden
  66631. */
  66632. _groupImgHeight: number;
  66633. /**
  66634. * Custom position function (internal use)
  66635. * @hidden
  66636. */
  66637. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66638. /**
  66639. * density per facet for surface points
  66640. * @hidden
  66641. */
  66642. _groupDensity: number[];
  66643. /**
  66644. * Only when points are colored by texture carries pointer to texture list array
  66645. * @hidden
  66646. */
  66647. _textureNb: number;
  66648. /**
  66649. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66650. * PCS internal tool, don't use it manually.
  66651. * @hidden
  66652. */
  66653. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66654. }
  66655. }
  66656. declare module BABYLON {
  66657. interface Scene {
  66658. /** @hidden (Backing field) */
  66659. _physicsEngine: Nullable<IPhysicsEngine>;
  66660. /** @hidden */
  66661. _physicsTimeAccumulator: number;
  66662. /**
  66663. * Gets the current physics engine
  66664. * @returns a IPhysicsEngine or null if none attached
  66665. */
  66666. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66667. /**
  66668. * Enables physics to the current scene
  66669. * @param gravity defines the scene's gravity for the physics engine
  66670. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66671. * @return a boolean indicating if the physics engine was initialized
  66672. */
  66673. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66674. /**
  66675. * Disables and disposes the physics engine associated with the scene
  66676. */
  66677. disablePhysicsEngine(): void;
  66678. /**
  66679. * Gets a boolean indicating if there is an active physics engine
  66680. * @returns a boolean indicating if there is an active physics engine
  66681. */
  66682. isPhysicsEnabled(): boolean;
  66683. /**
  66684. * Deletes a physics compound impostor
  66685. * @param compound defines the compound to delete
  66686. */
  66687. deleteCompoundImpostor(compound: any): void;
  66688. /**
  66689. * An event triggered when physic simulation is about to be run
  66690. */
  66691. onBeforePhysicsObservable: Observable<Scene>;
  66692. /**
  66693. * An event triggered when physic simulation has been done
  66694. */
  66695. onAfterPhysicsObservable: Observable<Scene>;
  66696. }
  66697. interface AbstractMesh {
  66698. /** @hidden */
  66699. _physicsImpostor: Nullable<PhysicsImpostor>;
  66700. /**
  66701. * Gets or sets impostor used for physic simulation
  66702. * @see http://doc.babylonjs.com/features/physics_engine
  66703. */
  66704. physicsImpostor: Nullable<PhysicsImpostor>;
  66705. /**
  66706. * Gets the current physics impostor
  66707. * @see http://doc.babylonjs.com/features/physics_engine
  66708. * @returns a physics impostor or null
  66709. */
  66710. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66711. /** Apply a physic impulse to the mesh
  66712. * @param force defines the force to apply
  66713. * @param contactPoint defines where to apply the force
  66714. * @returns the current mesh
  66715. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66716. */
  66717. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66718. /**
  66719. * Creates a physic joint between two meshes
  66720. * @param otherMesh defines the other mesh to use
  66721. * @param pivot1 defines the pivot to use on this mesh
  66722. * @param pivot2 defines the pivot to use on the other mesh
  66723. * @param options defines additional options (can be plugin dependent)
  66724. * @returns the current mesh
  66725. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66726. */
  66727. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66728. /** @hidden */
  66729. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66730. }
  66731. /**
  66732. * Defines the physics engine scene component responsible to manage a physics engine
  66733. */
  66734. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66735. /**
  66736. * The component name helpful to identify the component in the list of scene components.
  66737. */
  66738. readonly name: string;
  66739. /**
  66740. * The scene the component belongs to.
  66741. */
  66742. scene: Scene;
  66743. /**
  66744. * Creates a new instance of the component for the given scene
  66745. * @param scene Defines the scene to register the component in
  66746. */
  66747. constructor(scene: Scene);
  66748. /**
  66749. * Registers the component in a given scene
  66750. */
  66751. register(): void;
  66752. /**
  66753. * Rebuilds the elements related to this component in case of
  66754. * context lost for instance.
  66755. */
  66756. rebuild(): void;
  66757. /**
  66758. * Disposes the component and the associated ressources
  66759. */
  66760. dispose(): void;
  66761. }
  66762. }
  66763. declare module BABYLON {
  66764. /**
  66765. * A helper for physics simulations
  66766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66767. */
  66768. export class PhysicsHelper {
  66769. private _scene;
  66770. private _physicsEngine;
  66771. /**
  66772. * Initializes the Physics helper
  66773. * @param scene Babylon.js scene
  66774. */
  66775. constructor(scene: Scene);
  66776. /**
  66777. * Applies a radial explosion impulse
  66778. * @param origin the origin of the explosion
  66779. * @param radiusOrEventOptions the radius or the options of radial explosion
  66780. * @param strength the explosion strength
  66781. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66782. * @returns A physics radial explosion event, or null
  66783. */
  66784. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66785. /**
  66786. * Applies a radial explosion force
  66787. * @param origin the origin of the explosion
  66788. * @param radiusOrEventOptions the radius or the options of radial explosion
  66789. * @param strength the explosion strength
  66790. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66791. * @returns A physics radial explosion event, or null
  66792. */
  66793. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66794. /**
  66795. * Creates a gravitational field
  66796. * @param origin the origin of the explosion
  66797. * @param radiusOrEventOptions the radius or the options of radial explosion
  66798. * @param strength the explosion strength
  66799. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66800. * @returns A physics gravitational field event, or null
  66801. */
  66802. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66803. /**
  66804. * Creates a physics updraft event
  66805. * @param origin the origin of the updraft
  66806. * @param radiusOrEventOptions the radius or the options of the updraft
  66807. * @param strength the strength of the updraft
  66808. * @param height the height of the updraft
  66809. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66810. * @returns A physics updraft event, or null
  66811. */
  66812. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66813. /**
  66814. * Creates a physics vortex event
  66815. * @param origin the of the vortex
  66816. * @param radiusOrEventOptions the radius or the options of the vortex
  66817. * @param strength the strength of the vortex
  66818. * @param height the height of the vortex
  66819. * @returns a Physics vortex event, or null
  66820. * A physics vortex event or null
  66821. */
  66822. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66823. }
  66824. /**
  66825. * Represents a physics radial explosion event
  66826. */
  66827. class PhysicsRadialExplosionEvent {
  66828. private _scene;
  66829. private _options;
  66830. private _sphere;
  66831. private _dataFetched;
  66832. /**
  66833. * Initializes a radial explosioin event
  66834. * @param _scene BabylonJS scene
  66835. * @param _options The options for the vortex event
  66836. */
  66837. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66838. /**
  66839. * Returns the data related to the radial explosion event (sphere).
  66840. * @returns The radial explosion event data
  66841. */
  66842. getData(): PhysicsRadialExplosionEventData;
  66843. /**
  66844. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66845. * @param impostor A physics imposter
  66846. * @param origin the origin of the explosion
  66847. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66848. */
  66849. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66850. /**
  66851. * Triggers affecterd impostors callbacks
  66852. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66853. */
  66854. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66855. /**
  66856. * Disposes the sphere.
  66857. * @param force Specifies if the sphere should be disposed by force
  66858. */
  66859. dispose(force?: boolean): void;
  66860. /*** Helpers ***/
  66861. private _prepareSphere;
  66862. private _intersectsWithSphere;
  66863. }
  66864. /**
  66865. * Represents a gravitational field event
  66866. */
  66867. class PhysicsGravitationalFieldEvent {
  66868. private _physicsHelper;
  66869. private _scene;
  66870. private _origin;
  66871. private _options;
  66872. private _tickCallback;
  66873. private _sphere;
  66874. private _dataFetched;
  66875. /**
  66876. * Initializes the physics gravitational field event
  66877. * @param _physicsHelper A physics helper
  66878. * @param _scene BabylonJS scene
  66879. * @param _origin The origin position of the gravitational field event
  66880. * @param _options The options for the vortex event
  66881. */
  66882. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66883. /**
  66884. * Returns the data related to the gravitational field event (sphere).
  66885. * @returns A gravitational field event
  66886. */
  66887. getData(): PhysicsGravitationalFieldEventData;
  66888. /**
  66889. * Enables the gravitational field.
  66890. */
  66891. enable(): void;
  66892. /**
  66893. * Disables the gravitational field.
  66894. */
  66895. disable(): void;
  66896. /**
  66897. * Disposes the sphere.
  66898. * @param force The force to dispose from the gravitational field event
  66899. */
  66900. dispose(force?: boolean): void;
  66901. private _tick;
  66902. }
  66903. /**
  66904. * Represents a physics updraft event
  66905. */
  66906. class PhysicsUpdraftEvent {
  66907. private _scene;
  66908. private _origin;
  66909. private _options;
  66910. private _physicsEngine;
  66911. private _originTop;
  66912. private _originDirection;
  66913. private _tickCallback;
  66914. private _cylinder;
  66915. private _cylinderPosition;
  66916. private _dataFetched;
  66917. /**
  66918. * Initializes the physics updraft event
  66919. * @param _scene BabylonJS scene
  66920. * @param _origin The origin position of the updraft
  66921. * @param _options The options for the updraft event
  66922. */
  66923. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66924. /**
  66925. * Returns the data related to the updraft event (cylinder).
  66926. * @returns A physics updraft event
  66927. */
  66928. getData(): PhysicsUpdraftEventData;
  66929. /**
  66930. * Enables the updraft.
  66931. */
  66932. enable(): void;
  66933. /**
  66934. * Disables the updraft.
  66935. */
  66936. disable(): void;
  66937. /**
  66938. * Disposes the cylinder.
  66939. * @param force Specifies if the updraft should be disposed by force
  66940. */
  66941. dispose(force?: boolean): void;
  66942. private getImpostorHitData;
  66943. private _tick;
  66944. /*** Helpers ***/
  66945. private _prepareCylinder;
  66946. private _intersectsWithCylinder;
  66947. }
  66948. /**
  66949. * Represents a physics vortex event
  66950. */
  66951. class PhysicsVortexEvent {
  66952. private _scene;
  66953. private _origin;
  66954. private _options;
  66955. private _physicsEngine;
  66956. private _originTop;
  66957. private _tickCallback;
  66958. private _cylinder;
  66959. private _cylinderPosition;
  66960. private _dataFetched;
  66961. /**
  66962. * Initializes the physics vortex event
  66963. * @param _scene The BabylonJS scene
  66964. * @param _origin The origin position of the vortex
  66965. * @param _options The options for the vortex event
  66966. */
  66967. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66968. /**
  66969. * Returns the data related to the vortex event (cylinder).
  66970. * @returns The physics vortex event data
  66971. */
  66972. getData(): PhysicsVortexEventData;
  66973. /**
  66974. * Enables the vortex.
  66975. */
  66976. enable(): void;
  66977. /**
  66978. * Disables the cortex.
  66979. */
  66980. disable(): void;
  66981. /**
  66982. * Disposes the sphere.
  66983. * @param force
  66984. */
  66985. dispose(force?: boolean): void;
  66986. private getImpostorHitData;
  66987. private _tick;
  66988. /*** Helpers ***/
  66989. private _prepareCylinder;
  66990. private _intersectsWithCylinder;
  66991. }
  66992. /**
  66993. * Options fot the radial explosion event
  66994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66995. */
  66996. export class PhysicsRadialExplosionEventOptions {
  66997. /**
  66998. * The radius of the sphere for the radial explosion.
  66999. */
  67000. radius: number;
  67001. /**
  67002. * The strenth of the explosion.
  67003. */
  67004. strength: number;
  67005. /**
  67006. * The strenght of the force in correspondence to the distance of the affected object
  67007. */
  67008. falloff: PhysicsRadialImpulseFalloff;
  67009. /**
  67010. * Sphere options for the radial explosion.
  67011. */
  67012. sphere: {
  67013. segments: number;
  67014. diameter: number;
  67015. };
  67016. /**
  67017. * Sphere options for the radial explosion.
  67018. */
  67019. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67020. }
  67021. /**
  67022. * Options fot the updraft event
  67023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67024. */
  67025. export class PhysicsUpdraftEventOptions {
  67026. /**
  67027. * The radius of the cylinder for the vortex
  67028. */
  67029. radius: number;
  67030. /**
  67031. * The strenth of the updraft.
  67032. */
  67033. strength: number;
  67034. /**
  67035. * The height of the cylinder for the updraft.
  67036. */
  67037. height: number;
  67038. /**
  67039. * The mode for the the updraft.
  67040. */
  67041. updraftMode: PhysicsUpdraftMode;
  67042. }
  67043. /**
  67044. * Options fot the vortex event
  67045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67046. */
  67047. export class PhysicsVortexEventOptions {
  67048. /**
  67049. * The radius of the cylinder for the vortex
  67050. */
  67051. radius: number;
  67052. /**
  67053. * The strenth of the vortex.
  67054. */
  67055. strength: number;
  67056. /**
  67057. * The height of the cylinder for the vortex.
  67058. */
  67059. height: number;
  67060. /**
  67061. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67062. */
  67063. centripetalForceThreshold: number;
  67064. /**
  67065. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67066. */
  67067. centripetalForceMultiplier: number;
  67068. /**
  67069. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67070. */
  67071. centrifugalForceMultiplier: number;
  67072. /**
  67073. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67074. */
  67075. updraftForceMultiplier: number;
  67076. }
  67077. /**
  67078. * The strenght of the force in correspondence to the distance of the affected object
  67079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67080. */
  67081. export enum PhysicsRadialImpulseFalloff {
  67082. /** Defines that impulse is constant in strength across it's whole radius */
  67083. Constant = 0,
  67084. /** Defines that impulse gets weaker if it's further from the origin */
  67085. Linear = 1
  67086. }
  67087. /**
  67088. * The strength of the force in correspondence to the distance of the affected object
  67089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67090. */
  67091. export enum PhysicsUpdraftMode {
  67092. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67093. Center = 0,
  67094. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67095. Perpendicular = 1
  67096. }
  67097. /**
  67098. * Interface for a physics hit data
  67099. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67100. */
  67101. export interface PhysicsHitData {
  67102. /**
  67103. * The force applied at the contact point
  67104. */
  67105. force: Vector3;
  67106. /**
  67107. * The contact point
  67108. */
  67109. contactPoint: Vector3;
  67110. /**
  67111. * The distance from the origin to the contact point
  67112. */
  67113. distanceFromOrigin: number;
  67114. }
  67115. /**
  67116. * Interface for radial explosion event data
  67117. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67118. */
  67119. export interface PhysicsRadialExplosionEventData {
  67120. /**
  67121. * A sphere used for the radial explosion event
  67122. */
  67123. sphere: Mesh;
  67124. }
  67125. /**
  67126. * Interface for gravitational field event data
  67127. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67128. */
  67129. export interface PhysicsGravitationalFieldEventData {
  67130. /**
  67131. * A sphere mesh used for the gravitational field event
  67132. */
  67133. sphere: Mesh;
  67134. }
  67135. /**
  67136. * Interface for updraft event data
  67137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67138. */
  67139. export interface PhysicsUpdraftEventData {
  67140. /**
  67141. * A cylinder used for the updraft event
  67142. */
  67143. cylinder: Mesh;
  67144. }
  67145. /**
  67146. * Interface for vortex event data
  67147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67148. */
  67149. export interface PhysicsVortexEventData {
  67150. /**
  67151. * A cylinder used for the vortex event
  67152. */
  67153. cylinder: Mesh;
  67154. }
  67155. /**
  67156. * Interface for an affected physics impostor
  67157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67158. */
  67159. export interface PhysicsAffectedImpostorWithData {
  67160. /**
  67161. * The impostor affected by the effect
  67162. */
  67163. impostor: PhysicsImpostor;
  67164. /**
  67165. * The data about the hit/horce from the explosion
  67166. */
  67167. hitData: PhysicsHitData;
  67168. }
  67169. }
  67170. declare module BABYLON {
  67171. /** @hidden */
  67172. export var blackAndWhitePixelShader: {
  67173. name: string;
  67174. shader: string;
  67175. };
  67176. }
  67177. declare module BABYLON {
  67178. /**
  67179. * Post process used to render in black and white
  67180. */
  67181. export class BlackAndWhitePostProcess extends PostProcess {
  67182. /**
  67183. * Linear about to convert he result to black and white (default: 1)
  67184. */
  67185. degree: number;
  67186. /**
  67187. * Creates a black and white post process
  67188. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67189. * @param name The name of the effect.
  67190. * @param options The required width/height ratio to downsize to before computing the render pass.
  67191. * @param camera The camera to apply the render pass to.
  67192. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67193. * @param engine The engine which the post process will be applied. (default: current engine)
  67194. * @param reusable If the post process can be reused on the same frame. (default: false)
  67195. */
  67196. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67197. }
  67198. }
  67199. declare module BABYLON {
  67200. /**
  67201. * This represents a set of one or more post processes in Babylon.
  67202. * A post process can be used to apply a shader to a texture after it is rendered.
  67203. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67204. */
  67205. export class PostProcessRenderEffect {
  67206. private _postProcesses;
  67207. private _getPostProcesses;
  67208. private _singleInstance;
  67209. private _cameras;
  67210. private _indicesForCamera;
  67211. /**
  67212. * Name of the effect
  67213. * @hidden
  67214. */
  67215. _name: string;
  67216. /**
  67217. * Instantiates a post process render effect.
  67218. * A post process can be used to apply a shader to a texture after it is rendered.
  67219. * @param engine The engine the effect is tied to
  67220. * @param name The name of the effect
  67221. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67222. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67223. */
  67224. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67225. /**
  67226. * Checks if all the post processes in the effect are supported.
  67227. */
  67228. get isSupported(): boolean;
  67229. /**
  67230. * Updates the current state of the effect
  67231. * @hidden
  67232. */
  67233. _update(): void;
  67234. /**
  67235. * Attaches the effect on cameras
  67236. * @param cameras The camera to attach to.
  67237. * @hidden
  67238. */
  67239. _attachCameras(cameras: Camera): void;
  67240. /**
  67241. * Attaches the effect on cameras
  67242. * @param cameras The camera to attach to.
  67243. * @hidden
  67244. */
  67245. _attachCameras(cameras: Camera[]): void;
  67246. /**
  67247. * Detaches the effect on cameras
  67248. * @param cameras The camera to detatch from.
  67249. * @hidden
  67250. */
  67251. _detachCameras(cameras: Camera): void;
  67252. /**
  67253. * Detatches the effect on cameras
  67254. * @param cameras The camera to detatch from.
  67255. * @hidden
  67256. */
  67257. _detachCameras(cameras: Camera[]): void;
  67258. /**
  67259. * Enables the effect on given cameras
  67260. * @param cameras The camera to enable.
  67261. * @hidden
  67262. */
  67263. _enable(cameras: Camera): void;
  67264. /**
  67265. * Enables the effect on given cameras
  67266. * @param cameras The camera to enable.
  67267. * @hidden
  67268. */
  67269. _enable(cameras: Nullable<Camera[]>): void;
  67270. /**
  67271. * Disables the effect on the given cameras
  67272. * @param cameras The camera to disable.
  67273. * @hidden
  67274. */
  67275. _disable(cameras: Camera): void;
  67276. /**
  67277. * Disables the effect on the given cameras
  67278. * @param cameras The camera to disable.
  67279. * @hidden
  67280. */
  67281. _disable(cameras: Nullable<Camera[]>): void;
  67282. /**
  67283. * Gets a list of the post processes contained in the effect.
  67284. * @param camera The camera to get the post processes on.
  67285. * @returns The list of the post processes in the effect.
  67286. */
  67287. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67288. }
  67289. }
  67290. declare module BABYLON {
  67291. /** @hidden */
  67292. export var extractHighlightsPixelShader: {
  67293. name: string;
  67294. shader: string;
  67295. };
  67296. }
  67297. declare module BABYLON {
  67298. /**
  67299. * 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.
  67300. */
  67301. export class ExtractHighlightsPostProcess extends PostProcess {
  67302. /**
  67303. * The luminance threshold, pixels below this value will be set to black.
  67304. */
  67305. threshold: number;
  67306. /** @hidden */
  67307. _exposure: number;
  67308. /**
  67309. * Post process which has the input texture to be used when performing highlight extraction
  67310. * @hidden
  67311. */
  67312. _inputPostProcess: Nullable<PostProcess>;
  67313. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67314. }
  67315. }
  67316. declare module BABYLON {
  67317. /** @hidden */
  67318. export var bloomMergePixelShader: {
  67319. name: string;
  67320. shader: string;
  67321. };
  67322. }
  67323. declare module BABYLON {
  67324. /**
  67325. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67326. */
  67327. export class BloomMergePostProcess extends PostProcess {
  67328. /** Weight of the bloom to be added to the original input. */
  67329. weight: number;
  67330. /**
  67331. * Creates a new instance of @see BloomMergePostProcess
  67332. * @param name The name of the effect.
  67333. * @param originalFromInput Post process which's input will be used for the merge.
  67334. * @param blurred Blurred highlights post process which's output will be used.
  67335. * @param weight Weight of the bloom to be added to the original input.
  67336. * @param options The required width/height ratio to downsize to before computing the render pass.
  67337. * @param camera The camera to apply the render pass to.
  67338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67339. * @param engine The engine which the post process will be applied. (default: current engine)
  67340. * @param reusable If the post process can be reused on the same frame. (default: false)
  67341. * @param textureType Type of textures used when performing the post process. (default: 0)
  67342. * @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)
  67343. */
  67344. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67345. /** Weight of the bloom to be added to the original input. */
  67346. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67347. }
  67348. }
  67349. declare module BABYLON {
  67350. /**
  67351. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67352. */
  67353. export class BloomEffect extends PostProcessRenderEffect {
  67354. private bloomScale;
  67355. /**
  67356. * @hidden Internal
  67357. */
  67358. _effects: Array<PostProcess>;
  67359. /**
  67360. * @hidden Internal
  67361. */
  67362. _downscale: ExtractHighlightsPostProcess;
  67363. private _blurX;
  67364. private _blurY;
  67365. private _merge;
  67366. /**
  67367. * The luminance threshold to find bright areas of the image to bloom.
  67368. */
  67369. get threshold(): number;
  67370. set threshold(value: number);
  67371. /**
  67372. * The strength of the bloom.
  67373. */
  67374. get weight(): number;
  67375. set weight(value: number);
  67376. /**
  67377. * Specifies the size of the bloom blur kernel, relative to the final output size
  67378. */
  67379. get kernel(): number;
  67380. set kernel(value: number);
  67381. /**
  67382. * Creates a new instance of @see BloomEffect
  67383. * @param scene The scene the effect belongs to.
  67384. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67385. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67386. * @param bloomWeight The the strength of bloom.
  67387. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67388. * @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)
  67389. */
  67390. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67391. /**
  67392. * Disposes each of the internal effects for a given camera.
  67393. * @param camera The camera to dispose the effect on.
  67394. */
  67395. disposeEffects(camera: Camera): void;
  67396. /**
  67397. * @hidden Internal
  67398. */
  67399. _updateEffects(): void;
  67400. /**
  67401. * Internal
  67402. * @returns if all the contained post processes are ready.
  67403. * @hidden
  67404. */
  67405. _isReady(): boolean;
  67406. }
  67407. }
  67408. declare module BABYLON {
  67409. /** @hidden */
  67410. export var chromaticAberrationPixelShader: {
  67411. name: string;
  67412. shader: string;
  67413. };
  67414. }
  67415. declare module BABYLON {
  67416. /**
  67417. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67418. */
  67419. export class ChromaticAberrationPostProcess extends PostProcess {
  67420. /**
  67421. * The amount of seperation of rgb channels (default: 30)
  67422. */
  67423. aberrationAmount: number;
  67424. /**
  67425. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67426. */
  67427. radialIntensity: number;
  67428. /**
  67429. * 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))
  67430. */
  67431. direction: Vector2;
  67432. /**
  67433. * 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))
  67434. */
  67435. centerPosition: Vector2;
  67436. /**
  67437. * Creates a new instance ChromaticAberrationPostProcess
  67438. * @param name The name of the effect.
  67439. * @param screenWidth The width of the screen to apply the effect on.
  67440. * @param screenHeight The height of the screen to apply the effect on.
  67441. * @param options The required width/height ratio to downsize to before computing the render pass.
  67442. * @param camera The camera to apply the render pass to.
  67443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67444. * @param engine The engine which the post process will be applied. (default: current engine)
  67445. * @param reusable If the post process can be reused on the same frame. (default: false)
  67446. * @param textureType Type of textures used when performing the post process. (default: 0)
  67447. * @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)
  67448. */
  67449. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67450. }
  67451. }
  67452. declare module BABYLON {
  67453. /** @hidden */
  67454. export var circleOfConfusionPixelShader: {
  67455. name: string;
  67456. shader: string;
  67457. };
  67458. }
  67459. declare module BABYLON {
  67460. /**
  67461. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67462. */
  67463. export class CircleOfConfusionPostProcess extends PostProcess {
  67464. /**
  67465. * 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.
  67466. */
  67467. lensSize: number;
  67468. /**
  67469. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67470. */
  67471. fStop: number;
  67472. /**
  67473. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67474. */
  67475. focusDistance: number;
  67476. /**
  67477. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67478. */
  67479. focalLength: number;
  67480. private _depthTexture;
  67481. /**
  67482. * Creates a new instance CircleOfConfusionPostProcess
  67483. * @param name The name of the effect.
  67484. * @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.
  67485. * @param options The required width/height ratio to downsize to before computing the render pass.
  67486. * @param camera The camera to apply the render pass to.
  67487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67488. * @param engine The engine which the post process will be applied. (default: current engine)
  67489. * @param reusable If the post process can be reused on the same frame. (default: false)
  67490. * @param textureType Type of textures used when performing the post process. (default: 0)
  67491. * @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)
  67492. */
  67493. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67494. /**
  67495. * 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.
  67496. */
  67497. set depthTexture(value: RenderTargetTexture);
  67498. }
  67499. }
  67500. declare module BABYLON {
  67501. /** @hidden */
  67502. export var colorCorrectionPixelShader: {
  67503. name: string;
  67504. shader: string;
  67505. };
  67506. }
  67507. declare module BABYLON {
  67508. /**
  67509. *
  67510. * This post-process allows the modification of rendered colors by using
  67511. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67512. *
  67513. * The object needs to be provided an url to a texture containing the color
  67514. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67515. * Use an image editing software to tweak the LUT to match your needs.
  67516. *
  67517. * For an example of a color LUT, see here:
  67518. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67519. * For explanations on color grading, see here:
  67520. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67521. *
  67522. */
  67523. export class ColorCorrectionPostProcess extends PostProcess {
  67524. private _colorTableTexture;
  67525. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67526. }
  67527. }
  67528. declare module BABYLON {
  67529. /** @hidden */
  67530. export var convolutionPixelShader: {
  67531. name: string;
  67532. shader: string;
  67533. };
  67534. }
  67535. declare module BABYLON {
  67536. /**
  67537. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67538. * input texture to perform effects such as edge detection or sharpening
  67539. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67540. */
  67541. export class ConvolutionPostProcess extends PostProcess {
  67542. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67543. kernel: number[];
  67544. /**
  67545. * Creates a new instance ConvolutionPostProcess
  67546. * @param name The name of the effect.
  67547. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67548. * @param options The required width/height ratio to downsize to before computing the render pass.
  67549. * @param camera The camera to apply the render pass to.
  67550. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67551. * @param engine The engine which the post process will be applied. (default: current engine)
  67552. * @param reusable If the post process can be reused on the same frame. (default: false)
  67553. * @param textureType Type of textures used when performing the post process. (default: 0)
  67554. */
  67555. constructor(name: string,
  67556. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67557. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67558. /**
  67559. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67560. */
  67561. static EdgeDetect0Kernel: number[];
  67562. /**
  67563. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67564. */
  67565. static EdgeDetect1Kernel: number[];
  67566. /**
  67567. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67568. */
  67569. static EdgeDetect2Kernel: number[];
  67570. /**
  67571. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67572. */
  67573. static SharpenKernel: number[];
  67574. /**
  67575. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67576. */
  67577. static EmbossKernel: number[];
  67578. /**
  67579. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67580. */
  67581. static GaussianKernel: number[];
  67582. }
  67583. }
  67584. declare module BABYLON {
  67585. /**
  67586. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67587. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67588. * based on samples that have a large difference in distance than the center pixel.
  67589. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67590. */
  67591. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67592. direction: Vector2;
  67593. /**
  67594. * Creates a new instance CircleOfConfusionPostProcess
  67595. * @param name The name of the effect.
  67596. * @param scene The scene the effect belongs to.
  67597. * @param direction The direction the blur should be applied.
  67598. * @param kernel The size of the kernel used to blur.
  67599. * @param options The required width/height ratio to downsize to before computing the render pass.
  67600. * @param camera The camera to apply the render pass to.
  67601. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67602. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67604. * @param engine The engine which the post process will be applied. (default: current engine)
  67605. * @param reusable If the post process can be reused on the same frame. (default: false)
  67606. * @param textureType Type of textures used when performing the post process. (default: 0)
  67607. * @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)
  67608. */
  67609. 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);
  67610. }
  67611. }
  67612. declare module BABYLON {
  67613. /** @hidden */
  67614. export var depthOfFieldMergePixelShader: {
  67615. name: string;
  67616. shader: string;
  67617. };
  67618. }
  67619. declare module BABYLON {
  67620. /**
  67621. * Options to be set when merging outputs from the default pipeline.
  67622. */
  67623. export class DepthOfFieldMergePostProcessOptions {
  67624. /**
  67625. * The original image to merge on top of
  67626. */
  67627. originalFromInput: PostProcess;
  67628. /**
  67629. * Parameters to perform the merge of the depth of field effect
  67630. */
  67631. depthOfField?: {
  67632. circleOfConfusion: PostProcess;
  67633. blurSteps: Array<PostProcess>;
  67634. };
  67635. /**
  67636. * Parameters to perform the merge of bloom effect
  67637. */
  67638. bloom?: {
  67639. blurred: PostProcess;
  67640. weight: number;
  67641. };
  67642. }
  67643. /**
  67644. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67645. */
  67646. export class DepthOfFieldMergePostProcess extends PostProcess {
  67647. private blurSteps;
  67648. /**
  67649. * Creates a new instance of DepthOfFieldMergePostProcess
  67650. * @param name The name of the effect.
  67651. * @param originalFromInput Post process which's input will be used for the merge.
  67652. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67653. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67654. * @param options The required width/height ratio to downsize to before computing the render pass.
  67655. * @param camera The camera to apply the render pass to.
  67656. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67657. * @param engine The engine which the post process will be applied. (default: current engine)
  67658. * @param reusable If the post process can be reused on the same frame. (default: false)
  67659. * @param textureType Type of textures used when performing the post process. (default: 0)
  67660. * @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)
  67661. */
  67662. 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);
  67663. /**
  67664. * Updates the effect with the current post process compile time values and recompiles the shader.
  67665. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67666. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67667. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67668. * @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
  67669. * @param onCompiled Called when the shader has been compiled.
  67670. * @param onError Called if there is an error when compiling a shader.
  67671. */
  67672. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67673. }
  67674. }
  67675. declare module BABYLON {
  67676. /**
  67677. * Specifies the level of max blur that should be applied when using the depth of field effect
  67678. */
  67679. export enum DepthOfFieldEffectBlurLevel {
  67680. /**
  67681. * Subtle blur
  67682. */
  67683. Low = 0,
  67684. /**
  67685. * Medium blur
  67686. */
  67687. Medium = 1,
  67688. /**
  67689. * Large blur
  67690. */
  67691. High = 2
  67692. }
  67693. /**
  67694. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67695. */
  67696. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67697. private _circleOfConfusion;
  67698. /**
  67699. * @hidden Internal, blurs from high to low
  67700. */
  67701. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67702. private _depthOfFieldBlurY;
  67703. private _dofMerge;
  67704. /**
  67705. * @hidden Internal post processes in depth of field effect
  67706. */
  67707. _effects: Array<PostProcess>;
  67708. /**
  67709. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67710. */
  67711. set focalLength(value: number);
  67712. get focalLength(): number;
  67713. /**
  67714. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67715. */
  67716. set fStop(value: number);
  67717. get fStop(): number;
  67718. /**
  67719. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67720. */
  67721. set focusDistance(value: number);
  67722. get focusDistance(): number;
  67723. /**
  67724. * 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.
  67725. */
  67726. set lensSize(value: number);
  67727. get lensSize(): number;
  67728. /**
  67729. * Creates a new instance DepthOfFieldEffect
  67730. * @param scene The scene the effect belongs to.
  67731. * @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.
  67732. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67733. * @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)
  67734. */
  67735. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67736. /**
  67737. * Get the current class name of the current effet
  67738. * @returns "DepthOfFieldEffect"
  67739. */
  67740. getClassName(): string;
  67741. /**
  67742. * 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.
  67743. */
  67744. set depthTexture(value: RenderTargetTexture);
  67745. /**
  67746. * Disposes each of the internal effects for a given camera.
  67747. * @param camera The camera to dispose the effect on.
  67748. */
  67749. disposeEffects(camera: Camera): void;
  67750. /**
  67751. * @hidden Internal
  67752. */
  67753. _updateEffects(): void;
  67754. /**
  67755. * Internal
  67756. * @returns if all the contained post processes are ready.
  67757. * @hidden
  67758. */
  67759. _isReady(): boolean;
  67760. }
  67761. }
  67762. declare module BABYLON {
  67763. /** @hidden */
  67764. export var displayPassPixelShader: {
  67765. name: string;
  67766. shader: string;
  67767. };
  67768. }
  67769. declare module BABYLON {
  67770. /**
  67771. * DisplayPassPostProcess which produces an output the same as it's input
  67772. */
  67773. export class DisplayPassPostProcess extends PostProcess {
  67774. /**
  67775. * Creates the DisplayPassPostProcess
  67776. * @param name The name of the effect.
  67777. * @param options The required width/height ratio to downsize to before computing the render pass.
  67778. * @param camera The camera to apply the render pass to.
  67779. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67780. * @param engine The engine which the post process will be applied. (default: current engine)
  67781. * @param reusable If the post process can be reused on the same frame. (default: false)
  67782. */
  67783. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67784. }
  67785. }
  67786. declare module BABYLON {
  67787. /** @hidden */
  67788. export var filterPixelShader: {
  67789. name: string;
  67790. shader: string;
  67791. };
  67792. }
  67793. declare module BABYLON {
  67794. /**
  67795. * Applies a kernel filter to the image
  67796. */
  67797. export class FilterPostProcess extends PostProcess {
  67798. /** The matrix to be applied to the image */
  67799. kernelMatrix: Matrix;
  67800. /**
  67801. *
  67802. * @param name The name of the effect.
  67803. * @param kernelMatrix The matrix to be applied to the image
  67804. * @param options The required width/height ratio to downsize to before computing the render pass.
  67805. * @param camera The camera to apply the render pass to.
  67806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67807. * @param engine The engine which the post process will be applied. (default: current engine)
  67808. * @param reusable If the post process can be reused on the same frame. (default: false)
  67809. */
  67810. constructor(name: string,
  67811. /** The matrix to be applied to the image */
  67812. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67813. }
  67814. }
  67815. declare module BABYLON {
  67816. /** @hidden */
  67817. export var fxaaPixelShader: {
  67818. name: string;
  67819. shader: string;
  67820. };
  67821. }
  67822. declare module BABYLON {
  67823. /** @hidden */
  67824. export var fxaaVertexShader: {
  67825. name: string;
  67826. shader: string;
  67827. };
  67828. }
  67829. declare module BABYLON {
  67830. /**
  67831. * Fxaa post process
  67832. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67833. */
  67834. export class FxaaPostProcess extends PostProcess {
  67835. /** @hidden */
  67836. texelWidth: number;
  67837. /** @hidden */
  67838. texelHeight: number;
  67839. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67840. private _getDefines;
  67841. }
  67842. }
  67843. declare module BABYLON {
  67844. /** @hidden */
  67845. export var grainPixelShader: {
  67846. name: string;
  67847. shader: string;
  67848. };
  67849. }
  67850. declare module BABYLON {
  67851. /**
  67852. * The GrainPostProcess adds noise to the image at mid luminance levels
  67853. */
  67854. export class GrainPostProcess extends PostProcess {
  67855. /**
  67856. * The intensity of the grain added (default: 30)
  67857. */
  67858. intensity: number;
  67859. /**
  67860. * If the grain should be randomized on every frame
  67861. */
  67862. animated: boolean;
  67863. /**
  67864. * Creates a new instance of @see GrainPostProcess
  67865. * @param name The name of the effect.
  67866. * @param options The required width/height ratio to downsize to before computing the render pass.
  67867. * @param camera The camera to apply the render pass to.
  67868. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67869. * @param engine The engine which the post process will be applied. (default: current engine)
  67870. * @param reusable If the post process can be reused on the same frame. (default: false)
  67871. * @param textureType Type of textures used when performing the post process. (default: 0)
  67872. * @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)
  67873. */
  67874. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67875. }
  67876. }
  67877. declare module BABYLON {
  67878. /** @hidden */
  67879. export var highlightsPixelShader: {
  67880. name: string;
  67881. shader: string;
  67882. };
  67883. }
  67884. declare module BABYLON {
  67885. /**
  67886. * Extracts highlights from the image
  67887. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67888. */
  67889. export class HighlightsPostProcess extends PostProcess {
  67890. /**
  67891. * Extracts highlights from the image
  67892. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67893. * @param name The name of the effect.
  67894. * @param options The required width/height ratio to downsize to before computing the render pass.
  67895. * @param camera The camera to apply the render pass to.
  67896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67897. * @param engine The engine which the post process will be applied. (default: current engine)
  67898. * @param reusable If the post process can be reused on the same frame. (default: false)
  67899. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67900. */
  67901. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67902. }
  67903. }
  67904. declare module BABYLON {
  67905. /** @hidden */
  67906. export var mrtFragmentDeclaration: {
  67907. name: string;
  67908. shader: string;
  67909. };
  67910. }
  67911. declare module BABYLON {
  67912. /** @hidden */
  67913. export var geometryPixelShader: {
  67914. name: string;
  67915. shader: string;
  67916. };
  67917. }
  67918. declare module BABYLON {
  67919. /** @hidden */
  67920. export var geometryVertexShader: {
  67921. name: string;
  67922. shader: string;
  67923. };
  67924. }
  67925. declare module BABYLON {
  67926. /** @hidden */
  67927. interface ISavedTransformationMatrix {
  67928. world: Matrix;
  67929. viewProjection: Matrix;
  67930. }
  67931. /**
  67932. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67933. */
  67934. export class GeometryBufferRenderer {
  67935. /**
  67936. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67937. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67938. */
  67939. static readonly POSITION_TEXTURE_TYPE: number;
  67940. /**
  67941. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67942. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67943. */
  67944. static readonly VELOCITY_TEXTURE_TYPE: number;
  67945. /**
  67946. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67947. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67948. */
  67949. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67950. /**
  67951. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67952. * in order to compute objects velocities when enableVelocity is set to "true"
  67953. * @hidden
  67954. */
  67955. _previousTransformationMatrices: {
  67956. [index: number]: ISavedTransformationMatrix;
  67957. };
  67958. /**
  67959. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67960. * in order to compute objects velocities when enableVelocity is set to "true"
  67961. * @hidden
  67962. */
  67963. _previousBonesTransformationMatrices: {
  67964. [index: number]: Float32Array;
  67965. };
  67966. /**
  67967. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67968. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67969. */
  67970. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67971. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67972. renderTransparentMeshes: boolean;
  67973. private _scene;
  67974. private _multiRenderTarget;
  67975. private _ratio;
  67976. private _enablePosition;
  67977. private _enableVelocity;
  67978. private _enableReflectivity;
  67979. private _positionIndex;
  67980. private _velocityIndex;
  67981. private _reflectivityIndex;
  67982. protected _effect: Effect;
  67983. protected _cachedDefines: string;
  67984. /**
  67985. * Set the render list (meshes to be rendered) used in the G buffer.
  67986. */
  67987. set renderList(meshes: Mesh[]);
  67988. /**
  67989. * Gets wether or not G buffer are supported by the running hardware.
  67990. * This requires draw buffer supports
  67991. */
  67992. get isSupported(): boolean;
  67993. /**
  67994. * Returns the index of the given texture type in the G-Buffer textures array
  67995. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  67996. * @returns the index of the given texture type in the G-Buffer textures array
  67997. */
  67998. getTextureIndex(textureType: number): number;
  67999. /**
  68000. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68001. */
  68002. get enablePosition(): boolean;
  68003. /**
  68004. * Sets whether or not objects positions are enabled for the G buffer.
  68005. */
  68006. set enablePosition(enable: boolean);
  68007. /**
  68008. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68009. */
  68010. get enableVelocity(): boolean;
  68011. /**
  68012. * Sets wether or not objects velocities are enabled for the G buffer.
  68013. */
  68014. set enableVelocity(enable: boolean);
  68015. /**
  68016. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68017. */
  68018. get enableReflectivity(): boolean;
  68019. /**
  68020. * Sets wether or not objects roughness are enabled for the G buffer.
  68021. */
  68022. set enableReflectivity(enable: boolean);
  68023. /**
  68024. * Gets the scene associated with the buffer.
  68025. */
  68026. get scene(): Scene;
  68027. /**
  68028. * Gets the ratio used by the buffer during its creation.
  68029. * How big is the buffer related to the main canvas.
  68030. */
  68031. get ratio(): number;
  68032. /** @hidden */
  68033. static _SceneComponentInitialization: (scene: Scene) => void;
  68034. /**
  68035. * Creates a new G Buffer for the scene
  68036. * @param scene The scene the buffer belongs to
  68037. * @param ratio How big is the buffer related to the main canvas.
  68038. */
  68039. constructor(scene: Scene, ratio?: number);
  68040. /**
  68041. * Checks wether everything is ready to render a submesh to the G buffer.
  68042. * @param subMesh the submesh to check readiness for
  68043. * @param useInstances is the mesh drawn using instance or not
  68044. * @returns true if ready otherwise false
  68045. */
  68046. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68047. /**
  68048. * Gets the current underlying G Buffer.
  68049. * @returns the buffer
  68050. */
  68051. getGBuffer(): MultiRenderTarget;
  68052. /**
  68053. * Gets the number of samples used to render the buffer (anti aliasing).
  68054. */
  68055. get samples(): number;
  68056. /**
  68057. * Sets the number of samples used to render the buffer (anti aliasing).
  68058. */
  68059. set samples(value: number);
  68060. /**
  68061. * Disposes the renderer and frees up associated resources.
  68062. */
  68063. dispose(): void;
  68064. protected _createRenderTargets(): void;
  68065. private _copyBonesTransformationMatrices;
  68066. }
  68067. }
  68068. declare module BABYLON {
  68069. interface Scene {
  68070. /** @hidden (Backing field) */
  68071. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68072. /**
  68073. * Gets or Sets the current geometry buffer associated to the scene.
  68074. */
  68075. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68076. /**
  68077. * Enables a GeometryBufferRender and associates it with the scene
  68078. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68079. * @returns the GeometryBufferRenderer
  68080. */
  68081. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68082. /**
  68083. * Disables the GeometryBufferRender associated with the scene
  68084. */
  68085. disableGeometryBufferRenderer(): void;
  68086. }
  68087. /**
  68088. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68089. * in several rendering techniques.
  68090. */
  68091. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68092. /**
  68093. * The component name helpful to identify the component in the list of scene components.
  68094. */
  68095. readonly name: string;
  68096. /**
  68097. * The scene the component belongs to.
  68098. */
  68099. scene: Scene;
  68100. /**
  68101. * Creates a new instance of the component for the given scene
  68102. * @param scene Defines the scene to register the component in
  68103. */
  68104. constructor(scene: Scene);
  68105. /**
  68106. * Registers the component in a given scene
  68107. */
  68108. register(): void;
  68109. /**
  68110. * Rebuilds the elements related to this component in case of
  68111. * context lost for instance.
  68112. */
  68113. rebuild(): void;
  68114. /**
  68115. * Disposes the component and the associated ressources
  68116. */
  68117. dispose(): void;
  68118. private _gatherRenderTargets;
  68119. }
  68120. }
  68121. declare module BABYLON {
  68122. /** @hidden */
  68123. export var motionBlurPixelShader: {
  68124. name: string;
  68125. shader: string;
  68126. };
  68127. }
  68128. declare module BABYLON {
  68129. /**
  68130. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68131. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68132. * As an example, all you have to do is to create the post-process:
  68133. * var mb = new BABYLON.MotionBlurPostProcess(
  68134. * 'mb', // The name of the effect.
  68135. * scene, // The scene containing the objects to blur according to their velocity.
  68136. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68137. * camera // The camera to apply the render pass to.
  68138. * );
  68139. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68140. */
  68141. export class MotionBlurPostProcess extends PostProcess {
  68142. /**
  68143. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68144. */
  68145. motionStrength: number;
  68146. /**
  68147. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68148. */
  68149. get motionBlurSamples(): number;
  68150. /**
  68151. * Sets the number of iterations to be used for motion blur quality
  68152. */
  68153. set motionBlurSamples(samples: number);
  68154. private _motionBlurSamples;
  68155. private _geometryBufferRenderer;
  68156. /**
  68157. * Creates a new instance MotionBlurPostProcess
  68158. * @param name The name of the effect.
  68159. * @param scene The scene containing the objects to blur according to their velocity.
  68160. * @param options The required width/height ratio to downsize to before computing the render pass.
  68161. * @param camera The camera to apply the render pass to.
  68162. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68163. * @param engine The engine which the post process will be applied. (default: current engine)
  68164. * @param reusable If the post process can be reused on the same frame. (default: false)
  68165. * @param textureType Type of textures used when performing the post process. (default: 0)
  68166. * @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)
  68167. */
  68168. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68169. /**
  68170. * Excludes the given skinned mesh from computing bones velocities.
  68171. * 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.
  68172. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68173. */
  68174. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68175. /**
  68176. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68177. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68178. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68179. */
  68180. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68181. /**
  68182. * Disposes the post process.
  68183. * @param camera The camera to dispose the post process on.
  68184. */
  68185. dispose(camera?: Camera): void;
  68186. }
  68187. }
  68188. declare module BABYLON {
  68189. /** @hidden */
  68190. export var refractionPixelShader: {
  68191. name: string;
  68192. shader: string;
  68193. };
  68194. }
  68195. declare module BABYLON {
  68196. /**
  68197. * Post process which applies a refractin texture
  68198. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68199. */
  68200. export class RefractionPostProcess extends PostProcess {
  68201. /** the base color of the refraction (used to taint the rendering) */
  68202. color: Color3;
  68203. /** simulated refraction depth */
  68204. depth: number;
  68205. /** the coefficient of the base color (0 to remove base color tainting) */
  68206. colorLevel: number;
  68207. private _refTexture;
  68208. private _ownRefractionTexture;
  68209. /**
  68210. * Gets or sets the refraction texture
  68211. * Please note that you are responsible for disposing the texture if you set it manually
  68212. */
  68213. get refractionTexture(): Texture;
  68214. set refractionTexture(value: Texture);
  68215. /**
  68216. * Initializes the RefractionPostProcess
  68217. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68218. * @param name The name of the effect.
  68219. * @param refractionTextureUrl Url of the refraction texture to use
  68220. * @param color the base color of the refraction (used to taint the rendering)
  68221. * @param depth simulated refraction depth
  68222. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68223. * @param camera The camera to apply the render pass to.
  68224. * @param options The required width/height ratio to downsize to before computing the render pass.
  68225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68226. * @param engine The engine which the post process will be applied. (default: current engine)
  68227. * @param reusable If the post process can be reused on the same frame. (default: false)
  68228. */
  68229. constructor(name: string, refractionTextureUrl: string,
  68230. /** the base color of the refraction (used to taint the rendering) */
  68231. color: Color3,
  68232. /** simulated refraction depth */
  68233. depth: number,
  68234. /** the coefficient of the base color (0 to remove base color tainting) */
  68235. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68236. /**
  68237. * Disposes of the post process
  68238. * @param camera Camera to dispose post process on
  68239. */
  68240. dispose(camera: Camera): void;
  68241. }
  68242. }
  68243. declare module BABYLON {
  68244. /** @hidden */
  68245. export var sharpenPixelShader: {
  68246. name: string;
  68247. shader: string;
  68248. };
  68249. }
  68250. declare module BABYLON {
  68251. /**
  68252. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68253. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68254. */
  68255. export class SharpenPostProcess extends PostProcess {
  68256. /**
  68257. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68258. */
  68259. colorAmount: number;
  68260. /**
  68261. * How much sharpness should be applied (default: 0.3)
  68262. */
  68263. edgeAmount: number;
  68264. /**
  68265. * Creates a new instance ConvolutionPostProcess
  68266. * @param name The name of the effect.
  68267. * @param options The required width/height ratio to downsize to before computing the render pass.
  68268. * @param camera The camera to apply the render pass to.
  68269. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68270. * @param engine The engine which the post process will be applied. (default: current engine)
  68271. * @param reusable If the post process can be reused on the same frame. (default: false)
  68272. * @param textureType Type of textures used when performing the post process. (default: 0)
  68273. * @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)
  68274. */
  68275. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68276. }
  68277. }
  68278. declare module BABYLON {
  68279. /**
  68280. * PostProcessRenderPipeline
  68281. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68282. */
  68283. export class PostProcessRenderPipeline {
  68284. private engine;
  68285. private _renderEffects;
  68286. private _renderEffectsForIsolatedPass;
  68287. /**
  68288. * List of inspectable custom properties (used by the Inspector)
  68289. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68290. */
  68291. inspectableCustomProperties: IInspectable[];
  68292. /**
  68293. * @hidden
  68294. */
  68295. protected _cameras: Camera[];
  68296. /** @hidden */
  68297. _name: string;
  68298. /**
  68299. * Gets pipeline name
  68300. */
  68301. get name(): string;
  68302. /** Gets the list of attached cameras */
  68303. get cameras(): Camera[];
  68304. /**
  68305. * Initializes a PostProcessRenderPipeline
  68306. * @param engine engine to add the pipeline to
  68307. * @param name name of the pipeline
  68308. */
  68309. constructor(engine: Engine, name: string);
  68310. /**
  68311. * Gets the class name
  68312. * @returns "PostProcessRenderPipeline"
  68313. */
  68314. getClassName(): string;
  68315. /**
  68316. * If all the render effects in the pipeline are supported
  68317. */
  68318. get isSupported(): boolean;
  68319. /**
  68320. * Adds an effect to the pipeline
  68321. * @param renderEffect the effect to add
  68322. */
  68323. addEffect(renderEffect: PostProcessRenderEffect): void;
  68324. /** @hidden */
  68325. _rebuild(): void;
  68326. /** @hidden */
  68327. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68328. /** @hidden */
  68329. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68330. /** @hidden */
  68331. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68332. /** @hidden */
  68333. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68334. /** @hidden */
  68335. _attachCameras(cameras: Camera, unique: boolean): void;
  68336. /** @hidden */
  68337. _attachCameras(cameras: Camera[], unique: boolean): void;
  68338. /** @hidden */
  68339. _detachCameras(cameras: Camera): void;
  68340. /** @hidden */
  68341. _detachCameras(cameras: Nullable<Camera[]>): void;
  68342. /** @hidden */
  68343. _update(): void;
  68344. /** @hidden */
  68345. _reset(): void;
  68346. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68347. /**
  68348. * Disposes of the pipeline
  68349. */
  68350. dispose(): void;
  68351. }
  68352. }
  68353. declare module BABYLON {
  68354. /**
  68355. * PostProcessRenderPipelineManager class
  68356. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68357. */
  68358. export class PostProcessRenderPipelineManager {
  68359. private _renderPipelines;
  68360. /**
  68361. * Initializes a PostProcessRenderPipelineManager
  68362. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68363. */
  68364. constructor();
  68365. /**
  68366. * Gets the list of supported render pipelines
  68367. */
  68368. get supportedPipelines(): PostProcessRenderPipeline[];
  68369. /**
  68370. * Adds a pipeline to the manager
  68371. * @param renderPipeline The pipeline to add
  68372. */
  68373. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68374. /**
  68375. * Attaches a camera to the pipeline
  68376. * @param renderPipelineName The name of the pipeline to attach to
  68377. * @param cameras the camera to attach
  68378. * @param unique if the camera can be attached multiple times to the pipeline
  68379. */
  68380. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68381. /**
  68382. * Detaches a camera from the pipeline
  68383. * @param renderPipelineName The name of the pipeline to detach from
  68384. * @param cameras the camera to detach
  68385. */
  68386. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68387. /**
  68388. * Enables an effect by name on a pipeline
  68389. * @param renderPipelineName the name of the pipeline to enable the effect in
  68390. * @param renderEffectName the name of the effect to enable
  68391. * @param cameras the cameras that the effect should be enabled on
  68392. */
  68393. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68394. /**
  68395. * Disables an effect by name on a pipeline
  68396. * @param renderPipelineName the name of the pipeline to disable the effect in
  68397. * @param renderEffectName the name of the effect to disable
  68398. * @param cameras the cameras that the effect should be disabled on
  68399. */
  68400. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68401. /**
  68402. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68403. */
  68404. update(): void;
  68405. /** @hidden */
  68406. _rebuild(): void;
  68407. /**
  68408. * Disposes of the manager and pipelines
  68409. */
  68410. dispose(): void;
  68411. }
  68412. }
  68413. declare module BABYLON {
  68414. interface Scene {
  68415. /** @hidden (Backing field) */
  68416. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68417. /**
  68418. * Gets the postprocess render pipeline manager
  68419. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68420. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68421. */
  68422. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68423. }
  68424. /**
  68425. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68426. */
  68427. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68428. /**
  68429. * The component name helpfull to identify the component in the list of scene components.
  68430. */
  68431. readonly name: string;
  68432. /**
  68433. * The scene the component belongs to.
  68434. */
  68435. scene: Scene;
  68436. /**
  68437. * Creates a new instance of the component for the given scene
  68438. * @param scene Defines the scene to register the component in
  68439. */
  68440. constructor(scene: Scene);
  68441. /**
  68442. * Registers the component in a given scene
  68443. */
  68444. register(): void;
  68445. /**
  68446. * Rebuilds the elements related to this component in case of
  68447. * context lost for instance.
  68448. */
  68449. rebuild(): void;
  68450. /**
  68451. * Disposes the component and the associated ressources
  68452. */
  68453. dispose(): void;
  68454. private _gatherRenderTargets;
  68455. }
  68456. }
  68457. declare module BABYLON {
  68458. /**
  68459. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68460. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68461. */
  68462. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68463. private _scene;
  68464. private _camerasToBeAttached;
  68465. /**
  68466. * ID of the sharpen post process,
  68467. */
  68468. private readonly SharpenPostProcessId;
  68469. /**
  68470. * @ignore
  68471. * ID of the image processing post process;
  68472. */
  68473. readonly ImageProcessingPostProcessId: string;
  68474. /**
  68475. * @ignore
  68476. * ID of the Fast Approximate Anti-Aliasing post process;
  68477. */
  68478. readonly FxaaPostProcessId: string;
  68479. /**
  68480. * ID of the chromatic aberration post process,
  68481. */
  68482. private readonly ChromaticAberrationPostProcessId;
  68483. /**
  68484. * ID of the grain post process
  68485. */
  68486. private readonly GrainPostProcessId;
  68487. /**
  68488. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68489. */
  68490. sharpen: SharpenPostProcess;
  68491. private _sharpenEffect;
  68492. private bloom;
  68493. /**
  68494. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68495. */
  68496. depthOfField: DepthOfFieldEffect;
  68497. /**
  68498. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68499. */
  68500. fxaa: FxaaPostProcess;
  68501. /**
  68502. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68503. */
  68504. imageProcessing: ImageProcessingPostProcess;
  68505. /**
  68506. * Chromatic aberration post process which will shift rgb colors in the image
  68507. */
  68508. chromaticAberration: ChromaticAberrationPostProcess;
  68509. private _chromaticAberrationEffect;
  68510. /**
  68511. * Grain post process which add noise to the image
  68512. */
  68513. grain: GrainPostProcess;
  68514. private _grainEffect;
  68515. /**
  68516. * Glow post process which adds a glow to emissive areas of the image
  68517. */
  68518. private _glowLayer;
  68519. /**
  68520. * Animations which can be used to tweak settings over a period of time
  68521. */
  68522. animations: Animation[];
  68523. private _imageProcessingConfigurationObserver;
  68524. private _sharpenEnabled;
  68525. private _bloomEnabled;
  68526. private _depthOfFieldEnabled;
  68527. private _depthOfFieldBlurLevel;
  68528. private _fxaaEnabled;
  68529. private _imageProcessingEnabled;
  68530. private _defaultPipelineTextureType;
  68531. private _bloomScale;
  68532. private _chromaticAberrationEnabled;
  68533. private _grainEnabled;
  68534. private _buildAllowed;
  68535. /**
  68536. * Gets active scene
  68537. */
  68538. get scene(): Scene;
  68539. /**
  68540. * Enable or disable the sharpen process from the pipeline
  68541. */
  68542. set sharpenEnabled(enabled: boolean);
  68543. get sharpenEnabled(): boolean;
  68544. private _resizeObserver;
  68545. private _hardwareScaleLevel;
  68546. private _bloomKernel;
  68547. /**
  68548. * Specifies the size of the bloom blur kernel, relative to the final output size
  68549. */
  68550. get bloomKernel(): number;
  68551. set bloomKernel(value: number);
  68552. /**
  68553. * Specifies the weight of the bloom in the final rendering
  68554. */
  68555. private _bloomWeight;
  68556. /**
  68557. * Specifies the luma threshold for the area that will be blurred by the bloom
  68558. */
  68559. private _bloomThreshold;
  68560. private _hdr;
  68561. /**
  68562. * The strength of the bloom.
  68563. */
  68564. set bloomWeight(value: number);
  68565. get bloomWeight(): number;
  68566. /**
  68567. * The strength of the bloom.
  68568. */
  68569. set bloomThreshold(value: number);
  68570. get bloomThreshold(): number;
  68571. /**
  68572. * The scale of the bloom, lower value will provide better performance.
  68573. */
  68574. set bloomScale(value: number);
  68575. get bloomScale(): number;
  68576. /**
  68577. * Enable or disable the bloom from the pipeline
  68578. */
  68579. set bloomEnabled(enabled: boolean);
  68580. get bloomEnabled(): boolean;
  68581. private _rebuildBloom;
  68582. /**
  68583. * If the depth of field is enabled.
  68584. */
  68585. get depthOfFieldEnabled(): boolean;
  68586. set depthOfFieldEnabled(enabled: boolean);
  68587. /**
  68588. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68589. */
  68590. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68591. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68592. /**
  68593. * If the anti aliasing is enabled.
  68594. */
  68595. set fxaaEnabled(enabled: boolean);
  68596. get fxaaEnabled(): boolean;
  68597. private _samples;
  68598. /**
  68599. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68600. */
  68601. set samples(sampleCount: number);
  68602. get samples(): number;
  68603. /**
  68604. * If image processing is enabled.
  68605. */
  68606. set imageProcessingEnabled(enabled: boolean);
  68607. get imageProcessingEnabled(): boolean;
  68608. /**
  68609. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68610. */
  68611. set glowLayerEnabled(enabled: boolean);
  68612. get glowLayerEnabled(): boolean;
  68613. /**
  68614. * Gets the glow layer (or null if not defined)
  68615. */
  68616. get glowLayer(): Nullable<GlowLayer>;
  68617. /**
  68618. * Enable or disable the chromaticAberration process from the pipeline
  68619. */
  68620. set chromaticAberrationEnabled(enabled: boolean);
  68621. get chromaticAberrationEnabled(): boolean;
  68622. /**
  68623. * Enable or disable the grain process from the pipeline
  68624. */
  68625. set grainEnabled(enabled: boolean);
  68626. get grainEnabled(): boolean;
  68627. /**
  68628. * @constructor
  68629. * @param name - The rendering pipeline name (default: "")
  68630. * @param hdr - If high dynamic range textures should be used (default: true)
  68631. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68632. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68633. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68634. */
  68635. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68636. /**
  68637. * Get the class name
  68638. * @returns "DefaultRenderingPipeline"
  68639. */
  68640. getClassName(): string;
  68641. /**
  68642. * Force the compilation of the entire pipeline.
  68643. */
  68644. prepare(): void;
  68645. private _hasCleared;
  68646. private _prevPostProcess;
  68647. private _prevPrevPostProcess;
  68648. private _setAutoClearAndTextureSharing;
  68649. private _depthOfFieldSceneObserver;
  68650. private _buildPipeline;
  68651. private _disposePostProcesses;
  68652. /**
  68653. * Adds a camera to the pipeline
  68654. * @param camera the camera to be added
  68655. */
  68656. addCamera(camera: Camera): void;
  68657. /**
  68658. * Removes a camera from the pipeline
  68659. * @param camera the camera to remove
  68660. */
  68661. removeCamera(camera: Camera): void;
  68662. /**
  68663. * Dispose of the pipeline and stop all post processes
  68664. */
  68665. dispose(): void;
  68666. /**
  68667. * Serialize the rendering pipeline (Used when exporting)
  68668. * @returns the serialized object
  68669. */
  68670. serialize(): any;
  68671. /**
  68672. * Parse the serialized pipeline
  68673. * @param source Source pipeline.
  68674. * @param scene The scene to load the pipeline to.
  68675. * @param rootUrl The URL of the serialized pipeline.
  68676. * @returns An instantiated pipeline from the serialized object.
  68677. */
  68678. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68679. }
  68680. }
  68681. declare module BABYLON {
  68682. /** @hidden */
  68683. export var lensHighlightsPixelShader: {
  68684. name: string;
  68685. shader: string;
  68686. };
  68687. }
  68688. declare module BABYLON {
  68689. /** @hidden */
  68690. export var depthOfFieldPixelShader: {
  68691. name: string;
  68692. shader: string;
  68693. };
  68694. }
  68695. declare module BABYLON {
  68696. /**
  68697. * BABYLON.JS Chromatic Aberration GLSL Shader
  68698. * Author: Olivier Guyot
  68699. * Separates very slightly R, G and B colors on the edges of the screen
  68700. * Inspired by Francois Tarlier & Martins Upitis
  68701. */
  68702. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68703. /**
  68704. * @ignore
  68705. * The chromatic aberration PostProcess id in the pipeline
  68706. */
  68707. LensChromaticAberrationEffect: string;
  68708. /**
  68709. * @ignore
  68710. * The highlights enhancing PostProcess id in the pipeline
  68711. */
  68712. HighlightsEnhancingEffect: string;
  68713. /**
  68714. * @ignore
  68715. * The depth-of-field PostProcess id in the pipeline
  68716. */
  68717. LensDepthOfFieldEffect: string;
  68718. private _scene;
  68719. private _depthTexture;
  68720. private _grainTexture;
  68721. private _chromaticAberrationPostProcess;
  68722. private _highlightsPostProcess;
  68723. private _depthOfFieldPostProcess;
  68724. private _edgeBlur;
  68725. private _grainAmount;
  68726. private _chromaticAberration;
  68727. private _distortion;
  68728. private _highlightsGain;
  68729. private _highlightsThreshold;
  68730. private _dofDistance;
  68731. private _dofAperture;
  68732. private _dofDarken;
  68733. private _dofPentagon;
  68734. private _blurNoise;
  68735. /**
  68736. * @constructor
  68737. *
  68738. * Effect parameters are as follow:
  68739. * {
  68740. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68741. * edge_blur: number; // from 0 to x (1 for realism)
  68742. * distortion: number; // from 0 to x (1 for realism)
  68743. * grain_amount: number; // from 0 to 1
  68744. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68745. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68746. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68747. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68748. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68749. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68750. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68751. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68752. * }
  68753. * Note: if an effect parameter is unset, effect is disabled
  68754. *
  68755. * @param name The rendering pipeline name
  68756. * @param parameters - An object containing all parameters (see above)
  68757. * @param scene The scene linked to this pipeline
  68758. * @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)
  68759. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68760. */
  68761. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68762. /**
  68763. * Get the class name
  68764. * @returns "LensRenderingPipeline"
  68765. */
  68766. getClassName(): string;
  68767. /**
  68768. * Gets associated scene
  68769. */
  68770. get scene(): Scene;
  68771. /**
  68772. * Gets or sets the edge blur
  68773. */
  68774. get edgeBlur(): number;
  68775. set edgeBlur(value: number);
  68776. /**
  68777. * Gets or sets the grain amount
  68778. */
  68779. get grainAmount(): number;
  68780. set grainAmount(value: number);
  68781. /**
  68782. * Gets or sets the chromatic aberration amount
  68783. */
  68784. get chromaticAberration(): number;
  68785. set chromaticAberration(value: number);
  68786. /**
  68787. * Gets or sets the depth of field aperture
  68788. */
  68789. get dofAperture(): number;
  68790. set dofAperture(value: number);
  68791. /**
  68792. * Gets or sets the edge distortion
  68793. */
  68794. get edgeDistortion(): number;
  68795. set edgeDistortion(value: number);
  68796. /**
  68797. * Gets or sets the depth of field distortion
  68798. */
  68799. get dofDistortion(): number;
  68800. set dofDistortion(value: number);
  68801. /**
  68802. * Gets or sets the darken out of focus amount
  68803. */
  68804. get darkenOutOfFocus(): number;
  68805. set darkenOutOfFocus(value: number);
  68806. /**
  68807. * Gets or sets a boolean indicating if blur noise is enabled
  68808. */
  68809. get blurNoise(): boolean;
  68810. set blurNoise(value: boolean);
  68811. /**
  68812. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68813. */
  68814. get pentagonBokeh(): boolean;
  68815. set pentagonBokeh(value: boolean);
  68816. /**
  68817. * Gets or sets the highlight grain amount
  68818. */
  68819. get highlightsGain(): number;
  68820. set highlightsGain(value: number);
  68821. /**
  68822. * Gets or sets the highlight threshold
  68823. */
  68824. get highlightsThreshold(): number;
  68825. set highlightsThreshold(value: number);
  68826. /**
  68827. * Sets the amount of blur at the edges
  68828. * @param amount blur amount
  68829. */
  68830. setEdgeBlur(amount: number): void;
  68831. /**
  68832. * Sets edge blur to 0
  68833. */
  68834. disableEdgeBlur(): void;
  68835. /**
  68836. * Sets the amout of grain
  68837. * @param amount Amount of grain
  68838. */
  68839. setGrainAmount(amount: number): void;
  68840. /**
  68841. * Set grain amount to 0
  68842. */
  68843. disableGrain(): void;
  68844. /**
  68845. * Sets the chromatic aberration amount
  68846. * @param amount amount of chromatic aberration
  68847. */
  68848. setChromaticAberration(amount: number): void;
  68849. /**
  68850. * Sets chromatic aberration amount to 0
  68851. */
  68852. disableChromaticAberration(): void;
  68853. /**
  68854. * Sets the EdgeDistortion amount
  68855. * @param amount amount of EdgeDistortion
  68856. */
  68857. setEdgeDistortion(amount: number): void;
  68858. /**
  68859. * Sets edge distortion to 0
  68860. */
  68861. disableEdgeDistortion(): void;
  68862. /**
  68863. * Sets the FocusDistance amount
  68864. * @param amount amount of FocusDistance
  68865. */
  68866. setFocusDistance(amount: number): void;
  68867. /**
  68868. * Disables depth of field
  68869. */
  68870. disableDepthOfField(): void;
  68871. /**
  68872. * Sets the Aperture amount
  68873. * @param amount amount of Aperture
  68874. */
  68875. setAperture(amount: number): void;
  68876. /**
  68877. * Sets the DarkenOutOfFocus amount
  68878. * @param amount amount of DarkenOutOfFocus
  68879. */
  68880. setDarkenOutOfFocus(amount: number): void;
  68881. private _pentagonBokehIsEnabled;
  68882. /**
  68883. * Creates a pentagon bokeh effect
  68884. */
  68885. enablePentagonBokeh(): void;
  68886. /**
  68887. * Disables the pentagon bokeh effect
  68888. */
  68889. disablePentagonBokeh(): void;
  68890. /**
  68891. * Enables noise blur
  68892. */
  68893. enableNoiseBlur(): void;
  68894. /**
  68895. * Disables noise blur
  68896. */
  68897. disableNoiseBlur(): void;
  68898. /**
  68899. * Sets the HighlightsGain amount
  68900. * @param amount amount of HighlightsGain
  68901. */
  68902. setHighlightsGain(amount: number): void;
  68903. /**
  68904. * Sets the HighlightsThreshold amount
  68905. * @param amount amount of HighlightsThreshold
  68906. */
  68907. setHighlightsThreshold(amount: number): void;
  68908. /**
  68909. * Disables highlights
  68910. */
  68911. disableHighlights(): void;
  68912. /**
  68913. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68914. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68915. */
  68916. dispose(disableDepthRender?: boolean): void;
  68917. private _createChromaticAberrationPostProcess;
  68918. private _createHighlightsPostProcess;
  68919. private _createDepthOfFieldPostProcess;
  68920. private _createGrainTexture;
  68921. }
  68922. }
  68923. declare module BABYLON {
  68924. /** @hidden */
  68925. export var ssao2PixelShader: {
  68926. name: string;
  68927. shader: string;
  68928. };
  68929. }
  68930. declare module BABYLON {
  68931. /** @hidden */
  68932. export var ssaoCombinePixelShader: {
  68933. name: string;
  68934. shader: string;
  68935. };
  68936. }
  68937. declare module BABYLON {
  68938. /**
  68939. * Render pipeline to produce ssao effect
  68940. */
  68941. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  68942. /**
  68943. * @ignore
  68944. * The PassPostProcess id in the pipeline that contains the original scene color
  68945. */
  68946. SSAOOriginalSceneColorEffect: string;
  68947. /**
  68948. * @ignore
  68949. * The SSAO PostProcess id in the pipeline
  68950. */
  68951. SSAORenderEffect: string;
  68952. /**
  68953. * @ignore
  68954. * The horizontal blur PostProcess id in the pipeline
  68955. */
  68956. SSAOBlurHRenderEffect: string;
  68957. /**
  68958. * @ignore
  68959. * The vertical blur PostProcess id in the pipeline
  68960. */
  68961. SSAOBlurVRenderEffect: string;
  68962. /**
  68963. * @ignore
  68964. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68965. */
  68966. SSAOCombineRenderEffect: string;
  68967. /**
  68968. * The output strength of the SSAO post-process. Default value is 1.0.
  68969. */
  68970. totalStrength: number;
  68971. /**
  68972. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  68973. */
  68974. maxZ: number;
  68975. /**
  68976. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  68977. */
  68978. minZAspect: number;
  68979. private _samples;
  68980. /**
  68981. * Number of samples used for the SSAO calculations. Default value is 8
  68982. */
  68983. set samples(n: number);
  68984. get samples(): number;
  68985. private _textureSamples;
  68986. /**
  68987. * Number of samples to use for antialiasing
  68988. */
  68989. set textureSamples(n: number);
  68990. get textureSamples(): number;
  68991. /**
  68992. * Ratio object used for SSAO ratio and blur ratio
  68993. */
  68994. private _ratio;
  68995. /**
  68996. * Dynamically generated sphere sampler.
  68997. */
  68998. private _sampleSphere;
  68999. /**
  69000. * Blur filter offsets
  69001. */
  69002. private _samplerOffsets;
  69003. private _expensiveBlur;
  69004. /**
  69005. * If bilateral blur should be used
  69006. */
  69007. set expensiveBlur(b: boolean);
  69008. get expensiveBlur(): boolean;
  69009. /**
  69010. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69011. */
  69012. radius: number;
  69013. /**
  69014. * The base color of the SSAO post-process
  69015. * The final result is "base + ssao" between [0, 1]
  69016. */
  69017. base: number;
  69018. /**
  69019. * Support test.
  69020. */
  69021. static get IsSupported(): boolean;
  69022. private _scene;
  69023. private _depthTexture;
  69024. private _normalTexture;
  69025. private _randomTexture;
  69026. private _originalColorPostProcess;
  69027. private _ssaoPostProcess;
  69028. private _blurHPostProcess;
  69029. private _blurVPostProcess;
  69030. private _ssaoCombinePostProcess;
  69031. /**
  69032. * Gets active scene
  69033. */
  69034. get scene(): Scene;
  69035. /**
  69036. * @constructor
  69037. * @param name The rendering pipeline name
  69038. * @param scene The scene linked to this pipeline
  69039. * @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 }
  69040. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69041. */
  69042. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69043. /**
  69044. * Get the class name
  69045. * @returns "SSAO2RenderingPipeline"
  69046. */
  69047. getClassName(): string;
  69048. /**
  69049. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69050. */
  69051. dispose(disableGeometryBufferRenderer?: boolean): void;
  69052. private _createBlurPostProcess;
  69053. /** @hidden */
  69054. _rebuild(): void;
  69055. private _bits;
  69056. private _radicalInverse_VdC;
  69057. private _hammersley;
  69058. private _hemisphereSample_uniform;
  69059. private _generateHemisphere;
  69060. private _createSSAOPostProcess;
  69061. private _createSSAOCombinePostProcess;
  69062. private _createRandomTexture;
  69063. /**
  69064. * Serialize the rendering pipeline (Used when exporting)
  69065. * @returns the serialized object
  69066. */
  69067. serialize(): any;
  69068. /**
  69069. * Parse the serialized pipeline
  69070. * @param source Source pipeline.
  69071. * @param scene The scene to load the pipeline to.
  69072. * @param rootUrl The URL of the serialized pipeline.
  69073. * @returns An instantiated pipeline from the serialized object.
  69074. */
  69075. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69076. }
  69077. }
  69078. declare module BABYLON {
  69079. /** @hidden */
  69080. export var ssaoPixelShader: {
  69081. name: string;
  69082. shader: string;
  69083. };
  69084. }
  69085. declare module BABYLON {
  69086. /**
  69087. * Render pipeline to produce ssao effect
  69088. */
  69089. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69090. /**
  69091. * @ignore
  69092. * The PassPostProcess id in the pipeline that contains the original scene color
  69093. */
  69094. SSAOOriginalSceneColorEffect: string;
  69095. /**
  69096. * @ignore
  69097. * The SSAO PostProcess id in the pipeline
  69098. */
  69099. SSAORenderEffect: string;
  69100. /**
  69101. * @ignore
  69102. * The horizontal blur PostProcess id in the pipeline
  69103. */
  69104. SSAOBlurHRenderEffect: string;
  69105. /**
  69106. * @ignore
  69107. * The vertical blur PostProcess id in the pipeline
  69108. */
  69109. SSAOBlurVRenderEffect: string;
  69110. /**
  69111. * @ignore
  69112. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69113. */
  69114. SSAOCombineRenderEffect: string;
  69115. /**
  69116. * The output strength of the SSAO post-process. Default value is 1.0.
  69117. */
  69118. totalStrength: number;
  69119. /**
  69120. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69121. */
  69122. radius: number;
  69123. /**
  69124. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69125. * Must not be equal to fallOff and superior to fallOff.
  69126. * Default value is 0.0075
  69127. */
  69128. area: number;
  69129. /**
  69130. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69131. * Must not be equal to area and inferior to area.
  69132. * Default value is 0.000001
  69133. */
  69134. fallOff: number;
  69135. /**
  69136. * The base color of the SSAO post-process
  69137. * The final result is "base + ssao" between [0, 1]
  69138. */
  69139. base: number;
  69140. private _scene;
  69141. private _depthTexture;
  69142. private _randomTexture;
  69143. private _originalColorPostProcess;
  69144. private _ssaoPostProcess;
  69145. private _blurHPostProcess;
  69146. private _blurVPostProcess;
  69147. private _ssaoCombinePostProcess;
  69148. private _firstUpdate;
  69149. /**
  69150. * Gets active scene
  69151. */
  69152. get scene(): Scene;
  69153. /**
  69154. * @constructor
  69155. * @param name - The rendering pipeline name
  69156. * @param scene - The scene linked to this pipeline
  69157. * @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 }
  69158. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69159. */
  69160. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69161. /**
  69162. * Get the class name
  69163. * @returns "SSAORenderingPipeline"
  69164. */
  69165. getClassName(): string;
  69166. /**
  69167. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69168. */
  69169. dispose(disableDepthRender?: boolean): void;
  69170. private _createBlurPostProcess;
  69171. /** @hidden */
  69172. _rebuild(): void;
  69173. private _createSSAOPostProcess;
  69174. private _createSSAOCombinePostProcess;
  69175. private _createRandomTexture;
  69176. }
  69177. }
  69178. declare module BABYLON {
  69179. /** @hidden */
  69180. export var screenSpaceReflectionPixelShader: {
  69181. name: string;
  69182. shader: string;
  69183. };
  69184. }
  69185. declare module BABYLON {
  69186. /**
  69187. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69188. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69189. */
  69190. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69191. /**
  69192. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69193. */
  69194. threshold: number;
  69195. /**
  69196. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69197. */
  69198. strength: number;
  69199. /**
  69200. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69201. */
  69202. reflectionSpecularFalloffExponent: number;
  69203. /**
  69204. * 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]
  69205. */
  69206. step: number;
  69207. /**
  69208. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69209. */
  69210. roughnessFactor: number;
  69211. private _geometryBufferRenderer;
  69212. private _enableSmoothReflections;
  69213. private _reflectionSamples;
  69214. private _smoothSteps;
  69215. /**
  69216. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69217. * @param name The name of the effect.
  69218. * @param scene The scene containing the objects to calculate reflections.
  69219. * @param options The required width/height ratio to downsize to before computing the render pass.
  69220. * @param camera The camera to apply the render pass to.
  69221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69222. * @param engine The engine which the post process will be applied. (default: current engine)
  69223. * @param reusable If the post process can be reused on the same frame. (default: false)
  69224. * @param textureType Type of textures used when performing the post process. (default: 0)
  69225. * @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)
  69226. */
  69227. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69228. /**
  69229. * Gets wether or not smoothing reflections is enabled.
  69230. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69231. */
  69232. get enableSmoothReflections(): boolean;
  69233. /**
  69234. * Sets wether or not smoothing reflections is enabled.
  69235. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69236. */
  69237. set enableSmoothReflections(enabled: boolean);
  69238. /**
  69239. * Gets the number of samples taken while computing reflections. More samples count is high,
  69240. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69241. */
  69242. get reflectionSamples(): number;
  69243. /**
  69244. * Sets the number of samples taken while computing reflections. More samples count is high,
  69245. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69246. */
  69247. set reflectionSamples(samples: number);
  69248. /**
  69249. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69250. * more the post-process will require GPU power and can generate a drop in FPS.
  69251. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69252. */
  69253. get smoothSteps(): number;
  69254. set smoothSteps(steps: number);
  69255. private _updateEffectDefines;
  69256. }
  69257. }
  69258. declare module BABYLON {
  69259. /** @hidden */
  69260. export var standardPixelShader: {
  69261. name: string;
  69262. shader: string;
  69263. };
  69264. }
  69265. declare module BABYLON {
  69266. /**
  69267. * Standard rendering pipeline
  69268. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69269. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69270. */
  69271. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69272. /**
  69273. * Public members
  69274. */
  69275. /**
  69276. * Post-process which contains the original scene color before the pipeline applies all the effects
  69277. */
  69278. originalPostProcess: Nullable<PostProcess>;
  69279. /**
  69280. * Post-process used to down scale an image x4
  69281. */
  69282. downSampleX4PostProcess: Nullable<PostProcess>;
  69283. /**
  69284. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69285. */
  69286. brightPassPostProcess: Nullable<PostProcess>;
  69287. /**
  69288. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69289. */
  69290. blurHPostProcesses: PostProcess[];
  69291. /**
  69292. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69293. */
  69294. blurVPostProcesses: PostProcess[];
  69295. /**
  69296. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69297. */
  69298. textureAdderPostProcess: Nullable<PostProcess>;
  69299. /**
  69300. * Post-process used to create volumetric lighting effect
  69301. */
  69302. volumetricLightPostProcess: Nullable<PostProcess>;
  69303. /**
  69304. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69305. */
  69306. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69307. /**
  69308. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69309. */
  69310. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69311. /**
  69312. * Post-process used to merge the volumetric light effect and the real scene color
  69313. */
  69314. volumetricLightMergePostProces: Nullable<PostProcess>;
  69315. /**
  69316. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69317. */
  69318. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69319. /**
  69320. * Base post-process used to calculate the average luminance of the final image for HDR
  69321. */
  69322. luminancePostProcess: Nullable<PostProcess>;
  69323. /**
  69324. * Post-processes used to create down sample post-processes in order to get
  69325. * the average luminance of the final image for HDR
  69326. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69327. */
  69328. luminanceDownSamplePostProcesses: PostProcess[];
  69329. /**
  69330. * Post-process used to create a HDR effect (light adaptation)
  69331. */
  69332. hdrPostProcess: Nullable<PostProcess>;
  69333. /**
  69334. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69335. */
  69336. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69337. /**
  69338. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69339. */
  69340. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69341. /**
  69342. * Post-process used to merge the final HDR post-process and the real scene color
  69343. */
  69344. hdrFinalPostProcess: Nullable<PostProcess>;
  69345. /**
  69346. * Post-process used to create a lens flare effect
  69347. */
  69348. lensFlarePostProcess: Nullable<PostProcess>;
  69349. /**
  69350. * Post-process that merges the result of the lens flare post-process and the real scene color
  69351. */
  69352. lensFlareComposePostProcess: Nullable<PostProcess>;
  69353. /**
  69354. * Post-process used to create a motion blur effect
  69355. */
  69356. motionBlurPostProcess: Nullable<PostProcess>;
  69357. /**
  69358. * Post-process used to create a depth of field effect
  69359. */
  69360. depthOfFieldPostProcess: Nullable<PostProcess>;
  69361. /**
  69362. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69363. */
  69364. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69365. /**
  69366. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69367. */
  69368. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69369. /**
  69370. * Represents the brightness threshold in order to configure the illuminated surfaces
  69371. */
  69372. brightThreshold: number;
  69373. /**
  69374. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69375. */
  69376. blurWidth: number;
  69377. /**
  69378. * Sets if the blur for highlighted surfaces must be only horizontal
  69379. */
  69380. horizontalBlur: boolean;
  69381. /**
  69382. * Gets the overall exposure used by the pipeline
  69383. */
  69384. get exposure(): number;
  69385. /**
  69386. * Sets the overall exposure used by the pipeline
  69387. */
  69388. set exposure(value: number);
  69389. /**
  69390. * Texture used typically to simulate "dirty" on camera lens
  69391. */
  69392. lensTexture: Nullable<Texture>;
  69393. /**
  69394. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69395. */
  69396. volumetricLightCoefficient: number;
  69397. /**
  69398. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69399. */
  69400. volumetricLightPower: number;
  69401. /**
  69402. * Used the set the blur intensity to smooth the volumetric lights
  69403. */
  69404. volumetricLightBlurScale: number;
  69405. /**
  69406. * Light (spot or directional) used to generate the volumetric lights rays
  69407. * The source light must have a shadow generate so the pipeline can get its
  69408. * depth map
  69409. */
  69410. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69411. /**
  69412. * For eye adaptation, represents the minimum luminance the eye can see
  69413. */
  69414. hdrMinimumLuminance: number;
  69415. /**
  69416. * For eye adaptation, represents the decrease luminance speed
  69417. */
  69418. hdrDecreaseRate: number;
  69419. /**
  69420. * For eye adaptation, represents the increase luminance speed
  69421. */
  69422. hdrIncreaseRate: number;
  69423. /**
  69424. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69425. */
  69426. get hdrAutoExposure(): boolean;
  69427. /**
  69428. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69429. */
  69430. set hdrAutoExposure(value: boolean);
  69431. /**
  69432. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69433. */
  69434. lensColorTexture: Nullable<Texture>;
  69435. /**
  69436. * The overall strengh for the lens flare effect
  69437. */
  69438. lensFlareStrength: number;
  69439. /**
  69440. * Dispersion coefficient for lens flare ghosts
  69441. */
  69442. lensFlareGhostDispersal: number;
  69443. /**
  69444. * Main lens flare halo width
  69445. */
  69446. lensFlareHaloWidth: number;
  69447. /**
  69448. * Based on the lens distortion effect, defines how much the lens flare result
  69449. * is distorted
  69450. */
  69451. lensFlareDistortionStrength: number;
  69452. /**
  69453. * Configures the blur intensity used for for lens flare (halo)
  69454. */
  69455. lensFlareBlurWidth: number;
  69456. /**
  69457. * Lens star texture must be used to simulate rays on the flares and is available
  69458. * in the documentation
  69459. */
  69460. lensStarTexture: Nullable<Texture>;
  69461. /**
  69462. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69463. * flare effect by taking account of the dirt texture
  69464. */
  69465. lensFlareDirtTexture: Nullable<Texture>;
  69466. /**
  69467. * Represents the focal length for the depth of field effect
  69468. */
  69469. depthOfFieldDistance: number;
  69470. /**
  69471. * Represents the blur intensity for the blurred part of the depth of field effect
  69472. */
  69473. depthOfFieldBlurWidth: number;
  69474. /**
  69475. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69476. */
  69477. get motionStrength(): number;
  69478. /**
  69479. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69480. */
  69481. set motionStrength(strength: number);
  69482. /**
  69483. * Gets wether or not the motion blur post-process is object based or screen based.
  69484. */
  69485. get objectBasedMotionBlur(): boolean;
  69486. /**
  69487. * Sets wether or not the motion blur post-process should be object based or screen based
  69488. */
  69489. set objectBasedMotionBlur(value: boolean);
  69490. /**
  69491. * List of animations for the pipeline (IAnimatable implementation)
  69492. */
  69493. animations: Animation[];
  69494. /**
  69495. * Private members
  69496. */
  69497. private _scene;
  69498. private _currentDepthOfFieldSource;
  69499. private _basePostProcess;
  69500. private _fixedExposure;
  69501. private _currentExposure;
  69502. private _hdrAutoExposure;
  69503. private _hdrCurrentLuminance;
  69504. private _motionStrength;
  69505. private _isObjectBasedMotionBlur;
  69506. private _floatTextureType;
  69507. private _camerasToBeAttached;
  69508. private _ratio;
  69509. private _bloomEnabled;
  69510. private _depthOfFieldEnabled;
  69511. private _vlsEnabled;
  69512. private _lensFlareEnabled;
  69513. private _hdrEnabled;
  69514. private _motionBlurEnabled;
  69515. private _fxaaEnabled;
  69516. private _screenSpaceReflectionsEnabled;
  69517. private _motionBlurSamples;
  69518. private _volumetricLightStepsCount;
  69519. private _samples;
  69520. /**
  69521. * @ignore
  69522. * Specifies if the bloom pipeline is enabled
  69523. */
  69524. get BloomEnabled(): boolean;
  69525. set BloomEnabled(enabled: boolean);
  69526. /**
  69527. * @ignore
  69528. * Specifies if the depth of field pipeline is enabed
  69529. */
  69530. get DepthOfFieldEnabled(): boolean;
  69531. set DepthOfFieldEnabled(enabled: boolean);
  69532. /**
  69533. * @ignore
  69534. * Specifies if the lens flare pipeline is enabed
  69535. */
  69536. get LensFlareEnabled(): boolean;
  69537. set LensFlareEnabled(enabled: boolean);
  69538. /**
  69539. * @ignore
  69540. * Specifies if the HDR pipeline is enabled
  69541. */
  69542. get HDREnabled(): boolean;
  69543. set HDREnabled(enabled: boolean);
  69544. /**
  69545. * @ignore
  69546. * Specifies if the volumetric lights scattering effect is enabled
  69547. */
  69548. get VLSEnabled(): boolean;
  69549. set VLSEnabled(enabled: boolean);
  69550. /**
  69551. * @ignore
  69552. * Specifies if the motion blur effect is enabled
  69553. */
  69554. get MotionBlurEnabled(): boolean;
  69555. set MotionBlurEnabled(enabled: boolean);
  69556. /**
  69557. * Specifies if anti-aliasing is enabled
  69558. */
  69559. get fxaaEnabled(): boolean;
  69560. set fxaaEnabled(enabled: boolean);
  69561. /**
  69562. * Specifies if screen space reflections are enabled.
  69563. */
  69564. get screenSpaceReflectionsEnabled(): boolean;
  69565. set screenSpaceReflectionsEnabled(enabled: boolean);
  69566. /**
  69567. * Specifies the number of steps used to calculate the volumetric lights
  69568. * Typically in interval [50, 200]
  69569. */
  69570. get volumetricLightStepsCount(): number;
  69571. set volumetricLightStepsCount(count: number);
  69572. /**
  69573. * Specifies the number of samples used for the motion blur effect
  69574. * Typically in interval [16, 64]
  69575. */
  69576. get motionBlurSamples(): number;
  69577. set motionBlurSamples(samples: number);
  69578. /**
  69579. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69580. */
  69581. get samples(): number;
  69582. set samples(sampleCount: number);
  69583. /**
  69584. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69585. * @constructor
  69586. * @param name The rendering pipeline name
  69587. * @param scene The scene linked to this pipeline
  69588. * @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)
  69589. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69590. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69591. */
  69592. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69593. private _buildPipeline;
  69594. private _createDownSampleX4PostProcess;
  69595. private _createBrightPassPostProcess;
  69596. private _createBlurPostProcesses;
  69597. private _createTextureAdderPostProcess;
  69598. private _createVolumetricLightPostProcess;
  69599. private _createLuminancePostProcesses;
  69600. private _createHdrPostProcess;
  69601. private _createLensFlarePostProcess;
  69602. private _createDepthOfFieldPostProcess;
  69603. private _createMotionBlurPostProcess;
  69604. private _getDepthTexture;
  69605. private _disposePostProcesses;
  69606. /**
  69607. * Dispose of the pipeline and stop all post processes
  69608. */
  69609. dispose(): void;
  69610. /**
  69611. * Serialize the rendering pipeline (Used when exporting)
  69612. * @returns the serialized object
  69613. */
  69614. serialize(): any;
  69615. /**
  69616. * Parse the serialized pipeline
  69617. * @param source Source pipeline.
  69618. * @param scene The scene to load the pipeline to.
  69619. * @param rootUrl The URL of the serialized pipeline.
  69620. * @returns An instantiated pipeline from the serialized object.
  69621. */
  69622. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69623. /**
  69624. * Luminance steps
  69625. */
  69626. static LuminanceSteps: number;
  69627. }
  69628. }
  69629. declare module BABYLON {
  69630. /** @hidden */
  69631. export var stereoscopicInterlacePixelShader: {
  69632. name: string;
  69633. shader: string;
  69634. };
  69635. }
  69636. declare module BABYLON {
  69637. /**
  69638. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  69639. */
  69640. export class StereoscopicInterlacePostProcessI extends PostProcess {
  69641. private _stepSize;
  69642. private _passedProcess;
  69643. /**
  69644. * Initializes a StereoscopicInterlacePostProcessI
  69645. * @param name The name of the effect.
  69646. * @param rigCameras The rig cameras to be appled to the post process
  69647. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  69648. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  69649. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69650. * @param engine The engine which the post process will be applied. (default: current engine)
  69651. * @param reusable If the post process can be reused on the same frame. (default: false)
  69652. */
  69653. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69654. }
  69655. /**
  69656. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  69657. */
  69658. export class StereoscopicInterlacePostProcess extends PostProcess {
  69659. private _stepSize;
  69660. private _passedProcess;
  69661. /**
  69662. * Initializes a StereoscopicInterlacePostProcess
  69663. * @param name The name of the effect.
  69664. * @param rigCameras The rig cameras to be appled to the post process
  69665. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  69666. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69667. * @param engine The engine which the post process will be applied. (default: current engine)
  69668. * @param reusable If the post process can be reused on the same frame. (default: false)
  69669. */
  69670. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69671. }
  69672. }
  69673. declare module BABYLON {
  69674. /** @hidden */
  69675. export var tonemapPixelShader: {
  69676. name: string;
  69677. shader: string;
  69678. };
  69679. }
  69680. declare module BABYLON {
  69681. /** Defines operator used for tonemapping */
  69682. export enum TonemappingOperator {
  69683. /** Hable */
  69684. Hable = 0,
  69685. /** Reinhard */
  69686. Reinhard = 1,
  69687. /** HejiDawson */
  69688. HejiDawson = 2,
  69689. /** Photographic */
  69690. Photographic = 3
  69691. }
  69692. /**
  69693. * Defines a post process to apply tone mapping
  69694. */
  69695. export class TonemapPostProcess extends PostProcess {
  69696. private _operator;
  69697. /** Defines the required exposure adjustement */
  69698. exposureAdjustment: number;
  69699. /**
  69700. * Creates a new TonemapPostProcess
  69701. * @param name defines the name of the postprocess
  69702. * @param _operator defines the operator to use
  69703. * @param exposureAdjustment defines the required exposure adjustement
  69704. * @param camera defines the camera to use (can be null)
  69705. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69706. * @param engine defines the hosting engine (can be ignore if camera is set)
  69707. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69708. */
  69709. constructor(name: string, _operator: TonemappingOperator,
  69710. /** Defines the required exposure adjustement */
  69711. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69712. }
  69713. }
  69714. declare module BABYLON {
  69715. /** @hidden */
  69716. export var volumetricLightScatteringPixelShader: {
  69717. name: string;
  69718. shader: string;
  69719. };
  69720. }
  69721. declare module BABYLON {
  69722. /** @hidden */
  69723. export var volumetricLightScatteringPassVertexShader: {
  69724. name: string;
  69725. shader: string;
  69726. };
  69727. }
  69728. declare module BABYLON {
  69729. /** @hidden */
  69730. export var volumetricLightScatteringPassPixelShader: {
  69731. name: string;
  69732. shader: string;
  69733. };
  69734. }
  69735. declare module BABYLON {
  69736. /**
  69737. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69738. */
  69739. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69740. private _volumetricLightScatteringPass;
  69741. private _volumetricLightScatteringRTT;
  69742. private _viewPort;
  69743. private _screenCoordinates;
  69744. private _cachedDefines;
  69745. /**
  69746. * If not undefined, the mesh position is computed from the attached node position
  69747. */
  69748. attachedNode: {
  69749. position: Vector3;
  69750. };
  69751. /**
  69752. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69753. */
  69754. customMeshPosition: Vector3;
  69755. /**
  69756. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69757. */
  69758. useCustomMeshPosition: boolean;
  69759. /**
  69760. * If the post-process should inverse the light scattering direction
  69761. */
  69762. invert: boolean;
  69763. /**
  69764. * The internal mesh used by the post-process
  69765. */
  69766. mesh: Mesh;
  69767. /**
  69768. * @hidden
  69769. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69770. */
  69771. get useDiffuseColor(): boolean;
  69772. set useDiffuseColor(useDiffuseColor: boolean);
  69773. /**
  69774. * Array containing the excluded meshes not rendered in the internal pass
  69775. */
  69776. excludedMeshes: AbstractMesh[];
  69777. /**
  69778. * Controls the overall intensity of the post-process
  69779. */
  69780. exposure: number;
  69781. /**
  69782. * Dissipates each sample's contribution in range [0, 1]
  69783. */
  69784. decay: number;
  69785. /**
  69786. * Controls the overall intensity of each sample
  69787. */
  69788. weight: number;
  69789. /**
  69790. * Controls the density of each sample
  69791. */
  69792. density: number;
  69793. /**
  69794. * @constructor
  69795. * @param name The post-process name
  69796. * @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)
  69797. * @param camera The camera that the post-process will be attached to
  69798. * @param mesh The mesh used to create the light scattering
  69799. * @param samples The post-process quality, default 100
  69800. * @param samplingModeThe post-process filtering mode
  69801. * @param engine The babylon engine
  69802. * @param reusable If the post-process is reusable
  69803. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69804. */
  69805. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69806. /**
  69807. * Returns the string "VolumetricLightScatteringPostProcess"
  69808. * @returns "VolumetricLightScatteringPostProcess"
  69809. */
  69810. getClassName(): string;
  69811. private _isReady;
  69812. /**
  69813. * Sets the new light position for light scattering effect
  69814. * @param position The new custom light position
  69815. */
  69816. setCustomMeshPosition(position: Vector3): void;
  69817. /**
  69818. * Returns the light position for light scattering effect
  69819. * @return Vector3 The custom light position
  69820. */
  69821. getCustomMeshPosition(): Vector3;
  69822. /**
  69823. * Disposes the internal assets and detaches the post-process from the camera
  69824. */
  69825. dispose(camera: Camera): void;
  69826. /**
  69827. * Returns the render target texture used by the post-process
  69828. * @return the render target texture used by the post-process
  69829. */
  69830. getPass(): RenderTargetTexture;
  69831. private _meshExcluded;
  69832. private _createPass;
  69833. private _updateMeshScreenCoordinates;
  69834. /**
  69835. * Creates a default mesh for the Volumeric Light Scattering post-process
  69836. * @param name The mesh name
  69837. * @param scene The scene where to create the mesh
  69838. * @return the default mesh
  69839. */
  69840. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69841. }
  69842. }
  69843. declare module BABYLON {
  69844. interface Scene {
  69845. /** @hidden (Backing field) */
  69846. _boundingBoxRenderer: BoundingBoxRenderer;
  69847. /** @hidden (Backing field) */
  69848. _forceShowBoundingBoxes: boolean;
  69849. /**
  69850. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  69851. */
  69852. forceShowBoundingBoxes: boolean;
  69853. /**
  69854. * Gets the bounding box renderer associated with the scene
  69855. * @returns a BoundingBoxRenderer
  69856. */
  69857. getBoundingBoxRenderer(): BoundingBoxRenderer;
  69858. }
  69859. interface AbstractMesh {
  69860. /** @hidden (Backing field) */
  69861. _showBoundingBox: boolean;
  69862. /**
  69863. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  69864. */
  69865. showBoundingBox: boolean;
  69866. }
  69867. /**
  69868. * Component responsible of rendering the bounding box of the meshes in a scene.
  69869. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  69870. */
  69871. export class BoundingBoxRenderer implements ISceneComponent {
  69872. /**
  69873. * The component name helpfull to identify the component in the list of scene components.
  69874. */
  69875. readonly name: string;
  69876. /**
  69877. * The scene the component belongs to.
  69878. */
  69879. scene: Scene;
  69880. /**
  69881. * Color of the bounding box lines placed in front of an object
  69882. */
  69883. frontColor: Color3;
  69884. /**
  69885. * Color of the bounding box lines placed behind an object
  69886. */
  69887. backColor: Color3;
  69888. /**
  69889. * Defines if the renderer should show the back lines or not
  69890. */
  69891. showBackLines: boolean;
  69892. /**
  69893. * Observable raised before rendering a bounding box
  69894. */
  69895. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  69896. /**
  69897. * Observable raised after rendering a bounding box
  69898. */
  69899. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  69900. /**
  69901. * @hidden
  69902. */
  69903. renderList: SmartArray<BoundingBox>;
  69904. private _colorShader;
  69905. private _vertexBuffers;
  69906. private _indexBuffer;
  69907. private _fillIndexBuffer;
  69908. private _fillIndexData;
  69909. /**
  69910. * Instantiates a new bounding box renderer in a scene.
  69911. * @param scene the scene the renderer renders in
  69912. */
  69913. constructor(scene: Scene);
  69914. /**
  69915. * Registers the component in a given scene
  69916. */
  69917. register(): void;
  69918. private _evaluateSubMesh;
  69919. private _activeMesh;
  69920. private _prepareRessources;
  69921. private _createIndexBuffer;
  69922. /**
  69923. * Rebuilds the elements related to this component in case of
  69924. * context lost for instance.
  69925. */
  69926. rebuild(): void;
  69927. /**
  69928. * @hidden
  69929. */
  69930. reset(): void;
  69931. /**
  69932. * Render the bounding boxes of a specific rendering group
  69933. * @param renderingGroupId defines the rendering group to render
  69934. */
  69935. render(renderingGroupId: number): void;
  69936. /**
  69937. * In case of occlusion queries, we can render the occlusion bounding box through this method
  69938. * @param mesh Define the mesh to render the occlusion bounding box for
  69939. */
  69940. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  69941. /**
  69942. * Dispose and release the resources attached to this renderer.
  69943. */
  69944. dispose(): void;
  69945. }
  69946. }
  69947. declare module BABYLON {
  69948. interface Scene {
  69949. /** @hidden (Backing field) */
  69950. _depthRenderer: {
  69951. [id: string]: DepthRenderer;
  69952. };
  69953. /**
  69954. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  69955. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  69956. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  69957. * @returns the created depth renderer
  69958. */
  69959. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  69960. /**
  69961. * Disables a depth renderer for a given camera
  69962. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  69963. */
  69964. disableDepthRenderer(camera?: Nullable<Camera>): void;
  69965. }
  69966. /**
  69967. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  69968. * in several rendering techniques.
  69969. */
  69970. export class DepthRendererSceneComponent implements ISceneComponent {
  69971. /**
  69972. * The component name helpfull to identify the component in the list of scene components.
  69973. */
  69974. readonly name: string;
  69975. /**
  69976. * The scene the component belongs to.
  69977. */
  69978. scene: Scene;
  69979. /**
  69980. * Creates a new instance of the component for the given scene
  69981. * @param scene Defines the scene to register the component in
  69982. */
  69983. constructor(scene: Scene);
  69984. /**
  69985. * Registers the component in a given scene
  69986. */
  69987. register(): void;
  69988. /**
  69989. * Rebuilds the elements related to this component in case of
  69990. * context lost for instance.
  69991. */
  69992. rebuild(): void;
  69993. /**
  69994. * Disposes the component and the associated ressources
  69995. */
  69996. dispose(): void;
  69997. private _gatherRenderTargets;
  69998. private _gatherActiveCameraRenderTargets;
  69999. }
  70000. }
  70001. declare module BABYLON {
  70002. /** @hidden */
  70003. export var outlinePixelShader: {
  70004. name: string;
  70005. shader: string;
  70006. };
  70007. }
  70008. declare module BABYLON {
  70009. /** @hidden */
  70010. export var outlineVertexShader: {
  70011. name: string;
  70012. shader: string;
  70013. };
  70014. }
  70015. declare module BABYLON {
  70016. interface Scene {
  70017. /** @hidden */
  70018. _outlineRenderer: OutlineRenderer;
  70019. /**
  70020. * Gets the outline renderer associated with the scene
  70021. * @returns a OutlineRenderer
  70022. */
  70023. getOutlineRenderer(): OutlineRenderer;
  70024. }
  70025. interface AbstractMesh {
  70026. /** @hidden (Backing field) */
  70027. _renderOutline: boolean;
  70028. /**
  70029. * Gets or sets a boolean indicating if the outline must be rendered as well
  70030. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70031. */
  70032. renderOutline: boolean;
  70033. /** @hidden (Backing field) */
  70034. _renderOverlay: boolean;
  70035. /**
  70036. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70037. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70038. */
  70039. renderOverlay: boolean;
  70040. }
  70041. /**
  70042. * This class is responsible to draw bothe outline/overlay of meshes.
  70043. * It should not be used directly but through the available method on mesh.
  70044. */
  70045. export class OutlineRenderer implements ISceneComponent {
  70046. /**
  70047. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70048. */
  70049. private static _StencilReference;
  70050. /**
  70051. * The name of the component. Each component must have a unique name.
  70052. */
  70053. name: string;
  70054. /**
  70055. * The scene the component belongs to.
  70056. */
  70057. scene: Scene;
  70058. /**
  70059. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70060. */
  70061. zOffset: number;
  70062. private _engine;
  70063. private _effect;
  70064. private _cachedDefines;
  70065. private _savedDepthWrite;
  70066. /**
  70067. * Instantiates a new outline renderer. (There could be only one per scene).
  70068. * @param scene Defines the scene it belongs to
  70069. */
  70070. constructor(scene: Scene);
  70071. /**
  70072. * Register the component to one instance of a scene.
  70073. */
  70074. register(): void;
  70075. /**
  70076. * Rebuilds the elements related to this component in case of
  70077. * context lost for instance.
  70078. */
  70079. rebuild(): void;
  70080. /**
  70081. * Disposes the component and the associated ressources.
  70082. */
  70083. dispose(): void;
  70084. /**
  70085. * Renders the outline in the canvas.
  70086. * @param subMesh Defines the sumesh to render
  70087. * @param batch Defines the batch of meshes in case of instances
  70088. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70089. */
  70090. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70091. /**
  70092. * Returns whether or not the outline renderer is ready for a given submesh.
  70093. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70094. * @param subMesh Defines the submesh to check readyness for
  70095. * @param useInstances Defines wheter wee are trying to render instances or not
  70096. * @returns true if ready otherwise false
  70097. */
  70098. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70099. private _beforeRenderingMesh;
  70100. private _afterRenderingMesh;
  70101. }
  70102. }
  70103. declare module BABYLON {
  70104. /**
  70105. * Defines the basic options interface of a Sprite Frame Source Size.
  70106. */
  70107. export interface ISpriteJSONSpriteSourceSize {
  70108. /**
  70109. * number of the original width of the Frame
  70110. */
  70111. w: number;
  70112. /**
  70113. * number of the original height of the Frame
  70114. */
  70115. h: number;
  70116. }
  70117. /**
  70118. * Defines the basic options interface of a Sprite Frame Data.
  70119. */
  70120. export interface ISpriteJSONSpriteFrameData {
  70121. /**
  70122. * number of the x offset of the Frame
  70123. */
  70124. x: number;
  70125. /**
  70126. * number of the y offset of the Frame
  70127. */
  70128. y: number;
  70129. /**
  70130. * number of the width of the Frame
  70131. */
  70132. w: number;
  70133. /**
  70134. * number of the height of the Frame
  70135. */
  70136. h: number;
  70137. }
  70138. /**
  70139. * Defines the basic options interface of a JSON Sprite.
  70140. */
  70141. export interface ISpriteJSONSprite {
  70142. /**
  70143. * string name of the Frame
  70144. */
  70145. filename: string;
  70146. /**
  70147. * ISpriteJSONSpriteFrame basic object of the frame data
  70148. */
  70149. frame: ISpriteJSONSpriteFrameData;
  70150. /**
  70151. * boolean to flag is the frame was rotated.
  70152. */
  70153. rotated: boolean;
  70154. /**
  70155. * boolean to flag is the frame was trimmed.
  70156. */
  70157. trimmed: boolean;
  70158. /**
  70159. * ISpriteJSONSpriteFrame basic object of the source data
  70160. */
  70161. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70162. /**
  70163. * ISpriteJSONSpriteFrame basic object of the source data
  70164. */
  70165. sourceSize: ISpriteJSONSpriteSourceSize;
  70166. }
  70167. /**
  70168. * Defines the basic options interface of a JSON atlas.
  70169. */
  70170. export interface ISpriteJSONAtlas {
  70171. /**
  70172. * Array of objects that contain the frame data.
  70173. */
  70174. frames: Array<ISpriteJSONSprite>;
  70175. /**
  70176. * object basic object containing the sprite meta data.
  70177. */
  70178. meta?: object;
  70179. }
  70180. }
  70181. declare module BABYLON {
  70182. /** @hidden */
  70183. export var spriteMapPixelShader: {
  70184. name: string;
  70185. shader: string;
  70186. };
  70187. }
  70188. declare module BABYLON {
  70189. /** @hidden */
  70190. export var spriteMapVertexShader: {
  70191. name: string;
  70192. shader: string;
  70193. };
  70194. }
  70195. declare module BABYLON {
  70196. /**
  70197. * Defines the basic options interface of a SpriteMap
  70198. */
  70199. export interface ISpriteMapOptions {
  70200. /**
  70201. * Vector2 of the number of cells in the grid.
  70202. */
  70203. stageSize?: Vector2;
  70204. /**
  70205. * Vector2 of the size of the output plane in World Units.
  70206. */
  70207. outputSize?: Vector2;
  70208. /**
  70209. * Vector3 of the position of the output plane in World Units.
  70210. */
  70211. outputPosition?: Vector3;
  70212. /**
  70213. * Vector3 of the rotation of the output plane.
  70214. */
  70215. outputRotation?: Vector3;
  70216. /**
  70217. * number of layers that the system will reserve in resources.
  70218. */
  70219. layerCount?: number;
  70220. /**
  70221. * number of max animation frames a single cell will reserve in resources.
  70222. */
  70223. maxAnimationFrames?: number;
  70224. /**
  70225. * number cell index of the base tile when the system compiles.
  70226. */
  70227. baseTile?: number;
  70228. /**
  70229. * boolean flip the sprite after its been repositioned by the framing data.
  70230. */
  70231. flipU?: boolean;
  70232. /**
  70233. * Vector3 scalar of the global RGB values of the SpriteMap.
  70234. */
  70235. colorMultiply?: Vector3;
  70236. }
  70237. /**
  70238. * Defines the IDisposable interface in order to be cleanable from resources.
  70239. */
  70240. export interface ISpriteMap extends IDisposable {
  70241. /**
  70242. * String name of the SpriteMap.
  70243. */
  70244. name: string;
  70245. /**
  70246. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70247. */
  70248. atlasJSON: ISpriteJSONAtlas;
  70249. /**
  70250. * Texture of the SpriteMap.
  70251. */
  70252. spriteSheet: Texture;
  70253. /**
  70254. * The parameters to initialize the SpriteMap with.
  70255. */
  70256. options: ISpriteMapOptions;
  70257. }
  70258. /**
  70259. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70260. */
  70261. export class SpriteMap implements ISpriteMap {
  70262. /** The Name of the spriteMap */
  70263. name: string;
  70264. /** The JSON file with the frame and meta data */
  70265. atlasJSON: ISpriteJSONAtlas;
  70266. /** The systems Sprite Sheet Texture */
  70267. spriteSheet: Texture;
  70268. /** Arguments passed with the Constructor */
  70269. options: ISpriteMapOptions;
  70270. /** Public Sprite Storage array, parsed from atlasJSON */
  70271. sprites: Array<ISpriteJSONSprite>;
  70272. /** Returns the Number of Sprites in the System */
  70273. get spriteCount(): number;
  70274. /** Returns the Position of Output Plane*/
  70275. get position(): Vector3;
  70276. /** Returns the Position of Output Plane*/
  70277. set position(v: Vector3);
  70278. /** Returns the Rotation of Output Plane*/
  70279. get rotation(): Vector3;
  70280. /** Returns the Rotation of Output Plane*/
  70281. set rotation(v: Vector3);
  70282. /** Sets the AnimationMap*/
  70283. get animationMap(): RawTexture;
  70284. /** Sets the AnimationMap*/
  70285. set animationMap(v: RawTexture);
  70286. /** Scene that the SpriteMap was created in */
  70287. private _scene;
  70288. /** Texture Buffer of Float32 that holds tile frame data*/
  70289. private _frameMap;
  70290. /** Texture Buffers of Float32 that holds tileMap data*/
  70291. private _tileMaps;
  70292. /** Texture Buffer of Float32 that holds Animation Data*/
  70293. private _animationMap;
  70294. /** Custom ShaderMaterial Central to the System*/
  70295. private _material;
  70296. /** Custom ShaderMaterial Central to the System*/
  70297. private _output;
  70298. /** Systems Time Ticker*/
  70299. private _time;
  70300. /**
  70301. * Creates a new SpriteMap
  70302. * @param name defines the SpriteMaps Name
  70303. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70304. * @param spriteSheet is the Texture that the Sprites are on.
  70305. * @param options a basic deployment configuration
  70306. * @param scene The Scene that the map is deployed on
  70307. */
  70308. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70309. /**
  70310. * Returns tileID location
  70311. * @returns Vector2 the cell position ID
  70312. */
  70313. getTileID(): Vector2;
  70314. /**
  70315. * Gets the UV location of the mouse over the SpriteMap.
  70316. * @returns Vector2 the UV position of the mouse interaction
  70317. */
  70318. getMousePosition(): Vector2;
  70319. /**
  70320. * Creates the "frame" texture Buffer
  70321. * -------------------------------------
  70322. * Structure of frames
  70323. * "filename": "Falling-Water-2.png",
  70324. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70325. * "rotated": true,
  70326. * "trimmed": true,
  70327. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70328. * "sourceSize": {"w":32,"h":32}
  70329. * @returns RawTexture of the frameMap
  70330. */
  70331. private _createFrameBuffer;
  70332. /**
  70333. * Creates the tileMap texture Buffer
  70334. * @param buffer normally and array of numbers, or a false to generate from scratch
  70335. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70336. * @returns RawTexture of the tileMap
  70337. */
  70338. private _createTileBuffer;
  70339. /**
  70340. * Modifies the data of the tileMaps
  70341. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70342. * @param pos is the iVector2 Coordinates of the Tile
  70343. * @param tile The SpriteIndex of the new Tile
  70344. */
  70345. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70346. /**
  70347. * Creates the animationMap texture Buffer
  70348. * @param buffer normally and array of numbers, or a false to generate from scratch
  70349. * @returns RawTexture of the animationMap
  70350. */
  70351. private _createTileAnimationBuffer;
  70352. /**
  70353. * Modifies the data of the animationMap
  70354. * @param cellID is the Index of the Sprite
  70355. * @param _frame is the target Animation frame
  70356. * @param toCell is the Target Index of the next frame of the animation
  70357. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70358. * @param speed is a global scalar of the time variable on the map.
  70359. */
  70360. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70361. /**
  70362. * Exports the .tilemaps file
  70363. */
  70364. saveTileMaps(): void;
  70365. /**
  70366. * Imports the .tilemaps file
  70367. * @param url of the .tilemaps file
  70368. */
  70369. loadTileMaps(url: string): void;
  70370. /**
  70371. * Release associated resources
  70372. */
  70373. dispose(): void;
  70374. }
  70375. }
  70376. declare module BABYLON {
  70377. /**
  70378. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70379. * @see http://doc.babylonjs.com/babylon101/sprites
  70380. */
  70381. export class SpritePackedManager extends SpriteManager {
  70382. /** defines the packed manager's name */
  70383. name: string;
  70384. /**
  70385. * Creates a new sprite manager from a packed sprite sheet
  70386. * @param name defines the manager's name
  70387. * @param imgUrl defines the sprite sheet url
  70388. * @param capacity defines the maximum allowed number of sprites
  70389. * @param scene defines the hosting scene
  70390. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70391. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70392. * @param samplingMode defines the smapling mode to use with spritesheet
  70393. * @param fromPacked set to true; do not alter
  70394. */
  70395. constructor(
  70396. /** defines the packed manager's name */
  70397. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70398. }
  70399. }
  70400. declare module BABYLON {
  70401. /**
  70402. * Defines the list of states available for a task inside a AssetsManager
  70403. */
  70404. export enum AssetTaskState {
  70405. /**
  70406. * Initialization
  70407. */
  70408. INIT = 0,
  70409. /**
  70410. * Running
  70411. */
  70412. RUNNING = 1,
  70413. /**
  70414. * Done
  70415. */
  70416. DONE = 2,
  70417. /**
  70418. * Error
  70419. */
  70420. ERROR = 3
  70421. }
  70422. /**
  70423. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70424. */
  70425. export abstract class AbstractAssetTask {
  70426. /**
  70427. * Task name
  70428. */ name: string;
  70429. /**
  70430. * Callback called when the task is successful
  70431. */
  70432. onSuccess: (task: any) => void;
  70433. /**
  70434. * Callback called when the task is not successful
  70435. */
  70436. onError: (task: any, message?: string, exception?: any) => void;
  70437. /**
  70438. * Creates a new AssetsManager
  70439. * @param name defines the name of the task
  70440. */
  70441. constructor(
  70442. /**
  70443. * Task name
  70444. */ name: string);
  70445. private _isCompleted;
  70446. private _taskState;
  70447. private _errorObject;
  70448. /**
  70449. * Get if the task is completed
  70450. */
  70451. get isCompleted(): boolean;
  70452. /**
  70453. * Gets the current state of the task
  70454. */
  70455. get taskState(): AssetTaskState;
  70456. /**
  70457. * Gets the current error object (if task is in error)
  70458. */
  70459. get errorObject(): {
  70460. message?: string;
  70461. exception?: any;
  70462. };
  70463. /**
  70464. * Internal only
  70465. * @hidden
  70466. */
  70467. _setErrorObject(message?: string, exception?: any): void;
  70468. /**
  70469. * Execute the current task
  70470. * @param scene defines the scene where you want your assets to be loaded
  70471. * @param onSuccess is a callback called when the task is successfully executed
  70472. * @param onError is a callback called if an error occurs
  70473. */
  70474. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70475. /**
  70476. * Execute the current task
  70477. * @param scene defines the scene where you want your assets to be loaded
  70478. * @param onSuccess is a callback called when the task is successfully executed
  70479. * @param onError is a callback called if an error occurs
  70480. */
  70481. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70482. /**
  70483. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70484. * This can be used with failed tasks that have the reason for failure fixed.
  70485. */
  70486. reset(): void;
  70487. private onErrorCallback;
  70488. private onDoneCallback;
  70489. }
  70490. /**
  70491. * Define the interface used by progress events raised during assets loading
  70492. */
  70493. export interface IAssetsProgressEvent {
  70494. /**
  70495. * Defines the number of remaining tasks to process
  70496. */
  70497. remainingCount: number;
  70498. /**
  70499. * Defines the total number of tasks
  70500. */
  70501. totalCount: number;
  70502. /**
  70503. * Defines the task that was just processed
  70504. */
  70505. task: AbstractAssetTask;
  70506. }
  70507. /**
  70508. * Class used to share progress information about assets loading
  70509. */
  70510. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70511. /**
  70512. * Defines the number of remaining tasks to process
  70513. */
  70514. remainingCount: number;
  70515. /**
  70516. * Defines the total number of tasks
  70517. */
  70518. totalCount: number;
  70519. /**
  70520. * Defines the task that was just processed
  70521. */
  70522. task: AbstractAssetTask;
  70523. /**
  70524. * Creates a AssetsProgressEvent
  70525. * @param remainingCount defines the number of remaining tasks to process
  70526. * @param totalCount defines the total number of tasks
  70527. * @param task defines the task that was just processed
  70528. */
  70529. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70530. }
  70531. /**
  70532. * Define a task used by AssetsManager to load meshes
  70533. */
  70534. export class MeshAssetTask extends AbstractAssetTask {
  70535. /**
  70536. * Defines the name of the task
  70537. */
  70538. name: string;
  70539. /**
  70540. * Defines the list of mesh's names you want to load
  70541. */
  70542. meshesNames: any;
  70543. /**
  70544. * Defines the root url to use as a base to load your meshes and associated resources
  70545. */
  70546. rootUrl: string;
  70547. /**
  70548. * Defines the filename or File of the scene to load from
  70549. */
  70550. sceneFilename: string | File;
  70551. /**
  70552. * Gets the list of loaded meshes
  70553. */
  70554. loadedMeshes: Array<AbstractMesh>;
  70555. /**
  70556. * Gets the list of loaded particle systems
  70557. */
  70558. loadedParticleSystems: Array<IParticleSystem>;
  70559. /**
  70560. * Gets the list of loaded skeletons
  70561. */
  70562. loadedSkeletons: Array<Skeleton>;
  70563. /**
  70564. * Gets the list of loaded animation groups
  70565. */
  70566. loadedAnimationGroups: Array<AnimationGroup>;
  70567. /**
  70568. * Callback called when the task is successful
  70569. */
  70570. onSuccess: (task: MeshAssetTask) => void;
  70571. /**
  70572. * Callback called when the task is successful
  70573. */
  70574. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70575. /**
  70576. * Creates a new MeshAssetTask
  70577. * @param name defines the name of the task
  70578. * @param meshesNames defines the list of mesh's names you want to load
  70579. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70580. * @param sceneFilename defines the filename or File of the scene to load from
  70581. */
  70582. constructor(
  70583. /**
  70584. * Defines the name of the task
  70585. */
  70586. name: string,
  70587. /**
  70588. * Defines the list of mesh's names you want to load
  70589. */
  70590. meshesNames: any,
  70591. /**
  70592. * Defines the root url to use as a base to load your meshes and associated resources
  70593. */
  70594. rootUrl: string,
  70595. /**
  70596. * Defines the filename or File of the scene to load from
  70597. */
  70598. sceneFilename: string | File);
  70599. /**
  70600. * Execute the current task
  70601. * @param scene defines the scene where you want your assets to be loaded
  70602. * @param onSuccess is a callback called when the task is successfully executed
  70603. * @param onError is a callback called if an error occurs
  70604. */
  70605. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70606. }
  70607. /**
  70608. * Define a task used by AssetsManager to load text content
  70609. */
  70610. export class TextFileAssetTask extends AbstractAssetTask {
  70611. /**
  70612. * Defines the name of the task
  70613. */
  70614. name: string;
  70615. /**
  70616. * Defines the location of the file to load
  70617. */
  70618. url: string;
  70619. /**
  70620. * Gets the loaded text string
  70621. */
  70622. text: string;
  70623. /**
  70624. * Callback called when the task is successful
  70625. */
  70626. onSuccess: (task: TextFileAssetTask) => void;
  70627. /**
  70628. * Callback called when the task is successful
  70629. */
  70630. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70631. /**
  70632. * Creates a new TextFileAssetTask object
  70633. * @param name defines the name of the task
  70634. * @param url defines the location of the file to load
  70635. */
  70636. constructor(
  70637. /**
  70638. * Defines the name of the task
  70639. */
  70640. name: string,
  70641. /**
  70642. * Defines the location of the file to load
  70643. */
  70644. url: string);
  70645. /**
  70646. * Execute the current task
  70647. * @param scene defines the scene where you want your assets to be loaded
  70648. * @param onSuccess is a callback called when the task is successfully executed
  70649. * @param onError is a callback called if an error occurs
  70650. */
  70651. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70652. }
  70653. /**
  70654. * Define a task used by AssetsManager to load binary data
  70655. */
  70656. export class BinaryFileAssetTask extends AbstractAssetTask {
  70657. /**
  70658. * Defines the name of the task
  70659. */
  70660. name: string;
  70661. /**
  70662. * Defines the location of the file to load
  70663. */
  70664. url: string;
  70665. /**
  70666. * Gets the lodaded data (as an array buffer)
  70667. */
  70668. data: ArrayBuffer;
  70669. /**
  70670. * Callback called when the task is successful
  70671. */
  70672. onSuccess: (task: BinaryFileAssetTask) => void;
  70673. /**
  70674. * Callback called when the task is successful
  70675. */
  70676. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70677. /**
  70678. * Creates a new BinaryFileAssetTask object
  70679. * @param name defines the name of the new task
  70680. * @param url defines the location of the file to load
  70681. */
  70682. constructor(
  70683. /**
  70684. * Defines the name of the task
  70685. */
  70686. name: string,
  70687. /**
  70688. * Defines the location of the file to load
  70689. */
  70690. url: string);
  70691. /**
  70692. * Execute the current task
  70693. * @param scene defines the scene where you want your assets to be loaded
  70694. * @param onSuccess is a callback called when the task is successfully executed
  70695. * @param onError is a callback called if an error occurs
  70696. */
  70697. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70698. }
  70699. /**
  70700. * Define a task used by AssetsManager to load images
  70701. */
  70702. export class ImageAssetTask extends AbstractAssetTask {
  70703. /**
  70704. * Defines the name of the task
  70705. */
  70706. name: string;
  70707. /**
  70708. * Defines the location of the image to load
  70709. */
  70710. url: string;
  70711. /**
  70712. * Gets the loaded images
  70713. */
  70714. image: HTMLImageElement;
  70715. /**
  70716. * Callback called when the task is successful
  70717. */
  70718. onSuccess: (task: ImageAssetTask) => void;
  70719. /**
  70720. * Callback called when the task is successful
  70721. */
  70722. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70723. /**
  70724. * Creates a new ImageAssetTask
  70725. * @param name defines the name of the task
  70726. * @param url defines the location of the image to load
  70727. */
  70728. constructor(
  70729. /**
  70730. * Defines the name of the task
  70731. */
  70732. name: string,
  70733. /**
  70734. * Defines the location of the image to load
  70735. */
  70736. url: string);
  70737. /**
  70738. * Execute the current task
  70739. * @param scene defines the scene where you want your assets to be loaded
  70740. * @param onSuccess is a callback called when the task is successfully executed
  70741. * @param onError is a callback called if an error occurs
  70742. */
  70743. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70744. }
  70745. /**
  70746. * Defines the interface used by texture loading tasks
  70747. */
  70748. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70749. /**
  70750. * Gets the loaded texture
  70751. */
  70752. texture: TEX;
  70753. }
  70754. /**
  70755. * Define a task used by AssetsManager to load 2D textures
  70756. */
  70757. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70758. /**
  70759. * Defines the name of the task
  70760. */
  70761. name: string;
  70762. /**
  70763. * Defines the location of the file to load
  70764. */
  70765. url: string;
  70766. /**
  70767. * Defines if mipmap should not be generated (default is false)
  70768. */
  70769. noMipmap?: boolean | undefined;
  70770. /**
  70771. * Defines if texture must be inverted on Y axis (default is true)
  70772. */
  70773. invertY: boolean;
  70774. /**
  70775. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70776. */
  70777. samplingMode: number;
  70778. /**
  70779. * Gets the loaded texture
  70780. */
  70781. texture: Texture;
  70782. /**
  70783. * Callback called when the task is successful
  70784. */
  70785. onSuccess: (task: TextureAssetTask) => void;
  70786. /**
  70787. * Callback called when the task is successful
  70788. */
  70789. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  70790. /**
  70791. * Creates a new TextureAssetTask object
  70792. * @param name defines the name of the task
  70793. * @param url defines the location of the file to load
  70794. * @param noMipmap defines if mipmap should not be generated (default is false)
  70795. * @param invertY defines if texture must be inverted on Y axis (default is true)
  70796. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70797. */
  70798. constructor(
  70799. /**
  70800. * Defines the name of the task
  70801. */
  70802. name: string,
  70803. /**
  70804. * Defines the location of the file to load
  70805. */
  70806. url: string,
  70807. /**
  70808. * Defines if mipmap should not be generated (default is false)
  70809. */
  70810. noMipmap?: boolean | undefined,
  70811. /**
  70812. * Defines if texture must be inverted on Y axis (default is true)
  70813. */
  70814. invertY?: boolean,
  70815. /**
  70816. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70817. */
  70818. samplingMode?: number);
  70819. /**
  70820. * Execute the current task
  70821. * @param scene defines the scene where you want your assets to be loaded
  70822. * @param onSuccess is a callback called when the task is successfully executed
  70823. * @param onError is a callback called if an error occurs
  70824. */
  70825. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70826. }
  70827. /**
  70828. * Define a task used by AssetsManager to load cube textures
  70829. */
  70830. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  70831. /**
  70832. * Defines the name of the task
  70833. */
  70834. name: string;
  70835. /**
  70836. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70837. */
  70838. url: string;
  70839. /**
  70840. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70841. */
  70842. extensions?: string[] | undefined;
  70843. /**
  70844. * Defines if mipmaps should not be generated (default is false)
  70845. */
  70846. noMipmap?: boolean | undefined;
  70847. /**
  70848. * Defines the explicit list of files (undefined by default)
  70849. */
  70850. files?: string[] | undefined;
  70851. /**
  70852. * Gets the loaded texture
  70853. */
  70854. texture: CubeTexture;
  70855. /**
  70856. * Callback called when the task is successful
  70857. */
  70858. onSuccess: (task: CubeTextureAssetTask) => void;
  70859. /**
  70860. * Callback called when the task is successful
  70861. */
  70862. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  70863. /**
  70864. * Creates a new CubeTextureAssetTask
  70865. * @param name defines the name of the task
  70866. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70867. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70868. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70869. * @param files defines the explicit list of files (undefined by default)
  70870. */
  70871. constructor(
  70872. /**
  70873. * Defines the name of the task
  70874. */
  70875. name: string,
  70876. /**
  70877. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70878. */
  70879. url: string,
  70880. /**
  70881. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70882. */
  70883. extensions?: string[] | undefined,
  70884. /**
  70885. * Defines if mipmaps should not be generated (default is false)
  70886. */
  70887. noMipmap?: boolean | undefined,
  70888. /**
  70889. * Defines the explicit list of files (undefined by default)
  70890. */
  70891. files?: string[] | undefined);
  70892. /**
  70893. * Execute the current task
  70894. * @param scene defines the scene where you want your assets to be loaded
  70895. * @param onSuccess is a callback called when the task is successfully executed
  70896. * @param onError is a callback called if an error occurs
  70897. */
  70898. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70899. }
  70900. /**
  70901. * Define a task used by AssetsManager to load HDR cube textures
  70902. */
  70903. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  70904. /**
  70905. * Defines the name of the task
  70906. */
  70907. name: string;
  70908. /**
  70909. * Defines the location of the file to load
  70910. */
  70911. url: string;
  70912. /**
  70913. * Defines the desired size (the more it increases the longer the generation will be)
  70914. */
  70915. size: number;
  70916. /**
  70917. * Defines if mipmaps should not be generated (default is false)
  70918. */
  70919. noMipmap: boolean;
  70920. /**
  70921. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70922. */
  70923. generateHarmonics: boolean;
  70924. /**
  70925. * 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)
  70926. */
  70927. gammaSpace: boolean;
  70928. /**
  70929. * Internal Use Only
  70930. */
  70931. reserved: boolean;
  70932. /**
  70933. * Gets the loaded texture
  70934. */
  70935. texture: HDRCubeTexture;
  70936. /**
  70937. * Callback called when the task is successful
  70938. */
  70939. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  70940. /**
  70941. * Callback called when the task is successful
  70942. */
  70943. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  70944. /**
  70945. * Creates a new HDRCubeTextureAssetTask object
  70946. * @param name defines the name of the task
  70947. * @param url defines the location of the file to load
  70948. * @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.
  70949. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70950. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70951. * @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)
  70952. * @param reserved Internal use only
  70953. */
  70954. constructor(
  70955. /**
  70956. * Defines the name of the task
  70957. */
  70958. name: string,
  70959. /**
  70960. * Defines the location of the file to load
  70961. */
  70962. url: string,
  70963. /**
  70964. * Defines the desired size (the more it increases the longer the generation will be)
  70965. */
  70966. size: number,
  70967. /**
  70968. * Defines if mipmaps should not be generated (default is false)
  70969. */
  70970. noMipmap?: boolean,
  70971. /**
  70972. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70973. */
  70974. generateHarmonics?: boolean,
  70975. /**
  70976. * 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)
  70977. */
  70978. gammaSpace?: boolean,
  70979. /**
  70980. * Internal Use Only
  70981. */
  70982. reserved?: boolean);
  70983. /**
  70984. * Execute the current task
  70985. * @param scene defines the scene where you want your assets to be loaded
  70986. * @param onSuccess is a callback called when the task is successfully executed
  70987. * @param onError is a callback called if an error occurs
  70988. */
  70989. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70990. }
  70991. /**
  70992. * Define a task used by AssetsManager to load Equirectangular cube textures
  70993. */
  70994. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  70995. /**
  70996. * Defines the name of the task
  70997. */
  70998. name: string;
  70999. /**
  71000. * Defines the location of the file to load
  71001. */
  71002. url: string;
  71003. /**
  71004. * Defines the desired size (the more it increases the longer the generation will be)
  71005. */
  71006. size: number;
  71007. /**
  71008. * Defines if mipmaps should not be generated (default is false)
  71009. */
  71010. noMipmap: boolean;
  71011. /**
  71012. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71013. * but the standard material would require them in Gamma space) (default is true)
  71014. */
  71015. gammaSpace: boolean;
  71016. /**
  71017. * Gets the loaded texture
  71018. */
  71019. texture: EquiRectangularCubeTexture;
  71020. /**
  71021. * Callback called when the task is successful
  71022. */
  71023. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71024. /**
  71025. * Callback called when the task is successful
  71026. */
  71027. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71028. /**
  71029. * Creates a new EquiRectangularCubeTextureAssetTask object
  71030. * @param name defines the name of the task
  71031. * @param url defines the location of the file to load
  71032. * @param size defines the desired size (the more it increases the longer the generation will be)
  71033. * If the size is omitted this implies you are using a preprocessed cubemap.
  71034. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71035. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71036. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71037. * (default is true)
  71038. */
  71039. constructor(
  71040. /**
  71041. * Defines the name of the task
  71042. */
  71043. name: string,
  71044. /**
  71045. * Defines the location of the file to load
  71046. */
  71047. url: string,
  71048. /**
  71049. * Defines the desired size (the more it increases the longer the generation will be)
  71050. */
  71051. size: number,
  71052. /**
  71053. * Defines if mipmaps should not be generated (default is false)
  71054. */
  71055. noMipmap?: boolean,
  71056. /**
  71057. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71058. * but the standard material would require them in Gamma space) (default is true)
  71059. */
  71060. gammaSpace?: boolean);
  71061. /**
  71062. * Execute the current task
  71063. * @param scene defines the scene where you want your assets to be loaded
  71064. * @param onSuccess is a callback called when the task is successfully executed
  71065. * @param onError is a callback called if an error occurs
  71066. */
  71067. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71068. }
  71069. /**
  71070. * This class can be used to easily import assets into a scene
  71071. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71072. */
  71073. export class AssetsManager {
  71074. private _scene;
  71075. private _isLoading;
  71076. protected _tasks: AbstractAssetTask[];
  71077. protected _waitingTasksCount: number;
  71078. protected _totalTasksCount: number;
  71079. /**
  71080. * Callback called when all tasks are processed
  71081. */
  71082. onFinish: (tasks: AbstractAssetTask[]) => void;
  71083. /**
  71084. * Callback called when a task is successful
  71085. */
  71086. onTaskSuccess: (task: AbstractAssetTask) => void;
  71087. /**
  71088. * Callback called when a task had an error
  71089. */
  71090. onTaskError: (task: AbstractAssetTask) => void;
  71091. /**
  71092. * Callback called when a task is done (whatever the result is)
  71093. */
  71094. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71095. /**
  71096. * Observable called when all tasks are processed
  71097. */
  71098. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71099. /**
  71100. * Observable called when a task had an error
  71101. */
  71102. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71103. /**
  71104. * Observable called when all tasks were executed
  71105. */
  71106. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71107. /**
  71108. * Observable called when a task is done (whatever the result is)
  71109. */
  71110. onProgressObservable: Observable<IAssetsProgressEvent>;
  71111. /**
  71112. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71113. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71114. */
  71115. useDefaultLoadingScreen: boolean;
  71116. /**
  71117. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71118. * when all assets have been downloaded.
  71119. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71120. */
  71121. autoHideLoadingUI: boolean;
  71122. /**
  71123. * Creates a new AssetsManager
  71124. * @param scene defines the scene to work on
  71125. */
  71126. constructor(scene: Scene);
  71127. /**
  71128. * Add a MeshAssetTask to the list of active tasks
  71129. * @param taskName defines the name of the new task
  71130. * @param meshesNames defines the name of meshes to load
  71131. * @param rootUrl defines the root url to use to locate files
  71132. * @param sceneFilename defines the filename of the scene file
  71133. * @returns a new MeshAssetTask object
  71134. */
  71135. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71136. /**
  71137. * Add a TextFileAssetTask to the list of active tasks
  71138. * @param taskName defines the name of the new task
  71139. * @param url defines the url of the file to load
  71140. * @returns a new TextFileAssetTask object
  71141. */
  71142. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71143. /**
  71144. * Add a BinaryFileAssetTask to the list of active tasks
  71145. * @param taskName defines the name of the new task
  71146. * @param url defines the url of the file to load
  71147. * @returns a new BinaryFileAssetTask object
  71148. */
  71149. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71150. /**
  71151. * Add a ImageAssetTask to the list of active tasks
  71152. * @param taskName defines the name of the new task
  71153. * @param url defines the url of the file to load
  71154. * @returns a new ImageAssetTask object
  71155. */
  71156. addImageTask(taskName: string, url: string): ImageAssetTask;
  71157. /**
  71158. * Add a TextureAssetTask to the list of active tasks
  71159. * @param taskName defines the name of the new task
  71160. * @param url defines the url of the file to load
  71161. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71162. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71163. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71164. * @returns a new TextureAssetTask object
  71165. */
  71166. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71167. /**
  71168. * Add a CubeTextureAssetTask to the list of active tasks
  71169. * @param taskName defines the name of the new task
  71170. * @param url defines the url of the file to load
  71171. * @param extensions defines the extension to use to load the cube map (can be null)
  71172. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71173. * @param files defines the list of files to load (can be null)
  71174. * @returns a new CubeTextureAssetTask object
  71175. */
  71176. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71177. /**
  71178. *
  71179. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71180. * @param taskName defines the name of the new task
  71181. * @param url defines the url of the file to load
  71182. * @param size defines the size you want for the cubemap (can be null)
  71183. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71184. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71185. * @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)
  71186. * @param reserved Internal use only
  71187. * @returns a new HDRCubeTextureAssetTask object
  71188. */
  71189. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71190. /**
  71191. *
  71192. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71193. * @param taskName defines the name of the new task
  71194. * @param url defines the url of the file to load
  71195. * @param size defines the size you want for the cubemap (can be null)
  71196. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71197. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71198. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71199. * @returns a new EquiRectangularCubeTextureAssetTask object
  71200. */
  71201. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71202. /**
  71203. * Remove a task from the assets manager.
  71204. * @param task the task to remove
  71205. */
  71206. removeTask(task: AbstractAssetTask): void;
  71207. private _decreaseWaitingTasksCount;
  71208. private _runTask;
  71209. /**
  71210. * Reset the AssetsManager and remove all tasks
  71211. * @return the current instance of the AssetsManager
  71212. */
  71213. reset(): AssetsManager;
  71214. /**
  71215. * Start the loading process
  71216. * @return the current instance of the AssetsManager
  71217. */
  71218. load(): AssetsManager;
  71219. /**
  71220. * Start the loading process as an async operation
  71221. * @return a promise returning the list of failed tasks
  71222. */
  71223. loadAsync(): Promise<void>;
  71224. }
  71225. }
  71226. declare module BABYLON {
  71227. /**
  71228. * Wrapper class for promise with external resolve and reject.
  71229. */
  71230. export class Deferred<T> {
  71231. /**
  71232. * The promise associated with this deferred object.
  71233. */
  71234. readonly promise: Promise<T>;
  71235. private _resolve;
  71236. private _reject;
  71237. /**
  71238. * The resolve method of the promise associated with this deferred object.
  71239. */
  71240. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71241. /**
  71242. * The reject method of the promise associated with this deferred object.
  71243. */
  71244. get reject(): (reason?: any) => void;
  71245. /**
  71246. * Constructor for this deferred object.
  71247. */
  71248. constructor();
  71249. }
  71250. }
  71251. declare module BABYLON {
  71252. /**
  71253. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71254. */
  71255. export class MeshExploder {
  71256. private _centerMesh;
  71257. private _meshes;
  71258. private _meshesOrigins;
  71259. private _toCenterVectors;
  71260. private _scaledDirection;
  71261. private _newPosition;
  71262. private _centerPosition;
  71263. /**
  71264. * Explodes meshes from a center mesh.
  71265. * @param meshes The meshes to explode.
  71266. * @param centerMesh The mesh to be center of explosion.
  71267. */
  71268. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71269. private _setCenterMesh;
  71270. /**
  71271. * Get class name
  71272. * @returns "MeshExploder"
  71273. */
  71274. getClassName(): string;
  71275. /**
  71276. * "Exploded meshes"
  71277. * @returns Array of meshes with the centerMesh at index 0.
  71278. */
  71279. getMeshes(): Array<Mesh>;
  71280. /**
  71281. * Explodes meshes giving a specific direction
  71282. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71283. */
  71284. explode(direction?: number): void;
  71285. }
  71286. }
  71287. declare module BABYLON {
  71288. /**
  71289. * Class used to help managing file picking and drag'n'drop
  71290. */
  71291. export class FilesInput {
  71292. /**
  71293. * List of files ready to be loaded
  71294. */
  71295. static get FilesToLoad(): {
  71296. [key: string]: File;
  71297. };
  71298. /**
  71299. * Callback called when a file is processed
  71300. */
  71301. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71302. private _engine;
  71303. private _currentScene;
  71304. private _sceneLoadedCallback;
  71305. private _progressCallback;
  71306. private _additionalRenderLoopLogicCallback;
  71307. private _textureLoadingCallback;
  71308. private _startingProcessingFilesCallback;
  71309. private _onReloadCallback;
  71310. private _errorCallback;
  71311. private _elementToMonitor;
  71312. private _sceneFileToLoad;
  71313. private _filesToLoad;
  71314. /**
  71315. * Creates a new FilesInput
  71316. * @param engine defines the rendering engine
  71317. * @param scene defines the hosting scene
  71318. * @param sceneLoadedCallback callback called when scene is loaded
  71319. * @param progressCallback callback called to track progress
  71320. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71321. * @param textureLoadingCallback callback called when a texture is loading
  71322. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71323. * @param onReloadCallback callback called when a reload is requested
  71324. * @param errorCallback callback call if an error occurs
  71325. */
  71326. 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);
  71327. private _dragEnterHandler;
  71328. private _dragOverHandler;
  71329. private _dropHandler;
  71330. /**
  71331. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71332. * @param elementToMonitor defines the DOM element to track
  71333. */
  71334. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71335. /**
  71336. * Release all associated resources
  71337. */
  71338. dispose(): void;
  71339. private renderFunction;
  71340. private drag;
  71341. private drop;
  71342. private _traverseFolder;
  71343. private _processFiles;
  71344. /**
  71345. * Load files from a drop event
  71346. * @param event defines the drop event to use as source
  71347. */
  71348. loadFiles(event: any): void;
  71349. private _processReload;
  71350. /**
  71351. * Reload the current scene from the loaded files
  71352. */
  71353. reload(): void;
  71354. }
  71355. }
  71356. declare module BABYLON {
  71357. /**
  71358. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71359. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71360. */
  71361. export class SceneOptimization {
  71362. /**
  71363. * Defines the priority of this optimization (0 by default which means first in the list)
  71364. */
  71365. priority: number;
  71366. /**
  71367. * Gets a string describing the action executed by the current optimization
  71368. * @returns description string
  71369. */
  71370. getDescription(): string;
  71371. /**
  71372. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71373. * @param scene defines the current scene where to apply this optimization
  71374. * @param optimizer defines the current optimizer
  71375. * @returns true if everything that can be done was applied
  71376. */
  71377. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71378. /**
  71379. * Creates the SceneOptimization object
  71380. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71381. * @param desc defines the description associated with the optimization
  71382. */
  71383. constructor(
  71384. /**
  71385. * Defines the priority of this optimization (0 by default which means first in the list)
  71386. */
  71387. priority?: number);
  71388. }
  71389. /**
  71390. * Defines an optimization used to reduce the size of render target textures
  71391. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71392. */
  71393. export class TextureOptimization extends SceneOptimization {
  71394. /**
  71395. * Defines the priority of this optimization (0 by default which means first in the list)
  71396. */
  71397. priority: number;
  71398. /**
  71399. * 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
  71400. */
  71401. maximumSize: number;
  71402. /**
  71403. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71404. */
  71405. step: number;
  71406. /**
  71407. * Gets a string describing the action executed by the current optimization
  71408. * @returns description string
  71409. */
  71410. getDescription(): string;
  71411. /**
  71412. * Creates the TextureOptimization object
  71413. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71414. * @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
  71415. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71416. */
  71417. constructor(
  71418. /**
  71419. * Defines the priority of this optimization (0 by default which means first in the list)
  71420. */
  71421. priority?: number,
  71422. /**
  71423. * 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
  71424. */
  71425. maximumSize?: number,
  71426. /**
  71427. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71428. */
  71429. step?: number);
  71430. /**
  71431. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71432. * @param scene defines the current scene where to apply this optimization
  71433. * @param optimizer defines the current optimizer
  71434. * @returns true if everything that can be done was applied
  71435. */
  71436. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71437. }
  71438. /**
  71439. * Defines an optimization used to increase or decrease the rendering resolution
  71440. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71441. */
  71442. export class HardwareScalingOptimization extends SceneOptimization {
  71443. /**
  71444. * Defines the priority of this optimization (0 by default which means first in the list)
  71445. */
  71446. priority: number;
  71447. /**
  71448. * Defines the maximum scale to use (2 by default)
  71449. */
  71450. maximumScale: number;
  71451. /**
  71452. * Defines the step to use between two passes (0.5 by default)
  71453. */
  71454. step: number;
  71455. private _currentScale;
  71456. private _directionOffset;
  71457. /**
  71458. * Gets a string describing the action executed by the current optimization
  71459. * @return description string
  71460. */
  71461. getDescription(): string;
  71462. /**
  71463. * Creates the HardwareScalingOptimization object
  71464. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71465. * @param maximumScale defines the maximum scale to use (2 by default)
  71466. * @param step defines the step to use between two passes (0.5 by default)
  71467. */
  71468. constructor(
  71469. /**
  71470. * Defines the priority of this optimization (0 by default which means first in the list)
  71471. */
  71472. priority?: number,
  71473. /**
  71474. * Defines the maximum scale to use (2 by default)
  71475. */
  71476. maximumScale?: number,
  71477. /**
  71478. * Defines the step to use between two passes (0.5 by default)
  71479. */
  71480. step?: number);
  71481. /**
  71482. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71483. * @param scene defines the current scene where to apply this optimization
  71484. * @param optimizer defines the current optimizer
  71485. * @returns true if everything that can be done was applied
  71486. */
  71487. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71488. }
  71489. /**
  71490. * Defines an optimization used to remove shadows
  71491. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71492. */
  71493. export class ShadowsOptimization extends SceneOptimization {
  71494. /**
  71495. * Gets a string describing the action executed by the current optimization
  71496. * @return description string
  71497. */
  71498. getDescription(): string;
  71499. /**
  71500. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71501. * @param scene defines the current scene where to apply this optimization
  71502. * @param optimizer defines the current optimizer
  71503. * @returns true if everything that can be done was applied
  71504. */
  71505. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71506. }
  71507. /**
  71508. * Defines an optimization used to turn post-processes off
  71509. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71510. */
  71511. export class PostProcessesOptimization extends SceneOptimization {
  71512. /**
  71513. * Gets a string describing the action executed by the current optimization
  71514. * @return description string
  71515. */
  71516. getDescription(): string;
  71517. /**
  71518. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71519. * @param scene defines the current scene where to apply this optimization
  71520. * @param optimizer defines the current optimizer
  71521. * @returns true if everything that can be done was applied
  71522. */
  71523. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71524. }
  71525. /**
  71526. * Defines an optimization used to turn lens flares off
  71527. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71528. */
  71529. export class LensFlaresOptimization extends SceneOptimization {
  71530. /**
  71531. * Gets a string describing the action executed by the current optimization
  71532. * @return description string
  71533. */
  71534. getDescription(): string;
  71535. /**
  71536. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71537. * @param scene defines the current scene where to apply this optimization
  71538. * @param optimizer defines the current optimizer
  71539. * @returns true if everything that can be done was applied
  71540. */
  71541. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71542. }
  71543. /**
  71544. * Defines an optimization based on user defined callback.
  71545. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71546. */
  71547. export class CustomOptimization extends SceneOptimization {
  71548. /**
  71549. * Callback called to apply the custom optimization.
  71550. */
  71551. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71552. /**
  71553. * Callback called to get custom description
  71554. */
  71555. onGetDescription: () => string;
  71556. /**
  71557. * Gets a string describing the action executed by the current optimization
  71558. * @returns description string
  71559. */
  71560. getDescription(): string;
  71561. /**
  71562. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71563. * @param scene defines the current scene where to apply this optimization
  71564. * @param optimizer defines the current optimizer
  71565. * @returns true if everything that can be done was applied
  71566. */
  71567. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71568. }
  71569. /**
  71570. * Defines an optimization used to turn particles off
  71571. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71572. */
  71573. export class ParticlesOptimization extends SceneOptimization {
  71574. /**
  71575. * Gets a string describing the action executed by the current optimization
  71576. * @return description string
  71577. */
  71578. getDescription(): string;
  71579. /**
  71580. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71581. * @param scene defines the current scene where to apply this optimization
  71582. * @param optimizer defines the current optimizer
  71583. * @returns true if everything that can be done was applied
  71584. */
  71585. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71586. }
  71587. /**
  71588. * Defines an optimization used to turn render targets off
  71589. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71590. */
  71591. export class RenderTargetsOptimization extends SceneOptimization {
  71592. /**
  71593. * Gets a string describing the action executed by the current optimization
  71594. * @return description string
  71595. */
  71596. getDescription(): string;
  71597. /**
  71598. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71599. * @param scene defines the current scene where to apply this optimization
  71600. * @param optimizer defines the current optimizer
  71601. * @returns true if everything that can be done was applied
  71602. */
  71603. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71604. }
  71605. /**
  71606. * Defines an optimization used to merge meshes with compatible materials
  71607. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71608. */
  71609. export class MergeMeshesOptimization extends SceneOptimization {
  71610. private static _UpdateSelectionTree;
  71611. /**
  71612. * Gets or sets a boolean which defines if optimization octree has to be updated
  71613. */
  71614. static get UpdateSelectionTree(): boolean;
  71615. /**
  71616. * Gets or sets a boolean which defines if optimization octree has to be updated
  71617. */
  71618. static set UpdateSelectionTree(value: boolean);
  71619. /**
  71620. * Gets a string describing the action executed by the current optimization
  71621. * @return description string
  71622. */
  71623. getDescription(): string;
  71624. private _canBeMerged;
  71625. /**
  71626. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71627. * @param scene defines the current scene where to apply this optimization
  71628. * @param optimizer defines the current optimizer
  71629. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71630. * @returns true if everything that can be done was applied
  71631. */
  71632. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71633. }
  71634. /**
  71635. * Defines a list of options used by SceneOptimizer
  71636. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71637. */
  71638. export class SceneOptimizerOptions {
  71639. /**
  71640. * Defines the target frame rate to reach (60 by default)
  71641. */
  71642. targetFrameRate: number;
  71643. /**
  71644. * Defines the interval between two checkes (2000ms by default)
  71645. */
  71646. trackerDuration: number;
  71647. /**
  71648. * Gets the list of optimizations to apply
  71649. */
  71650. optimizations: SceneOptimization[];
  71651. /**
  71652. * Creates a new list of options used by SceneOptimizer
  71653. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71654. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71655. */
  71656. constructor(
  71657. /**
  71658. * Defines the target frame rate to reach (60 by default)
  71659. */
  71660. targetFrameRate?: number,
  71661. /**
  71662. * Defines the interval between two checkes (2000ms by default)
  71663. */
  71664. trackerDuration?: number);
  71665. /**
  71666. * Add a new optimization
  71667. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71668. * @returns the current SceneOptimizerOptions
  71669. */
  71670. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71671. /**
  71672. * Add a new custom optimization
  71673. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71674. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71675. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71676. * @returns the current SceneOptimizerOptions
  71677. */
  71678. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71679. /**
  71680. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71681. * @param targetFrameRate defines the target frame rate (60 by default)
  71682. * @returns a SceneOptimizerOptions object
  71683. */
  71684. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71685. /**
  71686. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71687. * @param targetFrameRate defines the target frame rate (60 by default)
  71688. * @returns a SceneOptimizerOptions object
  71689. */
  71690. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71691. /**
  71692. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71693. * @param targetFrameRate defines the target frame rate (60 by default)
  71694. * @returns a SceneOptimizerOptions object
  71695. */
  71696. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71697. }
  71698. /**
  71699. * Class used to run optimizations in order to reach a target frame rate
  71700. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71701. */
  71702. export class SceneOptimizer implements IDisposable {
  71703. private _isRunning;
  71704. private _options;
  71705. private _scene;
  71706. private _currentPriorityLevel;
  71707. private _targetFrameRate;
  71708. private _trackerDuration;
  71709. private _currentFrameRate;
  71710. private _sceneDisposeObserver;
  71711. private _improvementMode;
  71712. /**
  71713. * Defines an observable called when the optimizer reaches the target frame rate
  71714. */
  71715. onSuccessObservable: Observable<SceneOptimizer>;
  71716. /**
  71717. * Defines an observable called when the optimizer enables an optimization
  71718. */
  71719. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71720. /**
  71721. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71722. */
  71723. onFailureObservable: Observable<SceneOptimizer>;
  71724. /**
  71725. * Gets a boolean indicating if the optimizer is in improvement mode
  71726. */
  71727. get isInImprovementMode(): boolean;
  71728. /**
  71729. * Gets the current priority level (0 at start)
  71730. */
  71731. get currentPriorityLevel(): number;
  71732. /**
  71733. * Gets the current frame rate checked by the SceneOptimizer
  71734. */
  71735. get currentFrameRate(): number;
  71736. /**
  71737. * Gets or sets the current target frame rate (60 by default)
  71738. */
  71739. get targetFrameRate(): number;
  71740. /**
  71741. * Gets or sets the current target frame rate (60 by default)
  71742. */
  71743. set targetFrameRate(value: number);
  71744. /**
  71745. * Gets or sets the current interval between two checks (every 2000ms by default)
  71746. */
  71747. get trackerDuration(): number;
  71748. /**
  71749. * Gets or sets the current interval between two checks (every 2000ms by default)
  71750. */
  71751. set trackerDuration(value: number);
  71752. /**
  71753. * Gets the list of active optimizations
  71754. */
  71755. get optimizations(): SceneOptimization[];
  71756. /**
  71757. * Creates a new SceneOptimizer
  71758. * @param scene defines the scene to work on
  71759. * @param options defines the options to use with the SceneOptimizer
  71760. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71761. * @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)
  71762. */
  71763. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71764. /**
  71765. * Stops the current optimizer
  71766. */
  71767. stop(): void;
  71768. /**
  71769. * Reset the optimizer to initial step (current priority level = 0)
  71770. */
  71771. reset(): void;
  71772. /**
  71773. * Start the optimizer. By default it will try to reach a specific framerate
  71774. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  71775. */
  71776. start(): void;
  71777. private _checkCurrentState;
  71778. /**
  71779. * Release all resources
  71780. */
  71781. dispose(): void;
  71782. /**
  71783. * Helper function to create a SceneOptimizer with one single line of code
  71784. * @param scene defines the scene to work on
  71785. * @param options defines the options to use with the SceneOptimizer
  71786. * @param onSuccess defines a callback to call on success
  71787. * @param onFailure defines a callback to call on failure
  71788. * @returns the new SceneOptimizer object
  71789. */
  71790. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  71791. }
  71792. }
  71793. declare module BABYLON {
  71794. /**
  71795. * Class used to serialize a scene into a string
  71796. */
  71797. export class SceneSerializer {
  71798. /**
  71799. * Clear cache used by a previous serialization
  71800. */
  71801. static ClearCache(): void;
  71802. /**
  71803. * Serialize a scene into a JSON compatible object
  71804. * @param scene defines the scene to serialize
  71805. * @returns a JSON compatible object
  71806. */
  71807. static Serialize(scene: Scene): any;
  71808. /**
  71809. * Serialize a mesh into a JSON compatible object
  71810. * @param toSerialize defines the mesh to serialize
  71811. * @param withParents defines if parents must be serialized as well
  71812. * @param withChildren defines if children must be serialized as well
  71813. * @returns a JSON compatible object
  71814. */
  71815. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  71816. }
  71817. }
  71818. declare module BABYLON {
  71819. /**
  71820. * Class used to host texture specific utilities
  71821. */
  71822. export class TextureTools {
  71823. /**
  71824. * Uses the GPU to create a copy texture rescaled at a given size
  71825. * @param texture Texture to copy from
  71826. * @param width defines the desired width
  71827. * @param height defines the desired height
  71828. * @param useBilinearMode defines if bilinear mode has to be used
  71829. * @return the generated texture
  71830. */
  71831. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  71832. }
  71833. }
  71834. declare module BABYLON {
  71835. /**
  71836. * This represents the different options available for the video capture.
  71837. */
  71838. export interface VideoRecorderOptions {
  71839. /** Defines the mime type of the video. */
  71840. mimeType: string;
  71841. /** Defines the FPS the video should be recorded at. */
  71842. fps: number;
  71843. /** Defines the chunk size for the recording data. */
  71844. recordChunckSize: number;
  71845. /** The audio tracks to attach to the recording. */
  71846. audioTracks?: MediaStreamTrack[];
  71847. }
  71848. /**
  71849. * This can help with recording videos from BabylonJS.
  71850. * This is based on the available WebRTC functionalities of the browser.
  71851. *
  71852. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  71853. */
  71854. export class VideoRecorder {
  71855. private static readonly _defaultOptions;
  71856. /**
  71857. * Returns whether or not the VideoRecorder is available in your browser.
  71858. * @param engine Defines the Babylon Engine.
  71859. * @returns true if supported otherwise false.
  71860. */
  71861. static IsSupported(engine: Engine): boolean;
  71862. private readonly _options;
  71863. private _canvas;
  71864. private _mediaRecorder;
  71865. private _recordedChunks;
  71866. private _fileName;
  71867. private _resolve;
  71868. private _reject;
  71869. /**
  71870. * True when a recording is already in progress.
  71871. */
  71872. get isRecording(): boolean;
  71873. /**
  71874. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  71875. * @param engine Defines the BabylonJS Engine you wish to record.
  71876. * @param options Defines options that can be used to customize the capture.
  71877. */
  71878. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  71879. /**
  71880. * Stops the current recording before the default capture timeout passed in the startRecording function.
  71881. */
  71882. stopRecording(): void;
  71883. /**
  71884. * Starts recording the canvas for a max duration specified in parameters.
  71885. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  71886. * If null no automatic download will start and you can rely on the promise to get the data back.
  71887. * @param maxDuration Defines the maximum recording time in seconds.
  71888. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  71889. * @return A promise callback at the end of the recording with the video data in Blob.
  71890. */
  71891. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  71892. /**
  71893. * Releases internal resources used during the recording.
  71894. */
  71895. dispose(): void;
  71896. private _handleDataAvailable;
  71897. private _handleError;
  71898. private _handleStop;
  71899. }
  71900. }
  71901. declare module BABYLON {
  71902. /**
  71903. * Class containing a set of static utilities functions for screenshots
  71904. */
  71905. export class ScreenshotTools {
  71906. /**
  71907. * Captures a screenshot of the current rendering
  71908. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71909. * @param engine defines the rendering engine
  71910. * @param camera defines the source camera
  71911. * @param size This parameter can be set to a single number or to an object with the
  71912. * following (optional) properties: precision, width, height. If a single number is passed,
  71913. * it will be used for both width and height. If an object is passed, the screenshot size
  71914. * will be derived from the parameters. The precision property is a multiplier allowing
  71915. * rendering at a higher or lower resolution
  71916. * @param successCallback defines the callback receives a single parameter which contains the
  71917. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71918. * src parameter of an <img> to display it
  71919. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71920. * Check your browser for supported MIME types
  71921. */
  71922. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  71923. /**
  71924. * Captures a screenshot of the current rendering
  71925. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71926. * @param engine defines the rendering engine
  71927. * @param camera defines the source camera
  71928. * @param size This parameter can be set to a single number or to an object with the
  71929. * following (optional) properties: precision, width, height. If a single number is passed,
  71930. * it will be used for both width and height. If an object is passed, the screenshot size
  71931. * will be derived from the parameters. The precision property is a multiplier allowing
  71932. * rendering at a higher or lower resolution
  71933. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71934. * Check your browser for supported MIME types
  71935. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71936. * to the src parameter of an <img> to display it
  71937. */
  71938. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  71939. /**
  71940. * Generates an image screenshot from the specified camera.
  71941. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71942. * @param engine The engine to use for rendering
  71943. * @param camera The camera to use for rendering
  71944. * @param size This parameter can be set to a single number or to an object with the
  71945. * following (optional) properties: precision, width, height. If a single number is passed,
  71946. * it will be used for both width and height. If an object is passed, the screenshot size
  71947. * will be derived from the parameters. The precision property is a multiplier allowing
  71948. * rendering at a higher or lower resolution
  71949. * @param successCallback The callback receives a single parameter which contains the
  71950. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71951. * src parameter of an <img> to display it
  71952. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71953. * Check your browser for supported MIME types
  71954. * @param samples Texture samples (default: 1)
  71955. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71956. * @param fileName A name for for the downloaded file.
  71957. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71958. */
  71959. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  71960. /**
  71961. * Generates an image screenshot from the specified camera.
  71962. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71963. * @param engine The engine to use for rendering
  71964. * @param camera The camera to use for rendering
  71965. * @param size This parameter can be set to a single number or to an object with the
  71966. * following (optional) properties: precision, width, height. If a single number is passed,
  71967. * it will be used for both width and height. If an object is passed, the screenshot size
  71968. * will be derived from the parameters. The precision property is a multiplier allowing
  71969. * rendering at a higher or lower resolution
  71970. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71971. * Check your browser for supported MIME types
  71972. * @param samples Texture samples (default: 1)
  71973. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71974. * @param fileName A name for for the downloaded file.
  71975. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71976. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71977. * to the src parameter of an <img> to display it
  71978. */
  71979. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  71980. /**
  71981. * Gets height and width for screenshot size
  71982. * @private
  71983. */
  71984. private static _getScreenshotSize;
  71985. }
  71986. }
  71987. declare module BABYLON {
  71988. /**
  71989. * Interface for a data buffer
  71990. */
  71991. export interface IDataBuffer {
  71992. /**
  71993. * Reads bytes from the data buffer.
  71994. * @param byteOffset The byte offset to read
  71995. * @param byteLength The byte length to read
  71996. * @returns A promise that resolves when the bytes are read
  71997. */
  71998. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  71999. /**
  72000. * The byte length of the buffer.
  72001. */
  72002. readonly byteLength: number;
  72003. }
  72004. /**
  72005. * Utility class for reading from a data buffer
  72006. */
  72007. export class DataReader {
  72008. /**
  72009. * The data buffer associated with this data reader.
  72010. */
  72011. readonly buffer: IDataBuffer;
  72012. /**
  72013. * The current byte offset from the beginning of the data buffer.
  72014. */
  72015. byteOffset: number;
  72016. private _dataView;
  72017. private _dataByteOffset;
  72018. /**
  72019. * Constructor
  72020. * @param buffer The buffer to read
  72021. */
  72022. constructor(buffer: IDataBuffer);
  72023. /**
  72024. * Loads the given byte length.
  72025. * @param byteLength The byte length to load
  72026. * @returns A promise that resolves when the load is complete
  72027. */
  72028. loadAsync(byteLength: number): Promise<void>;
  72029. /**
  72030. * Read a unsigned 32-bit integer from the currently loaded data range.
  72031. * @returns The 32-bit integer read
  72032. */
  72033. readUint32(): number;
  72034. /**
  72035. * Read a byte array from the currently loaded data range.
  72036. * @param byteLength The byte length to read
  72037. * @returns The byte array read
  72038. */
  72039. readUint8Array(byteLength: number): Uint8Array;
  72040. /**
  72041. * Read a string from the currently loaded data range.
  72042. * @param byteLength The byte length to read
  72043. * @returns The string read
  72044. */
  72045. readString(byteLength: number): string;
  72046. /**
  72047. * Skips the given byte length the currently loaded data range.
  72048. * @param byteLength The byte length to skip
  72049. */
  72050. skipBytes(byteLength: number): void;
  72051. }
  72052. }
  72053. declare module BABYLON {
  72054. /**
  72055. * Class for storing data to local storage if available or in-memory storage otherwise
  72056. */
  72057. export class DataStorage {
  72058. private static _Storage;
  72059. private static _GetStorage;
  72060. /**
  72061. * Reads a string from the data storage
  72062. * @param key The key to read
  72063. * @param defaultValue The value if the key doesn't exist
  72064. * @returns The string value
  72065. */
  72066. static ReadString(key: string, defaultValue: string): string;
  72067. /**
  72068. * Writes a string to the data storage
  72069. * @param key The key to write
  72070. * @param value The value to write
  72071. */
  72072. static WriteString(key: string, value: string): void;
  72073. /**
  72074. * Reads a boolean from the data storage
  72075. * @param key The key to read
  72076. * @param defaultValue The value if the key doesn't exist
  72077. * @returns The boolean value
  72078. */
  72079. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72080. /**
  72081. * Writes a boolean to the data storage
  72082. * @param key The key to write
  72083. * @param value The value to write
  72084. */
  72085. static WriteBoolean(key: string, value: boolean): void;
  72086. /**
  72087. * Reads a number from the data storage
  72088. * @param key The key to read
  72089. * @param defaultValue The value if the key doesn't exist
  72090. * @returns The number value
  72091. */
  72092. static ReadNumber(key: string, defaultValue: number): number;
  72093. /**
  72094. * Writes a number to the data storage
  72095. * @param key The key to write
  72096. * @param value The value to write
  72097. */
  72098. static WriteNumber(key: string, value: number): void;
  72099. }
  72100. }
  72101. declare module BABYLON {
  72102. /**
  72103. * An interface for all Hit test features
  72104. */
  72105. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  72106. /**
  72107. * Triggered when new babylon (transformed) hit test results are available
  72108. */
  72109. onHitTestResultObservable: Observable<T[]>;
  72110. }
  72111. /**
  72112. * Options used for hit testing
  72113. */
  72114. export interface IWebXRLegacyHitTestOptions {
  72115. /**
  72116. * Only test when user interacted with the scene. Default - hit test every frame
  72117. */
  72118. testOnPointerDownOnly?: boolean;
  72119. /**
  72120. * The node to use to transform the local results to world coordinates
  72121. */
  72122. worldParentNode?: TransformNode;
  72123. }
  72124. /**
  72125. * Interface defining the babylon result of raycasting/hit-test
  72126. */
  72127. export interface IWebXRLegacyHitResult {
  72128. /**
  72129. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72130. */
  72131. transformationMatrix: Matrix;
  72132. /**
  72133. * The native hit test result
  72134. */
  72135. xrHitResult: XRHitResult | XRHitTestResult;
  72136. }
  72137. /**
  72138. * The currently-working hit-test module.
  72139. * Hit test (or Ray-casting) is used to interact with the real world.
  72140. * For further information read here - https://github.com/immersive-web/hit-test
  72141. */
  72142. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  72143. /**
  72144. * options to use when constructing this feature
  72145. */
  72146. readonly options: IWebXRLegacyHitTestOptions;
  72147. private _direction;
  72148. private _mat;
  72149. private _onSelectEnabled;
  72150. private _origin;
  72151. /**
  72152. * The module's name
  72153. */
  72154. static readonly Name: string;
  72155. /**
  72156. * The (Babylon) version of this module.
  72157. * This is an integer representing the implementation version.
  72158. * This number does not correspond to the WebXR specs version
  72159. */
  72160. static readonly Version: number;
  72161. /**
  72162. * Populated with the last native XR Hit Results
  72163. */
  72164. lastNativeXRHitResults: XRHitResult[];
  72165. /**
  72166. * Triggered when new babylon (transformed) hit test results are available
  72167. */
  72168. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  72169. /**
  72170. * Creates a new instance of the (legacy version) hit test feature
  72171. * @param _xrSessionManager an instance of WebXRSessionManager
  72172. * @param options options to use when constructing this feature
  72173. */
  72174. constructor(_xrSessionManager: WebXRSessionManager,
  72175. /**
  72176. * options to use when constructing this feature
  72177. */
  72178. options?: IWebXRLegacyHitTestOptions);
  72179. /**
  72180. * execute a hit test with an XR Ray
  72181. *
  72182. * @param xrSession a native xrSession that will execute this hit test
  72183. * @param xrRay the ray (position and direction) to use for ray-casting
  72184. * @param referenceSpace native XR reference space to use for the hit-test
  72185. * @param filter filter function that will filter the results
  72186. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72187. */
  72188. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72189. /**
  72190. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72191. * @param event the (select) event to use to select with
  72192. * @param referenceSpace the reference space to use for this hit test
  72193. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72194. */
  72195. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72196. /**
  72197. * attach this feature
  72198. * Will usually be called by the features manager
  72199. *
  72200. * @returns true if successful.
  72201. */
  72202. attach(): boolean;
  72203. /**
  72204. * detach this feature.
  72205. * Will usually be called by the features manager
  72206. *
  72207. * @returns true if successful.
  72208. */
  72209. detach(): boolean;
  72210. /**
  72211. * Dispose this feature and all of the resources attached
  72212. */
  72213. dispose(): void;
  72214. protected _onXRFrame(frame: XRFrame): void;
  72215. private _onHitTestResults;
  72216. private _onSelect;
  72217. }
  72218. }
  72219. declare module BABYLON {
  72220. /**
  72221. * Options used for hit testing (version 2)
  72222. */
  72223. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72224. /**
  72225. * Do not create a permanent hit test. Will usually be used when only
  72226. * transient inputs are needed.
  72227. */
  72228. disablePermanentHitTest?: boolean;
  72229. /**
  72230. * Enable transient (for example touch-based) hit test inspections
  72231. */
  72232. enableTransientHitTest?: boolean;
  72233. /**
  72234. * Offset ray for the permanent hit test
  72235. */
  72236. offsetRay?: Vector3;
  72237. /**
  72238. * Offset ray for the transient hit test
  72239. */
  72240. transientOffsetRay?: Vector3;
  72241. /**
  72242. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72243. */
  72244. useReferenceSpace?: boolean;
  72245. }
  72246. /**
  72247. * Interface defining the babylon result of hit-test
  72248. */
  72249. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72250. /**
  72251. * The input source that generated this hit test (if transient)
  72252. */
  72253. inputSource?: XRInputSource;
  72254. /**
  72255. * Is this a transient hit test
  72256. */
  72257. isTransient?: boolean;
  72258. /**
  72259. * Position of the hit test result
  72260. */
  72261. position: Vector3;
  72262. /**
  72263. * Rotation of the hit test result
  72264. */
  72265. rotationQuaternion: Quaternion;
  72266. /**
  72267. * The native hit test result
  72268. */
  72269. xrHitResult: XRHitTestResult;
  72270. }
  72271. /**
  72272. * The currently-working hit-test module.
  72273. * Hit test (or Ray-casting) is used to interact with the real world.
  72274. * For further information read here - https://github.com/immersive-web/hit-test
  72275. *
  72276. * Tested on chrome (mobile) 80.
  72277. */
  72278. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  72279. /**
  72280. * options to use when constructing this feature
  72281. */
  72282. readonly options: IWebXRHitTestOptions;
  72283. private _tmpMat;
  72284. private _tmpPos;
  72285. private _tmpQuat;
  72286. private _transientXrHitTestSource;
  72287. private _xrHitTestSource;
  72288. private initHitTestSource;
  72289. /**
  72290. * The module's name
  72291. */
  72292. static readonly Name: string;
  72293. /**
  72294. * The (Babylon) version of this module.
  72295. * This is an integer representing the implementation version.
  72296. * This number does not correspond to the WebXR specs version
  72297. */
  72298. static readonly Version: number;
  72299. /**
  72300. * When set to true, each hit test will have its own position/rotation objects
  72301. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72302. * the developers will clone them or copy them as they see fit.
  72303. */
  72304. autoCloneTransformation: boolean;
  72305. /**
  72306. * Triggered when new babylon (transformed) hit test results are available
  72307. */
  72308. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72309. /**
  72310. * Use this to temporarily pause hit test checks.
  72311. */
  72312. paused: boolean;
  72313. /**
  72314. * Creates a new instance of the hit test feature
  72315. * @param _xrSessionManager an instance of WebXRSessionManager
  72316. * @param options options to use when constructing this feature
  72317. */
  72318. constructor(_xrSessionManager: WebXRSessionManager,
  72319. /**
  72320. * options to use when constructing this feature
  72321. */
  72322. options?: IWebXRHitTestOptions);
  72323. /**
  72324. * attach this feature
  72325. * Will usually be called by the features manager
  72326. *
  72327. * @returns true if successful.
  72328. */
  72329. attach(): boolean;
  72330. /**
  72331. * detach this feature.
  72332. * Will usually be called by the features manager
  72333. *
  72334. * @returns true if successful.
  72335. */
  72336. detach(): boolean;
  72337. /**
  72338. * Dispose this feature and all of the resources attached
  72339. */
  72340. dispose(): void;
  72341. protected _onXRFrame(frame: XRFrame): void;
  72342. private _processWebXRHitTestResult;
  72343. }
  72344. }
  72345. declare module BABYLON {
  72346. /**
  72347. * Configuration options of the anchor system
  72348. */
  72349. export interface IWebXRAnchorSystemOptions {
  72350. /**
  72351. * a node that will be used to convert local to world coordinates
  72352. */
  72353. worldParentNode?: TransformNode;
  72354. /**
  72355. * If set to true a reference of the created anchors will be kept until the next session starts
  72356. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  72357. */
  72358. doNotRemoveAnchorsOnSessionEnded?: boolean;
  72359. }
  72360. /**
  72361. * A babylon container for an XR Anchor
  72362. */
  72363. export interface IWebXRAnchor {
  72364. /**
  72365. * A babylon-assigned ID for this anchor
  72366. */
  72367. id: number;
  72368. /**
  72369. * Transformation matrix to apply to an object attached to this anchor
  72370. */
  72371. transformationMatrix: Matrix;
  72372. /**
  72373. * The native anchor object
  72374. */
  72375. xrAnchor: XRAnchor;
  72376. /**
  72377. * if defined, this object will be constantly updated by the anchor's position and rotation
  72378. */
  72379. attachedNode?: TransformNode;
  72380. }
  72381. /**
  72382. * An implementation of the anchor system for WebXR.
  72383. * For further information see https://github.com/immersive-web/anchors/
  72384. */
  72385. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72386. private _options;
  72387. private _lastFrameDetected;
  72388. private _trackedAnchors;
  72389. private _referenceSpaceForFrameAnchors;
  72390. private _futureAnchors;
  72391. /**
  72392. * The module's name
  72393. */
  72394. static readonly Name: string;
  72395. /**
  72396. * The (Babylon) version of this module.
  72397. * This is an integer representing the implementation version.
  72398. * This number does not correspond to the WebXR specs version
  72399. */
  72400. static readonly Version: number;
  72401. /**
  72402. * Observers registered here will be executed when a new anchor was added to the session
  72403. */
  72404. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72405. /**
  72406. * Observers registered here will be executed when an anchor was removed from the session
  72407. */
  72408. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72409. /**
  72410. * Observers registered here will be executed when an existing anchor updates
  72411. * This can execute N times every frame
  72412. */
  72413. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72414. /**
  72415. * Set the reference space to use for anchor creation, when not using a hit test.
  72416. * Will default to the session's reference space if not defined
  72417. */
  72418. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  72419. /**
  72420. * constructs a new anchor system
  72421. * @param _xrSessionManager an instance of WebXRSessionManager
  72422. * @param _options configuration object for this feature
  72423. */
  72424. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72425. private _tmpVector;
  72426. private _tmpQuaternion;
  72427. private _populateTmpTransformation;
  72428. /**
  72429. * Create a new anchor point using a hit test result at a specific point in the scene
  72430. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72431. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72432. *
  72433. * @param hitTestResult The hit test result to use for this anchor creation
  72434. * @param position an optional position offset for this anchor
  72435. * @param rotationQuaternion an optional rotation offset for this anchor
  72436. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72437. */
  72438. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  72439. /**
  72440. * Add a new anchor at a specific position and rotation
  72441. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  72442. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  72443. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72444. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72445. *
  72446. * @param position the position in which to add an anchor
  72447. * @param rotationQuaternion an optional rotation for the anchor transformation
  72448. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  72449. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72450. */
  72451. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  72452. /**
  72453. * detach this feature.
  72454. * Will usually be called by the features manager
  72455. *
  72456. * @returns true if successful.
  72457. */
  72458. detach(): boolean;
  72459. /**
  72460. * Dispose this feature and all of the resources attached
  72461. */
  72462. dispose(): void;
  72463. protected _onXRFrame(frame: XRFrame): void;
  72464. /**
  72465. * avoiding using Array.find for global support.
  72466. * @param xrAnchor the plane to find in the array
  72467. */
  72468. private _findIndexInAnchorArray;
  72469. private _updateAnchorWithXRFrame;
  72470. private _createAnchorAtTransformation;
  72471. }
  72472. }
  72473. declare module BABYLON {
  72474. /**
  72475. * Options used in the plane detector module
  72476. */
  72477. export interface IWebXRPlaneDetectorOptions {
  72478. /**
  72479. * The node to use to transform the local results to world coordinates
  72480. */
  72481. worldParentNode?: TransformNode;
  72482. /**
  72483. * If set to true a reference of the created planes will be kept until the next session starts
  72484. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  72485. */
  72486. doNotRemovePlanesOnSessionEnded?: boolean;
  72487. }
  72488. /**
  72489. * A babylon interface for a WebXR plane.
  72490. * A Plane is actually a polygon, built from N points in space
  72491. *
  72492. * Supported in chrome 79, not supported in canary 81 ATM
  72493. */
  72494. export interface IWebXRPlane {
  72495. /**
  72496. * a babylon-assigned ID for this polygon
  72497. */
  72498. id: number;
  72499. /**
  72500. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72501. */
  72502. polygonDefinition: Array<Vector3>;
  72503. /**
  72504. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72505. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72506. */
  72507. transformationMatrix: Matrix;
  72508. /**
  72509. * the native xr-plane object
  72510. */
  72511. xrPlane: XRPlane;
  72512. }
  72513. /**
  72514. * The plane detector is used to detect planes in the real world when in AR
  72515. * For more information see https://github.com/immersive-web/real-world-geometry/
  72516. */
  72517. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72518. private _options;
  72519. private _detectedPlanes;
  72520. private _enabled;
  72521. private _lastFrameDetected;
  72522. /**
  72523. * The module's name
  72524. */
  72525. static readonly Name: string;
  72526. /**
  72527. * The (Babylon) version of this module.
  72528. * This is an integer representing the implementation version.
  72529. * This number does not correspond to the WebXR specs version
  72530. */
  72531. static readonly Version: number;
  72532. /**
  72533. * Observers registered here will be executed when a new plane was added to the session
  72534. */
  72535. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72536. /**
  72537. * Observers registered here will be executed when a plane is no longer detected in the session
  72538. */
  72539. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72540. /**
  72541. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72542. * This can execute N times every frame
  72543. */
  72544. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72545. /**
  72546. * construct a new Plane Detector
  72547. * @param _xrSessionManager an instance of xr Session manager
  72548. * @param _options configuration to use when constructing this feature
  72549. */
  72550. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72551. /**
  72552. * detach this feature.
  72553. * Will usually be called by the features manager
  72554. *
  72555. * @returns true if successful.
  72556. */
  72557. detach(): boolean;
  72558. /**
  72559. * Dispose this feature and all of the resources attached
  72560. */
  72561. dispose(): void;
  72562. protected _onXRFrame(frame: XRFrame): void;
  72563. private _init;
  72564. private _updatePlaneWithXRPlane;
  72565. /**
  72566. * avoiding using Array.find for global support.
  72567. * @param xrPlane the plane to find in the array
  72568. */
  72569. private findIndexInPlaneArray;
  72570. }
  72571. }
  72572. declare module BABYLON {
  72573. /**
  72574. * Options interface for the background remover plugin
  72575. */
  72576. export interface IWebXRBackgroundRemoverOptions {
  72577. /**
  72578. * Further background meshes to disable when entering AR
  72579. */
  72580. backgroundMeshes?: AbstractMesh[];
  72581. /**
  72582. * flags to configure the removal of the environment helper.
  72583. * If not set, the entire background will be removed. If set, flags should be set as well.
  72584. */
  72585. environmentHelperRemovalFlags?: {
  72586. /**
  72587. * Should the skybox be removed (default false)
  72588. */
  72589. skyBox?: boolean;
  72590. /**
  72591. * Should the ground be removed (default false)
  72592. */
  72593. ground?: boolean;
  72594. };
  72595. /**
  72596. * don't disable the environment helper
  72597. */
  72598. ignoreEnvironmentHelper?: boolean;
  72599. }
  72600. /**
  72601. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72602. */
  72603. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72604. /**
  72605. * read-only options to be used in this module
  72606. */
  72607. readonly options: IWebXRBackgroundRemoverOptions;
  72608. /**
  72609. * The module's name
  72610. */
  72611. static readonly Name: string;
  72612. /**
  72613. * The (Babylon) version of this module.
  72614. * This is an integer representing the implementation version.
  72615. * This number does not correspond to the WebXR specs version
  72616. */
  72617. static readonly Version: number;
  72618. /**
  72619. * registered observers will be triggered when the background state changes
  72620. */
  72621. onBackgroundStateChangedObservable: Observable<boolean>;
  72622. /**
  72623. * constructs a new background remover module
  72624. * @param _xrSessionManager the session manager for this module
  72625. * @param options read-only options to be used in this module
  72626. */
  72627. constructor(_xrSessionManager: WebXRSessionManager,
  72628. /**
  72629. * read-only options to be used in this module
  72630. */
  72631. options?: IWebXRBackgroundRemoverOptions);
  72632. /**
  72633. * attach this feature
  72634. * Will usually be called by the features manager
  72635. *
  72636. * @returns true if successful.
  72637. */
  72638. attach(): boolean;
  72639. /**
  72640. * detach this feature.
  72641. * Will usually be called by the features manager
  72642. *
  72643. * @returns true if successful.
  72644. */
  72645. detach(): boolean;
  72646. /**
  72647. * Dispose this feature and all of the resources attached
  72648. */
  72649. dispose(): void;
  72650. protected _onXRFrame(_xrFrame: XRFrame): void;
  72651. private _setBackgroundState;
  72652. }
  72653. }
  72654. declare module BABYLON {
  72655. /**
  72656. * Options for the controller physics feature
  72657. */
  72658. export class IWebXRControllerPhysicsOptions {
  72659. /**
  72660. * Should the headset get its own impostor
  72661. */
  72662. enableHeadsetImpostor?: boolean;
  72663. /**
  72664. * Optional parameters for the headset impostor
  72665. */
  72666. headsetImpostorParams?: {
  72667. /**
  72668. * The type of impostor to create. Default is sphere
  72669. */
  72670. impostorType: number;
  72671. /**
  72672. * the size of the impostor. Defaults to 10cm
  72673. */
  72674. impostorSize?: number | {
  72675. width: number;
  72676. height: number;
  72677. depth: number;
  72678. };
  72679. /**
  72680. * Friction definitions
  72681. */
  72682. friction?: number;
  72683. /**
  72684. * Restitution
  72685. */
  72686. restitution?: number;
  72687. };
  72688. /**
  72689. * The physics properties of the future impostors
  72690. */
  72691. physicsProperties?: {
  72692. /**
  72693. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72694. * Note that this requires a physics engine that supports mesh impostors!
  72695. */
  72696. useControllerMesh?: boolean;
  72697. /**
  72698. * The type of impostor to create. Default is sphere
  72699. */
  72700. impostorType?: number;
  72701. /**
  72702. * the size of the impostor. Defaults to 10cm
  72703. */
  72704. impostorSize?: number | {
  72705. width: number;
  72706. height: number;
  72707. depth: number;
  72708. };
  72709. /**
  72710. * Friction definitions
  72711. */
  72712. friction?: number;
  72713. /**
  72714. * Restitution
  72715. */
  72716. restitution?: number;
  72717. };
  72718. /**
  72719. * the xr input to use with this pointer selection
  72720. */
  72721. xrInput: WebXRInput;
  72722. }
  72723. /**
  72724. * Add physics impostor to your webxr controllers,
  72725. * including naive calculation of their linear and angular velocity
  72726. */
  72727. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72728. private readonly _options;
  72729. private _attachController;
  72730. private _controllers;
  72731. private _debugMode;
  72732. private _delta;
  72733. private _headsetImpostor?;
  72734. private _headsetMesh?;
  72735. private _lastTimestamp;
  72736. private _tmpQuaternion;
  72737. private _tmpVector;
  72738. /**
  72739. * The module's name
  72740. */
  72741. static readonly Name: string;
  72742. /**
  72743. * The (Babylon) version of this module.
  72744. * This is an integer representing the implementation version.
  72745. * This number does not correspond to the webxr specs version
  72746. */
  72747. static readonly Version: number;
  72748. /**
  72749. * Construct a new Controller Physics Feature
  72750. * @param _xrSessionManager the corresponding xr session manager
  72751. * @param _options options to create this feature with
  72752. */
  72753. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72754. /**
  72755. * @hidden
  72756. * enable debugging - will show console outputs and the impostor mesh
  72757. */
  72758. _enablePhysicsDebug(): void;
  72759. /**
  72760. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72761. * @param xrController the controller to add
  72762. */
  72763. addController(xrController: WebXRInputSource): void;
  72764. /**
  72765. * attach this feature
  72766. * Will usually be called by the features manager
  72767. *
  72768. * @returns true if successful.
  72769. */
  72770. attach(): boolean;
  72771. /**
  72772. * detach this feature.
  72773. * Will usually be called by the features manager
  72774. *
  72775. * @returns true if successful.
  72776. */
  72777. detach(): boolean;
  72778. /**
  72779. * Get the headset impostor, if enabled
  72780. * @returns the impostor
  72781. */
  72782. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72783. /**
  72784. * Get the physics impostor of a specific controller.
  72785. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72786. * @param controller the controller or the controller id of which to get the impostor
  72787. * @returns the impostor or null
  72788. */
  72789. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72790. /**
  72791. * Update the physics properties provided in the constructor
  72792. * @param newProperties the new properties object
  72793. */
  72794. setPhysicsProperties(newProperties: {
  72795. impostorType?: number;
  72796. impostorSize?: number | {
  72797. width: number;
  72798. height: number;
  72799. depth: number;
  72800. };
  72801. friction?: number;
  72802. restitution?: number;
  72803. }): void;
  72804. protected _onXRFrame(_xrFrame: any): void;
  72805. private _detachController;
  72806. }
  72807. }
  72808. declare module BABYLON {
  72809. /**
  72810. * The motion controller class for all microsoft mixed reality controllers
  72811. */
  72812. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72813. protected readonly _mapping: {
  72814. defaultButton: {
  72815. valueNodeName: string;
  72816. unpressedNodeName: string;
  72817. pressedNodeName: string;
  72818. };
  72819. defaultAxis: {
  72820. valueNodeName: string;
  72821. minNodeName: string;
  72822. maxNodeName: string;
  72823. };
  72824. buttons: {
  72825. "xr-standard-trigger": {
  72826. rootNodeName: string;
  72827. componentProperty: string;
  72828. states: string[];
  72829. };
  72830. "xr-standard-squeeze": {
  72831. rootNodeName: string;
  72832. componentProperty: string;
  72833. states: string[];
  72834. };
  72835. "xr-standard-touchpad": {
  72836. rootNodeName: string;
  72837. labelAnchorNodeName: string;
  72838. touchPointNodeName: string;
  72839. };
  72840. "xr-standard-thumbstick": {
  72841. rootNodeName: string;
  72842. componentProperty: string;
  72843. states: string[];
  72844. };
  72845. };
  72846. axes: {
  72847. "xr-standard-touchpad": {
  72848. "x-axis": {
  72849. rootNodeName: string;
  72850. };
  72851. "y-axis": {
  72852. rootNodeName: string;
  72853. };
  72854. };
  72855. "xr-standard-thumbstick": {
  72856. "x-axis": {
  72857. rootNodeName: string;
  72858. };
  72859. "y-axis": {
  72860. rootNodeName: string;
  72861. };
  72862. };
  72863. };
  72864. };
  72865. /**
  72866. * The base url used to load the left and right controller models
  72867. */
  72868. static MODEL_BASE_URL: string;
  72869. /**
  72870. * The name of the left controller model file
  72871. */
  72872. static MODEL_LEFT_FILENAME: string;
  72873. /**
  72874. * The name of the right controller model file
  72875. */
  72876. static MODEL_RIGHT_FILENAME: string;
  72877. profileId: string;
  72878. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72879. protected _getFilenameAndPath(): {
  72880. filename: string;
  72881. path: string;
  72882. };
  72883. protected _getModelLoadingConstraints(): boolean;
  72884. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72885. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72886. protected _updateModel(): void;
  72887. }
  72888. }
  72889. declare module BABYLON {
  72890. /**
  72891. * The motion controller class for oculus touch (quest, rift).
  72892. * This class supports legacy mapping as well the standard xr mapping
  72893. */
  72894. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  72895. private _forceLegacyControllers;
  72896. private _modelRootNode;
  72897. /**
  72898. * The base url used to load the left and right controller models
  72899. */
  72900. static MODEL_BASE_URL: string;
  72901. /**
  72902. * The name of the left controller model file
  72903. */
  72904. static MODEL_LEFT_FILENAME: string;
  72905. /**
  72906. * The name of the right controller model file
  72907. */
  72908. static MODEL_RIGHT_FILENAME: string;
  72909. /**
  72910. * Base Url for the Quest controller model.
  72911. */
  72912. static QUEST_MODEL_BASE_URL: string;
  72913. profileId: string;
  72914. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  72915. protected _getFilenameAndPath(): {
  72916. filename: string;
  72917. path: string;
  72918. };
  72919. protected _getModelLoadingConstraints(): boolean;
  72920. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72921. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72922. protected _updateModel(): void;
  72923. /**
  72924. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  72925. * between the touch and touch 2.
  72926. */
  72927. private _isQuest;
  72928. }
  72929. }
  72930. declare module BABYLON {
  72931. /**
  72932. * The motion controller class for the standard HTC-Vive controllers
  72933. */
  72934. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  72935. private _modelRootNode;
  72936. /**
  72937. * The base url used to load the left and right controller models
  72938. */
  72939. static MODEL_BASE_URL: string;
  72940. /**
  72941. * File name for the controller model.
  72942. */
  72943. static MODEL_FILENAME: string;
  72944. profileId: string;
  72945. /**
  72946. * Create a new Vive motion controller object
  72947. * @param scene the scene to use to create this controller
  72948. * @param gamepadObject the corresponding gamepad object
  72949. * @param handedness the handedness of the controller
  72950. */
  72951. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72952. protected _getFilenameAndPath(): {
  72953. filename: string;
  72954. path: string;
  72955. };
  72956. protected _getModelLoadingConstraints(): boolean;
  72957. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72958. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72959. protected _updateModel(): void;
  72960. }
  72961. }
  72962. declare module BABYLON {
  72963. /**
  72964. * A cursor which tracks a point on a path
  72965. */
  72966. export class PathCursor {
  72967. private path;
  72968. /**
  72969. * Stores path cursor callbacks for when an onchange event is triggered
  72970. */
  72971. private _onchange;
  72972. /**
  72973. * The value of the path cursor
  72974. */
  72975. value: number;
  72976. /**
  72977. * The animation array of the path cursor
  72978. */
  72979. animations: Animation[];
  72980. /**
  72981. * Initializes the path cursor
  72982. * @param path The path to track
  72983. */
  72984. constructor(path: Path2);
  72985. /**
  72986. * Gets the cursor point on the path
  72987. * @returns A point on the path cursor at the cursor location
  72988. */
  72989. getPoint(): Vector3;
  72990. /**
  72991. * Moves the cursor ahead by the step amount
  72992. * @param step The amount to move the cursor forward
  72993. * @returns This path cursor
  72994. */
  72995. moveAhead(step?: number): PathCursor;
  72996. /**
  72997. * Moves the cursor behind by the step amount
  72998. * @param step The amount to move the cursor back
  72999. * @returns This path cursor
  73000. */
  73001. moveBack(step?: number): PathCursor;
  73002. /**
  73003. * Moves the cursor by the step amount
  73004. * If the step amount is greater than one, an exception is thrown
  73005. * @param step The amount to move the cursor
  73006. * @returns This path cursor
  73007. */
  73008. move(step: number): PathCursor;
  73009. /**
  73010. * Ensures that the value is limited between zero and one
  73011. * @returns This path cursor
  73012. */
  73013. private ensureLimits;
  73014. /**
  73015. * Runs onchange callbacks on change (used by the animation engine)
  73016. * @returns This path cursor
  73017. */
  73018. private raiseOnChange;
  73019. /**
  73020. * Executes a function on change
  73021. * @param f A path cursor onchange callback
  73022. * @returns This path cursor
  73023. */
  73024. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73025. }
  73026. }
  73027. declare module BABYLON {
  73028. /** @hidden */
  73029. export var blurPixelShader: {
  73030. name: string;
  73031. shader: string;
  73032. };
  73033. }
  73034. declare module BABYLON {
  73035. /** @hidden */
  73036. export var pointCloudVertexDeclaration: {
  73037. name: string;
  73038. shader: string;
  73039. };
  73040. }
  73041. // Mixins
  73042. interface Window {
  73043. mozIndexedDB: IDBFactory;
  73044. webkitIndexedDB: IDBFactory;
  73045. msIndexedDB: IDBFactory;
  73046. webkitURL: typeof URL;
  73047. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  73048. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  73049. WebGLRenderingContext: WebGLRenderingContext;
  73050. MSGesture: MSGesture;
  73051. CANNON: any;
  73052. AudioContext: AudioContext;
  73053. webkitAudioContext: AudioContext;
  73054. PointerEvent: any;
  73055. Math: Math;
  73056. Uint8Array: Uint8ArrayConstructor;
  73057. Float32Array: Float32ArrayConstructor;
  73058. mozURL: typeof URL;
  73059. msURL: typeof URL;
  73060. VRFrameData: any; // WebVR, from specs 1.1
  73061. DracoDecoderModule: any;
  73062. setImmediate(handler: (...args: any[]) => void): number;
  73063. }
  73064. interface HTMLCanvasElement {
  73065. requestPointerLock(): void;
  73066. msRequestPointerLock?(): void;
  73067. mozRequestPointerLock?(): void;
  73068. webkitRequestPointerLock?(): void;
  73069. /** Track wether a record is in progress */
  73070. isRecording: boolean;
  73071. /** Capture Stream method defined by some browsers */
  73072. captureStream(fps?: number): MediaStream;
  73073. }
  73074. interface CanvasRenderingContext2D {
  73075. msImageSmoothingEnabled: boolean;
  73076. }
  73077. interface MouseEvent {
  73078. mozMovementX: number;
  73079. mozMovementY: number;
  73080. webkitMovementX: number;
  73081. webkitMovementY: number;
  73082. msMovementX: number;
  73083. msMovementY: number;
  73084. }
  73085. interface Navigator {
  73086. mozGetVRDevices: (any: any) => any;
  73087. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73088. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73089. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73090. webkitGetGamepads(): Gamepad[];
  73091. msGetGamepads(): Gamepad[];
  73092. webkitGamepads(): Gamepad[];
  73093. }
  73094. interface HTMLVideoElement {
  73095. mozSrcObject: any;
  73096. }
  73097. interface Math {
  73098. fround(x: number): number;
  73099. imul(a: number, b: number): number;
  73100. }
  73101. interface WebGLRenderingContext {
  73102. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  73103. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  73104. vertexAttribDivisor(index: number, divisor: number): void;
  73105. createVertexArray(): any;
  73106. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  73107. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  73108. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  73109. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  73110. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  73111. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  73112. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  73113. // Queries
  73114. createQuery(): WebGLQuery;
  73115. deleteQuery(query: WebGLQuery): void;
  73116. beginQuery(target: number, query: WebGLQuery): void;
  73117. endQuery(target: number): void;
  73118. getQueryParameter(query: WebGLQuery, pname: number): any;
  73119. getQuery(target: number, pname: number): any;
  73120. MAX_SAMPLES: number;
  73121. RGBA8: number;
  73122. READ_FRAMEBUFFER: number;
  73123. DRAW_FRAMEBUFFER: number;
  73124. UNIFORM_BUFFER: number;
  73125. HALF_FLOAT_OES: number;
  73126. RGBA16F: number;
  73127. RGBA32F: number;
  73128. R32F: number;
  73129. RG32F: number;
  73130. RGB32F: number;
  73131. R16F: number;
  73132. RG16F: number;
  73133. RGB16F: number;
  73134. RED: number;
  73135. RG: number;
  73136. R8: number;
  73137. RG8: number;
  73138. UNSIGNED_INT_24_8: number;
  73139. DEPTH24_STENCIL8: number;
  73140. MIN: number;
  73141. MAX: number;
  73142. /* Multiple Render Targets */
  73143. drawBuffers(buffers: number[]): void;
  73144. readBuffer(src: number): void;
  73145. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  73146. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  73147. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  73148. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  73149. // Occlusion Query
  73150. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  73151. ANY_SAMPLES_PASSED: number;
  73152. QUERY_RESULT_AVAILABLE: number;
  73153. QUERY_RESULT: number;
  73154. }
  73155. interface WebGLProgram {
  73156. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  73157. }
  73158. interface EXT_disjoint_timer_query {
  73159. QUERY_COUNTER_BITS_EXT: number;
  73160. TIME_ELAPSED_EXT: number;
  73161. TIMESTAMP_EXT: number;
  73162. GPU_DISJOINT_EXT: number;
  73163. QUERY_RESULT_EXT: number;
  73164. QUERY_RESULT_AVAILABLE_EXT: number;
  73165. queryCounterEXT(query: WebGLQuery, target: number): void;
  73166. createQueryEXT(): WebGLQuery;
  73167. beginQueryEXT(target: number, query: WebGLQuery): void;
  73168. endQueryEXT(target: number): void;
  73169. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  73170. deleteQueryEXT(query: WebGLQuery): void;
  73171. }
  73172. interface WebGLUniformLocation {
  73173. _currentState: any;
  73174. }
  73175. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  73176. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  73177. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  73178. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73179. interface WebGLRenderingContext {
  73180. readonly RASTERIZER_DISCARD: number;
  73181. readonly DEPTH_COMPONENT24: number;
  73182. readonly TEXTURE_3D: number;
  73183. readonly TEXTURE_2D_ARRAY: number;
  73184. readonly TEXTURE_COMPARE_FUNC: number;
  73185. readonly TEXTURE_COMPARE_MODE: number;
  73186. readonly COMPARE_REF_TO_TEXTURE: number;
  73187. readonly TEXTURE_WRAP_R: number;
  73188. readonly HALF_FLOAT: number;
  73189. readonly RGB8: number;
  73190. readonly RED_INTEGER: number;
  73191. readonly RG_INTEGER: number;
  73192. readonly RGB_INTEGER: number;
  73193. readonly RGBA_INTEGER: number;
  73194. readonly R8_SNORM: number;
  73195. readonly RG8_SNORM: number;
  73196. readonly RGB8_SNORM: number;
  73197. readonly RGBA8_SNORM: number;
  73198. readonly R8I: number;
  73199. readonly RG8I: number;
  73200. readonly RGB8I: number;
  73201. readonly RGBA8I: number;
  73202. readonly R8UI: number;
  73203. readonly RG8UI: number;
  73204. readonly RGB8UI: number;
  73205. readonly RGBA8UI: number;
  73206. readonly R16I: number;
  73207. readonly RG16I: number;
  73208. readonly RGB16I: number;
  73209. readonly RGBA16I: number;
  73210. readonly R16UI: number;
  73211. readonly RG16UI: number;
  73212. readonly RGB16UI: number;
  73213. readonly RGBA16UI: number;
  73214. readonly R32I: number;
  73215. readonly RG32I: number;
  73216. readonly RGB32I: number;
  73217. readonly RGBA32I: number;
  73218. readonly R32UI: number;
  73219. readonly RG32UI: number;
  73220. readonly RGB32UI: number;
  73221. readonly RGBA32UI: number;
  73222. readonly RGB10_A2UI: number;
  73223. readonly R11F_G11F_B10F: number;
  73224. readonly RGB9_E5: number;
  73225. readonly RGB10_A2: number;
  73226. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  73227. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  73228. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  73229. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73230. readonly DEPTH_COMPONENT32F: number;
  73231. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  73232. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  73233. 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;
  73234. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  73235. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  73236. readonly TRANSFORM_FEEDBACK: number;
  73237. readonly INTERLEAVED_ATTRIBS: number;
  73238. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  73239. createTransformFeedback(): WebGLTransformFeedback;
  73240. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  73241. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  73242. beginTransformFeedback(primitiveMode: number): void;
  73243. endTransformFeedback(): void;
  73244. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  73245. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73246. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73247. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73248. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73249. }
  73250. interface ImageBitmap {
  73251. readonly width: number;
  73252. readonly height: number;
  73253. close(): void;
  73254. }
  73255. interface WebGLQuery extends WebGLObject {
  73256. }
  73257. declare var WebGLQuery: {
  73258. prototype: WebGLQuery;
  73259. new(): WebGLQuery;
  73260. };
  73261. interface WebGLSampler extends WebGLObject {
  73262. }
  73263. declare var WebGLSampler: {
  73264. prototype: WebGLSampler;
  73265. new(): WebGLSampler;
  73266. };
  73267. interface WebGLSync extends WebGLObject {
  73268. }
  73269. declare var WebGLSync: {
  73270. prototype: WebGLSync;
  73271. new(): WebGLSync;
  73272. };
  73273. interface WebGLTransformFeedback extends WebGLObject {
  73274. }
  73275. declare var WebGLTransformFeedback: {
  73276. prototype: WebGLTransformFeedback;
  73277. new(): WebGLTransformFeedback;
  73278. };
  73279. interface WebGLVertexArrayObject extends WebGLObject {
  73280. }
  73281. declare var WebGLVertexArrayObject: {
  73282. prototype: WebGLVertexArrayObject;
  73283. new(): WebGLVertexArrayObject;
  73284. };
  73285. // Type definitions for WebVR API
  73286. // Project: https://w3c.github.io/webvr/
  73287. // Definitions by: six a <https://github.com/lostfictions>
  73288. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73289. interface VRDisplay extends EventTarget {
  73290. /**
  73291. * Dictionary of capabilities describing the VRDisplay.
  73292. */
  73293. readonly capabilities: VRDisplayCapabilities;
  73294. /**
  73295. * z-depth defining the far plane of the eye view frustum
  73296. * enables mapping of values in the render target depth
  73297. * attachment to scene coordinates. Initially set to 10000.0.
  73298. */
  73299. depthFar: number;
  73300. /**
  73301. * z-depth defining the near plane of the eye view frustum
  73302. * enables mapping of values in the render target depth
  73303. * attachment to scene coordinates. Initially set to 0.01.
  73304. */
  73305. depthNear: number;
  73306. /**
  73307. * An identifier for this distinct VRDisplay. Used as an
  73308. * association point in the Gamepad API.
  73309. */
  73310. readonly displayId: number;
  73311. /**
  73312. * A display name, a user-readable name identifying it.
  73313. */
  73314. readonly displayName: string;
  73315. readonly isConnected: boolean;
  73316. readonly isPresenting: boolean;
  73317. /**
  73318. * If this VRDisplay supports room-scale experiences, the optional
  73319. * stage attribute contains details on the room-scale parameters.
  73320. */
  73321. readonly stageParameters: VRStageParameters | null;
  73322. /**
  73323. * Passing the value returned by `requestAnimationFrame` to
  73324. * `cancelAnimationFrame` will unregister the callback.
  73325. * @param handle Define the hanle of the request to cancel
  73326. */
  73327. cancelAnimationFrame(handle: number): void;
  73328. /**
  73329. * Stops presenting to the VRDisplay.
  73330. * @returns a promise to know when it stopped
  73331. */
  73332. exitPresent(): Promise<void>;
  73333. /**
  73334. * Return the current VREyeParameters for the given eye.
  73335. * @param whichEye Define the eye we want the parameter for
  73336. * @returns the eye parameters
  73337. */
  73338. getEyeParameters(whichEye: string): VREyeParameters;
  73339. /**
  73340. * Populates the passed VRFrameData with the information required to render
  73341. * the current frame.
  73342. * @param frameData Define the data structure to populate
  73343. * @returns true if ok otherwise false
  73344. */
  73345. getFrameData(frameData: VRFrameData): boolean;
  73346. /**
  73347. * Get the layers currently being presented.
  73348. * @returns the list of VR layers
  73349. */
  73350. getLayers(): VRLayer[];
  73351. /**
  73352. * Return a VRPose containing the future predicted pose of the VRDisplay
  73353. * when the current frame will be presented. The value returned will not
  73354. * change until JavaScript has returned control to the browser.
  73355. *
  73356. * The VRPose will contain the position, orientation, velocity,
  73357. * and acceleration of each of these properties.
  73358. * @returns the pose object
  73359. */
  73360. getPose(): VRPose;
  73361. /**
  73362. * Return the current instantaneous pose of the VRDisplay, with no
  73363. * prediction applied.
  73364. * @returns the current instantaneous pose
  73365. */
  73366. getImmediatePose(): VRPose;
  73367. /**
  73368. * The callback passed to `requestAnimationFrame` will be called
  73369. * any time a new frame should be rendered. When the VRDisplay is
  73370. * presenting the callback will be called at the native refresh
  73371. * rate of the HMD. When not presenting this function acts
  73372. * identically to how window.requestAnimationFrame acts. Content should
  73373. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73374. * asynchronously from other displays and at differing refresh rates.
  73375. * @param callback Define the eaction to run next frame
  73376. * @returns the request handle it
  73377. */
  73378. requestAnimationFrame(callback: FrameRequestCallback): number;
  73379. /**
  73380. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73381. * Repeat calls while already presenting will update the VRLayers being displayed.
  73382. * @param layers Define the list of layer to present
  73383. * @returns a promise to know when the request has been fulfilled
  73384. */
  73385. requestPresent(layers: VRLayer[]): Promise<void>;
  73386. /**
  73387. * Reset the pose for this display, treating its current position and
  73388. * orientation as the "origin/zero" values. VRPose.position,
  73389. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73390. * updated when calling resetPose(). This should be called in only
  73391. * sitting-space experiences.
  73392. */
  73393. resetPose(): void;
  73394. /**
  73395. * The VRLayer provided to the VRDisplay will be captured and presented
  73396. * in the HMD. Calling this function has the same effect on the source
  73397. * canvas as any other operation that uses its source image, and canvases
  73398. * created without preserveDrawingBuffer set to true will be cleared.
  73399. * @param pose Define the pose to submit
  73400. */
  73401. submitFrame(pose?: VRPose): void;
  73402. }
  73403. declare var VRDisplay: {
  73404. prototype: VRDisplay;
  73405. new(): VRDisplay;
  73406. };
  73407. interface VRLayer {
  73408. leftBounds?: number[] | Float32Array | null;
  73409. rightBounds?: number[] | Float32Array | null;
  73410. source?: HTMLCanvasElement | null;
  73411. }
  73412. interface VRDisplayCapabilities {
  73413. readonly canPresent: boolean;
  73414. readonly hasExternalDisplay: boolean;
  73415. readonly hasOrientation: boolean;
  73416. readonly hasPosition: boolean;
  73417. readonly maxLayers: number;
  73418. }
  73419. interface VREyeParameters {
  73420. /** @deprecated */
  73421. readonly fieldOfView: VRFieldOfView;
  73422. readonly offset: Float32Array;
  73423. readonly renderHeight: number;
  73424. readonly renderWidth: number;
  73425. }
  73426. interface VRFieldOfView {
  73427. readonly downDegrees: number;
  73428. readonly leftDegrees: number;
  73429. readonly rightDegrees: number;
  73430. readonly upDegrees: number;
  73431. }
  73432. interface VRFrameData {
  73433. readonly leftProjectionMatrix: Float32Array;
  73434. readonly leftViewMatrix: Float32Array;
  73435. readonly pose: VRPose;
  73436. readonly rightProjectionMatrix: Float32Array;
  73437. readonly rightViewMatrix: Float32Array;
  73438. readonly timestamp: number;
  73439. }
  73440. interface VRPose {
  73441. readonly angularAcceleration: Float32Array | null;
  73442. readonly angularVelocity: Float32Array | null;
  73443. readonly linearAcceleration: Float32Array | null;
  73444. readonly linearVelocity: Float32Array | null;
  73445. readonly orientation: Float32Array | null;
  73446. readonly position: Float32Array | null;
  73447. readonly timestamp: number;
  73448. }
  73449. interface VRStageParameters {
  73450. sittingToStandingTransform?: Float32Array;
  73451. sizeX?: number;
  73452. sizeY?: number;
  73453. }
  73454. interface Navigator {
  73455. getVRDisplays(): Promise<VRDisplay[]>;
  73456. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73457. }
  73458. interface Window {
  73459. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73460. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73461. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73462. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73463. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73464. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73465. }
  73466. interface Gamepad {
  73467. readonly displayId: number;
  73468. }
  73469. type XRSessionMode =
  73470. | "inline"
  73471. | "immersive-vr"
  73472. | "immersive-ar";
  73473. type XRReferenceSpaceType =
  73474. | "viewer"
  73475. | "local"
  73476. | "local-floor"
  73477. | "bounded-floor"
  73478. | "unbounded";
  73479. type XREnvironmentBlendMode =
  73480. | "opaque"
  73481. | "additive"
  73482. | "alpha-blend";
  73483. type XRVisibilityState =
  73484. | "visible"
  73485. | "visible-blurred"
  73486. | "hidden";
  73487. type XRHandedness =
  73488. | "none"
  73489. | "left"
  73490. | "right";
  73491. type XRTargetRayMode =
  73492. | "gaze"
  73493. | "tracked-pointer"
  73494. | "screen";
  73495. type XREye =
  73496. | "none"
  73497. | "left"
  73498. | "right";
  73499. type XREventType =
  73500. | "devicechange"
  73501. | "visibilitychange"
  73502. | "end"
  73503. | "inputsourceschange"
  73504. | "select"
  73505. | "selectstart"
  73506. | "selectend"
  73507. | "squeeze"
  73508. | "squeezestart"
  73509. | "squeezeend"
  73510. | "reset";
  73511. interface XRSpace extends EventTarget {
  73512. }
  73513. interface XRRenderState {
  73514. depthNear?: number;
  73515. depthFar?: number;
  73516. inlineVerticalFieldOfView?: number;
  73517. baseLayer?: XRWebGLLayer;
  73518. }
  73519. interface XRInputSource {
  73520. handedness: XRHandedness;
  73521. targetRayMode: XRTargetRayMode;
  73522. targetRaySpace: XRSpace;
  73523. gripSpace: XRSpace | undefined;
  73524. gamepad: Gamepad | undefined;
  73525. profiles: Array<string>;
  73526. }
  73527. interface XRSessionInit {
  73528. optionalFeatures?: string[];
  73529. requiredFeatures?: string[];
  73530. }
  73531. interface XRSession {
  73532. addEventListener: Function;
  73533. removeEventListener: Function;
  73534. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  73535. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  73536. requestAnimationFrame: Function;
  73537. end(): Promise<void>;
  73538. renderState: XRRenderState;
  73539. inputSources: Array<XRInputSource>;
  73540. // hit test
  73541. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  73542. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  73543. // legacy AR hit test
  73544. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73545. // legacy plane detection
  73546. updateWorldTrackingState(options: {
  73547. planeDetectionState?: { enabled: boolean; }
  73548. }): void;
  73549. }
  73550. interface XRReferenceSpace extends XRSpace {
  73551. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  73552. onreset: any;
  73553. }
  73554. type XRPlaneSet = Set<XRPlane>;
  73555. type XRAnchorSet = Set<XRAnchor>;
  73556. interface XRFrame {
  73557. session: XRSession;
  73558. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  73559. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  73560. // AR
  73561. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  73562. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  73563. // Anchors
  73564. trackedAnchors?: XRAnchorSet;
  73565. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  73566. // Planes
  73567. worldInformation: {
  73568. detectedPlanes?: XRPlaneSet;
  73569. };
  73570. }
  73571. interface XRViewerPose extends XRPose {
  73572. views: Array<XRView>;
  73573. }
  73574. interface XRPose {
  73575. transform: XRRigidTransform;
  73576. emulatedPosition: boolean;
  73577. }
  73578. interface XRWebGLLayerOptions {
  73579. antialias?: boolean;
  73580. depth?: boolean;
  73581. stencil?: boolean;
  73582. alpha?: boolean;
  73583. multiview?: boolean;
  73584. framebufferScaleFactor?: number;
  73585. }
  73586. declare var XRWebGLLayer: {
  73587. prototype: XRWebGLLayer;
  73588. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  73589. };
  73590. interface XRWebGLLayer {
  73591. framebuffer: WebGLFramebuffer;
  73592. framebufferWidth: number;
  73593. framebufferHeight: number;
  73594. getViewport: Function;
  73595. }
  73596. declare class XRRigidTransform {
  73597. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  73598. position: DOMPointReadOnly;
  73599. orientation: DOMPointReadOnly;
  73600. matrix: Float32Array;
  73601. inverse: XRRigidTransform;
  73602. }
  73603. interface XRView {
  73604. eye: XREye;
  73605. projectionMatrix: Float32Array;
  73606. transform: XRRigidTransform;
  73607. }
  73608. interface XRInputSourceChangeEvent {
  73609. session: XRSession;
  73610. removed: Array<XRInputSource>;
  73611. added: Array<XRInputSource>;
  73612. }
  73613. interface XRInputSourceEvent extends Event {
  73614. readonly frame: XRFrame;
  73615. readonly inputSource: XRInputSource;
  73616. }
  73617. // Experimental(er) features
  73618. declare class XRRay {
  73619. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  73620. origin: DOMPointReadOnly;
  73621. direction: DOMPointReadOnly;
  73622. matrix: Float32Array;
  73623. }
  73624. declare enum XRHitTestTrackableType {
  73625. "point",
  73626. "plane"
  73627. }
  73628. interface XRHitResult {
  73629. hitMatrix: Float32Array;
  73630. }
  73631. interface XRTransientInputHitTestResult {
  73632. readonly inputSource: XRInputSource;
  73633. readonly results: Array<XRHitTestResult>;
  73634. }
  73635. interface XRHitTestResult {
  73636. getPose(baseSpace: XRSpace): XRPose | undefined;
  73637. // When anchor system is enabled
  73638. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  73639. }
  73640. interface XRHitTestSource {
  73641. cancel(): void;
  73642. }
  73643. interface XRTransientInputHitTestSource {
  73644. cancel(): void;
  73645. }
  73646. interface XRHitTestOptionsInit {
  73647. space: XRSpace;
  73648. entityTypes?: Array<XRHitTestTrackableType>;
  73649. offsetRay?: XRRay;
  73650. }
  73651. interface XRTransientInputHitTestOptionsInit {
  73652. profile: string;
  73653. entityTypes?: Array<XRHitTestTrackableType>;
  73654. offsetRay?: XRRay;
  73655. }
  73656. interface XRAnchor {
  73657. anchorSpace: XRSpace;
  73658. delete(): void;
  73659. }
  73660. interface XRPlane {
  73661. orientation: "Horizontal" | "Vertical";
  73662. planeSpace: XRSpace;
  73663. polygon: Array<DOMPointReadOnly>;
  73664. lastChangedTime: number;
  73665. }
  73666. /**
  73667. * @ignore
  73668. */
  73669. declare module BABYLON.GLTF2.Exporter {
  73670. }
  73671. /**
  73672. * @ignore
  73673. */
  73674. declare module BABYLON.GLTF1 {
  73675. }
  73676. declare module BABYLON.GUI {
  73677. /**
  73678. * Class used to specific a value and its associated unit
  73679. */
  73680. export class ValueAndUnit {
  73681. /** defines the unit to store */
  73682. unit: number;
  73683. /** defines a boolean indicating if the value can be negative */
  73684. negativeValueAllowed: boolean;
  73685. private _value;
  73686. private _originalUnit;
  73687. /**
  73688. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  73689. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73690. */
  73691. ignoreAdaptiveScaling: boolean;
  73692. /**
  73693. * Creates a new ValueAndUnit
  73694. * @param value defines the value to store
  73695. * @param unit defines the unit to store
  73696. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  73697. */
  73698. constructor(value: number,
  73699. /** defines the unit to store */
  73700. unit?: number,
  73701. /** defines a boolean indicating if the value can be negative */
  73702. negativeValueAllowed?: boolean);
  73703. /** Gets a boolean indicating if the value is a percentage */
  73704. get isPercentage(): boolean;
  73705. /** Gets a boolean indicating if the value is store as pixel */
  73706. get isPixel(): boolean;
  73707. /** Gets direct internal value */
  73708. get internalValue(): number;
  73709. /**
  73710. * Gets value as pixel
  73711. * @param host defines the root host
  73712. * @param refValue defines the reference value for percentages
  73713. * @returns the value as pixel
  73714. */
  73715. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  73716. /**
  73717. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  73718. * @param value defines the value to store
  73719. * @param unit defines the unit to store
  73720. * @returns the current ValueAndUnit
  73721. */
  73722. updateInPlace(value: number, unit?: number): ValueAndUnit;
  73723. /**
  73724. * Gets the value accordingly to its unit
  73725. * @param host defines the root host
  73726. * @returns the value
  73727. */
  73728. getValue(host: AdvancedDynamicTexture): number;
  73729. /**
  73730. * Gets a string representation of the value
  73731. * @param host defines the root host
  73732. * @param decimals defines an optional number of decimals to display
  73733. * @returns a string
  73734. */
  73735. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  73736. /**
  73737. * Store a value parsed from a string
  73738. * @param source defines the source string
  73739. * @returns true if the value was successfully parsed
  73740. */
  73741. fromString(source: string | number): boolean;
  73742. private static _Regex;
  73743. private static _UNITMODE_PERCENTAGE;
  73744. private static _UNITMODE_PIXEL;
  73745. /** UNITMODE_PERCENTAGE */
  73746. static get UNITMODE_PERCENTAGE(): number;
  73747. /** UNITMODE_PIXEL */
  73748. static get UNITMODE_PIXEL(): number;
  73749. }
  73750. }
  73751. declare module BABYLON.GUI {
  73752. /**
  73753. * Define a style used by control to automatically setup properties based on a template.
  73754. * Only support font related properties so far
  73755. */
  73756. export class Style implements BABYLON.IDisposable {
  73757. private _fontFamily;
  73758. private _fontStyle;
  73759. private _fontWeight;
  73760. /** @hidden */
  73761. _host: AdvancedDynamicTexture;
  73762. /** @hidden */
  73763. _fontSize: ValueAndUnit;
  73764. /**
  73765. * BABYLON.Observable raised when the style values are changed
  73766. */
  73767. onChangedObservable: BABYLON.Observable<Style>;
  73768. /**
  73769. * Creates a new style object
  73770. * @param host defines the AdvancedDynamicTexture which hosts this style
  73771. */
  73772. constructor(host: AdvancedDynamicTexture);
  73773. /**
  73774. * Gets or sets the font size
  73775. */
  73776. get fontSize(): string | number;
  73777. set fontSize(value: string | number);
  73778. /**
  73779. * Gets or sets the font family
  73780. */
  73781. get fontFamily(): string;
  73782. set fontFamily(value: string);
  73783. /**
  73784. * Gets or sets the font style
  73785. */
  73786. get fontStyle(): string;
  73787. set fontStyle(value: string);
  73788. /** Gets or sets font weight */
  73789. get fontWeight(): string;
  73790. set fontWeight(value: string);
  73791. /** Dispose all associated resources */
  73792. dispose(): void;
  73793. }
  73794. }
  73795. declare module BABYLON.GUI {
  73796. /**
  73797. * Class used to transport BABYLON.Vector2 information for pointer events
  73798. */
  73799. export class Vector2WithInfo extends BABYLON.Vector2 {
  73800. /** defines the current mouse button index */
  73801. buttonIndex: number;
  73802. /**
  73803. * Creates a new Vector2WithInfo
  73804. * @param source defines the vector2 data to transport
  73805. * @param buttonIndex defines the current mouse button index
  73806. */
  73807. constructor(source: BABYLON.Vector2,
  73808. /** defines the current mouse button index */
  73809. buttonIndex?: number);
  73810. }
  73811. /** Class used to provide 2D matrix features */
  73812. export class Matrix2D {
  73813. /** Gets the internal array of 6 floats used to store matrix data */
  73814. m: Float32Array;
  73815. /**
  73816. * Creates a new matrix
  73817. * @param m00 defines value for (0, 0)
  73818. * @param m01 defines value for (0, 1)
  73819. * @param m10 defines value for (1, 0)
  73820. * @param m11 defines value for (1, 1)
  73821. * @param m20 defines value for (2, 0)
  73822. * @param m21 defines value for (2, 1)
  73823. */
  73824. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  73825. /**
  73826. * Fills the matrix from direct values
  73827. * @param m00 defines value for (0, 0)
  73828. * @param m01 defines value for (0, 1)
  73829. * @param m10 defines value for (1, 0)
  73830. * @param m11 defines value for (1, 1)
  73831. * @param m20 defines value for (2, 0)
  73832. * @param m21 defines value for (2, 1)
  73833. * @returns the current modified matrix
  73834. */
  73835. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  73836. /**
  73837. * Gets matrix determinant
  73838. * @returns the determinant
  73839. */
  73840. determinant(): number;
  73841. /**
  73842. * Inverses the matrix and stores it in a target matrix
  73843. * @param result defines the target matrix
  73844. * @returns the current matrix
  73845. */
  73846. invertToRef(result: Matrix2D): Matrix2D;
  73847. /**
  73848. * Multiplies the current matrix with another one
  73849. * @param other defines the second operand
  73850. * @param result defines the target matrix
  73851. * @returns the current matrix
  73852. */
  73853. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  73854. /**
  73855. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  73856. * @param x defines the x coordinate to transform
  73857. * @param y defines the x coordinate to transform
  73858. * @param result defines the target vector2
  73859. * @returns the current matrix
  73860. */
  73861. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  73862. /**
  73863. * Creates an identity matrix
  73864. * @returns a new matrix
  73865. */
  73866. static Identity(): Matrix2D;
  73867. /**
  73868. * Creates a translation matrix and stores it in a target matrix
  73869. * @param x defines the x coordinate of the translation
  73870. * @param y defines the y coordinate of the translation
  73871. * @param result defines the target matrix
  73872. */
  73873. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  73874. /**
  73875. * Creates a scaling matrix and stores it in a target matrix
  73876. * @param x defines the x coordinate of the scaling
  73877. * @param y defines the y coordinate of the scaling
  73878. * @param result defines the target matrix
  73879. */
  73880. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  73881. /**
  73882. * Creates a rotation matrix and stores it in a target matrix
  73883. * @param angle defines the rotation angle
  73884. * @param result defines the target matrix
  73885. */
  73886. static RotationToRef(angle: number, result: Matrix2D): void;
  73887. private static _TempPreTranslationMatrix;
  73888. private static _TempPostTranslationMatrix;
  73889. private static _TempRotationMatrix;
  73890. private static _TempScalingMatrix;
  73891. private static _TempCompose0;
  73892. private static _TempCompose1;
  73893. private static _TempCompose2;
  73894. /**
  73895. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  73896. * @param tx defines the x coordinate of the translation
  73897. * @param ty defines the y coordinate of the translation
  73898. * @param angle defines the rotation angle
  73899. * @param scaleX defines the x coordinate of the scaling
  73900. * @param scaleY defines the y coordinate of the scaling
  73901. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  73902. * @param result defines the target matrix
  73903. */
  73904. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  73905. }
  73906. }
  73907. declare module BABYLON.GUI {
  73908. /**
  73909. * Class used to store 2D control sizes
  73910. */
  73911. export class Measure {
  73912. /** defines left coordinate */
  73913. left: number;
  73914. /** defines top coordinate */
  73915. top: number;
  73916. /** defines width dimension */
  73917. width: number;
  73918. /** defines height dimension */
  73919. height: number;
  73920. /**
  73921. * Creates a new measure
  73922. * @param left defines left coordinate
  73923. * @param top defines top coordinate
  73924. * @param width defines width dimension
  73925. * @param height defines height dimension
  73926. */
  73927. constructor(
  73928. /** defines left coordinate */
  73929. left: number,
  73930. /** defines top coordinate */
  73931. top: number,
  73932. /** defines width dimension */
  73933. width: number,
  73934. /** defines height dimension */
  73935. height: number);
  73936. /**
  73937. * Copy from another measure
  73938. * @param other defines the other measure to copy from
  73939. */
  73940. copyFrom(other: Measure): void;
  73941. /**
  73942. * Copy from a group of 4 floats
  73943. * @param left defines left coordinate
  73944. * @param top defines top coordinate
  73945. * @param width defines width dimension
  73946. * @param height defines height dimension
  73947. */
  73948. copyFromFloats(left: number, top: number, width: number, height: number): void;
  73949. /**
  73950. * Computes the axis aligned bounding box measure for two given measures
  73951. * @param a Input measure
  73952. * @param b Input measure
  73953. * @param result the resulting bounding measure
  73954. */
  73955. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  73956. /**
  73957. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  73958. * @param transform the matrix to transform the measure before computing the AABB
  73959. * @param result the resulting AABB
  73960. */
  73961. transformToRef(transform: Matrix2D, result: Measure): void;
  73962. /**
  73963. * Check equality between this measure and another one
  73964. * @param other defines the other measures
  73965. * @returns true if both measures are equals
  73966. */
  73967. isEqualsTo(other: Measure): boolean;
  73968. /**
  73969. * Creates an empty measure
  73970. * @returns a new measure
  73971. */
  73972. static Empty(): Measure;
  73973. }
  73974. }
  73975. declare module BABYLON.GUI {
  73976. /**
  73977. * Interface used to define a control that can receive focus
  73978. */
  73979. export interface IFocusableControl {
  73980. /**
  73981. * Function called when the control receives the focus
  73982. */
  73983. onFocus(): void;
  73984. /**
  73985. * Function called when the control loses the focus
  73986. */
  73987. onBlur(): void;
  73988. /**
  73989. * Function called to let the control handle keyboard events
  73990. * @param evt defines the current keyboard event
  73991. */
  73992. processKeyboard(evt: KeyboardEvent): void;
  73993. /**
  73994. * Function called to get the list of controls that should not steal the focus from this control
  73995. * @returns an array of controls
  73996. */
  73997. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73998. }
  73999. /**
  74000. * Class used to create texture to support 2D GUI elements
  74001. * @see http://doc.babylonjs.com/how_to/gui
  74002. */
  74003. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  74004. private _isDirty;
  74005. private _renderObserver;
  74006. private _resizeObserver;
  74007. private _preKeyboardObserver;
  74008. private _pointerMoveObserver;
  74009. private _pointerObserver;
  74010. private _canvasPointerOutObserver;
  74011. private _background;
  74012. /** @hidden */
  74013. _rootContainer: Container;
  74014. /** @hidden */
  74015. _lastPickedControl: Control;
  74016. /** @hidden */
  74017. _lastControlOver: {
  74018. [pointerId: number]: Control;
  74019. };
  74020. /** @hidden */
  74021. _lastControlDown: {
  74022. [pointerId: number]: Control;
  74023. };
  74024. /** @hidden */
  74025. _capturingControl: {
  74026. [pointerId: number]: Control;
  74027. };
  74028. /** @hidden */
  74029. _shouldBlockPointer: boolean;
  74030. /** @hidden */
  74031. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  74032. /** @hidden */
  74033. _linkedControls: Control[];
  74034. private _isFullscreen;
  74035. private _fullscreenViewport;
  74036. private _idealWidth;
  74037. private _idealHeight;
  74038. private _useSmallestIdeal;
  74039. private _renderAtIdealSize;
  74040. private _focusedControl;
  74041. private _blockNextFocusCheck;
  74042. private _renderScale;
  74043. private _rootElement;
  74044. private _cursorChanged;
  74045. private _defaultMousePointerId;
  74046. /** @hidden */
  74047. _numLayoutCalls: number;
  74048. /** Gets the number of layout calls made the last time the ADT has been rendered */
  74049. get numLayoutCalls(): number;
  74050. /** @hidden */
  74051. _numRenderCalls: number;
  74052. /** Gets the number of render calls made the last time the ADT has been rendered */
  74053. get numRenderCalls(): number;
  74054. /**
  74055. * Define type to string to ensure compatibility across browsers
  74056. * Safari doesn't support DataTransfer constructor
  74057. */
  74058. private _clipboardData;
  74059. /**
  74060. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  74061. */
  74062. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  74063. /**
  74064. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  74065. */
  74066. onControlPickedObservable: BABYLON.Observable<Control>;
  74067. /**
  74068. * BABYLON.Observable event triggered before layout is evaluated
  74069. */
  74070. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74071. /**
  74072. * BABYLON.Observable event triggered after the layout was evaluated
  74073. */
  74074. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74075. /**
  74076. * BABYLON.Observable event triggered before the texture is rendered
  74077. */
  74078. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74079. /**
  74080. * BABYLON.Observable event triggered after the texture was rendered
  74081. */
  74082. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74083. /**
  74084. * Gets or sets a boolean defining if alpha is stored as premultiplied
  74085. */
  74086. premulAlpha: boolean;
  74087. /**
  74088. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  74089. * Useful when you want more antialiasing
  74090. */
  74091. get renderScale(): number;
  74092. set renderScale(value: number);
  74093. /** Gets or sets the background color */
  74094. get background(): string;
  74095. set background(value: string);
  74096. /**
  74097. * Gets or sets the ideal width used to design controls.
  74098. * The GUI will then rescale everything accordingly
  74099. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74100. */
  74101. get idealWidth(): number;
  74102. set idealWidth(value: number);
  74103. /**
  74104. * Gets or sets the ideal height used to design controls.
  74105. * The GUI will then rescale everything accordingly
  74106. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74107. */
  74108. get idealHeight(): number;
  74109. set idealHeight(value: number);
  74110. /**
  74111. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  74112. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74113. */
  74114. get useSmallestIdeal(): boolean;
  74115. set useSmallestIdeal(value: boolean);
  74116. /**
  74117. * Gets or sets a boolean indicating if adaptive scaling must be used
  74118. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74119. */
  74120. get renderAtIdealSize(): boolean;
  74121. set renderAtIdealSize(value: boolean);
  74122. /**
  74123. * Gets the ratio used when in "ideal mode"
  74124. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74125. * */
  74126. get idealRatio(): number;
  74127. /**
  74128. * Gets the underlying layer used to render the texture when in fullscreen mode
  74129. */
  74130. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  74131. /**
  74132. * Gets the root container control
  74133. */
  74134. get rootContainer(): Container;
  74135. /**
  74136. * Returns an array containing the root container.
  74137. * This is mostly used to let the Inspector introspects the ADT
  74138. * @returns an array containing the rootContainer
  74139. */
  74140. getChildren(): Array<Container>;
  74141. /**
  74142. * Will return all controls that are inside this texture
  74143. * @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
  74144. * @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
  74145. * @return all child controls
  74146. */
  74147. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74148. /**
  74149. * Gets or sets the current focused control
  74150. */
  74151. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  74152. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  74153. /**
  74154. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  74155. */
  74156. get isForeground(): boolean;
  74157. set isForeground(value: boolean);
  74158. /**
  74159. * Gets or set information about clipboardData
  74160. */
  74161. get clipboardData(): string;
  74162. set clipboardData(value: string);
  74163. /**
  74164. * Creates a new AdvancedDynamicTexture
  74165. * @param name defines the name of the texture
  74166. * @param width defines the width of the texture
  74167. * @param height defines the height of the texture
  74168. * @param scene defines the hosting scene
  74169. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  74170. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  74171. */
  74172. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  74173. /**
  74174. * Get the current class name of the texture useful for serialization or dynamic coding.
  74175. * @returns "AdvancedDynamicTexture"
  74176. */
  74177. getClassName(): string;
  74178. /**
  74179. * Function used to execute a function on all controls
  74180. * @param func defines the function to execute
  74181. * @param container defines the container where controls belong. If null the root container will be used
  74182. */
  74183. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  74184. private _useInvalidateRectOptimization;
  74185. /**
  74186. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  74187. */
  74188. get useInvalidateRectOptimization(): boolean;
  74189. set useInvalidateRectOptimization(value: boolean);
  74190. private _invalidatedRectangle;
  74191. /**
  74192. * Invalidates a rectangle area on the gui texture
  74193. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  74194. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  74195. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  74196. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  74197. */
  74198. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  74199. /**
  74200. * Marks the texture as dirty forcing a complete update
  74201. */
  74202. markAsDirty(): void;
  74203. /**
  74204. * Helper function used to create a new style
  74205. * @returns a new style
  74206. * @see http://doc.babylonjs.com/how_to/gui#styles
  74207. */
  74208. createStyle(): Style;
  74209. /**
  74210. * Adds a new control to the root container
  74211. * @param control defines the control to add
  74212. * @returns the current texture
  74213. */
  74214. addControl(control: Control): AdvancedDynamicTexture;
  74215. /**
  74216. * Removes a control from the root container
  74217. * @param control defines the control to remove
  74218. * @returns the current texture
  74219. */
  74220. removeControl(control: Control): AdvancedDynamicTexture;
  74221. /**
  74222. * Release all resources
  74223. */
  74224. dispose(): void;
  74225. private _onResize;
  74226. /** @hidden */
  74227. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  74228. /**
  74229. * Get screen coordinates for a vector3
  74230. * @param position defines the position to project
  74231. * @param worldMatrix defines the world matrix to use
  74232. * @returns the projected position
  74233. */
  74234. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  74235. private _checkUpdate;
  74236. private _clearMeasure;
  74237. private _render;
  74238. /** @hidden */
  74239. _changeCursor(cursor: string): void;
  74240. /** @hidden */
  74241. _registerLastControlDown(control: Control, pointerId: number): void;
  74242. private _doPicking;
  74243. /** @hidden */
  74244. _cleanControlAfterRemovalFromList(list: {
  74245. [pointerId: number]: Control;
  74246. }, control: Control): void;
  74247. /** @hidden */
  74248. _cleanControlAfterRemoval(control: Control): void;
  74249. /** Attach to all scene events required to support pointer events */
  74250. attach(): void;
  74251. /** @hidden */
  74252. private onClipboardCopy;
  74253. /** @hidden */
  74254. private onClipboardCut;
  74255. /** @hidden */
  74256. private onClipboardPaste;
  74257. /**
  74258. * Register the clipboard Events onto the canvas
  74259. */
  74260. registerClipboardEvents(): void;
  74261. /**
  74262. * Unregister the clipboard Events from the canvas
  74263. */
  74264. unRegisterClipboardEvents(): void;
  74265. /**
  74266. * Connect the texture to a hosting mesh to enable interactions
  74267. * @param mesh defines the mesh to attach to
  74268. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  74269. */
  74270. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  74271. /**
  74272. * Move the focus to a specific control
  74273. * @param control defines the control which will receive the focus
  74274. */
  74275. moveFocusToControl(control: IFocusableControl): void;
  74276. private _manageFocus;
  74277. private _attachToOnPointerOut;
  74278. /**
  74279. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  74280. * @param mesh defines the mesh which will receive the texture
  74281. * @param width defines the texture width (1024 by default)
  74282. * @param height defines the texture height (1024 by default)
  74283. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  74284. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  74285. * @returns a new AdvancedDynamicTexture
  74286. */
  74287. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  74288. /**
  74289. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  74290. * In this mode the texture will rely on a layer for its rendering.
  74291. * This allows it to be treated like any other layer.
  74292. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  74293. * LayerMask is set through advancedTexture.layer.layerMask
  74294. * @param name defines name for the texture
  74295. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  74296. * @param scene defines the hsoting scene
  74297. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  74298. * @returns a new AdvancedDynamicTexture
  74299. */
  74300. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  74301. }
  74302. }
  74303. declare module BABYLON.GUI {
  74304. /**
  74305. * Root class used for all 2D controls
  74306. * @see http://doc.babylonjs.com/how_to/gui#controls
  74307. */
  74308. export class Control {
  74309. /** defines the name of the control */
  74310. name?: string | undefined;
  74311. /**
  74312. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  74313. */
  74314. static AllowAlphaInheritance: boolean;
  74315. private _alpha;
  74316. private _alphaSet;
  74317. private _zIndex;
  74318. /** @hidden */
  74319. _host: AdvancedDynamicTexture;
  74320. /** Gets or sets the control parent */
  74321. parent: BABYLON.Nullable<Container>;
  74322. /** @hidden */
  74323. _currentMeasure: Measure;
  74324. private _fontFamily;
  74325. private _fontStyle;
  74326. private _fontWeight;
  74327. private _fontSize;
  74328. private _font;
  74329. /** @hidden */
  74330. _width: ValueAndUnit;
  74331. /** @hidden */
  74332. _height: ValueAndUnit;
  74333. /** @hidden */
  74334. protected _fontOffset: {
  74335. ascent: number;
  74336. height: number;
  74337. descent: number;
  74338. };
  74339. private _color;
  74340. private _style;
  74341. private _styleObserver;
  74342. /** @hidden */
  74343. protected _horizontalAlignment: number;
  74344. /** @hidden */
  74345. protected _verticalAlignment: number;
  74346. /** @hidden */
  74347. protected _isDirty: boolean;
  74348. /** @hidden */
  74349. protected _wasDirty: boolean;
  74350. /** @hidden */
  74351. _tempParentMeasure: Measure;
  74352. /** @hidden */
  74353. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  74354. /** @hidden */
  74355. protected _cachedParentMeasure: Measure;
  74356. private _paddingLeft;
  74357. private _paddingRight;
  74358. private _paddingTop;
  74359. private _paddingBottom;
  74360. /** @hidden */
  74361. _left: ValueAndUnit;
  74362. /** @hidden */
  74363. _top: ValueAndUnit;
  74364. private _scaleX;
  74365. private _scaleY;
  74366. private _rotation;
  74367. private _transformCenterX;
  74368. private _transformCenterY;
  74369. /** @hidden */
  74370. _transformMatrix: Matrix2D;
  74371. /** @hidden */
  74372. protected _invertTransformMatrix: Matrix2D;
  74373. /** @hidden */
  74374. protected _transformedPosition: BABYLON.Vector2;
  74375. private _isMatrixDirty;
  74376. private _cachedOffsetX;
  74377. private _cachedOffsetY;
  74378. private _isVisible;
  74379. private _isHighlighted;
  74380. /** @hidden */
  74381. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  74382. private _fontSet;
  74383. private _dummyVector2;
  74384. private _downCount;
  74385. private _enterCount;
  74386. private _doNotRender;
  74387. private _downPointerIds;
  74388. protected _isEnabled: boolean;
  74389. protected _disabledColor: string;
  74390. protected _disabledColorItem: string;
  74391. /** @hidden */
  74392. protected _rebuildLayout: boolean;
  74393. /** @hidden */
  74394. _customData: any;
  74395. /** @hidden */
  74396. _isClipped: boolean;
  74397. /** @hidden */
  74398. _automaticSize: boolean;
  74399. /** @hidden */
  74400. _tag: any;
  74401. /**
  74402. * 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
  74403. */
  74404. uniqueId: number;
  74405. /**
  74406. * Gets or sets an object used to store user defined information for the node
  74407. */
  74408. metadata: any;
  74409. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  74410. isHitTestVisible: boolean;
  74411. /** Gets or sets a boolean indicating if the control can block pointer events */
  74412. isPointerBlocker: boolean;
  74413. /** Gets or sets a boolean indicating if the control can be focusable */
  74414. isFocusInvisible: boolean;
  74415. /**
  74416. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  74417. * 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
  74418. */
  74419. clipChildren: boolean;
  74420. /**
  74421. * Gets or sets a boolean indicating that control content must be clipped
  74422. * 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
  74423. */
  74424. clipContent: boolean;
  74425. /**
  74426. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  74427. */
  74428. useBitmapCache: boolean;
  74429. private _cacheData;
  74430. private _shadowOffsetX;
  74431. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  74432. get shadowOffsetX(): number;
  74433. set shadowOffsetX(value: number);
  74434. private _shadowOffsetY;
  74435. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  74436. get shadowOffsetY(): number;
  74437. set shadowOffsetY(value: number);
  74438. private _shadowBlur;
  74439. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  74440. get shadowBlur(): number;
  74441. set shadowBlur(value: number);
  74442. private _shadowColor;
  74443. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  74444. get shadowColor(): string;
  74445. set shadowColor(value: string);
  74446. /** Gets or sets the cursor to use when the control is hovered */
  74447. hoverCursor: string;
  74448. /** @hidden */
  74449. protected _linkOffsetX: ValueAndUnit;
  74450. /** @hidden */
  74451. protected _linkOffsetY: ValueAndUnit;
  74452. /** Gets the control type name */
  74453. get typeName(): string;
  74454. /**
  74455. * Get the current class name of the control.
  74456. * @returns current class name
  74457. */
  74458. getClassName(): string;
  74459. /**
  74460. * An event triggered when pointer wheel is scrolled
  74461. */
  74462. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  74463. /**
  74464. * An event triggered when the pointer move over the control.
  74465. */
  74466. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  74467. /**
  74468. * An event triggered when the pointer move out of the control.
  74469. */
  74470. onPointerOutObservable: BABYLON.Observable<Control>;
  74471. /**
  74472. * An event triggered when the pointer taps the control
  74473. */
  74474. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  74475. /**
  74476. * An event triggered when pointer up
  74477. */
  74478. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  74479. /**
  74480. * An event triggered when a control is clicked on
  74481. */
  74482. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  74483. /**
  74484. * An event triggered when pointer enters the control
  74485. */
  74486. onPointerEnterObservable: BABYLON.Observable<Control>;
  74487. /**
  74488. * An event triggered when the control is marked as dirty
  74489. */
  74490. onDirtyObservable: BABYLON.Observable<Control>;
  74491. /**
  74492. * An event triggered before drawing the control
  74493. */
  74494. onBeforeDrawObservable: BABYLON.Observable<Control>;
  74495. /**
  74496. * An event triggered after the control was drawn
  74497. */
  74498. onAfterDrawObservable: BABYLON.Observable<Control>;
  74499. /**
  74500. * An event triggered when the control has been disposed
  74501. */
  74502. onDisposeObservable: BABYLON.Observable<Control>;
  74503. /**
  74504. * Get the hosting AdvancedDynamicTexture
  74505. */
  74506. get host(): AdvancedDynamicTexture;
  74507. /** Gets or set information about font offsets (used to render and align text) */
  74508. get fontOffset(): {
  74509. ascent: number;
  74510. height: number;
  74511. descent: number;
  74512. };
  74513. set fontOffset(offset: {
  74514. ascent: number;
  74515. height: number;
  74516. descent: number;
  74517. });
  74518. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  74519. get alpha(): number;
  74520. set alpha(value: number);
  74521. /**
  74522. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  74523. */
  74524. get isHighlighted(): boolean;
  74525. set isHighlighted(value: boolean);
  74526. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  74527. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74528. */
  74529. get scaleX(): number;
  74530. set scaleX(value: number);
  74531. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  74532. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74533. */
  74534. get scaleY(): number;
  74535. set scaleY(value: number);
  74536. /** Gets or sets the rotation angle (0 by default)
  74537. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74538. */
  74539. get rotation(): number;
  74540. set rotation(value: number);
  74541. /** Gets or sets the transformation center on Y axis (0 by default)
  74542. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74543. */
  74544. get transformCenterY(): number;
  74545. set transformCenterY(value: number);
  74546. /** Gets or sets the transformation center on X axis (0 by default)
  74547. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74548. */
  74549. get transformCenterX(): number;
  74550. set transformCenterX(value: number);
  74551. /**
  74552. * Gets or sets the horizontal alignment
  74553. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74554. */
  74555. get horizontalAlignment(): number;
  74556. set horizontalAlignment(value: number);
  74557. /**
  74558. * Gets or sets the vertical alignment
  74559. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74560. */
  74561. get verticalAlignment(): number;
  74562. set verticalAlignment(value: number);
  74563. /**
  74564. * Gets or sets control width
  74565. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74566. */
  74567. get width(): string | number;
  74568. set width(value: string | number);
  74569. /**
  74570. * Gets or sets the control width in pixel
  74571. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74572. */
  74573. get widthInPixels(): number;
  74574. set widthInPixels(value: number);
  74575. /**
  74576. * Gets or sets control height
  74577. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74578. */
  74579. get height(): string | number;
  74580. set height(value: string | number);
  74581. /**
  74582. * Gets or sets control height in pixel
  74583. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74584. */
  74585. get heightInPixels(): number;
  74586. set heightInPixels(value: number);
  74587. /** Gets or set font family */
  74588. get fontFamily(): string;
  74589. set fontFamily(value: string);
  74590. /** Gets or sets font style */
  74591. get fontStyle(): string;
  74592. set fontStyle(value: string);
  74593. /** Gets or sets font weight */
  74594. get fontWeight(): string;
  74595. set fontWeight(value: string);
  74596. /**
  74597. * Gets or sets style
  74598. * @see http://doc.babylonjs.com/how_to/gui#styles
  74599. */
  74600. get style(): BABYLON.Nullable<Style>;
  74601. set style(value: BABYLON.Nullable<Style>);
  74602. /** @hidden */
  74603. get _isFontSizeInPercentage(): boolean;
  74604. /** Gets or sets font size in pixels */
  74605. get fontSizeInPixels(): number;
  74606. set fontSizeInPixels(value: number);
  74607. /** Gets or sets font size */
  74608. get fontSize(): string | number;
  74609. set fontSize(value: string | number);
  74610. /** Gets or sets foreground color */
  74611. get color(): string;
  74612. set color(value: string);
  74613. /** Gets or sets z index which is used to reorder controls on the z axis */
  74614. get zIndex(): number;
  74615. set zIndex(value: number);
  74616. /** Gets or sets a boolean indicating if the control can be rendered */
  74617. get notRenderable(): boolean;
  74618. set notRenderable(value: boolean);
  74619. /** Gets or sets a boolean indicating if the control is visible */
  74620. get isVisible(): boolean;
  74621. set isVisible(value: boolean);
  74622. /** Gets a boolean indicating that the control needs to update its rendering */
  74623. get isDirty(): boolean;
  74624. /**
  74625. * Gets the current linked mesh (or null if none)
  74626. */
  74627. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74628. /**
  74629. * Gets or sets a value indicating the padding to use on the left of the control
  74630. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74631. */
  74632. get paddingLeft(): string | number;
  74633. set paddingLeft(value: string | number);
  74634. /**
  74635. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  74636. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74637. */
  74638. get paddingLeftInPixels(): number;
  74639. set paddingLeftInPixels(value: number);
  74640. /**
  74641. * Gets or sets a value indicating the padding to use on the right of the control
  74642. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74643. */
  74644. get paddingRight(): string | number;
  74645. set paddingRight(value: string | number);
  74646. /**
  74647. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  74648. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74649. */
  74650. get paddingRightInPixels(): number;
  74651. set paddingRightInPixels(value: number);
  74652. /**
  74653. * Gets or sets a value indicating the padding to use on the top of the control
  74654. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74655. */
  74656. get paddingTop(): string | number;
  74657. set paddingTop(value: string | number);
  74658. /**
  74659. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  74660. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74661. */
  74662. get paddingTopInPixels(): number;
  74663. set paddingTopInPixels(value: number);
  74664. /**
  74665. * Gets or sets a value indicating the padding to use on the bottom of the control
  74666. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74667. */
  74668. get paddingBottom(): string | number;
  74669. set paddingBottom(value: string | number);
  74670. /**
  74671. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  74672. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74673. */
  74674. get paddingBottomInPixels(): number;
  74675. set paddingBottomInPixels(value: number);
  74676. /**
  74677. * Gets or sets a value indicating the left coordinate of the control
  74678. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74679. */
  74680. get left(): string | number;
  74681. set left(value: string | number);
  74682. /**
  74683. * Gets or sets a value indicating the left coordinate in pixels of the control
  74684. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74685. */
  74686. get leftInPixels(): number;
  74687. set leftInPixels(value: number);
  74688. /**
  74689. * Gets or sets a value indicating the top coordinate of the control
  74690. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74691. */
  74692. get top(): string | number;
  74693. set top(value: string | number);
  74694. /**
  74695. * Gets or sets a value indicating the top coordinate in pixels of the control
  74696. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74697. */
  74698. get topInPixels(): number;
  74699. set topInPixels(value: number);
  74700. /**
  74701. * Gets or sets a value indicating the offset on X axis to the linked mesh
  74702. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74703. */
  74704. get linkOffsetX(): string | number;
  74705. set linkOffsetX(value: string | number);
  74706. /**
  74707. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  74708. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74709. */
  74710. get linkOffsetXInPixels(): number;
  74711. set linkOffsetXInPixels(value: number);
  74712. /**
  74713. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  74714. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74715. */
  74716. get linkOffsetY(): string | number;
  74717. set linkOffsetY(value: string | number);
  74718. /**
  74719. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  74720. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74721. */
  74722. get linkOffsetYInPixels(): number;
  74723. set linkOffsetYInPixels(value: number);
  74724. /** Gets the center coordinate on X axis */
  74725. get centerX(): number;
  74726. /** Gets the center coordinate on Y axis */
  74727. get centerY(): number;
  74728. /** Gets or sets if control is Enabled*/
  74729. get isEnabled(): boolean;
  74730. set isEnabled(value: boolean);
  74731. /** Gets or sets background color of control if it's disabled*/
  74732. get disabledColor(): string;
  74733. set disabledColor(value: string);
  74734. /** Gets or sets front color of control if it's disabled*/
  74735. get disabledColorItem(): string;
  74736. set disabledColorItem(value: string);
  74737. /**
  74738. * Creates a new control
  74739. * @param name defines the name of the control
  74740. */
  74741. constructor(
  74742. /** defines the name of the control */
  74743. name?: string | undefined);
  74744. /** @hidden */
  74745. protected _getTypeName(): string;
  74746. /**
  74747. * Gets the first ascendant in the hierarchy of the given type
  74748. * @param className defines the required type
  74749. * @returns the ascendant or null if not found
  74750. */
  74751. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  74752. /** @hidden */
  74753. _resetFontCache(): void;
  74754. /**
  74755. * Determines if a container is an ascendant of the current control
  74756. * @param container defines the container to look for
  74757. * @returns true if the container is one of the ascendant of the control
  74758. */
  74759. isAscendant(container: Control): boolean;
  74760. /**
  74761. * Gets coordinates in local control space
  74762. * @param globalCoordinates defines the coordinates to transform
  74763. * @returns the new coordinates in local space
  74764. */
  74765. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74766. /**
  74767. * Gets coordinates in local control space
  74768. * @param globalCoordinates defines the coordinates to transform
  74769. * @param result defines the target vector2 where to store the result
  74770. * @returns the current control
  74771. */
  74772. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  74773. /**
  74774. * Gets coordinates in parent local control space
  74775. * @param globalCoordinates defines the coordinates to transform
  74776. * @returns the new coordinates in parent local space
  74777. */
  74778. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74779. /**
  74780. * Move the current control to a vector3 position projected onto the screen.
  74781. * @param position defines the target position
  74782. * @param scene defines the hosting scene
  74783. */
  74784. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  74785. /**
  74786. * Will store all controls that have this control as ascendant in a given array
  74787. * @param results defines the array where to store the descendants
  74788. * @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
  74789. * @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
  74790. */
  74791. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  74792. /**
  74793. * Will return all controls that have this control as ascendant
  74794. * @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
  74795. * @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
  74796. * @return all child controls
  74797. */
  74798. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74799. /**
  74800. * Link current control with a target mesh
  74801. * @param mesh defines the mesh to link with
  74802. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74803. */
  74804. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  74805. /** @hidden */
  74806. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  74807. /** @hidden */
  74808. _offsetLeft(offset: number): void;
  74809. /** @hidden */
  74810. _offsetTop(offset: number): void;
  74811. /** @hidden */
  74812. _markMatrixAsDirty(): void;
  74813. /** @hidden */
  74814. _flagDescendantsAsMatrixDirty(): void;
  74815. /** @hidden */
  74816. _intersectsRect(rect: Measure): boolean;
  74817. /** @hidden */
  74818. protected invalidateRect(): void;
  74819. /** @hidden */
  74820. _markAsDirty(force?: boolean): void;
  74821. /** @hidden */
  74822. _markAllAsDirty(): void;
  74823. /** @hidden */
  74824. _link(host: AdvancedDynamicTexture): void;
  74825. /** @hidden */
  74826. protected _transform(context?: CanvasRenderingContext2D): void;
  74827. /** @hidden */
  74828. _renderHighlight(context: CanvasRenderingContext2D): void;
  74829. /** @hidden */
  74830. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74831. /** @hidden */
  74832. protected _applyStates(context: CanvasRenderingContext2D): void;
  74833. /** @hidden */
  74834. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74835. /** @hidden */
  74836. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74837. protected _evaluateClippingState(parentMeasure: Measure): void;
  74838. /** @hidden */
  74839. _measure(): void;
  74840. /** @hidden */
  74841. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74842. /** @hidden */
  74843. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74844. /** @hidden */
  74845. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74846. /** @hidden */
  74847. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74848. private static _ClipMeasure;
  74849. private _tmpMeasureA;
  74850. private _clip;
  74851. /** @hidden */
  74852. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  74853. /** @hidden */
  74854. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74855. /**
  74856. * Tests if a given coordinates belong to the current control
  74857. * @param x defines x coordinate to test
  74858. * @param y defines y coordinate to test
  74859. * @returns true if the coordinates are inside the control
  74860. */
  74861. contains(x: number, y: number): boolean;
  74862. /** @hidden */
  74863. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74864. /** @hidden */
  74865. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74866. /** @hidden */
  74867. _onPointerEnter(target: Control): boolean;
  74868. /** @hidden */
  74869. _onPointerOut(target: Control, force?: boolean): void;
  74870. /** @hidden */
  74871. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74872. /** @hidden */
  74873. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74874. /** @hidden */
  74875. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74876. /** @hidden */
  74877. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  74878. /** @hidden */
  74879. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74880. private _prepareFont;
  74881. /** Releases associated resources */
  74882. dispose(): void;
  74883. private static _HORIZONTAL_ALIGNMENT_LEFT;
  74884. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  74885. private static _HORIZONTAL_ALIGNMENT_CENTER;
  74886. private static _VERTICAL_ALIGNMENT_TOP;
  74887. private static _VERTICAL_ALIGNMENT_BOTTOM;
  74888. private static _VERTICAL_ALIGNMENT_CENTER;
  74889. /** HORIZONTAL_ALIGNMENT_LEFT */
  74890. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  74891. /** HORIZONTAL_ALIGNMENT_RIGHT */
  74892. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  74893. /** HORIZONTAL_ALIGNMENT_CENTER */
  74894. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  74895. /** VERTICAL_ALIGNMENT_TOP */
  74896. static get VERTICAL_ALIGNMENT_TOP(): number;
  74897. /** VERTICAL_ALIGNMENT_BOTTOM */
  74898. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  74899. /** VERTICAL_ALIGNMENT_CENTER */
  74900. static get VERTICAL_ALIGNMENT_CENTER(): number;
  74901. private static _FontHeightSizes;
  74902. /** @hidden */
  74903. static _GetFontOffset(font: string): {
  74904. ascent: number;
  74905. height: number;
  74906. descent: number;
  74907. };
  74908. /**
  74909. * Creates a stack panel that can be used to render headers
  74910. * @param control defines the control to associate with the header
  74911. * @param text defines the text of the header
  74912. * @param size defines the size of the header
  74913. * @param options defines options used to configure the header
  74914. * @returns a new StackPanel
  74915. * @ignore
  74916. * @hidden
  74917. */
  74918. static AddHeader: (control: Control, text: string, size: string | number, options: {
  74919. isHorizontal: boolean;
  74920. controlFirst: boolean;
  74921. }) => any;
  74922. /** @hidden */
  74923. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  74924. }
  74925. }
  74926. declare module BABYLON.GUI {
  74927. /**
  74928. * Root class for 2D containers
  74929. * @see http://doc.babylonjs.com/how_to/gui#containers
  74930. */
  74931. export class Container extends Control {
  74932. name?: string | undefined;
  74933. /** @hidden */
  74934. _children: Control[];
  74935. /** @hidden */
  74936. protected _measureForChildren: Measure;
  74937. /** @hidden */
  74938. protected _background: string;
  74939. /** @hidden */
  74940. protected _adaptWidthToChildren: boolean;
  74941. /** @hidden */
  74942. protected _adaptHeightToChildren: boolean;
  74943. /**
  74944. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  74945. */
  74946. logLayoutCycleErrors: boolean;
  74947. /**
  74948. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  74949. */
  74950. maxLayoutCycle: number;
  74951. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  74952. get adaptHeightToChildren(): boolean;
  74953. set adaptHeightToChildren(value: boolean);
  74954. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  74955. get adaptWidthToChildren(): boolean;
  74956. set adaptWidthToChildren(value: boolean);
  74957. /** Gets or sets background color */
  74958. get background(): string;
  74959. set background(value: string);
  74960. /** Gets the list of children */
  74961. get children(): Control[];
  74962. /**
  74963. * Creates a new Container
  74964. * @param name defines the name of the container
  74965. */
  74966. constructor(name?: string | undefined);
  74967. protected _getTypeName(): string;
  74968. _flagDescendantsAsMatrixDirty(): void;
  74969. /**
  74970. * Gets a child using its name
  74971. * @param name defines the child name to look for
  74972. * @returns the child control if found
  74973. */
  74974. getChildByName(name: string): BABYLON.Nullable<Control>;
  74975. /**
  74976. * Gets a child using its type and its name
  74977. * @param name defines the child name to look for
  74978. * @param type defines the child type to look for
  74979. * @returns the child control if found
  74980. */
  74981. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  74982. /**
  74983. * Search for a specific control in children
  74984. * @param control defines the control to look for
  74985. * @returns true if the control is in child list
  74986. */
  74987. containsControl(control: Control): boolean;
  74988. /**
  74989. * Adds a new control to the current container
  74990. * @param control defines the control to add
  74991. * @returns the current container
  74992. */
  74993. addControl(control: BABYLON.Nullable<Control>): Container;
  74994. /**
  74995. * Removes all controls from the current container
  74996. * @returns the current container
  74997. */
  74998. clearControls(): Container;
  74999. /**
  75000. * Removes a control from the current container
  75001. * @param control defines the control to remove
  75002. * @returns the current container
  75003. */
  75004. removeControl(control: Control): Container;
  75005. /** @hidden */
  75006. _reOrderControl(control: Control): void;
  75007. /** @hidden */
  75008. _offsetLeft(offset: number): void;
  75009. /** @hidden */
  75010. _offsetTop(offset: number): void;
  75011. /** @hidden */
  75012. _markAllAsDirty(): void;
  75013. /** @hidden */
  75014. protected _localDraw(context: CanvasRenderingContext2D): void;
  75015. /** @hidden */
  75016. _link(host: AdvancedDynamicTexture): void;
  75017. /** @hidden */
  75018. protected _beforeLayout(): void;
  75019. /** @hidden */
  75020. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75021. /** @hidden */
  75022. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75023. protected _postMeasure(): void;
  75024. /** @hidden */
  75025. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  75026. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75027. /** @hidden */
  75028. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75029. /** @hidden */
  75030. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75031. /** Releases associated resources */
  75032. dispose(): void;
  75033. }
  75034. }
  75035. declare module BABYLON.GUI {
  75036. /** Class used to create rectangle container */
  75037. export class Rectangle extends Container {
  75038. name?: string | undefined;
  75039. private _thickness;
  75040. private _cornerRadius;
  75041. /** Gets or sets border thickness */
  75042. get thickness(): number;
  75043. set thickness(value: number);
  75044. /** Gets or sets the corner radius angle */
  75045. get cornerRadius(): number;
  75046. set cornerRadius(value: number);
  75047. /**
  75048. * Creates a new Rectangle
  75049. * @param name defines the control name
  75050. */
  75051. constructor(name?: string | undefined);
  75052. protected _getTypeName(): string;
  75053. protected _localDraw(context: CanvasRenderingContext2D): void;
  75054. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75055. private _drawRoundedRect;
  75056. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75057. }
  75058. }
  75059. declare module BABYLON.GUI {
  75060. /**
  75061. * Enum that determines the text-wrapping mode to use.
  75062. */
  75063. export enum TextWrapping {
  75064. /**
  75065. * Clip the text when it's larger than Control.width; this is the default mode.
  75066. */
  75067. Clip = 0,
  75068. /**
  75069. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  75070. */
  75071. WordWrap = 1,
  75072. /**
  75073. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  75074. */
  75075. Ellipsis = 2
  75076. }
  75077. /**
  75078. * Class used to create text block control
  75079. */
  75080. export class TextBlock extends Control {
  75081. /**
  75082. * Defines the name of the control
  75083. */
  75084. name?: string | undefined;
  75085. private _text;
  75086. private _textWrapping;
  75087. private _textHorizontalAlignment;
  75088. private _textVerticalAlignment;
  75089. private _lines;
  75090. private _resizeToFit;
  75091. private _lineSpacing;
  75092. private _outlineWidth;
  75093. private _outlineColor;
  75094. /**
  75095. * An event triggered after the text is changed
  75096. */
  75097. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  75098. /**
  75099. * An event triggered after the text was broken up into lines
  75100. */
  75101. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  75102. /**
  75103. * Function used to split a string into words. By default, a string is split at each space character found
  75104. */
  75105. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  75106. /**
  75107. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  75108. */
  75109. get lines(): any[];
  75110. /**
  75111. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75112. */
  75113. get resizeToFit(): boolean;
  75114. /**
  75115. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75116. */
  75117. set resizeToFit(value: boolean);
  75118. /**
  75119. * Gets or sets a boolean indicating if text must be wrapped
  75120. */
  75121. get textWrapping(): TextWrapping | boolean;
  75122. /**
  75123. * Gets or sets a boolean indicating if text must be wrapped
  75124. */
  75125. set textWrapping(value: TextWrapping | boolean);
  75126. /**
  75127. * Gets or sets text to display
  75128. */
  75129. get text(): string;
  75130. /**
  75131. * Gets or sets text to display
  75132. */
  75133. set text(value: string);
  75134. /**
  75135. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75136. */
  75137. get textHorizontalAlignment(): number;
  75138. /**
  75139. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75140. */
  75141. set textHorizontalAlignment(value: number);
  75142. /**
  75143. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75144. */
  75145. get textVerticalAlignment(): number;
  75146. /**
  75147. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75148. */
  75149. set textVerticalAlignment(value: number);
  75150. /**
  75151. * Gets or sets line spacing value
  75152. */
  75153. set lineSpacing(value: string | number);
  75154. /**
  75155. * Gets or sets line spacing value
  75156. */
  75157. get lineSpacing(): string | number;
  75158. /**
  75159. * Gets or sets outlineWidth of the text to display
  75160. */
  75161. get outlineWidth(): number;
  75162. /**
  75163. * Gets or sets outlineWidth of the text to display
  75164. */
  75165. set outlineWidth(value: number);
  75166. /**
  75167. * Gets or sets outlineColor of the text to display
  75168. */
  75169. get outlineColor(): string;
  75170. /**
  75171. * Gets or sets outlineColor of the text to display
  75172. */
  75173. set outlineColor(value: string);
  75174. /**
  75175. * Creates a new TextBlock object
  75176. * @param name defines the name of the control
  75177. * @param text defines the text to display (emptry string by default)
  75178. */
  75179. constructor(
  75180. /**
  75181. * Defines the name of the control
  75182. */
  75183. name?: string | undefined, text?: string);
  75184. protected _getTypeName(): string;
  75185. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75186. private _drawText;
  75187. /** @hidden */
  75188. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75189. protected _applyStates(context: CanvasRenderingContext2D): void;
  75190. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  75191. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  75192. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  75193. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  75194. protected _renderLines(context: CanvasRenderingContext2D): void;
  75195. /**
  75196. * Given a width constraint applied on the text block, find the expected height
  75197. * @returns expected height
  75198. */
  75199. computeExpectedHeight(): number;
  75200. dispose(): void;
  75201. }
  75202. }
  75203. declare module BABYLON.GUI {
  75204. /**
  75205. * Class used to create 2D images
  75206. */
  75207. export class Image extends Control {
  75208. name?: string | undefined;
  75209. private _workingCanvas;
  75210. private _domImage;
  75211. private _imageWidth;
  75212. private _imageHeight;
  75213. private _loaded;
  75214. private _stretch;
  75215. private _source;
  75216. private _autoScale;
  75217. private _sourceLeft;
  75218. private _sourceTop;
  75219. private _sourceWidth;
  75220. private _sourceHeight;
  75221. private _svgAttributesComputationCompleted;
  75222. private _isSVG;
  75223. private _cellWidth;
  75224. private _cellHeight;
  75225. private _cellId;
  75226. private _populateNinePatchSlicesFromImage;
  75227. private _sliceLeft;
  75228. private _sliceRight;
  75229. private _sliceTop;
  75230. private _sliceBottom;
  75231. private _detectPointerOnOpaqueOnly;
  75232. /**
  75233. * BABYLON.Observable notified when the content is loaded
  75234. */
  75235. onImageLoadedObservable: BABYLON.Observable<Image>;
  75236. /**
  75237. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  75238. */
  75239. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  75240. /**
  75241. * Gets a boolean indicating that the content is loaded
  75242. */
  75243. get isLoaded(): boolean;
  75244. /**
  75245. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  75246. */
  75247. get populateNinePatchSlicesFromImage(): boolean;
  75248. set populateNinePatchSlicesFromImage(value: boolean);
  75249. /**
  75250. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  75251. * Beware using this as this will comsume more memory as the image has to be stored twice
  75252. */
  75253. get detectPointerOnOpaqueOnly(): boolean;
  75254. set detectPointerOnOpaqueOnly(value: boolean);
  75255. /**
  75256. * Gets or sets the left value for slicing (9-patch)
  75257. */
  75258. get sliceLeft(): number;
  75259. set sliceLeft(value: number);
  75260. /**
  75261. * Gets or sets the right value for slicing (9-patch)
  75262. */
  75263. get sliceRight(): number;
  75264. set sliceRight(value: number);
  75265. /**
  75266. * Gets or sets the top value for slicing (9-patch)
  75267. */
  75268. get sliceTop(): number;
  75269. set sliceTop(value: number);
  75270. /**
  75271. * Gets or sets the bottom value for slicing (9-patch)
  75272. */
  75273. get sliceBottom(): number;
  75274. set sliceBottom(value: number);
  75275. /**
  75276. * Gets or sets the left coordinate in the source image
  75277. */
  75278. get sourceLeft(): number;
  75279. set sourceLeft(value: number);
  75280. /**
  75281. * Gets or sets the top coordinate in the source image
  75282. */
  75283. get sourceTop(): number;
  75284. set sourceTop(value: number);
  75285. /**
  75286. * Gets or sets the width to capture in the source image
  75287. */
  75288. get sourceWidth(): number;
  75289. set sourceWidth(value: number);
  75290. /**
  75291. * Gets or sets the height to capture in the source image
  75292. */
  75293. get sourceHeight(): number;
  75294. set sourceHeight(value: number);
  75295. /** Indicates if the format of the image is SVG */
  75296. get isSVG(): boolean;
  75297. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  75298. get svgAttributesComputationCompleted(): boolean;
  75299. /**
  75300. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  75301. * @see http://doc.babylonjs.com/how_to/gui#image
  75302. */
  75303. get autoScale(): boolean;
  75304. set autoScale(value: boolean);
  75305. /** Gets or sets the streching mode used by the image */
  75306. get stretch(): number;
  75307. set stretch(value: number);
  75308. /** @hidden */
  75309. _rotate90(n: number, preserveProperties?: boolean): Image;
  75310. private _handleRotationForSVGImage;
  75311. private _rotate90SourceProperties;
  75312. /**
  75313. * Gets or sets the internal DOM image used to render the control
  75314. */
  75315. set domImage(value: HTMLImageElement);
  75316. get domImage(): HTMLImageElement;
  75317. private _onImageLoaded;
  75318. private _extractNinePatchSliceDataFromImage;
  75319. /**
  75320. * Gets or sets image source url
  75321. */
  75322. set source(value: BABYLON.Nullable<string>);
  75323. /**
  75324. * Checks for svg document with icon id present
  75325. */
  75326. private _svgCheck;
  75327. /**
  75328. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  75329. * given external svg file and icon id
  75330. */
  75331. private _getSVGAttribs;
  75332. /**
  75333. * Gets or sets the cell width to use when animation sheet is enabled
  75334. * @see http://doc.babylonjs.com/how_to/gui#image
  75335. */
  75336. get cellWidth(): number;
  75337. set cellWidth(value: number);
  75338. /**
  75339. * Gets or sets the cell height to use when animation sheet is enabled
  75340. * @see http://doc.babylonjs.com/how_to/gui#image
  75341. */
  75342. get cellHeight(): number;
  75343. set cellHeight(value: number);
  75344. /**
  75345. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  75346. * @see http://doc.babylonjs.com/how_to/gui#image
  75347. */
  75348. get cellId(): number;
  75349. set cellId(value: number);
  75350. /**
  75351. * Creates a new Image
  75352. * @param name defines the control name
  75353. * @param url defines the image url
  75354. */
  75355. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  75356. /**
  75357. * Tests if a given coordinates belong to the current control
  75358. * @param x defines x coordinate to test
  75359. * @param y defines y coordinate to test
  75360. * @returns true if the coordinates are inside the control
  75361. */
  75362. contains(x: number, y: number): boolean;
  75363. protected _getTypeName(): string;
  75364. /** Force the control to synchronize with its content */
  75365. synchronizeSizeWithContent(): void;
  75366. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75367. private _prepareWorkingCanvasForOpaqueDetection;
  75368. private _drawImage;
  75369. _draw(context: CanvasRenderingContext2D): void;
  75370. private _renderCornerPatch;
  75371. private _renderNinePatch;
  75372. dispose(): void;
  75373. /** STRETCH_NONE */
  75374. static readonly STRETCH_NONE: number;
  75375. /** STRETCH_FILL */
  75376. static readonly STRETCH_FILL: number;
  75377. /** STRETCH_UNIFORM */
  75378. static readonly STRETCH_UNIFORM: number;
  75379. /** STRETCH_EXTEND */
  75380. static readonly STRETCH_EXTEND: number;
  75381. /** NINE_PATCH */
  75382. static readonly STRETCH_NINE_PATCH: number;
  75383. }
  75384. }
  75385. declare module BABYLON.GUI {
  75386. /**
  75387. * Class used to create 2D buttons
  75388. */
  75389. export class Button extends Rectangle {
  75390. name?: string | undefined;
  75391. /**
  75392. * Function called to generate a pointer enter animation
  75393. */
  75394. pointerEnterAnimation: () => void;
  75395. /**
  75396. * Function called to generate a pointer out animation
  75397. */
  75398. pointerOutAnimation: () => void;
  75399. /**
  75400. * Function called to generate a pointer down animation
  75401. */
  75402. pointerDownAnimation: () => void;
  75403. /**
  75404. * Function called to generate a pointer up animation
  75405. */
  75406. pointerUpAnimation: () => void;
  75407. /**
  75408. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  75409. */
  75410. delegatePickingToChildren: boolean;
  75411. private _image;
  75412. /**
  75413. * Returns the image part of the button (if any)
  75414. */
  75415. get image(): BABYLON.Nullable<Image>;
  75416. private _textBlock;
  75417. /**
  75418. * Returns the image part of the button (if any)
  75419. */
  75420. get textBlock(): BABYLON.Nullable<TextBlock>;
  75421. /**
  75422. * Creates a new Button
  75423. * @param name defines the name of the button
  75424. */
  75425. constructor(name?: string | undefined);
  75426. protected _getTypeName(): string;
  75427. /** @hidden */
  75428. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75429. /** @hidden */
  75430. _onPointerEnter(target: Control): boolean;
  75431. /** @hidden */
  75432. _onPointerOut(target: Control, force?: boolean): void;
  75433. /** @hidden */
  75434. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75435. /** @hidden */
  75436. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75437. /**
  75438. * Creates a new button made with an image and a text
  75439. * @param name defines the name of the button
  75440. * @param text defines the text of the button
  75441. * @param imageUrl defines the url of the image
  75442. * @returns a new Button
  75443. */
  75444. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  75445. /**
  75446. * Creates a new button made with an image
  75447. * @param name defines the name of the button
  75448. * @param imageUrl defines the url of the image
  75449. * @returns a new Button
  75450. */
  75451. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  75452. /**
  75453. * Creates a new button made with a text
  75454. * @param name defines the name of the button
  75455. * @param text defines the text of the button
  75456. * @returns a new Button
  75457. */
  75458. static CreateSimpleButton(name: string, text: string): Button;
  75459. /**
  75460. * Creates a new button made with an image and a centered text
  75461. * @param name defines the name of the button
  75462. * @param text defines the text of the button
  75463. * @param imageUrl defines the url of the image
  75464. * @returns a new Button
  75465. */
  75466. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  75467. }
  75468. }
  75469. declare module BABYLON.GUI {
  75470. /**
  75471. * Class used to create a 2D stack panel container
  75472. */
  75473. export class StackPanel extends Container {
  75474. name?: string | undefined;
  75475. private _isVertical;
  75476. private _manualWidth;
  75477. private _manualHeight;
  75478. private _doNotTrackManualChanges;
  75479. /**
  75480. * Gets or sets a boolean indicating that layou warnings should be ignored
  75481. */
  75482. ignoreLayoutWarnings: boolean;
  75483. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  75484. get isVertical(): boolean;
  75485. set isVertical(value: boolean);
  75486. /**
  75487. * Gets or sets panel width.
  75488. * This value should not be set when in horizontal mode as it will be computed automatically
  75489. */
  75490. set width(value: string | number);
  75491. get width(): string | number;
  75492. /**
  75493. * Gets or sets panel height.
  75494. * This value should not be set when in vertical mode as it will be computed automatically
  75495. */
  75496. set height(value: string | number);
  75497. get height(): string | number;
  75498. /**
  75499. * Creates a new StackPanel
  75500. * @param name defines control name
  75501. */
  75502. constructor(name?: string | undefined);
  75503. protected _getTypeName(): string;
  75504. /** @hidden */
  75505. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75506. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75507. protected _postMeasure(): void;
  75508. }
  75509. }
  75510. declare module BABYLON.GUI {
  75511. /**
  75512. * Class used to represent a 2D checkbox
  75513. */
  75514. export class Checkbox extends Control {
  75515. name?: string | undefined;
  75516. private _isChecked;
  75517. private _background;
  75518. private _checkSizeRatio;
  75519. private _thickness;
  75520. /** Gets or sets border thickness */
  75521. get thickness(): number;
  75522. set thickness(value: number);
  75523. /**
  75524. * BABYLON.Observable raised when isChecked property changes
  75525. */
  75526. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  75527. /** Gets or sets a value indicating the ratio between overall size and check size */
  75528. get checkSizeRatio(): number;
  75529. set checkSizeRatio(value: number);
  75530. /** Gets or sets background color */
  75531. get background(): string;
  75532. set background(value: string);
  75533. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  75534. get isChecked(): boolean;
  75535. set isChecked(value: boolean);
  75536. /**
  75537. * Creates a new CheckBox
  75538. * @param name defines the control name
  75539. */
  75540. constructor(name?: string | undefined);
  75541. protected _getTypeName(): string;
  75542. /** @hidden */
  75543. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75544. /** @hidden */
  75545. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75546. /**
  75547. * Utility function to easily create a checkbox with a header
  75548. * @param title defines the label to use for the header
  75549. * @param onValueChanged defines the callback to call when value changes
  75550. * @returns a StackPanel containing the checkbox and a textBlock
  75551. */
  75552. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  75553. }
  75554. }
  75555. declare module BABYLON.GUI {
  75556. /**
  75557. * Class used to store key control properties
  75558. */
  75559. export class KeyPropertySet {
  75560. /** Width */
  75561. width?: string;
  75562. /** Height */
  75563. height?: string;
  75564. /** Left padding */
  75565. paddingLeft?: string;
  75566. /** Right padding */
  75567. paddingRight?: string;
  75568. /** Top padding */
  75569. paddingTop?: string;
  75570. /** Bottom padding */
  75571. paddingBottom?: string;
  75572. /** Foreground color */
  75573. color?: string;
  75574. /** Background color */
  75575. background?: string;
  75576. }
  75577. /**
  75578. * Class used to create virtual keyboard
  75579. */
  75580. export class VirtualKeyboard extends StackPanel {
  75581. /** BABYLON.Observable raised when a key is pressed */
  75582. onKeyPressObservable: BABYLON.Observable<string>;
  75583. /** Gets or sets default key button width */
  75584. defaultButtonWidth: string;
  75585. /** Gets or sets default key button height */
  75586. defaultButtonHeight: string;
  75587. /** Gets or sets default key button left padding */
  75588. defaultButtonPaddingLeft: string;
  75589. /** Gets or sets default key button right padding */
  75590. defaultButtonPaddingRight: string;
  75591. /** Gets or sets default key button top padding */
  75592. defaultButtonPaddingTop: string;
  75593. /** Gets or sets default key button bottom padding */
  75594. defaultButtonPaddingBottom: string;
  75595. /** Gets or sets default key button foreground color */
  75596. defaultButtonColor: string;
  75597. /** Gets or sets default key button background color */
  75598. defaultButtonBackground: string;
  75599. /** Gets or sets shift button foreground color */
  75600. shiftButtonColor: string;
  75601. /** Gets or sets shift button thickness*/
  75602. selectedShiftThickness: number;
  75603. /** Gets shift key state */
  75604. shiftState: number;
  75605. protected _getTypeName(): string;
  75606. private _createKey;
  75607. /**
  75608. * Adds a new row of keys
  75609. * @param keys defines the list of keys to add
  75610. * @param propertySets defines the associated property sets
  75611. */
  75612. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  75613. /**
  75614. * Set the shift key to a specific state
  75615. * @param shiftState defines the new shift state
  75616. */
  75617. applyShiftState(shiftState: number): void;
  75618. private _currentlyConnectedInputText;
  75619. private _connectedInputTexts;
  75620. private _onKeyPressObserver;
  75621. /** Gets the input text control currently attached to the keyboard */
  75622. get connectedInputText(): BABYLON.Nullable<InputText>;
  75623. /**
  75624. * Connects the keyboard with an input text control
  75625. *
  75626. * @param input defines the target control
  75627. */
  75628. connect(input: InputText): void;
  75629. /**
  75630. * Disconnects the keyboard from connected InputText controls
  75631. *
  75632. * @param input optionally defines a target control, otherwise all are disconnected
  75633. */
  75634. disconnect(input?: InputText): void;
  75635. private _removeConnectedInputObservables;
  75636. /**
  75637. * Release all resources
  75638. */
  75639. dispose(): void;
  75640. /**
  75641. * Creates a new keyboard using a default layout
  75642. *
  75643. * @param name defines control name
  75644. * @returns a new VirtualKeyboard
  75645. */
  75646. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  75647. }
  75648. }
  75649. declare module BABYLON.GUI {
  75650. /**
  75651. * Class used to create input text control
  75652. */
  75653. export class InputText extends Control implements IFocusableControl {
  75654. name?: string | undefined;
  75655. private _text;
  75656. private _placeholderText;
  75657. private _background;
  75658. private _focusedBackground;
  75659. private _focusedColor;
  75660. private _placeholderColor;
  75661. private _thickness;
  75662. private _margin;
  75663. private _autoStretchWidth;
  75664. private _maxWidth;
  75665. private _isFocused;
  75666. private _blinkTimeout;
  75667. private _blinkIsEven;
  75668. private _cursorOffset;
  75669. private _scrollLeft;
  75670. private _textWidth;
  75671. private _clickedCoordinate;
  75672. private _deadKey;
  75673. private _addKey;
  75674. private _currentKey;
  75675. private _isTextHighlightOn;
  75676. private _textHighlightColor;
  75677. private _highligherOpacity;
  75678. private _highlightedText;
  75679. private _startHighlightIndex;
  75680. private _endHighlightIndex;
  75681. private _cursorIndex;
  75682. private _onFocusSelectAll;
  75683. private _isPointerDown;
  75684. private _onClipboardObserver;
  75685. private _onPointerDblTapObserver;
  75686. /** @hidden */
  75687. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  75688. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  75689. promptMessage: string;
  75690. /** Force disable prompt on mobile device */
  75691. disableMobilePrompt: boolean;
  75692. /** BABYLON.Observable raised when the text changes */
  75693. onTextChangedObservable: BABYLON.Observable<InputText>;
  75694. /** BABYLON.Observable raised just before an entered character is to be added */
  75695. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  75696. /** BABYLON.Observable raised when the control gets the focus */
  75697. onFocusObservable: BABYLON.Observable<InputText>;
  75698. /** BABYLON.Observable raised when the control loses the focus */
  75699. onBlurObservable: BABYLON.Observable<InputText>;
  75700. /**Observable raised when the text is highlighted */
  75701. onTextHighlightObservable: BABYLON.Observable<InputText>;
  75702. /**Observable raised when copy event is triggered */
  75703. onTextCopyObservable: BABYLON.Observable<InputText>;
  75704. /** BABYLON.Observable raised when cut event is triggered */
  75705. onTextCutObservable: BABYLON.Observable<InputText>;
  75706. /** BABYLON.Observable raised when paste event is triggered */
  75707. onTextPasteObservable: BABYLON.Observable<InputText>;
  75708. /** BABYLON.Observable raised when a key event was processed */
  75709. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  75710. /** Gets or sets the maximum width allowed by the control */
  75711. get maxWidth(): string | number;
  75712. /** Gets the maximum width allowed by the control in pixels */
  75713. get maxWidthInPixels(): number;
  75714. set maxWidth(value: string | number);
  75715. /** Gets or sets the text highlighter transparency; default: 0.4 */
  75716. get highligherOpacity(): number;
  75717. set highligherOpacity(value: number);
  75718. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  75719. get onFocusSelectAll(): boolean;
  75720. set onFocusSelectAll(value: boolean);
  75721. /** Gets or sets the text hightlight color */
  75722. get textHighlightColor(): string;
  75723. set textHighlightColor(value: string);
  75724. /** Gets or sets control margin */
  75725. get margin(): string;
  75726. /** Gets control margin in pixels */
  75727. get marginInPixels(): number;
  75728. set margin(value: string);
  75729. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  75730. get autoStretchWidth(): boolean;
  75731. set autoStretchWidth(value: boolean);
  75732. /** Gets or sets border thickness */
  75733. get thickness(): number;
  75734. set thickness(value: number);
  75735. /** Gets or sets the background color when focused */
  75736. get focusedBackground(): string;
  75737. set focusedBackground(value: string);
  75738. /** Gets or sets the background color when focused */
  75739. get focusedColor(): string;
  75740. set focusedColor(value: string);
  75741. /** Gets or sets the background color */
  75742. get background(): string;
  75743. set background(value: string);
  75744. /** Gets or sets the placeholder color */
  75745. get placeholderColor(): string;
  75746. set placeholderColor(value: string);
  75747. /** Gets or sets the text displayed when the control is empty */
  75748. get placeholderText(): string;
  75749. set placeholderText(value: string);
  75750. /** Gets or sets the dead key flag */
  75751. get deadKey(): boolean;
  75752. set deadKey(flag: boolean);
  75753. /** Gets or sets the highlight text */
  75754. get highlightedText(): string;
  75755. set highlightedText(text: string);
  75756. /** Gets or sets if the current key should be added */
  75757. get addKey(): boolean;
  75758. set addKey(flag: boolean);
  75759. /** Gets or sets the value of the current key being entered */
  75760. get currentKey(): string;
  75761. set currentKey(key: string);
  75762. /** Gets or sets the text displayed in the control */
  75763. get text(): string;
  75764. set text(value: string);
  75765. /** Gets or sets control width */
  75766. get width(): string | number;
  75767. set width(value: string | number);
  75768. /**
  75769. * Creates a new InputText
  75770. * @param name defines the control name
  75771. * @param text defines the text of the control
  75772. */
  75773. constructor(name?: string | undefined, text?: string);
  75774. /** @hidden */
  75775. onBlur(): void;
  75776. /** @hidden */
  75777. onFocus(): void;
  75778. protected _getTypeName(): string;
  75779. /**
  75780. * Function called to get the list of controls that should not steal the focus from this control
  75781. * @returns an array of controls
  75782. */
  75783. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75784. /** @hidden */
  75785. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  75786. /** @hidden */
  75787. private _updateValueFromCursorIndex;
  75788. /** @hidden */
  75789. private _processDblClick;
  75790. /** @hidden */
  75791. private _selectAllText;
  75792. /**
  75793. * Handles the keyboard event
  75794. * @param evt Defines the KeyboardEvent
  75795. */
  75796. processKeyboard(evt: KeyboardEvent): void;
  75797. /** @hidden */
  75798. private _onCopyText;
  75799. /** @hidden */
  75800. private _onCutText;
  75801. /** @hidden */
  75802. private _onPasteText;
  75803. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75804. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75805. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75806. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75807. protected _beforeRenderText(text: string): string;
  75808. dispose(): void;
  75809. }
  75810. }
  75811. declare module BABYLON.GUI {
  75812. /**
  75813. * Class used to create a 2D grid container
  75814. */
  75815. export class Grid extends Container {
  75816. name?: string | undefined;
  75817. private _rowDefinitions;
  75818. private _columnDefinitions;
  75819. private _cells;
  75820. private _childControls;
  75821. /**
  75822. * Gets the number of columns
  75823. */
  75824. get columnCount(): number;
  75825. /**
  75826. * Gets the number of rows
  75827. */
  75828. get rowCount(): number;
  75829. /** Gets the list of children */
  75830. get children(): Control[];
  75831. /** Gets the list of cells (e.g. the containers) */
  75832. get cells(): {
  75833. [key: string]: Container;
  75834. };
  75835. /**
  75836. * Gets the definition of a specific row
  75837. * @param index defines the index of the row
  75838. * @returns the row definition
  75839. */
  75840. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75841. /**
  75842. * Gets the definition of a specific column
  75843. * @param index defines the index of the column
  75844. * @returns the column definition
  75845. */
  75846. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75847. /**
  75848. * Adds a new row to the grid
  75849. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75850. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  75851. * @returns the current grid
  75852. */
  75853. addRowDefinition(height: number, isPixel?: boolean): Grid;
  75854. /**
  75855. * Adds a new column to the grid
  75856. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75857. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75858. * @returns the current grid
  75859. */
  75860. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  75861. /**
  75862. * Update a row definition
  75863. * @param index defines the index of the row to update
  75864. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75865. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  75866. * @returns the current grid
  75867. */
  75868. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  75869. /**
  75870. * Update a column definition
  75871. * @param index defines the index of the column to update
  75872. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75873. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75874. * @returns the current grid
  75875. */
  75876. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  75877. /**
  75878. * Gets the list of children stored in a specific cell
  75879. * @param row defines the row to check
  75880. * @param column defines the column to check
  75881. * @returns the list of controls
  75882. */
  75883. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  75884. /**
  75885. * Gets a string representing the child cell info (row x column)
  75886. * @param child defines the control to get info from
  75887. * @returns a string containing the child cell info (row x column)
  75888. */
  75889. getChildCellInfo(child: Control): string;
  75890. private _removeCell;
  75891. private _offsetCell;
  75892. /**
  75893. * Remove a column definition at specified index
  75894. * @param index defines the index of the column to remove
  75895. * @returns the current grid
  75896. */
  75897. removeColumnDefinition(index: number): Grid;
  75898. /**
  75899. * Remove a row definition at specified index
  75900. * @param index defines the index of the row to remove
  75901. * @returns the current grid
  75902. */
  75903. removeRowDefinition(index: number): Grid;
  75904. /**
  75905. * Adds a new control to the current grid
  75906. * @param control defines the control to add
  75907. * @param row defines the row where to add the control (0 by default)
  75908. * @param column defines the column where to add the control (0 by default)
  75909. * @returns the current grid
  75910. */
  75911. addControl(control: Control, row?: number, column?: number): Grid;
  75912. /**
  75913. * Removes a control from the current container
  75914. * @param control defines the control to remove
  75915. * @returns the current container
  75916. */
  75917. removeControl(control: Control): Container;
  75918. /**
  75919. * Creates a new Grid
  75920. * @param name defines control name
  75921. */
  75922. constructor(name?: string | undefined);
  75923. protected _getTypeName(): string;
  75924. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  75925. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75926. _flagDescendantsAsMatrixDirty(): void;
  75927. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75928. /** Releases associated resources */
  75929. dispose(): void;
  75930. }
  75931. }
  75932. declare module BABYLON.GUI {
  75933. /** Class used to create color pickers */
  75934. export class ColorPicker extends Control {
  75935. name?: string | undefined;
  75936. private static _Epsilon;
  75937. private _colorWheelCanvas;
  75938. private _value;
  75939. private _tmpColor;
  75940. private _pointerStartedOnSquare;
  75941. private _pointerStartedOnWheel;
  75942. private _squareLeft;
  75943. private _squareTop;
  75944. private _squareSize;
  75945. private _h;
  75946. private _s;
  75947. private _v;
  75948. private _lastPointerDownID;
  75949. /**
  75950. * BABYLON.Observable raised when the value changes
  75951. */
  75952. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  75953. /** Gets or sets the color of the color picker */
  75954. get value(): BABYLON.Color3;
  75955. set value(value: BABYLON.Color3);
  75956. /**
  75957. * Gets or sets control width
  75958. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75959. */
  75960. get width(): string | number;
  75961. set width(value: string | number);
  75962. /**
  75963. * Gets or sets control height
  75964. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75965. */
  75966. get height(): string | number;
  75967. /** Gets or sets control height */
  75968. set height(value: string | number);
  75969. /** Gets or sets control size */
  75970. get size(): string | number;
  75971. set size(value: string | number);
  75972. /**
  75973. * Creates a new ColorPicker
  75974. * @param name defines the control name
  75975. */
  75976. constructor(name?: string | undefined);
  75977. protected _getTypeName(): string;
  75978. /** @hidden */
  75979. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75980. private _updateSquareProps;
  75981. private _drawGradientSquare;
  75982. private _drawCircle;
  75983. private _createColorWheelCanvas;
  75984. /** @hidden */
  75985. _draw(context: CanvasRenderingContext2D): void;
  75986. private _pointerIsDown;
  75987. private _updateValueFromPointer;
  75988. private _isPointOnSquare;
  75989. private _isPointOnWheel;
  75990. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75991. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75992. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75993. /**
  75994. * This function expands the color picker by creating a color picker dialog with manual
  75995. * color value input and the ability to save colors into an array to be used later in
  75996. * subsequent launches of the dialogue.
  75997. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  75998. * @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.
  75999. * @returns picked color as a hex string and the saved colors array as hex strings.
  76000. */
  76001. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  76002. pickerWidth?: string;
  76003. pickerHeight?: string;
  76004. headerHeight?: string;
  76005. lastColor?: string;
  76006. swatchLimit?: number;
  76007. numSwatchesPerLine?: number;
  76008. savedColors?: Array<string>;
  76009. }): Promise<{
  76010. savedColors?: string[];
  76011. pickedColor: string;
  76012. }>;
  76013. }
  76014. }
  76015. declare module BABYLON.GUI {
  76016. /** Class used to create 2D ellipse containers */
  76017. export class Ellipse extends Container {
  76018. name?: string | undefined;
  76019. private _thickness;
  76020. /** Gets or sets border thickness */
  76021. get thickness(): number;
  76022. set thickness(value: number);
  76023. /**
  76024. * Creates a new Ellipse
  76025. * @param name defines the control name
  76026. */
  76027. constructor(name?: string | undefined);
  76028. protected _getTypeName(): string;
  76029. protected _localDraw(context: CanvasRenderingContext2D): void;
  76030. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76031. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76032. }
  76033. }
  76034. declare module BABYLON.GUI {
  76035. /**
  76036. * Class used to create a password control
  76037. */
  76038. export class InputPassword extends InputText {
  76039. protected _beforeRenderText(text: string): string;
  76040. }
  76041. }
  76042. declare module BABYLON.GUI {
  76043. /** Class used to render 2D lines */
  76044. export class Line extends Control {
  76045. name?: string | undefined;
  76046. private _lineWidth;
  76047. private _x1;
  76048. private _y1;
  76049. private _x2;
  76050. private _y2;
  76051. private _dash;
  76052. private _connectedControl;
  76053. private _connectedControlDirtyObserver;
  76054. /** Gets or sets the dash pattern */
  76055. get dash(): Array<number>;
  76056. set dash(value: Array<number>);
  76057. /** Gets or sets the control connected with the line end */
  76058. get connectedControl(): Control;
  76059. set connectedControl(value: Control);
  76060. /** Gets or sets start coordinates on X axis */
  76061. get x1(): string | number;
  76062. set x1(value: string | number);
  76063. /** Gets or sets start coordinates on Y axis */
  76064. get y1(): string | number;
  76065. set y1(value: string | number);
  76066. /** Gets or sets end coordinates on X axis */
  76067. get x2(): string | number;
  76068. set x2(value: string | number);
  76069. /** Gets or sets end coordinates on Y axis */
  76070. get y2(): string | number;
  76071. set y2(value: string | number);
  76072. /** Gets or sets line width */
  76073. get lineWidth(): number;
  76074. set lineWidth(value: number);
  76075. /** Gets or sets horizontal alignment */
  76076. set horizontalAlignment(value: number);
  76077. /** Gets or sets vertical alignment */
  76078. set verticalAlignment(value: number);
  76079. private get _effectiveX2();
  76080. private get _effectiveY2();
  76081. /**
  76082. * Creates a new Line
  76083. * @param name defines the control name
  76084. */
  76085. constructor(name?: string | undefined);
  76086. protected _getTypeName(): string;
  76087. _draw(context: CanvasRenderingContext2D): void;
  76088. _measure(): void;
  76089. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76090. /**
  76091. * Move one end of the line given 3D cartesian coordinates.
  76092. * @param position Targeted world position
  76093. * @param scene BABYLON.Scene
  76094. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76095. */
  76096. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  76097. /**
  76098. * Move one end of the line to a position in screen absolute space.
  76099. * @param projectedPosition Position in screen absolute space (X, Y)
  76100. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76101. */
  76102. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  76103. }
  76104. }
  76105. declare module BABYLON.GUI {
  76106. /**
  76107. * Class used to store a point for a MultiLine object.
  76108. * The point can be pure 2D coordinates, a mesh or a control
  76109. */
  76110. export class MultiLinePoint {
  76111. private _multiLine;
  76112. private _x;
  76113. private _y;
  76114. private _control;
  76115. private _mesh;
  76116. private _controlObserver;
  76117. private _meshObserver;
  76118. /** @hidden */
  76119. _point: BABYLON.Vector2;
  76120. /**
  76121. * Creates a new MultiLinePoint
  76122. * @param multiLine defines the source MultiLine object
  76123. */
  76124. constructor(multiLine: MultiLine);
  76125. /** Gets or sets x coordinate */
  76126. get x(): string | number;
  76127. set x(value: string | number);
  76128. /** Gets or sets y coordinate */
  76129. get y(): string | number;
  76130. set y(value: string | number);
  76131. /** Gets or sets the control associated with this point */
  76132. get control(): BABYLON.Nullable<Control>;
  76133. set control(value: BABYLON.Nullable<Control>);
  76134. /** Gets or sets the mesh associated with this point */
  76135. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76136. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  76137. /** Resets links */
  76138. resetLinks(): void;
  76139. /**
  76140. * Gets a translation vector
  76141. * @returns the translation vector
  76142. */
  76143. translate(): BABYLON.Vector2;
  76144. private _translatePoint;
  76145. /** Release associated resources */
  76146. dispose(): void;
  76147. }
  76148. }
  76149. declare module BABYLON.GUI {
  76150. /**
  76151. * Class used to create multi line control
  76152. */
  76153. export class MultiLine extends Control {
  76154. name?: string | undefined;
  76155. private _lineWidth;
  76156. private _dash;
  76157. private _points;
  76158. private _minX;
  76159. private _minY;
  76160. private _maxX;
  76161. private _maxY;
  76162. /**
  76163. * Creates a new MultiLine
  76164. * @param name defines the control name
  76165. */
  76166. constructor(name?: string | undefined);
  76167. /** Gets or sets dash pattern */
  76168. get dash(): Array<number>;
  76169. set dash(value: Array<number>);
  76170. /**
  76171. * Gets point stored at specified index
  76172. * @param index defines the index to look for
  76173. * @returns the requested point if found
  76174. */
  76175. getAt(index: number): MultiLinePoint;
  76176. /** Function called when a point is updated */
  76177. onPointUpdate: () => void;
  76178. /**
  76179. * Adds new points to the point collection
  76180. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  76181. * @returns the list of created MultiLinePoint
  76182. */
  76183. add(...items: (AbstractMesh | Control | {
  76184. x: string | number;
  76185. y: string | number;
  76186. })[]): MultiLinePoint[];
  76187. /**
  76188. * Adds a new point to the point collection
  76189. * @param item defines the item (mesh, control or 2d coordiantes) to add
  76190. * @returns the created MultiLinePoint
  76191. */
  76192. push(item?: (AbstractMesh | Control | {
  76193. x: string | number;
  76194. y: string | number;
  76195. })): MultiLinePoint;
  76196. /**
  76197. * Remove a specific value or point from the active point collection
  76198. * @param value defines the value or point to remove
  76199. */
  76200. remove(value: number | MultiLinePoint): void;
  76201. /**
  76202. * Resets this object to initial state (no point)
  76203. */
  76204. reset(): void;
  76205. /**
  76206. * Resets all links
  76207. */
  76208. resetLinks(): void;
  76209. /** Gets or sets line width */
  76210. get lineWidth(): number;
  76211. set lineWidth(value: number);
  76212. set horizontalAlignment(value: number);
  76213. set verticalAlignment(value: number);
  76214. protected _getTypeName(): string;
  76215. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76216. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76217. _measure(): void;
  76218. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76219. dispose(): void;
  76220. }
  76221. }
  76222. declare module BABYLON.GUI {
  76223. /**
  76224. * Class used to create radio button controls
  76225. */
  76226. export class RadioButton extends Control {
  76227. name?: string | undefined;
  76228. private _isChecked;
  76229. private _background;
  76230. private _checkSizeRatio;
  76231. private _thickness;
  76232. /** Gets or sets border thickness */
  76233. get thickness(): number;
  76234. set thickness(value: number);
  76235. /** Gets or sets group name */
  76236. group: string;
  76237. /** BABYLON.Observable raised when isChecked is changed */
  76238. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76239. /** Gets or sets a value indicating the ratio between overall size and check size */
  76240. get checkSizeRatio(): number;
  76241. set checkSizeRatio(value: number);
  76242. /** Gets or sets background color */
  76243. get background(): string;
  76244. set background(value: string);
  76245. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76246. get isChecked(): boolean;
  76247. set isChecked(value: boolean);
  76248. /**
  76249. * Creates a new RadioButton
  76250. * @param name defines the control name
  76251. */
  76252. constructor(name?: string | undefined);
  76253. protected _getTypeName(): string;
  76254. _draw(context: CanvasRenderingContext2D): void;
  76255. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76256. /**
  76257. * Utility function to easily create a radio button with a header
  76258. * @param title defines the label to use for the header
  76259. * @param group defines the group to use for the radio button
  76260. * @param isChecked defines the initial state of the radio button
  76261. * @param onValueChanged defines the callback to call when value changes
  76262. * @returns a StackPanel containing the radio button and a textBlock
  76263. */
  76264. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  76265. }
  76266. }
  76267. declare module BABYLON.GUI {
  76268. /**
  76269. * Class used to create slider controls
  76270. */
  76271. export class BaseSlider extends Control {
  76272. name?: string | undefined;
  76273. protected _thumbWidth: ValueAndUnit;
  76274. private _minimum;
  76275. private _maximum;
  76276. private _value;
  76277. private _isVertical;
  76278. protected _barOffset: ValueAndUnit;
  76279. private _isThumbClamped;
  76280. protected _displayThumb: boolean;
  76281. private _step;
  76282. private _lastPointerDownID;
  76283. protected _effectiveBarOffset: number;
  76284. protected _renderLeft: number;
  76285. protected _renderTop: number;
  76286. protected _renderWidth: number;
  76287. protected _renderHeight: number;
  76288. protected _backgroundBoxLength: number;
  76289. protected _backgroundBoxThickness: number;
  76290. protected _effectiveThumbThickness: number;
  76291. /** BABYLON.Observable raised when the sldier value changes */
  76292. onValueChangedObservable: BABYLON.Observable<number>;
  76293. /** Gets or sets a boolean indicating if the thumb must be rendered */
  76294. get displayThumb(): boolean;
  76295. set displayThumb(value: boolean);
  76296. /** Gets or sets a step to apply to values (0 by default) */
  76297. get step(): number;
  76298. set step(value: number);
  76299. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  76300. get barOffset(): string | number;
  76301. /** Gets main bar offset in pixels*/
  76302. get barOffsetInPixels(): number;
  76303. set barOffset(value: string | number);
  76304. /** Gets or sets thumb width */
  76305. get thumbWidth(): string | number;
  76306. /** Gets thumb width in pixels */
  76307. get thumbWidthInPixels(): number;
  76308. set thumbWidth(value: string | number);
  76309. /** Gets or sets minimum value */
  76310. get minimum(): number;
  76311. set minimum(value: number);
  76312. /** Gets or sets maximum value */
  76313. get maximum(): number;
  76314. set maximum(value: number);
  76315. /** Gets or sets current value */
  76316. get value(): number;
  76317. set value(value: number);
  76318. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  76319. get isVertical(): boolean;
  76320. set isVertical(value: boolean);
  76321. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  76322. get isThumbClamped(): boolean;
  76323. set isThumbClamped(value: boolean);
  76324. /**
  76325. * Creates a new BaseSlider
  76326. * @param name defines the control name
  76327. */
  76328. constructor(name?: string | undefined);
  76329. protected _getTypeName(): string;
  76330. protected _getThumbPosition(): number;
  76331. protected _getThumbThickness(type: string): number;
  76332. protected _prepareRenderingData(type: string): void;
  76333. private _pointerIsDown;
  76334. /** @hidden */
  76335. protected _updateValueFromPointer(x: number, y: number): void;
  76336. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76337. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76338. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76339. }
  76340. }
  76341. declare module BABYLON.GUI {
  76342. /**
  76343. * Class used to create slider controls
  76344. */
  76345. export class Slider extends BaseSlider {
  76346. name?: string | undefined;
  76347. private _background;
  76348. private _borderColor;
  76349. private _isThumbCircle;
  76350. protected _displayValueBar: boolean;
  76351. /** Gets or sets a boolean indicating if the value bar must be rendered */
  76352. get displayValueBar(): boolean;
  76353. set displayValueBar(value: boolean);
  76354. /** Gets or sets border color */
  76355. get borderColor(): string;
  76356. set borderColor(value: string);
  76357. /** Gets or sets background color */
  76358. get background(): string;
  76359. set background(value: string);
  76360. /** Gets or sets a boolean indicating if the thumb should be round or square */
  76361. get isThumbCircle(): boolean;
  76362. set isThumbCircle(value: boolean);
  76363. /**
  76364. * Creates a new Slider
  76365. * @param name defines the control name
  76366. */
  76367. constructor(name?: string | undefined);
  76368. protected _getTypeName(): string;
  76369. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76370. }
  76371. }
  76372. declare module BABYLON.GUI {
  76373. /** Class used to create a RadioGroup
  76374. * which contains groups of radio buttons
  76375. */
  76376. export class SelectorGroup {
  76377. /** name of SelectorGroup */
  76378. name: string;
  76379. private _groupPanel;
  76380. private _selectors;
  76381. private _groupHeader;
  76382. /**
  76383. * Creates a new SelectorGroup
  76384. * @param name of group, used as a group heading
  76385. */
  76386. constructor(
  76387. /** name of SelectorGroup */
  76388. name: string);
  76389. /** Gets the groupPanel of the SelectorGroup */
  76390. get groupPanel(): StackPanel;
  76391. /** Gets the selectors array */
  76392. get selectors(): StackPanel[];
  76393. /** Gets and sets the group header */
  76394. get header(): string;
  76395. set header(label: string);
  76396. /** @hidden */
  76397. private _addGroupHeader;
  76398. /** @hidden*/
  76399. _getSelector(selectorNb: number): StackPanel | undefined;
  76400. /** Removes the selector at the given position
  76401. * @param selectorNb the position of the selector within the group
  76402. */
  76403. removeSelector(selectorNb: number): void;
  76404. }
  76405. /** Class used to create a CheckboxGroup
  76406. * which contains groups of checkbox buttons
  76407. */
  76408. export class CheckboxGroup extends SelectorGroup {
  76409. /** Adds a checkbox as a control
  76410. * @param text is the label for the selector
  76411. * @param func is the function called when the Selector is checked
  76412. * @param checked is true when Selector is checked
  76413. */
  76414. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  76415. /** @hidden */
  76416. _setSelectorLabel(selectorNb: number, label: string): void;
  76417. /** @hidden */
  76418. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76419. /** @hidden */
  76420. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76421. /** @hidden */
  76422. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76423. }
  76424. /** Class used to create a RadioGroup
  76425. * which contains groups of radio buttons
  76426. */
  76427. export class RadioGroup extends SelectorGroup {
  76428. private _selectNb;
  76429. /** Adds a radio button as a control
  76430. * @param label is the label for the selector
  76431. * @param func is the function called when the Selector is checked
  76432. * @param checked is true when Selector is checked
  76433. */
  76434. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  76435. /** @hidden */
  76436. _setSelectorLabel(selectorNb: number, label: string): void;
  76437. /** @hidden */
  76438. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76439. /** @hidden */
  76440. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76441. /** @hidden */
  76442. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76443. }
  76444. /** Class used to create a SliderGroup
  76445. * which contains groups of slider buttons
  76446. */
  76447. export class SliderGroup extends SelectorGroup {
  76448. /**
  76449. * Adds a slider to the SelectorGroup
  76450. * @param label is the label for the SliderBar
  76451. * @param func is the function called when the Slider moves
  76452. * @param unit is a string describing the units used, eg degrees or metres
  76453. * @param min is the minimum value for the Slider
  76454. * @param max is the maximum value for the Slider
  76455. * @param value is the start value for the Slider between min and max
  76456. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  76457. */
  76458. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  76459. /** @hidden */
  76460. _setSelectorLabel(selectorNb: number, label: string): void;
  76461. /** @hidden */
  76462. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76463. /** @hidden */
  76464. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76465. /** @hidden */
  76466. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76467. }
  76468. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  76469. * @see http://doc.babylonjs.com/how_to/selector
  76470. */
  76471. export class SelectionPanel extends Rectangle {
  76472. /** name of SelectionPanel */
  76473. name: string;
  76474. /** an array of SelectionGroups */
  76475. groups: SelectorGroup[];
  76476. private _panel;
  76477. private _buttonColor;
  76478. private _buttonBackground;
  76479. private _headerColor;
  76480. private _barColor;
  76481. private _barHeight;
  76482. private _spacerHeight;
  76483. private _labelColor;
  76484. private _groups;
  76485. private _bars;
  76486. /**
  76487. * Creates a new SelectionPanel
  76488. * @param name of SelectionPanel
  76489. * @param groups is an array of SelectionGroups
  76490. */
  76491. constructor(
  76492. /** name of SelectionPanel */
  76493. name: string,
  76494. /** an array of SelectionGroups */
  76495. groups?: SelectorGroup[]);
  76496. protected _getTypeName(): string;
  76497. /** Gets or sets the headerColor */
  76498. get headerColor(): string;
  76499. set headerColor(color: string);
  76500. private _setHeaderColor;
  76501. /** Gets or sets the button color */
  76502. get buttonColor(): string;
  76503. set buttonColor(color: string);
  76504. private _setbuttonColor;
  76505. /** Gets or sets the label color */
  76506. get labelColor(): string;
  76507. set labelColor(color: string);
  76508. private _setLabelColor;
  76509. /** Gets or sets the button background */
  76510. get buttonBackground(): string;
  76511. set buttonBackground(color: string);
  76512. private _setButtonBackground;
  76513. /** Gets or sets the color of separator bar */
  76514. get barColor(): string;
  76515. set barColor(color: string);
  76516. private _setBarColor;
  76517. /** Gets or sets the height of separator bar */
  76518. get barHeight(): string;
  76519. set barHeight(value: string);
  76520. private _setBarHeight;
  76521. /** Gets or sets the height of spacers*/
  76522. get spacerHeight(): string;
  76523. set spacerHeight(value: string);
  76524. private _setSpacerHeight;
  76525. /** Adds a bar between groups */
  76526. private _addSpacer;
  76527. /** Add a group to the selection panel
  76528. * @param group is the selector group to add
  76529. */
  76530. addGroup(group: SelectorGroup): void;
  76531. /** Remove the group from the given position
  76532. * @param groupNb is the position of the group in the list
  76533. */
  76534. removeGroup(groupNb: number): void;
  76535. /** Change a group header label
  76536. * @param label is the new group header label
  76537. * @param groupNb is the number of the group to relabel
  76538. * */
  76539. setHeaderName(label: string, groupNb: number): void;
  76540. /** Change selector label to the one given
  76541. * @param label is the new selector label
  76542. * @param groupNb is the number of the groupcontaining the selector
  76543. * @param selectorNb is the number of the selector within a group to relabel
  76544. * */
  76545. relabel(label: string, groupNb: number, selectorNb: number): void;
  76546. /** For a given group position remove the selector at the given position
  76547. * @param groupNb is the number of the group to remove the selector from
  76548. * @param selectorNb is the number of the selector within the group
  76549. */
  76550. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  76551. /** For a given group position of correct type add a checkbox button
  76552. * @param groupNb is the number of the group to remove the selector from
  76553. * @param label is the label for the selector
  76554. * @param func is the function called when the Selector is checked
  76555. * @param checked is true when Selector is checked
  76556. */
  76557. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76558. /** For a given group position of correct type add a radio button
  76559. * @param groupNb is the number of the group to remove the selector from
  76560. * @param label is the label for the selector
  76561. * @param func is the function called when the Selector is checked
  76562. * @param checked is true when Selector is checked
  76563. */
  76564. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76565. /**
  76566. * For a given slider group add a slider
  76567. * @param groupNb is the number of the group to add the slider to
  76568. * @param label is the label for the Slider
  76569. * @param func is the function called when the Slider moves
  76570. * @param unit is a string describing the units used, eg degrees or metres
  76571. * @param min is the minimum value for the Slider
  76572. * @param max is the maximum value for the Slider
  76573. * @param value is the start value for the Slider between min and max
  76574. * @param onVal is the function used to format the value displayed, eg radians to degrees
  76575. */
  76576. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  76577. }
  76578. }
  76579. declare module BABYLON.GUI {
  76580. /**
  76581. * Class used to hold a the container for ScrollViewer
  76582. * @hidden
  76583. */
  76584. export class _ScrollViewerWindow extends Container {
  76585. parentClientWidth: number;
  76586. parentClientHeight: number;
  76587. private _freezeControls;
  76588. private _parentMeasure;
  76589. private _oldLeft;
  76590. private _oldTop;
  76591. get freezeControls(): boolean;
  76592. set freezeControls(value: boolean);
  76593. private _bucketWidth;
  76594. private _bucketHeight;
  76595. private _buckets;
  76596. private _bucketLen;
  76597. get bucketWidth(): number;
  76598. get bucketHeight(): number;
  76599. setBucketSizes(width: number, height: number): void;
  76600. private _useBuckets;
  76601. private _makeBuckets;
  76602. private _dispatchInBuckets;
  76603. private _updateMeasures;
  76604. private _updateChildrenMeasures;
  76605. private _restoreMeasures;
  76606. /**
  76607. * Creates a new ScrollViewerWindow
  76608. * @param name of ScrollViewerWindow
  76609. */
  76610. constructor(name?: string);
  76611. protected _getTypeName(): string;
  76612. /** @hidden */
  76613. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76614. /** @hidden */
  76615. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76616. private _scrollChildren;
  76617. private _scrollChildrenWithBuckets;
  76618. /** @hidden */
  76619. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76620. protected _postMeasure(): void;
  76621. }
  76622. }
  76623. declare module BABYLON.GUI {
  76624. /**
  76625. * Class used to create slider controls
  76626. */
  76627. export class ScrollBar extends BaseSlider {
  76628. name?: string | undefined;
  76629. private _background;
  76630. private _borderColor;
  76631. private _tempMeasure;
  76632. /** Gets or sets border color */
  76633. get borderColor(): string;
  76634. set borderColor(value: string);
  76635. /** Gets or sets background color */
  76636. get background(): string;
  76637. set background(value: string);
  76638. /**
  76639. * Creates a new Slider
  76640. * @param name defines the control name
  76641. */
  76642. constructor(name?: string | undefined);
  76643. protected _getTypeName(): string;
  76644. protected _getThumbThickness(): number;
  76645. _draw(context: CanvasRenderingContext2D): void;
  76646. private _first;
  76647. private _originX;
  76648. private _originY;
  76649. /** @hidden */
  76650. protected _updateValueFromPointer(x: number, y: number): void;
  76651. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76652. }
  76653. }
  76654. declare module BABYLON.GUI {
  76655. /**
  76656. * Class used to create slider controls
  76657. */
  76658. export class ImageScrollBar extends BaseSlider {
  76659. name?: string | undefined;
  76660. private _backgroundBaseImage;
  76661. private _backgroundImage;
  76662. private _thumbImage;
  76663. private _thumbBaseImage;
  76664. private _thumbLength;
  76665. private _thumbHeight;
  76666. private _barImageHeight;
  76667. private _tempMeasure;
  76668. /** Number of 90° rotation to apply on the images when in vertical mode */
  76669. num90RotationInVerticalMode: number;
  76670. /**
  76671. * Gets or sets the image used to render the background for horizontal bar
  76672. */
  76673. get backgroundImage(): Image;
  76674. set backgroundImage(value: Image);
  76675. /**
  76676. * Gets or sets the image used to render the thumb
  76677. */
  76678. get thumbImage(): Image;
  76679. set thumbImage(value: Image);
  76680. /**
  76681. * Gets or sets the length of the thumb
  76682. */
  76683. get thumbLength(): number;
  76684. set thumbLength(value: number);
  76685. /**
  76686. * Gets or sets the height of the thumb
  76687. */
  76688. get thumbHeight(): number;
  76689. set thumbHeight(value: number);
  76690. /**
  76691. * Gets or sets the height of the bar image
  76692. */
  76693. get barImageHeight(): number;
  76694. set barImageHeight(value: number);
  76695. /**
  76696. * Creates a new ImageScrollBar
  76697. * @param name defines the control name
  76698. */
  76699. constructor(name?: string | undefined);
  76700. protected _getTypeName(): string;
  76701. protected _getThumbThickness(): number;
  76702. _draw(context: CanvasRenderingContext2D): void;
  76703. private _first;
  76704. private _originX;
  76705. private _originY;
  76706. /** @hidden */
  76707. protected _updateValueFromPointer(x: number, y: number): void;
  76708. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76709. }
  76710. }
  76711. declare module BABYLON.GUI {
  76712. /**
  76713. * Class used to hold a viewer window and sliders in a grid
  76714. */
  76715. export class ScrollViewer extends Rectangle {
  76716. private _grid;
  76717. private _horizontalBarSpace;
  76718. private _verticalBarSpace;
  76719. private _dragSpace;
  76720. private _horizontalBar;
  76721. private _verticalBar;
  76722. private _barColor;
  76723. private _barBackground;
  76724. private _barImage;
  76725. private _horizontalBarImage;
  76726. private _verticalBarImage;
  76727. private _barBackgroundImage;
  76728. private _horizontalBarBackgroundImage;
  76729. private _verticalBarBackgroundImage;
  76730. private _barSize;
  76731. private _window;
  76732. private _pointerIsOver;
  76733. private _wheelPrecision;
  76734. private _onWheelObserver;
  76735. private _clientWidth;
  76736. private _clientHeight;
  76737. private _useImageBar;
  76738. private _thumbLength;
  76739. private _thumbHeight;
  76740. private _barImageHeight;
  76741. private _horizontalBarImageHeight;
  76742. private _verticalBarImageHeight;
  76743. private _oldWindowContentsWidth;
  76744. private _oldWindowContentsHeight;
  76745. /**
  76746. * Gets the horizontal scrollbar
  76747. */
  76748. get horizontalBar(): ScrollBar | ImageScrollBar;
  76749. /**
  76750. * Gets the vertical scrollbar
  76751. */
  76752. get verticalBar(): ScrollBar | ImageScrollBar;
  76753. /**
  76754. * Adds a new control to the current container
  76755. * @param control defines the control to add
  76756. * @returns the current container
  76757. */
  76758. addControl(control: BABYLON.Nullable<Control>): Container;
  76759. /**
  76760. * Removes a control from the current container
  76761. * @param control defines the control to remove
  76762. * @returns the current container
  76763. */
  76764. removeControl(control: Control): Container;
  76765. /** Gets the list of children */
  76766. get children(): Control[];
  76767. _flagDescendantsAsMatrixDirty(): void;
  76768. /**
  76769. * Freezes or unfreezes the controls in the window.
  76770. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  76771. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  76772. */
  76773. get freezeControls(): boolean;
  76774. set freezeControls(value: boolean);
  76775. /** Gets the bucket width */
  76776. get bucketWidth(): number;
  76777. /** Gets the bucket height */
  76778. get bucketHeight(): number;
  76779. /**
  76780. * Sets the bucket sizes.
  76781. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  76782. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  76783. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  76784. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  76785. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  76786. * used), that's why it is not enabled by default.
  76787. * @param width width of the bucket
  76788. * @param height height of the bucket
  76789. */
  76790. setBucketSizes(width: number, height: number): void;
  76791. private _forceHorizontalBar;
  76792. private _forceVerticalBar;
  76793. /**
  76794. * Forces the horizontal scroll bar to be displayed
  76795. */
  76796. get forceHorizontalBar(): boolean;
  76797. set forceHorizontalBar(value: boolean);
  76798. /**
  76799. * Forces the vertical scroll bar to be displayed
  76800. */
  76801. get forceVerticalBar(): boolean;
  76802. set forceVerticalBar(value: boolean);
  76803. /**
  76804. * Creates a new ScrollViewer
  76805. * @param name of ScrollViewer
  76806. */
  76807. constructor(name?: string, isImageBased?: boolean);
  76808. /** Reset the scroll viewer window to initial size */
  76809. resetWindow(): void;
  76810. protected _getTypeName(): string;
  76811. private _buildClientSizes;
  76812. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76813. protected _postMeasure(): void;
  76814. /**
  76815. * Gets or sets the mouse wheel precision
  76816. * from 0 to 1 with a default value of 0.05
  76817. * */
  76818. get wheelPrecision(): number;
  76819. set wheelPrecision(value: number);
  76820. /** Gets or sets the scroll bar container background color */
  76821. get scrollBackground(): string;
  76822. set scrollBackground(color: string);
  76823. /** Gets or sets the bar color */
  76824. get barColor(): string;
  76825. set barColor(color: string);
  76826. /** Gets or sets the bar image */
  76827. get thumbImage(): Image;
  76828. set thumbImage(value: Image);
  76829. /** Gets or sets the horizontal bar image */
  76830. get horizontalThumbImage(): Image;
  76831. set horizontalThumbImage(value: Image);
  76832. /** Gets or sets the vertical bar image */
  76833. get verticalThumbImage(): Image;
  76834. set verticalThumbImage(value: Image);
  76835. /** Gets or sets the size of the bar */
  76836. get barSize(): number;
  76837. set barSize(value: number);
  76838. /** Gets or sets the length of the thumb */
  76839. get thumbLength(): number;
  76840. set thumbLength(value: number);
  76841. /** Gets or sets the height of the thumb */
  76842. get thumbHeight(): number;
  76843. set thumbHeight(value: number);
  76844. /** Gets or sets the height of the bar image */
  76845. get barImageHeight(): number;
  76846. set barImageHeight(value: number);
  76847. /** Gets or sets the height of the horizontal bar image */
  76848. get horizontalBarImageHeight(): number;
  76849. set horizontalBarImageHeight(value: number);
  76850. /** Gets or sets the height of the vertical bar image */
  76851. get verticalBarImageHeight(): number;
  76852. set verticalBarImageHeight(value: number);
  76853. /** Gets or sets the bar background */
  76854. get barBackground(): string;
  76855. set barBackground(color: string);
  76856. /** Gets or sets the bar background image */
  76857. get barImage(): Image;
  76858. set barImage(value: Image);
  76859. /** Gets or sets the horizontal bar background image */
  76860. get horizontalBarImage(): Image;
  76861. set horizontalBarImage(value: Image);
  76862. /** Gets or sets the vertical bar background image */
  76863. get verticalBarImage(): Image;
  76864. set verticalBarImage(value: Image);
  76865. private _setWindowPosition;
  76866. /** @hidden */
  76867. private _updateScroller;
  76868. _link(host: AdvancedDynamicTexture): void;
  76869. /** @hidden */
  76870. private _addBar;
  76871. /** @hidden */
  76872. private _attachWheel;
  76873. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76874. /** Releases associated resources */
  76875. dispose(): void;
  76876. }
  76877. }
  76878. declare module BABYLON.GUI {
  76879. /** Class used to render a grid */
  76880. export class DisplayGrid extends Control {
  76881. name?: string | undefined;
  76882. private _cellWidth;
  76883. private _cellHeight;
  76884. private _minorLineTickness;
  76885. private _minorLineColor;
  76886. private _majorLineTickness;
  76887. private _majorLineColor;
  76888. private _majorLineFrequency;
  76889. private _background;
  76890. private _displayMajorLines;
  76891. private _displayMinorLines;
  76892. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  76893. get displayMinorLines(): boolean;
  76894. set displayMinorLines(value: boolean);
  76895. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  76896. get displayMajorLines(): boolean;
  76897. set displayMajorLines(value: boolean);
  76898. /** Gets or sets background color (Black by default) */
  76899. get background(): string;
  76900. set background(value: string);
  76901. /** Gets or sets the width of each cell (20 by default) */
  76902. get cellWidth(): number;
  76903. set cellWidth(value: number);
  76904. /** Gets or sets the height of each cell (20 by default) */
  76905. get cellHeight(): number;
  76906. set cellHeight(value: number);
  76907. /** Gets or sets the tickness of minor lines (1 by default) */
  76908. get minorLineTickness(): number;
  76909. set minorLineTickness(value: number);
  76910. /** Gets or sets the color of minor lines (DarkGray by default) */
  76911. get minorLineColor(): string;
  76912. set minorLineColor(value: string);
  76913. /** Gets or sets the tickness of major lines (2 by default) */
  76914. get majorLineTickness(): number;
  76915. set majorLineTickness(value: number);
  76916. /** Gets or sets the color of major lines (White by default) */
  76917. get majorLineColor(): string;
  76918. set majorLineColor(value: string);
  76919. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  76920. get majorLineFrequency(): number;
  76921. set majorLineFrequency(value: number);
  76922. /**
  76923. * Creates a new GridDisplayRectangle
  76924. * @param name defines the control name
  76925. */
  76926. constructor(name?: string | undefined);
  76927. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76928. protected _getTypeName(): string;
  76929. }
  76930. }
  76931. declare module BABYLON.GUI {
  76932. /**
  76933. * Class used to create slider controls based on images
  76934. */
  76935. export class ImageBasedSlider extends BaseSlider {
  76936. name?: string | undefined;
  76937. private _backgroundImage;
  76938. private _thumbImage;
  76939. private _valueBarImage;
  76940. private _tempMeasure;
  76941. get displayThumb(): boolean;
  76942. set displayThumb(value: boolean);
  76943. /**
  76944. * Gets or sets the image used to render the background
  76945. */
  76946. get backgroundImage(): Image;
  76947. set backgroundImage(value: Image);
  76948. /**
  76949. * Gets or sets the image used to render the value bar
  76950. */
  76951. get valueBarImage(): Image;
  76952. set valueBarImage(value: Image);
  76953. /**
  76954. * Gets or sets the image used to render the thumb
  76955. */
  76956. get thumbImage(): Image;
  76957. set thumbImage(value: Image);
  76958. /**
  76959. * Creates a new ImageBasedSlider
  76960. * @param name defines the control name
  76961. */
  76962. constructor(name?: string | undefined);
  76963. protected _getTypeName(): string;
  76964. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76965. }
  76966. }
  76967. declare module BABYLON.GUI {
  76968. /**
  76969. * Forcing an export so that this code will execute
  76970. * @hidden
  76971. */
  76972. const name = "Statics";
  76973. }
  76974. declare module BABYLON.GUI {
  76975. /**
  76976. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  76977. */
  76978. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  76979. /**
  76980. * Define the instrumented AdvancedDynamicTexture.
  76981. */
  76982. texture: AdvancedDynamicTexture;
  76983. private _captureRenderTime;
  76984. private _renderTime;
  76985. private _captureLayoutTime;
  76986. private _layoutTime;
  76987. private _onBeginRenderObserver;
  76988. private _onEndRenderObserver;
  76989. private _onBeginLayoutObserver;
  76990. private _onEndLayoutObserver;
  76991. /**
  76992. * Gets the perf counter used to capture render time
  76993. */
  76994. get renderTimeCounter(): BABYLON.PerfCounter;
  76995. /**
  76996. * Gets the perf counter used to capture layout time
  76997. */
  76998. get layoutTimeCounter(): BABYLON.PerfCounter;
  76999. /**
  77000. * Enable or disable the render time capture
  77001. */
  77002. get captureRenderTime(): boolean;
  77003. set captureRenderTime(value: boolean);
  77004. /**
  77005. * Enable or disable the layout time capture
  77006. */
  77007. get captureLayoutTime(): boolean;
  77008. set captureLayoutTime(value: boolean);
  77009. /**
  77010. * Instantiates a new advanced dynamic texture instrumentation.
  77011. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  77012. * @param texture Defines the AdvancedDynamicTexture to instrument
  77013. */
  77014. constructor(
  77015. /**
  77016. * Define the instrumented AdvancedDynamicTexture.
  77017. */
  77018. texture: AdvancedDynamicTexture);
  77019. /**
  77020. * Dispose and release associated resources.
  77021. */
  77022. dispose(): void;
  77023. }
  77024. }
  77025. declare module BABYLON.GUI {
  77026. /**
  77027. * Class used to load GUI via XML.
  77028. */
  77029. export class XmlLoader {
  77030. private _nodes;
  77031. private _nodeTypes;
  77032. private _isLoaded;
  77033. private _objectAttributes;
  77034. private _parentClass;
  77035. /**
  77036. * Create a new xml loader
  77037. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  77038. */
  77039. constructor(parentClass?: null);
  77040. private _getChainElement;
  77041. private _getClassAttribute;
  77042. private _createGuiElement;
  77043. private _parseGrid;
  77044. private _parseElement;
  77045. private _prepareSourceElement;
  77046. private _parseElementsFromSource;
  77047. private _parseXml;
  77048. /**
  77049. * Gets if the loading has finished.
  77050. * @returns whether the loading has finished or not
  77051. */
  77052. isLoaded(): boolean;
  77053. /**
  77054. * Gets a loaded node / control by id.
  77055. * @param id the Controls id set in the xml
  77056. * @returns element of type Control
  77057. */
  77058. getNodeById(id: string): any;
  77059. /**
  77060. * Gets all loaded nodes / controls
  77061. * @returns Array of controls
  77062. */
  77063. getNodes(): any;
  77064. /**
  77065. * Initiates the xml layout loading
  77066. * @param xmlFile defines the xml layout to load
  77067. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  77068. * @param callback defines the callback called on layout load.
  77069. */
  77070. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  77071. }
  77072. }
  77073. declare module BABYLON.GUI {
  77074. /**
  77075. * Class used to create containers for controls
  77076. */
  77077. export class Container3D extends Control3D {
  77078. private _blockLayout;
  77079. /**
  77080. * Gets the list of child controls
  77081. */
  77082. protected _children: Control3D[];
  77083. /**
  77084. * Gets the list of child controls
  77085. */
  77086. get children(): Array<Control3D>;
  77087. /**
  77088. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  77089. * This is helpful to optimize layout operation when adding multiple children in a row
  77090. */
  77091. get blockLayout(): boolean;
  77092. set blockLayout(value: boolean);
  77093. /**
  77094. * Creates a new container
  77095. * @param name defines the container name
  77096. */
  77097. constructor(name?: string);
  77098. /**
  77099. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  77100. * @returns the current container
  77101. */
  77102. updateLayout(): Container3D;
  77103. /**
  77104. * Gets a boolean indicating if the given control is in the children of this control
  77105. * @param control defines the control to check
  77106. * @returns true if the control is in the child list
  77107. */
  77108. containsControl(control: Control3D): boolean;
  77109. /**
  77110. * Adds a control to the children of this control
  77111. * @param control defines the control to add
  77112. * @returns the current container
  77113. */
  77114. addControl(control: Control3D): Container3D;
  77115. /**
  77116. * This function will be called everytime a new control is added
  77117. */
  77118. protected _arrangeChildren(): void;
  77119. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77120. /**
  77121. * Removes a control from the children of this control
  77122. * @param control defines the control to remove
  77123. * @returns the current container
  77124. */
  77125. removeControl(control: Control3D): Container3D;
  77126. protected _getTypeName(): string;
  77127. /**
  77128. * Releases all associated resources
  77129. */
  77130. dispose(): void;
  77131. /** Control rotation will remain unchanged */
  77132. static readonly UNSET_ORIENTATION: number;
  77133. /** Control will rotate to make it look at sphere central axis */
  77134. static readonly FACEORIGIN_ORIENTATION: number;
  77135. /** Control will rotate to make it look back at sphere central axis */
  77136. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  77137. /** Control will rotate to look at z axis (0, 0, 1) */
  77138. static readonly FACEFORWARD_ORIENTATION: number;
  77139. /** Control will rotate to look at negative z axis (0, 0, -1) */
  77140. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  77141. }
  77142. }
  77143. declare module BABYLON.GUI {
  77144. /**
  77145. * Class used to manage 3D user interface
  77146. * @see http://doc.babylonjs.com/how_to/gui3d
  77147. */
  77148. export class GUI3DManager implements BABYLON.IDisposable {
  77149. private _scene;
  77150. private _sceneDisposeObserver;
  77151. private _utilityLayer;
  77152. private _rootContainer;
  77153. private _pointerObserver;
  77154. private _pointerOutObserver;
  77155. /** @hidden */
  77156. _lastPickedControl: Control3D;
  77157. /** @hidden */
  77158. _lastControlOver: {
  77159. [pointerId: number]: Control3D;
  77160. };
  77161. /** @hidden */
  77162. _lastControlDown: {
  77163. [pointerId: number]: Control3D;
  77164. };
  77165. /**
  77166. * BABYLON.Observable raised when the point picked by the pointer events changed
  77167. */
  77168. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  77169. /** @hidden */
  77170. _sharedMaterials: {
  77171. [key: string]: BABYLON.Material;
  77172. };
  77173. /** Gets the hosting scene */
  77174. get scene(): BABYLON.Scene;
  77175. /** Gets associated utility layer */
  77176. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  77177. /**
  77178. * Creates a new GUI3DManager
  77179. * @param scene
  77180. */
  77181. constructor(scene?: BABYLON.Scene);
  77182. private _handlePointerOut;
  77183. private _doPicking;
  77184. /**
  77185. * Gets the root container
  77186. */
  77187. get rootContainer(): Container3D;
  77188. /**
  77189. * Gets a boolean indicating if the given control is in the root child list
  77190. * @param control defines the control to check
  77191. * @returns true if the control is in the root child list
  77192. */
  77193. containsControl(control: Control3D): boolean;
  77194. /**
  77195. * Adds a control to the root child list
  77196. * @param control defines the control to add
  77197. * @returns the current manager
  77198. */
  77199. addControl(control: Control3D): GUI3DManager;
  77200. /**
  77201. * Removes a control from the root child list
  77202. * @param control defines the control to remove
  77203. * @returns the current container
  77204. */
  77205. removeControl(control: Control3D): GUI3DManager;
  77206. /**
  77207. * Releases all associated resources
  77208. */
  77209. dispose(): void;
  77210. }
  77211. }
  77212. declare module BABYLON.GUI {
  77213. /**
  77214. * Class used to transport BABYLON.Vector3 information for pointer events
  77215. */
  77216. export class Vector3WithInfo extends BABYLON.Vector3 {
  77217. /** defines the current mouse button index */
  77218. buttonIndex: number;
  77219. /**
  77220. * Creates a new Vector3WithInfo
  77221. * @param source defines the vector3 data to transport
  77222. * @param buttonIndex defines the current mouse button index
  77223. */
  77224. constructor(source: BABYLON.Vector3,
  77225. /** defines the current mouse button index */
  77226. buttonIndex?: number);
  77227. }
  77228. }
  77229. declare module BABYLON.GUI {
  77230. /**
  77231. * Class used as base class for controls
  77232. */
  77233. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  77234. /** Defines the control name */
  77235. name?: string | undefined;
  77236. /** @hidden */
  77237. _host: GUI3DManager;
  77238. private _node;
  77239. private _downCount;
  77240. private _enterCount;
  77241. private _downPointerIds;
  77242. private _isVisible;
  77243. /** Gets or sets the control position in world space */
  77244. get position(): BABYLON.Vector3;
  77245. set position(value: BABYLON.Vector3);
  77246. /** Gets or sets the control scaling in world space */
  77247. get scaling(): BABYLON.Vector3;
  77248. set scaling(value: BABYLON.Vector3);
  77249. /** Callback used to start pointer enter animation */
  77250. pointerEnterAnimation: () => void;
  77251. /** Callback used to start pointer out animation */
  77252. pointerOutAnimation: () => void;
  77253. /** Callback used to start pointer down animation */
  77254. pointerDownAnimation: () => void;
  77255. /** Callback used to start pointer up animation */
  77256. pointerUpAnimation: () => void;
  77257. /**
  77258. * An event triggered when the pointer move over the control
  77259. */
  77260. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  77261. /**
  77262. * An event triggered when the pointer move out of the control
  77263. */
  77264. onPointerOutObservable: BABYLON.Observable<Control3D>;
  77265. /**
  77266. * An event triggered when the pointer taps the control
  77267. */
  77268. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  77269. /**
  77270. * An event triggered when pointer is up
  77271. */
  77272. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  77273. /**
  77274. * An event triggered when a control is clicked on (with a mouse)
  77275. */
  77276. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  77277. /**
  77278. * An event triggered when pointer enters the control
  77279. */
  77280. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  77281. /**
  77282. * Gets or sets the parent container
  77283. */
  77284. parent: BABYLON.Nullable<Container3D>;
  77285. private _behaviors;
  77286. /**
  77287. * Gets the list of attached behaviors
  77288. * @see http://doc.babylonjs.com/features/behaviour
  77289. */
  77290. get behaviors(): BABYLON.Behavior<Control3D>[];
  77291. /**
  77292. * Attach a behavior to the control
  77293. * @see http://doc.babylonjs.com/features/behaviour
  77294. * @param behavior defines the behavior to attach
  77295. * @returns the current control
  77296. */
  77297. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77298. /**
  77299. * Remove an attached behavior
  77300. * @see http://doc.babylonjs.com/features/behaviour
  77301. * @param behavior defines the behavior to attach
  77302. * @returns the current control
  77303. */
  77304. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77305. /**
  77306. * Gets an attached behavior by name
  77307. * @param name defines the name of the behavior to look for
  77308. * @see http://doc.babylonjs.com/features/behaviour
  77309. * @returns null if behavior was not found else the requested behavior
  77310. */
  77311. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  77312. /** Gets or sets a boolean indicating if the control is visible */
  77313. get isVisible(): boolean;
  77314. set isVisible(value: boolean);
  77315. /**
  77316. * Creates a new control
  77317. * @param name defines the control name
  77318. */
  77319. constructor(
  77320. /** Defines the control name */
  77321. name?: string | undefined);
  77322. /**
  77323. * Gets a string representing the class name
  77324. */
  77325. get typeName(): string;
  77326. /**
  77327. * Get the current class name of the control.
  77328. * @returns current class name
  77329. */
  77330. getClassName(): string;
  77331. protected _getTypeName(): string;
  77332. /**
  77333. * Gets the transform node used by this control
  77334. */
  77335. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  77336. /**
  77337. * Gets the mesh used to render this control
  77338. */
  77339. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77340. /**
  77341. * Link the control as child of the given node
  77342. * @param node defines the node to link to. Use null to unlink the control
  77343. * @returns the current control
  77344. */
  77345. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  77346. /** @hidden **/
  77347. _prepareNode(scene: BABYLON.Scene): void;
  77348. /**
  77349. * Node creation.
  77350. * Can be overriden by children
  77351. * @param scene defines the scene where the node must be attached
  77352. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  77353. */
  77354. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77355. /**
  77356. * Affect a material to the given mesh
  77357. * @param mesh defines the mesh which will represent the control
  77358. */
  77359. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77360. /** @hidden */
  77361. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  77362. /** @hidden */
  77363. _onPointerEnter(target: Control3D): boolean;
  77364. /** @hidden */
  77365. _onPointerOut(target: Control3D): void;
  77366. /** @hidden */
  77367. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77368. /** @hidden */
  77369. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77370. /** @hidden */
  77371. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77372. /** @hidden */
  77373. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77374. /** @hidden */
  77375. _disposeNode(): void;
  77376. /**
  77377. * Releases all associated resources
  77378. */
  77379. dispose(): void;
  77380. }
  77381. }
  77382. declare module BABYLON.GUI {
  77383. /**
  77384. * Class used as a root to all buttons
  77385. */
  77386. export class AbstractButton3D extends Control3D {
  77387. /**
  77388. * Creates a new button
  77389. * @param name defines the control name
  77390. */
  77391. constructor(name?: string);
  77392. protected _getTypeName(): string;
  77393. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77394. }
  77395. }
  77396. declare module BABYLON.GUI {
  77397. /**
  77398. * Class used to create a button in 3D
  77399. */
  77400. export class Button3D extends AbstractButton3D {
  77401. /** @hidden */
  77402. protected _currentMaterial: BABYLON.Material;
  77403. private _facadeTexture;
  77404. private _content;
  77405. private _contentResolution;
  77406. private _contentScaleRatio;
  77407. /**
  77408. * Gets or sets the texture resolution used to render content (512 by default)
  77409. */
  77410. get contentResolution(): BABYLON.int;
  77411. set contentResolution(value: BABYLON.int);
  77412. /**
  77413. * Gets or sets the texture scale ratio used to render content (2 by default)
  77414. */
  77415. get contentScaleRatio(): number;
  77416. set contentScaleRatio(value: number);
  77417. protected _disposeFacadeTexture(): void;
  77418. protected _resetContent(): void;
  77419. /**
  77420. * Creates a new button
  77421. * @param name defines the control name
  77422. */
  77423. constructor(name?: string);
  77424. /**
  77425. * Gets or sets the GUI 2D content used to display the button's facade
  77426. */
  77427. get content(): Control;
  77428. set content(value: Control);
  77429. /**
  77430. * Apply the facade texture (created from the content property).
  77431. * This function can be overloaded by child classes
  77432. * @param facadeTexture defines the AdvancedDynamicTexture to use
  77433. */
  77434. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77435. protected _getTypeName(): string;
  77436. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77437. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77438. /**
  77439. * Releases all associated resources
  77440. */
  77441. dispose(): void;
  77442. }
  77443. }
  77444. declare module BABYLON.GUI {
  77445. /**
  77446. * Abstract class used to create a container panel deployed on the surface of a volume
  77447. */
  77448. export abstract class VolumeBasedPanel extends Container3D {
  77449. private _columns;
  77450. private _rows;
  77451. private _rowThenColum;
  77452. private _orientation;
  77453. protected _cellWidth: number;
  77454. protected _cellHeight: number;
  77455. /**
  77456. * Gets or sets the distance between elements
  77457. */
  77458. margin: number;
  77459. /**
  77460. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  77461. * | Value | Type | Description |
  77462. * | ----- | ----------------------------------- | ----------- |
  77463. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  77464. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  77465. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  77466. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  77467. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  77468. */
  77469. get orientation(): number;
  77470. set orientation(value: number);
  77471. /**
  77472. * Gets or sets the number of columns requested (10 by default).
  77473. * The panel will automatically compute the number of rows based on number of child controls.
  77474. */
  77475. get columns(): BABYLON.int;
  77476. set columns(value: BABYLON.int);
  77477. /**
  77478. * Gets or sets a the number of rows requested.
  77479. * The panel will automatically compute the number of columns based on number of child controls.
  77480. */
  77481. get rows(): BABYLON.int;
  77482. set rows(value: BABYLON.int);
  77483. /**
  77484. * Creates new VolumeBasedPanel
  77485. */
  77486. constructor();
  77487. protected _arrangeChildren(): void;
  77488. /** Child classes must implement this function to provide correct control positioning */
  77489. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77490. /** Child classes can implement this function to provide additional processing */
  77491. protected _finalProcessing(): void;
  77492. }
  77493. }
  77494. declare module BABYLON.GUI {
  77495. /**
  77496. * Class used to create a container panel deployed on the surface of a cylinder
  77497. */
  77498. export class CylinderPanel extends VolumeBasedPanel {
  77499. private _radius;
  77500. /**
  77501. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  77502. */
  77503. get radius(): BABYLON.float;
  77504. set radius(value: BABYLON.float);
  77505. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77506. private _cylindricalMapping;
  77507. }
  77508. }
  77509. declare module BABYLON.GUI {
  77510. /** @hidden */
  77511. export var fluentVertexShader: {
  77512. name: string;
  77513. shader: string;
  77514. };
  77515. }
  77516. declare module BABYLON.GUI {
  77517. /** @hidden */
  77518. export var fluentPixelShader: {
  77519. name: string;
  77520. shader: string;
  77521. };
  77522. }
  77523. declare module BABYLON.GUI {
  77524. /** @hidden */
  77525. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  77526. INNERGLOW: boolean;
  77527. BORDER: boolean;
  77528. HOVERLIGHT: boolean;
  77529. TEXTURE: boolean;
  77530. constructor();
  77531. }
  77532. /**
  77533. * Class used to render controls with fluent desgin
  77534. */
  77535. export class FluentMaterial extends BABYLON.PushMaterial {
  77536. /**
  77537. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  77538. */
  77539. innerGlowColorIntensity: number;
  77540. /**
  77541. * Gets or sets the inner glow color (white by default)
  77542. */
  77543. innerGlowColor: BABYLON.Color3;
  77544. /**
  77545. * Gets or sets alpha value (default is 1.0)
  77546. */
  77547. alpha: number;
  77548. /**
  77549. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  77550. */
  77551. albedoColor: BABYLON.Color3;
  77552. /**
  77553. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  77554. */
  77555. renderBorders: boolean;
  77556. /**
  77557. * Gets or sets border width (default is 0.5)
  77558. */
  77559. borderWidth: number;
  77560. /**
  77561. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  77562. */
  77563. edgeSmoothingValue: number;
  77564. /**
  77565. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  77566. */
  77567. borderMinValue: number;
  77568. /**
  77569. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  77570. */
  77571. renderHoverLight: boolean;
  77572. /**
  77573. * Gets or sets the radius used to render the hover light (default is 1.0)
  77574. */
  77575. hoverRadius: number;
  77576. /**
  77577. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  77578. */
  77579. hoverColor: BABYLON.Color4;
  77580. /**
  77581. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  77582. */
  77583. hoverPosition: BABYLON.Vector3;
  77584. private _albedoTexture;
  77585. /** Gets or sets the texture to use for albedo color */
  77586. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77587. /**
  77588. * Creates a new Fluent material
  77589. * @param name defines the name of the material
  77590. * @param scene defines the hosting scene
  77591. */
  77592. constructor(name: string, scene: BABYLON.Scene);
  77593. needAlphaBlending(): boolean;
  77594. needAlphaTesting(): boolean;
  77595. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77596. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77597. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77598. getActiveTextures(): BABYLON.BaseTexture[];
  77599. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77600. dispose(forceDisposeEffect?: boolean): void;
  77601. clone(name: string): FluentMaterial;
  77602. serialize(): any;
  77603. getClassName(): string;
  77604. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  77605. }
  77606. }
  77607. declare module BABYLON.GUI {
  77608. /**
  77609. * Class used to create a holographic button in 3D
  77610. */
  77611. export class HolographicButton extends Button3D {
  77612. private _backPlate;
  77613. private _textPlate;
  77614. private _frontPlate;
  77615. private _text;
  77616. private _imageUrl;
  77617. private _shareMaterials;
  77618. private _frontMaterial;
  77619. private _backMaterial;
  77620. private _plateMaterial;
  77621. private _pickedPointObserver;
  77622. private _tooltipFade;
  77623. private _tooltipTextBlock;
  77624. private _tooltipTexture;
  77625. private _tooltipMesh;
  77626. private _tooltipHoverObserver;
  77627. private _tooltipOutObserver;
  77628. private _disposeTooltip;
  77629. /**
  77630. * Rendering ground id of all the mesh in the button
  77631. */
  77632. set renderingGroupId(id: number);
  77633. get renderingGroupId(): number;
  77634. /**
  77635. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  77636. */
  77637. set tooltipText(text: BABYLON.Nullable<string>);
  77638. get tooltipText(): BABYLON.Nullable<string>;
  77639. /**
  77640. * Gets or sets text for the button
  77641. */
  77642. get text(): string;
  77643. set text(value: string);
  77644. /**
  77645. * Gets or sets the image url for the button
  77646. */
  77647. get imageUrl(): string;
  77648. set imageUrl(value: string);
  77649. /**
  77650. * Gets the back material used by this button
  77651. */
  77652. get backMaterial(): FluentMaterial;
  77653. /**
  77654. * Gets the front material used by this button
  77655. */
  77656. get frontMaterial(): FluentMaterial;
  77657. /**
  77658. * Gets the plate material used by this button
  77659. */
  77660. get plateMaterial(): BABYLON.StandardMaterial;
  77661. /**
  77662. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  77663. */
  77664. get shareMaterials(): boolean;
  77665. /**
  77666. * Creates a new button
  77667. * @param name defines the control name
  77668. */
  77669. constructor(name?: string, shareMaterials?: boolean);
  77670. protected _getTypeName(): string;
  77671. private _rebuildContent;
  77672. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77673. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77674. private _createBackMaterial;
  77675. private _createFrontMaterial;
  77676. private _createPlateMaterial;
  77677. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  77678. /**
  77679. * Releases all associated resources
  77680. */
  77681. dispose(): void;
  77682. }
  77683. }
  77684. declare module BABYLON.GUI {
  77685. /**
  77686. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  77687. */
  77688. export class MeshButton3D extends Button3D {
  77689. /** @hidden */
  77690. protected _currentMesh: BABYLON.Mesh;
  77691. /**
  77692. * Creates a new 3D button based on a mesh
  77693. * @param mesh mesh to become a 3D button
  77694. * @param name defines the control name
  77695. */
  77696. constructor(mesh: BABYLON.Mesh, name?: string);
  77697. protected _getTypeName(): string;
  77698. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77699. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77700. }
  77701. }
  77702. declare module BABYLON.GUI {
  77703. /**
  77704. * Class used to create a container panel deployed on the surface of a plane
  77705. */
  77706. export class PlanePanel extends VolumeBasedPanel {
  77707. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77708. }
  77709. }
  77710. declare module BABYLON.GUI {
  77711. /**
  77712. * Class used to create a container panel where items get randomized planar mapping
  77713. */
  77714. export class ScatterPanel extends VolumeBasedPanel {
  77715. private _iteration;
  77716. /**
  77717. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  77718. */
  77719. get iteration(): BABYLON.float;
  77720. set iteration(value: BABYLON.float);
  77721. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77722. private _scatterMapping;
  77723. protected _finalProcessing(): void;
  77724. }
  77725. }
  77726. declare module BABYLON.GUI {
  77727. /**
  77728. * Class used to create a container panel deployed on the surface of a sphere
  77729. */
  77730. export class SpherePanel extends VolumeBasedPanel {
  77731. private _radius;
  77732. /**
  77733. * Gets or sets the radius of the sphere where to project controls (5 by default)
  77734. */
  77735. get radius(): BABYLON.float;
  77736. set radius(value: BABYLON.float);
  77737. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77738. private _sphericalMapping;
  77739. }
  77740. }
  77741. declare module BABYLON.GUI {
  77742. /**
  77743. * Class used to create a stack panel in 3D on XY plane
  77744. */
  77745. export class StackPanel3D extends Container3D {
  77746. private _isVertical;
  77747. /**
  77748. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  77749. */
  77750. get isVertical(): boolean;
  77751. set isVertical(value: boolean);
  77752. /**
  77753. * Gets or sets the distance between elements
  77754. */
  77755. margin: number;
  77756. /**
  77757. * Creates new StackPanel
  77758. * @param isVertical
  77759. */
  77760. constructor(isVertical?: boolean);
  77761. protected _arrangeChildren(): void;
  77762. }
  77763. }
  77764. declare module BABYLON {
  77765. /**
  77766. * Configuration for glTF validation
  77767. */
  77768. export interface IGLTFValidationConfiguration {
  77769. /**
  77770. * The url of the glTF validator.
  77771. */
  77772. url: string;
  77773. }
  77774. /**
  77775. * glTF validation
  77776. */
  77777. export class GLTFValidation {
  77778. /**
  77779. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  77780. */
  77781. static Configuration: IGLTFValidationConfiguration;
  77782. private static _LoadScriptPromise;
  77783. /**
  77784. * Validate a glTF asset using the glTF-Validator.
  77785. * @param data The JSON of a glTF or the array buffer of a binary glTF
  77786. * @param rootUrl The root url for the glTF
  77787. * @param fileName The file name for the glTF
  77788. * @param getExternalResource The callback to get external resources for the glTF validator
  77789. * @returns A promise that resolves with the glTF validation results once complete
  77790. */
  77791. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  77792. }
  77793. }
  77794. declare module BABYLON {
  77795. /**
  77796. * Mode that determines the coordinate system to use.
  77797. */
  77798. export enum GLTFLoaderCoordinateSystemMode {
  77799. /**
  77800. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  77801. */
  77802. AUTO = 0,
  77803. /**
  77804. * Sets the useRightHandedSystem flag on the scene.
  77805. */
  77806. FORCE_RIGHT_HANDED = 1
  77807. }
  77808. /**
  77809. * Mode that determines what animations will start.
  77810. */
  77811. export enum GLTFLoaderAnimationStartMode {
  77812. /**
  77813. * No animation will start.
  77814. */
  77815. NONE = 0,
  77816. /**
  77817. * The first animation will start.
  77818. */
  77819. FIRST = 1,
  77820. /**
  77821. * All animations will start.
  77822. */
  77823. ALL = 2
  77824. }
  77825. /**
  77826. * Interface that contains the data for the glTF asset.
  77827. */
  77828. export interface IGLTFLoaderData {
  77829. /**
  77830. * The object that represents the glTF JSON.
  77831. */
  77832. json: Object;
  77833. /**
  77834. * The BIN chunk of a binary glTF.
  77835. */
  77836. bin: Nullable<IDataBuffer>;
  77837. }
  77838. /**
  77839. * Interface for extending the loader.
  77840. */
  77841. export interface IGLTFLoaderExtension {
  77842. /**
  77843. * The name of this extension.
  77844. */
  77845. readonly name: string;
  77846. /**
  77847. * Defines whether this extension is enabled.
  77848. */
  77849. enabled: boolean;
  77850. /**
  77851. * Defines the order of this extension.
  77852. * The loader sorts the extensions using these values when loading.
  77853. */
  77854. order?: number;
  77855. }
  77856. /**
  77857. * Loader state.
  77858. */
  77859. export enum GLTFLoaderState {
  77860. /**
  77861. * The asset is loading.
  77862. */
  77863. LOADING = 0,
  77864. /**
  77865. * The asset is ready for rendering.
  77866. */
  77867. READY = 1,
  77868. /**
  77869. * The asset is completely loaded.
  77870. */
  77871. COMPLETE = 2
  77872. }
  77873. /** @hidden */
  77874. export interface IImportMeshAsyncOutput {
  77875. meshes: AbstractMesh[];
  77876. particleSystems: IParticleSystem[];
  77877. skeletons: Skeleton[];
  77878. animationGroups: AnimationGroup[];
  77879. lights: Light[];
  77880. transformNodes: TransformNode[];
  77881. }
  77882. /** @hidden */
  77883. export interface IGLTFLoader extends IDisposable {
  77884. readonly state: Nullable<GLTFLoaderState>;
  77885. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  77886. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  77887. }
  77888. /**
  77889. * File loader for loading glTF files into a scene.
  77890. */
  77891. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77892. /** @hidden */
  77893. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77894. /** @hidden */
  77895. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77896. /**
  77897. * Raised when the asset has been parsed
  77898. */
  77899. onParsedObservable: Observable<IGLTFLoaderData>;
  77900. private _onParsedObserver;
  77901. /**
  77902. * Raised when the asset has been parsed
  77903. */
  77904. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  77905. /**
  77906. * 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.
  77907. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  77908. * Defaults to true.
  77909. * @hidden
  77910. */
  77911. static IncrementalLoading: boolean;
  77912. /**
  77913. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  77914. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  77915. * @hidden
  77916. */
  77917. static HomogeneousCoordinates: boolean;
  77918. /**
  77919. * The coordinate system mode. Defaults to AUTO.
  77920. */
  77921. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  77922. /**
  77923. * The animation start mode. Defaults to FIRST.
  77924. */
  77925. animationStartMode: GLTFLoaderAnimationStartMode;
  77926. /**
  77927. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  77928. */
  77929. compileMaterials: boolean;
  77930. /**
  77931. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  77932. */
  77933. useClipPlane: boolean;
  77934. /**
  77935. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  77936. */
  77937. compileShadowGenerators: boolean;
  77938. /**
  77939. * Defines if the Alpha blended materials are only applied as coverage.
  77940. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  77941. * If true, no extra effects are applied to transparent pixels.
  77942. */
  77943. transparencyAsCoverage: boolean;
  77944. /**
  77945. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  77946. * Enabling will disable offline support and glTF validator.
  77947. * Defaults to false.
  77948. */
  77949. useRangeRequests: boolean;
  77950. /**
  77951. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  77952. */
  77953. createInstances: boolean;
  77954. /**
  77955. * Function called before loading a url referenced by the asset.
  77956. */
  77957. preprocessUrlAsync: (url: string) => Promise<string>;
  77958. /**
  77959. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  77960. */
  77961. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  77962. private _onMeshLoadedObserver;
  77963. /**
  77964. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  77965. */
  77966. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  77967. /**
  77968. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  77969. */
  77970. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  77971. private _onTextureLoadedObserver;
  77972. /**
  77973. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  77974. */
  77975. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  77976. /**
  77977. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  77978. */
  77979. readonly onMaterialLoadedObservable: Observable<Material>;
  77980. private _onMaterialLoadedObserver;
  77981. /**
  77982. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  77983. */
  77984. set onMaterialLoaded(callback: (material: Material) => void);
  77985. /**
  77986. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  77987. */
  77988. readonly onCameraLoadedObservable: Observable<Camera>;
  77989. private _onCameraLoadedObserver;
  77990. /**
  77991. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  77992. */
  77993. set onCameraLoaded(callback: (camera: Camera) => void);
  77994. /**
  77995. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  77996. * For assets with LODs, raised when all of the LODs are complete.
  77997. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  77998. */
  77999. readonly onCompleteObservable: Observable<void>;
  78000. private _onCompleteObserver;
  78001. /**
  78002. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  78003. * For assets with LODs, raised when all of the LODs are complete.
  78004. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78005. */
  78006. set onComplete(callback: () => void);
  78007. /**
  78008. * Observable raised when an error occurs.
  78009. */
  78010. readonly onErrorObservable: Observable<any>;
  78011. private _onErrorObserver;
  78012. /**
  78013. * Callback raised when an error occurs.
  78014. */
  78015. set onError(callback: (reason: any) => void);
  78016. /**
  78017. * Observable raised after the loader is disposed.
  78018. */
  78019. readonly onDisposeObservable: Observable<void>;
  78020. private _onDisposeObserver;
  78021. /**
  78022. * Callback raised after the loader is disposed.
  78023. */
  78024. set onDispose(callback: () => void);
  78025. /**
  78026. * Observable raised after a loader extension is created.
  78027. * Set additional options for a loader extension in this event.
  78028. */
  78029. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  78030. private _onExtensionLoadedObserver;
  78031. /**
  78032. * Callback raised after a loader extension is created.
  78033. */
  78034. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  78035. /**
  78036. * Defines if the loader logging is enabled.
  78037. */
  78038. get loggingEnabled(): boolean;
  78039. set loggingEnabled(value: boolean);
  78040. /**
  78041. * Defines if the loader should capture performance counters.
  78042. */
  78043. get capturePerformanceCounters(): boolean;
  78044. set capturePerformanceCounters(value: boolean);
  78045. /**
  78046. * Defines if the loader should validate the asset.
  78047. */
  78048. validate: boolean;
  78049. /**
  78050. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  78051. */
  78052. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  78053. private _onValidatedObserver;
  78054. /**
  78055. * Callback raised after a loader extension is created.
  78056. */
  78057. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  78058. private _loader;
  78059. /**
  78060. * Name of the loader ("gltf")
  78061. */
  78062. name: string;
  78063. /** @hidden */
  78064. extensions: ISceneLoaderPluginExtensions;
  78065. /**
  78066. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  78067. */
  78068. dispose(): void;
  78069. /** @hidden */
  78070. _clear(): void;
  78071. /** @hidden */
  78072. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78073. /** @hidden */
  78074. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78075. /** @hidden */
  78076. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  78077. meshes: AbstractMesh[];
  78078. particleSystems: IParticleSystem[];
  78079. skeletons: Skeleton[];
  78080. animationGroups: AnimationGroup[];
  78081. }>;
  78082. /** @hidden */
  78083. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78084. /** @hidden */
  78085. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  78086. /** @hidden */
  78087. canDirectLoad(data: string): boolean;
  78088. /** @hidden */
  78089. directLoad(scene: Scene, data: string): any;
  78090. /**
  78091. * The callback that allows custom handling of the root url based on the response url.
  78092. * @param rootUrl the original root url
  78093. * @param responseURL the response url if available
  78094. * @returns the new root url
  78095. */
  78096. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  78097. /** @hidden */
  78098. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  78099. /**
  78100. * The loader state or null if the loader is not active.
  78101. */
  78102. get loaderState(): Nullable<GLTFLoaderState>;
  78103. /**
  78104. * Returns a promise that resolves when the asset is completely loaded.
  78105. * @returns a promise that resolves when the asset is completely loaded.
  78106. */
  78107. whenCompleteAsync(): Promise<void>;
  78108. private _validate;
  78109. private _getLoader;
  78110. private _parseJson;
  78111. private _unpackBinaryAsync;
  78112. private _unpackBinaryV1Async;
  78113. private _unpackBinaryV2Async;
  78114. private static _parseVersion;
  78115. private static _compareVersion;
  78116. private static readonly _logSpaces;
  78117. private _logIndentLevel;
  78118. private _loggingEnabled;
  78119. /** @hidden */
  78120. _log: (message: string) => void;
  78121. /** @hidden */
  78122. _logOpen(message: string): void;
  78123. /** @hidden */
  78124. _logClose(): void;
  78125. private _logEnabled;
  78126. private _logDisabled;
  78127. private _capturePerformanceCounters;
  78128. /** @hidden */
  78129. _startPerformanceCounter: (counterName: string) => void;
  78130. /** @hidden */
  78131. _endPerformanceCounter: (counterName: string) => void;
  78132. private _startPerformanceCounterEnabled;
  78133. private _startPerformanceCounterDisabled;
  78134. private _endPerformanceCounterEnabled;
  78135. private _endPerformanceCounterDisabled;
  78136. }
  78137. }
  78138. declare module BABYLON.GLTF1 {
  78139. /**
  78140. * Enums
  78141. * @hidden
  78142. */
  78143. export enum EComponentType {
  78144. BYTE = 5120,
  78145. UNSIGNED_BYTE = 5121,
  78146. SHORT = 5122,
  78147. UNSIGNED_SHORT = 5123,
  78148. FLOAT = 5126
  78149. }
  78150. /** @hidden */
  78151. export enum EShaderType {
  78152. FRAGMENT = 35632,
  78153. VERTEX = 35633
  78154. }
  78155. /** @hidden */
  78156. export enum EParameterType {
  78157. BYTE = 5120,
  78158. UNSIGNED_BYTE = 5121,
  78159. SHORT = 5122,
  78160. UNSIGNED_SHORT = 5123,
  78161. INT = 5124,
  78162. UNSIGNED_INT = 5125,
  78163. FLOAT = 5126,
  78164. FLOAT_VEC2 = 35664,
  78165. FLOAT_VEC3 = 35665,
  78166. FLOAT_VEC4 = 35666,
  78167. INT_VEC2 = 35667,
  78168. INT_VEC3 = 35668,
  78169. INT_VEC4 = 35669,
  78170. BOOL = 35670,
  78171. BOOL_VEC2 = 35671,
  78172. BOOL_VEC3 = 35672,
  78173. BOOL_VEC4 = 35673,
  78174. FLOAT_MAT2 = 35674,
  78175. FLOAT_MAT3 = 35675,
  78176. FLOAT_MAT4 = 35676,
  78177. SAMPLER_2D = 35678
  78178. }
  78179. /** @hidden */
  78180. export enum ETextureWrapMode {
  78181. CLAMP_TO_EDGE = 33071,
  78182. MIRRORED_REPEAT = 33648,
  78183. REPEAT = 10497
  78184. }
  78185. /** @hidden */
  78186. export enum ETextureFilterType {
  78187. NEAREST = 9728,
  78188. LINEAR = 9728,
  78189. NEAREST_MIPMAP_NEAREST = 9984,
  78190. LINEAR_MIPMAP_NEAREST = 9985,
  78191. NEAREST_MIPMAP_LINEAR = 9986,
  78192. LINEAR_MIPMAP_LINEAR = 9987
  78193. }
  78194. /** @hidden */
  78195. export enum ETextureFormat {
  78196. ALPHA = 6406,
  78197. RGB = 6407,
  78198. RGBA = 6408,
  78199. LUMINANCE = 6409,
  78200. LUMINANCE_ALPHA = 6410
  78201. }
  78202. /** @hidden */
  78203. export enum ECullingType {
  78204. FRONT = 1028,
  78205. BACK = 1029,
  78206. FRONT_AND_BACK = 1032
  78207. }
  78208. /** @hidden */
  78209. export enum EBlendingFunction {
  78210. ZERO = 0,
  78211. ONE = 1,
  78212. SRC_COLOR = 768,
  78213. ONE_MINUS_SRC_COLOR = 769,
  78214. DST_COLOR = 774,
  78215. ONE_MINUS_DST_COLOR = 775,
  78216. SRC_ALPHA = 770,
  78217. ONE_MINUS_SRC_ALPHA = 771,
  78218. DST_ALPHA = 772,
  78219. ONE_MINUS_DST_ALPHA = 773,
  78220. CONSTANT_COLOR = 32769,
  78221. ONE_MINUS_CONSTANT_COLOR = 32770,
  78222. CONSTANT_ALPHA = 32771,
  78223. ONE_MINUS_CONSTANT_ALPHA = 32772,
  78224. SRC_ALPHA_SATURATE = 776
  78225. }
  78226. /** @hidden */
  78227. export interface IGLTFProperty {
  78228. extensions?: {
  78229. [key: string]: any;
  78230. };
  78231. extras?: Object;
  78232. }
  78233. /** @hidden */
  78234. export interface IGLTFChildRootProperty extends IGLTFProperty {
  78235. name?: string;
  78236. }
  78237. /** @hidden */
  78238. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  78239. bufferView: string;
  78240. byteOffset: number;
  78241. byteStride: number;
  78242. count: number;
  78243. type: string;
  78244. componentType: EComponentType;
  78245. max?: number[];
  78246. min?: number[];
  78247. name?: string;
  78248. }
  78249. /** @hidden */
  78250. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  78251. buffer: string;
  78252. byteOffset: number;
  78253. byteLength: number;
  78254. byteStride: number;
  78255. target?: number;
  78256. }
  78257. /** @hidden */
  78258. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  78259. uri: string;
  78260. byteLength?: number;
  78261. type?: string;
  78262. }
  78263. /** @hidden */
  78264. export interface IGLTFShader extends IGLTFChildRootProperty {
  78265. uri: string;
  78266. type: EShaderType;
  78267. }
  78268. /** @hidden */
  78269. export interface IGLTFProgram extends IGLTFChildRootProperty {
  78270. attributes: string[];
  78271. fragmentShader: string;
  78272. vertexShader: string;
  78273. }
  78274. /** @hidden */
  78275. export interface IGLTFTechniqueParameter {
  78276. type: number;
  78277. count?: number;
  78278. semantic?: string;
  78279. node?: string;
  78280. value?: number | boolean | string | Array<any>;
  78281. source?: string;
  78282. babylonValue?: any;
  78283. }
  78284. /** @hidden */
  78285. export interface IGLTFTechniqueCommonProfile {
  78286. lightingModel: string;
  78287. texcoordBindings: Object;
  78288. parameters?: Array<any>;
  78289. }
  78290. /** @hidden */
  78291. export interface IGLTFTechniqueStatesFunctions {
  78292. blendColor?: number[];
  78293. blendEquationSeparate?: number[];
  78294. blendFuncSeparate?: number[];
  78295. colorMask: boolean[];
  78296. cullFace: number[];
  78297. }
  78298. /** @hidden */
  78299. export interface IGLTFTechniqueStates {
  78300. enable: number[];
  78301. functions: IGLTFTechniqueStatesFunctions;
  78302. }
  78303. /** @hidden */
  78304. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  78305. parameters: {
  78306. [key: string]: IGLTFTechniqueParameter;
  78307. };
  78308. program: string;
  78309. attributes: {
  78310. [key: string]: string;
  78311. };
  78312. uniforms: {
  78313. [key: string]: string;
  78314. };
  78315. states: IGLTFTechniqueStates;
  78316. }
  78317. /** @hidden */
  78318. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  78319. technique?: string;
  78320. values: string[];
  78321. }
  78322. /** @hidden */
  78323. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  78324. attributes: {
  78325. [key: string]: string;
  78326. };
  78327. indices: string;
  78328. material: string;
  78329. mode?: number;
  78330. }
  78331. /** @hidden */
  78332. export interface IGLTFMesh extends IGLTFChildRootProperty {
  78333. primitives: IGLTFMeshPrimitive[];
  78334. }
  78335. /** @hidden */
  78336. export interface IGLTFImage extends IGLTFChildRootProperty {
  78337. uri: string;
  78338. }
  78339. /** @hidden */
  78340. export interface IGLTFSampler extends IGLTFChildRootProperty {
  78341. magFilter?: number;
  78342. minFilter?: number;
  78343. wrapS?: number;
  78344. wrapT?: number;
  78345. }
  78346. /** @hidden */
  78347. export interface IGLTFTexture extends IGLTFChildRootProperty {
  78348. sampler: string;
  78349. source: string;
  78350. format?: ETextureFormat;
  78351. internalFormat?: ETextureFormat;
  78352. target?: number;
  78353. type?: number;
  78354. babylonTexture?: Texture;
  78355. }
  78356. /** @hidden */
  78357. export interface IGLTFAmbienLight {
  78358. color?: number[];
  78359. }
  78360. /** @hidden */
  78361. export interface IGLTFDirectionalLight {
  78362. color?: number[];
  78363. }
  78364. /** @hidden */
  78365. export interface IGLTFPointLight {
  78366. color?: number[];
  78367. constantAttenuation?: number;
  78368. linearAttenuation?: number;
  78369. quadraticAttenuation?: number;
  78370. }
  78371. /** @hidden */
  78372. export interface IGLTFSpotLight {
  78373. color?: number[];
  78374. constantAttenuation?: number;
  78375. fallOfAngle?: number;
  78376. fallOffExponent?: number;
  78377. linearAttenuation?: number;
  78378. quadraticAttenuation?: number;
  78379. }
  78380. /** @hidden */
  78381. export interface IGLTFLight extends IGLTFChildRootProperty {
  78382. type: string;
  78383. }
  78384. /** @hidden */
  78385. export interface IGLTFCameraOrthographic {
  78386. xmag: number;
  78387. ymag: number;
  78388. zfar: number;
  78389. znear: number;
  78390. }
  78391. /** @hidden */
  78392. export interface IGLTFCameraPerspective {
  78393. aspectRatio: number;
  78394. yfov: number;
  78395. zfar: number;
  78396. znear: number;
  78397. }
  78398. /** @hidden */
  78399. export interface IGLTFCamera extends IGLTFChildRootProperty {
  78400. type: string;
  78401. }
  78402. /** @hidden */
  78403. export interface IGLTFAnimationChannelTarget {
  78404. id: string;
  78405. path: string;
  78406. }
  78407. /** @hidden */
  78408. export interface IGLTFAnimationChannel {
  78409. sampler: string;
  78410. target: IGLTFAnimationChannelTarget;
  78411. }
  78412. /** @hidden */
  78413. export interface IGLTFAnimationSampler {
  78414. input: string;
  78415. output: string;
  78416. interpolation?: string;
  78417. }
  78418. /** @hidden */
  78419. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  78420. channels?: IGLTFAnimationChannel[];
  78421. parameters?: {
  78422. [key: string]: string;
  78423. };
  78424. samplers?: {
  78425. [key: string]: IGLTFAnimationSampler;
  78426. };
  78427. }
  78428. /** @hidden */
  78429. export interface IGLTFNodeInstanceSkin {
  78430. skeletons: string[];
  78431. skin: string;
  78432. meshes: string[];
  78433. }
  78434. /** @hidden */
  78435. export interface IGLTFSkins extends IGLTFChildRootProperty {
  78436. bindShapeMatrix: number[];
  78437. inverseBindMatrices: string;
  78438. jointNames: string[];
  78439. babylonSkeleton?: Skeleton;
  78440. }
  78441. /** @hidden */
  78442. export interface IGLTFNode extends IGLTFChildRootProperty {
  78443. camera?: string;
  78444. children: string[];
  78445. skin?: string;
  78446. jointName?: string;
  78447. light?: string;
  78448. matrix: number[];
  78449. mesh?: string;
  78450. meshes?: string[];
  78451. rotation?: number[];
  78452. scale?: number[];
  78453. translation?: number[];
  78454. babylonNode?: Node;
  78455. }
  78456. /** @hidden */
  78457. export interface IGLTFScene extends IGLTFChildRootProperty {
  78458. nodes: string[];
  78459. }
  78460. /** @hidden */
  78461. export interface IGLTFRuntime {
  78462. extensions: {
  78463. [key: string]: any;
  78464. };
  78465. accessors: {
  78466. [key: string]: IGLTFAccessor;
  78467. };
  78468. buffers: {
  78469. [key: string]: IGLTFBuffer;
  78470. };
  78471. bufferViews: {
  78472. [key: string]: IGLTFBufferView;
  78473. };
  78474. meshes: {
  78475. [key: string]: IGLTFMesh;
  78476. };
  78477. lights: {
  78478. [key: string]: IGLTFLight;
  78479. };
  78480. cameras: {
  78481. [key: string]: IGLTFCamera;
  78482. };
  78483. nodes: {
  78484. [key: string]: IGLTFNode;
  78485. };
  78486. images: {
  78487. [key: string]: IGLTFImage;
  78488. };
  78489. textures: {
  78490. [key: string]: IGLTFTexture;
  78491. };
  78492. shaders: {
  78493. [key: string]: IGLTFShader;
  78494. };
  78495. programs: {
  78496. [key: string]: IGLTFProgram;
  78497. };
  78498. samplers: {
  78499. [key: string]: IGLTFSampler;
  78500. };
  78501. techniques: {
  78502. [key: string]: IGLTFTechnique;
  78503. };
  78504. materials: {
  78505. [key: string]: IGLTFMaterial;
  78506. };
  78507. animations: {
  78508. [key: string]: IGLTFAnimation;
  78509. };
  78510. skins: {
  78511. [key: string]: IGLTFSkins;
  78512. };
  78513. currentScene?: Object;
  78514. scenes: {
  78515. [key: string]: IGLTFScene;
  78516. };
  78517. extensionsUsed: string[];
  78518. extensionsRequired?: string[];
  78519. buffersCount: number;
  78520. shaderscount: number;
  78521. scene: Scene;
  78522. rootUrl: string;
  78523. loadedBufferCount: number;
  78524. loadedBufferViews: {
  78525. [name: string]: ArrayBufferView;
  78526. };
  78527. loadedShaderCount: number;
  78528. importOnlyMeshes: boolean;
  78529. importMeshesNames?: string[];
  78530. dummyNodes: Node[];
  78531. forAssetContainer: boolean;
  78532. }
  78533. /** @hidden */
  78534. export interface INodeToRoot {
  78535. bone: Bone;
  78536. node: IGLTFNode;
  78537. id: string;
  78538. }
  78539. /** @hidden */
  78540. export interface IJointNode {
  78541. node: IGLTFNode;
  78542. id: string;
  78543. }
  78544. }
  78545. declare module BABYLON.GLTF1 {
  78546. /**
  78547. * Utils functions for GLTF
  78548. * @hidden
  78549. */
  78550. export class GLTFUtils {
  78551. /**
  78552. * Sets the given "parameter" matrix
  78553. * @param scene: the Scene object
  78554. * @param source: the source node where to pick the matrix
  78555. * @param parameter: the GLTF technique parameter
  78556. * @param uniformName: the name of the shader's uniform
  78557. * @param shaderMaterial: the shader material
  78558. */
  78559. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  78560. /**
  78561. * Sets the given "parameter" matrix
  78562. * @param shaderMaterial: the shader material
  78563. * @param uniform: the name of the shader's uniform
  78564. * @param value: the value of the uniform
  78565. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  78566. */
  78567. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  78568. /**
  78569. * Returns the wrap mode of the texture
  78570. * @param mode: the mode value
  78571. */
  78572. static GetWrapMode(mode: number): number;
  78573. /**
  78574. * Returns the byte stride giving an accessor
  78575. * @param accessor: the GLTF accessor objet
  78576. */
  78577. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  78578. /**
  78579. * Returns the texture filter mode giving a mode value
  78580. * @param mode: the filter mode value
  78581. */
  78582. static GetTextureFilterMode(mode: number): ETextureFilterType;
  78583. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  78584. /**
  78585. * Returns a buffer from its accessor
  78586. * @param gltfRuntime: the GLTF runtime
  78587. * @param accessor: the GLTF accessor
  78588. */
  78589. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  78590. /**
  78591. * Decodes a buffer view into a string
  78592. * @param view: the buffer view
  78593. */
  78594. static DecodeBufferToText(view: ArrayBufferView): string;
  78595. /**
  78596. * Returns the default material of gltf. Related to
  78597. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  78598. * @param scene: the Babylon.js scene
  78599. */
  78600. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  78601. private static _DefaultMaterial;
  78602. }
  78603. }
  78604. declare module BABYLON.GLTF1 {
  78605. /**
  78606. * Implementation of the base glTF spec
  78607. * @hidden
  78608. */
  78609. export class GLTFLoaderBase {
  78610. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  78611. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78612. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  78613. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78614. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  78615. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78616. }
  78617. /**
  78618. * glTF V1 Loader
  78619. * @hidden
  78620. */
  78621. export class GLTFLoader implements IGLTFLoader {
  78622. static Extensions: {
  78623. [name: string]: GLTFLoaderExtension;
  78624. };
  78625. static RegisterExtension(extension: GLTFLoaderExtension): void;
  78626. state: Nullable<GLTFLoaderState>;
  78627. dispose(): void;
  78628. private _importMeshAsync;
  78629. /**
  78630. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  78631. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  78632. * @param scene the scene the meshes should be added to
  78633. * @param forAssetContainer defines if the entities must be stored in the scene
  78634. * @param data gltf data containing information of the meshes in a loaded file
  78635. * @param rootUrl root url to load from
  78636. * @param onProgress event that fires when loading progress has occured
  78637. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  78638. */
  78639. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  78640. private _loadAsync;
  78641. /**
  78642. * Imports all objects from a loaded gltf file and adds them to the scene
  78643. * @param scene the scene the objects should be added to
  78644. * @param data gltf data containing information of the meshes in a loaded file
  78645. * @param rootUrl root url to load from
  78646. * @param onProgress event that fires when loading progress has occured
  78647. * @returns a promise which completes when objects have been loaded to the scene
  78648. */
  78649. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  78650. private _loadShadersAsync;
  78651. private _loadBuffersAsync;
  78652. private _createNodes;
  78653. }
  78654. /** @hidden */
  78655. export abstract class GLTFLoaderExtension {
  78656. private _name;
  78657. constructor(name: string);
  78658. get name(): string;
  78659. /**
  78660. * Defines an override for loading the runtime
  78661. * Return true to stop further extensions from loading the runtime
  78662. */
  78663. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  78664. /**
  78665. * Defines an onverride for creating gltf runtime
  78666. * Return true to stop further extensions from creating the runtime
  78667. */
  78668. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  78669. /**
  78670. * Defines an override for loading buffers
  78671. * Return true to stop further extensions from loading this buffer
  78672. */
  78673. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  78674. /**
  78675. * Defines an override for loading texture buffers
  78676. * Return true to stop further extensions from loading this texture data
  78677. */
  78678. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78679. /**
  78680. * Defines an override for creating textures
  78681. * Return true to stop further extensions from loading this texture
  78682. */
  78683. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  78684. /**
  78685. * Defines an override for loading shader strings
  78686. * Return true to stop further extensions from loading this shader data
  78687. */
  78688. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78689. /**
  78690. * Defines an override for loading materials
  78691. * Return true to stop further extensions from loading this material
  78692. */
  78693. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78694. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  78695. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  78696. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78697. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78698. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  78699. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78700. private static LoadTextureBufferAsync;
  78701. private static CreateTextureAsync;
  78702. private static ApplyExtensions;
  78703. }
  78704. }
  78705. declare module BABYLON.GLTF1 {
  78706. /** @hidden */
  78707. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  78708. private _bin;
  78709. constructor();
  78710. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  78711. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78712. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78713. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78714. }
  78715. }
  78716. declare module BABYLON.GLTF1 {
  78717. /** @hidden */
  78718. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  78719. constructor();
  78720. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  78721. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78722. private _loadTexture;
  78723. }
  78724. }
  78725. declare module BABYLON.GLTF2.Loader {
  78726. /**
  78727. * Loader interface with an index field.
  78728. */
  78729. export interface IArrayItem {
  78730. /**
  78731. * The index of this item in the array.
  78732. */
  78733. index: number;
  78734. }
  78735. /**
  78736. * Loader interface with additional members.
  78737. */
  78738. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  78739. /** @hidden */
  78740. _data?: Promise<ArrayBufferView>;
  78741. /** @hidden */
  78742. _babylonVertexBuffer?: Promise<VertexBuffer>;
  78743. }
  78744. /**
  78745. * Loader interface with additional members.
  78746. */
  78747. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  78748. }
  78749. /** @hidden */
  78750. export interface _IAnimationSamplerData {
  78751. input: Float32Array;
  78752. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  78753. output: Float32Array;
  78754. }
  78755. /**
  78756. * Loader interface with additional members.
  78757. */
  78758. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  78759. /** @hidden */
  78760. _data?: Promise<_IAnimationSamplerData>;
  78761. }
  78762. /**
  78763. * Loader interface with additional members.
  78764. */
  78765. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  78766. channels: IAnimationChannel[];
  78767. samplers: IAnimationSampler[];
  78768. /** @hidden */
  78769. _babylonAnimationGroup?: AnimationGroup;
  78770. }
  78771. /**
  78772. * Loader interface with additional members.
  78773. */
  78774. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  78775. /** @hidden */
  78776. _data?: Promise<ArrayBufferView>;
  78777. }
  78778. /**
  78779. * Loader interface with additional members.
  78780. */
  78781. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  78782. /** @hidden */
  78783. _data?: Promise<ArrayBufferView>;
  78784. /** @hidden */
  78785. _babylonBuffer?: Promise<Buffer>;
  78786. }
  78787. /**
  78788. * Loader interface with additional members.
  78789. */
  78790. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  78791. }
  78792. /**
  78793. * Loader interface with additional members.
  78794. */
  78795. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  78796. /** @hidden */
  78797. _data?: Promise<ArrayBufferView>;
  78798. }
  78799. /**
  78800. * Loader interface with additional members.
  78801. */
  78802. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  78803. }
  78804. /**
  78805. * Loader interface with additional members.
  78806. */
  78807. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  78808. }
  78809. /**
  78810. * Loader interface with additional members.
  78811. */
  78812. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  78813. baseColorTexture?: ITextureInfo;
  78814. metallicRoughnessTexture?: ITextureInfo;
  78815. }
  78816. /**
  78817. * Loader interface with additional members.
  78818. */
  78819. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  78820. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78821. normalTexture?: IMaterialNormalTextureInfo;
  78822. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78823. emissiveTexture?: ITextureInfo;
  78824. /** @hidden */
  78825. _data?: {
  78826. [babylonDrawMode: number]: {
  78827. babylonMaterial: Material;
  78828. babylonMeshes: AbstractMesh[];
  78829. promise: Promise<void>;
  78830. };
  78831. };
  78832. }
  78833. /**
  78834. * Loader interface with additional members.
  78835. */
  78836. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  78837. primitives: IMeshPrimitive[];
  78838. }
  78839. /**
  78840. * Loader interface with additional members.
  78841. */
  78842. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  78843. /** @hidden */
  78844. _instanceData?: {
  78845. babylonSourceMesh: Mesh;
  78846. promise: Promise<any>;
  78847. };
  78848. }
  78849. /**
  78850. * Loader interface with additional members.
  78851. */
  78852. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  78853. /**
  78854. * The parent glTF node.
  78855. */
  78856. parent?: INode;
  78857. /** @hidden */
  78858. _babylonTransformNode?: TransformNode;
  78859. /** @hidden */
  78860. _primitiveBabylonMeshes?: AbstractMesh[];
  78861. /** @hidden */
  78862. _babylonBones?: Bone[];
  78863. /** @hidden */
  78864. _numMorphTargets?: number;
  78865. }
  78866. /** @hidden */
  78867. export interface _ISamplerData {
  78868. noMipMaps: boolean;
  78869. samplingMode: number;
  78870. wrapU: number;
  78871. wrapV: number;
  78872. }
  78873. /**
  78874. * Loader interface with additional members.
  78875. */
  78876. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  78877. /** @hidden */
  78878. _data?: _ISamplerData;
  78879. }
  78880. /**
  78881. * Loader interface with additional members.
  78882. */
  78883. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  78884. }
  78885. /**
  78886. * Loader interface with additional members.
  78887. */
  78888. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  78889. /** @hidden */
  78890. _data?: {
  78891. babylonSkeleton: Skeleton;
  78892. promise: Promise<void>;
  78893. };
  78894. }
  78895. /**
  78896. * Loader interface with additional members.
  78897. */
  78898. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  78899. }
  78900. /**
  78901. * Loader interface with additional members.
  78902. */
  78903. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  78904. }
  78905. /**
  78906. * Loader interface with additional members.
  78907. */
  78908. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  78909. accessors?: IAccessor[];
  78910. animations?: IAnimation[];
  78911. buffers?: IBuffer[];
  78912. bufferViews?: IBufferView[];
  78913. cameras?: ICamera[];
  78914. images?: IImage[];
  78915. materials?: IMaterial[];
  78916. meshes?: IMesh[];
  78917. nodes?: INode[];
  78918. samplers?: ISampler[];
  78919. scenes?: IScene[];
  78920. skins?: ISkin[];
  78921. textures?: ITexture[];
  78922. }
  78923. }
  78924. declare module BABYLON.GLTF2 {
  78925. /**
  78926. * Interface for a glTF loader extension.
  78927. */
  78928. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  78929. /**
  78930. * Called after the loader state changes to LOADING.
  78931. */
  78932. onLoading?(): void;
  78933. /**
  78934. * Called after the loader state changes to READY.
  78935. */
  78936. onReady?(): void;
  78937. /**
  78938. * Define this method to modify the default behavior when loading scenes.
  78939. * @param context The context when loading the asset
  78940. * @param scene The glTF scene property
  78941. * @returns A promise that resolves when the load is complete or null if not handled
  78942. */
  78943. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  78944. /**
  78945. * Define this method to modify the default behavior when loading nodes.
  78946. * @param context The context when loading the asset
  78947. * @param node The glTF node property
  78948. * @param assign A function called synchronously after parsing the glTF properties
  78949. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  78950. */
  78951. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78952. /**
  78953. * Define this method to modify the default behavior when loading cameras.
  78954. * @param context The context when loading the asset
  78955. * @param camera The glTF camera property
  78956. * @param assign A function called synchronously after parsing the glTF properties
  78957. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  78958. */
  78959. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  78960. /**
  78961. * @hidden
  78962. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  78963. * @param context The context when loading the asset
  78964. * @param primitive The glTF mesh primitive property
  78965. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  78966. */
  78967. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  78968. /**
  78969. * @hidden
  78970. * Define this method to modify the default behavior when loading data for mesh primitives.
  78971. * @param context The context when loading the asset
  78972. * @param name The mesh name when loading the asset
  78973. * @param node The glTF node when loading the asset
  78974. * @param mesh The glTF mesh when loading the asset
  78975. * @param primitive The glTF mesh primitive property
  78976. * @param assign A function called synchronously after parsing the glTF properties
  78977. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  78978. */
  78979. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  78980. /**
  78981. * @hidden
  78982. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  78983. * @param context The context when loading the asset
  78984. * @param material The glTF material property
  78985. * @param assign A function called synchronously after parsing the glTF properties
  78986. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  78987. */
  78988. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  78989. /**
  78990. * Define this method to modify the default behavior when creating materials.
  78991. * @param context The context when loading the asset
  78992. * @param material The glTF material property
  78993. * @param babylonDrawMode The draw mode for the Babylon material
  78994. * @returns The Babylon material or null if not handled
  78995. */
  78996. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  78997. /**
  78998. * Define this method to modify the default behavior when loading material properties.
  78999. * @param context The context when loading the asset
  79000. * @param material The glTF material property
  79001. * @param babylonMaterial The Babylon material
  79002. * @returns A promise that resolves when the load is complete or null if not handled
  79003. */
  79004. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79005. /**
  79006. * Define this method to modify the default behavior when loading texture infos.
  79007. * @param context The context when loading the asset
  79008. * @param textureInfo The glTF texture info property
  79009. * @param assign A function called synchronously after parsing the glTF properties
  79010. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79011. */
  79012. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79013. /**
  79014. * @hidden
  79015. * Define this method to modify the default behavior when loading textures.
  79016. * @param context The context when loading the asset
  79017. * @param texture The glTF texture property
  79018. * @param assign A function called synchronously after parsing the glTF properties
  79019. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79020. */
  79021. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79022. /**
  79023. * Define this method to modify the default behavior when loading animations.
  79024. * @param context The context when loading the asset
  79025. * @param animation The glTF animation property
  79026. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  79027. */
  79028. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79029. /**
  79030. * @hidden
  79031. * Define this method to modify the default behavior when loading skins.
  79032. * @param context The context when loading the asset
  79033. * @param node The glTF node property
  79034. * @param skin The glTF skin property
  79035. * @returns A promise that resolves when the load is complete or null if not handled
  79036. */
  79037. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  79038. /**
  79039. * @hidden
  79040. * Define this method to modify the default behavior when loading uris.
  79041. * @param context The context when loading the asset
  79042. * @param property The glTF property associated with the uri
  79043. * @param uri The uri to load
  79044. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79045. */
  79046. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79047. /**
  79048. * Define this method to modify the default behavior when loading buffer views.
  79049. * @param context The context when loading the asset
  79050. * @param bufferView The glTF buffer view property
  79051. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79052. */
  79053. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  79054. /**
  79055. * Define this method to modify the default behavior when loading buffers.
  79056. * @param context The context when loading the asset
  79057. * @param buffer The glTF buffer property
  79058. * @param byteOffset The byte offset to load
  79059. * @param byteLength The byte length to load
  79060. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79061. */
  79062. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79063. }
  79064. }
  79065. declare module BABYLON.GLTF2 {
  79066. /**
  79067. * Helper class for working with arrays when loading the glTF asset
  79068. */
  79069. export class ArrayItem {
  79070. /**
  79071. * Gets an item from the given array.
  79072. * @param context The context when loading the asset
  79073. * @param array The array to get the item from
  79074. * @param index The index to the array
  79075. * @returns The array item
  79076. */
  79077. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  79078. /**
  79079. * Assign an `index` field to each item of the given array.
  79080. * @param array The array of items
  79081. */
  79082. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  79083. }
  79084. /**
  79085. * The glTF 2.0 loader
  79086. */
  79087. export class GLTFLoader implements IGLTFLoader {
  79088. /** @hidden */
  79089. _completePromises: Promise<any>[];
  79090. /** @hidden */
  79091. _forAssetContainer: boolean;
  79092. /** Storage */
  79093. _babylonLights: Light[];
  79094. /** @hidden */
  79095. _disableInstancedMesh: number;
  79096. private _disposed;
  79097. private _parent;
  79098. private _state;
  79099. private _extensions;
  79100. private _rootUrl;
  79101. private _fileName;
  79102. private _uniqueRootUrl;
  79103. private _gltf;
  79104. private _bin;
  79105. private _babylonScene;
  79106. private _rootBabylonMesh;
  79107. private _defaultBabylonMaterialData;
  79108. private _progressCallback?;
  79109. private _requests;
  79110. private static _RegisteredExtensions;
  79111. /**
  79112. * The default glTF sampler.
  79113. */
  79114. static readonly DefaultSampler: ISampler;
  79115. /**
  79116. * Registers a loader extension.
  79117. * @param name The name of the loader extension.
  79118. * @param factory The factory function that creates the loader extension.
  79119. */
  79120. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  79121. /**
  79122. * Unregisters a loader extension.
  79123. * @param name The name of the loader extension.
  79124. * @returns A boolean indicating whether the extension has been unregistered
  79125. */
  79126. static UnregisterExtension(name: string): boolean;
  79127. /**
  79128. * The loader state.
  79129. */
  79130. get state(): Nullable<GLTFLoaderState>;
  79131. /**
  79132. * The object that represents the glTF JSON.
  79133. */
  79134. get gltf(): IGLTF;
  79135. /**
  79136. * The BIN chunk of a binary glTF.
  79137. */
  79138. get bin(): Nullable<IDataBuffer>;
  79139. /**
  79140. * The parent file loader.
  79141. */
  79142. get parent(): GLTFFileLoader;
  79143. /**
  79144. * The Babylon scene when loading the asset.
  79145. */
  79146. get babylonScene(): Scene;
  79147. /**
  79148. * The root Babylon mesh when loading the asset.
  79149. */
  79150. get rootBabylonMesh(): Mesh;
  79151. /** @hidden */
  79152. constructor(parent: GLTFFileLoader);
  79153. /** @hidden */
  79154. dispose(): void;
  79155. /** @hidden */
  79156. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  79157. /** @hidden */
  79158. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79159. private _loadAsync;
  79160. private _loadData;
  79161. private _setupData;
  79162. private _loadExtensions;
  79163. private _checkExtensions;
  79164. private _setState;
  79165. private _createRootNode;
  79166. /**
  79167. * Loads a glTF scene.
  79168. * @param context The context when loading the asset
  79169. * @param scene The glTF scene property
  79170. * @returns A promise that resolves when the load is complete
  79171. */
  79172. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  79173. private _forEachPrimitive;
  79174. private _getMeshes;
  79175. private _getTransformNodes;
  79176. private _getSkeletons;
  79177. private _getAnimationGroups;
  79178. private _startAnimations;
  79179. /**
  79180. * Loads a glTF node.
  79181. * @param context The context when loading the asset
  79182. * @param node The glTF node property
  79183. * @param assign A function called synchronously after parsing the glTF properties
  79184. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  79185. */
  79186. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  79187. private _loadMeshAsync;
  79188. /**
  79189. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  79190. * @param context The context when loading the asset
  79191. * @param name The mesh name when loading the asset
  79192. * @param node The glTF node when loading the asset
  79193. * @param mesh The glTF mesh when loading the asset
  79194. * @param primitive The glTF mesh primitive property
  79195. * @param assign A function called synchronously after parsing the glTF properties
  79196. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79197. */
  79198. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  79199. private _loadVertexDataAsync;
  79200. private _createMorphTargets;
  79201. private _loadMorphTargetsAsync;
  79202. private _loadMorphTargetVertexDataAsync;
  79203. private static _LoadTransform;
  79204. private _loadSkinAsync;
  79205. private _loadBones;
  79206. private _loadBone;
  79207. private _loadSkinInverseBindMatricesDataAsync;
  79208. private _updateBoneMatrices;
  79209. private _getNodeMatrix;
  79210. /**
  79211. * Loads a glTF camera.
  79212. * @param context The context when loading the asset
  79213. * @param camera The glTF camera property
  79214. * @param assign A function called synchronously after parsing the glTF properties
  79215. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  79216. */
  79217. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  79218. private _loadAnimationsAsync;
  79219. /**
  79220. * Loads a glTF animation.
  79221. * @param context The context when loading the asset
  79222. * @param animation The glTF animation property
  79223. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  79224. */
  79225. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  79226. /**
  79227. * @hidden Loads a glTF animation channel.
  79228. * @param context The context when loading the asset
  79229. * @param animationContext The context of the animation when loading the asset
  79230. * @param animation The glTF animation property
  79231. * @param channel The glTF animation channel property
  79232. * @param babylonAnimationGroup The babylon animation group property
  79233. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  79234. * @returns A void promise when the channel load is complete
  79235. */
  79236. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  79237. private _loadAnimationSamplerAsync;
  79238. private _loadBufferAsync;
  79239. /**
  79240. * Loads a glTF buffer view.
  79241. * @param context The context when loading the asset
  79242. * @param bufferView The glTF buffer view property
  79243. * @returns A promise that resolves with the loaded data when the load is complete
  79244. */
  79245. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  79246. private _loadAccessorAsync;
  79247. /** @hidden */
  79248. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  79249. private _loadIndicesAccessorAsync;
  79250. private _loadVertexBufferViewAsync;
  79251. private _loadVertexAccessorAsync;
  79252. private _loadMaterialMetallicRoughnessPropertiesAsync;
  79253. /** @hidden */
  79254. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  79255. private _createDefaultMaterial;
  79256. /**
  79257. * Creates a Babylon material from a glTF material.
  79258. * @param context The context when loading the asset
  79259. * @param material The glTF material property
  79260. * @param babylonDrawMode The draw mode for the Babylon material
  79261. * @returns The Babylon material
  79262. */
  79263. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  79264. /**
  79265. * Loads properties from a glTF material into a Babylon material.
  79266. * @param context The context when loading the asset
  79267. * @param material The glTF material property
  79268. * @param babylonMaterial The Babylon material
  79269. * @returns A promise that resolves when the load is complete
  79270. */
  79271. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79272. /**
  79273. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  79274. * @param context The context when loading the asset
  79275. * @param material The glTF material property
  79276. * @param babylonMaterial The Babylon material
  79277. * @returns A promise that resolves when the load is complete
  79278. */
  79279. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79280. /**
  79281. * Loads the alpha properties from a glTF material into a Babylon material.
  79282. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  79283. * @param context The context when loading the asset
  79284. * @param material The glTF material property
  79285. * @param babylonMaterial The Babylon material
  79286. */
  79287. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  79288. /**
  79289. * Loads a glTF texture info.
  79290. * @param context The context when loading the asset
  79291. * @param textureInfo The glTF texture info property
  79292. * @param assign A function called synchronously after parsing the glTF properties
  79293. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  79294. */
  79295. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79296. /** @hidden */
  79297. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79298. /** @hidden */
  79299. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79300. private _loadSampler;
  79301. /**
  79302. * Loads a glTF image.
  79303. * @param context The context when loading the asset
  79304. * @param image The glTF image property
  79305. * @returns A promise that resolves with the loaded data when the load is complete
  79306. */
  79307. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  79308. /**
  79309. * Loads a glTF uri.
  79310. * @param context The context when loading the asset
  79311. * @param property The glTF property associated with the uri
  79312. * @param uri The base64 or relative uri
  79313. * @returns A promise that resolves with the loaded data when the load is complete
  79314. */
  79315. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  79316. private _onProgress;
  79317. /**
  79318. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  79319. * @param babylonObject the Babylon object with metadata
  79320. * @param pointer the JSON pointer
  79321. */
  79322. static AddPointerMetadata(babylonObject: {
  79323. metadata: any;
  79324. }, pointer: string): void;
  79325. private static _GetTextureWrapMode;
  79326. private static _GetTextureSamplingMode;
  79327. private static _GetTypedArrayConstructor;
  79328. private static _GetTypedArray;
  79329. private static _GetNumComponents;
  79330. private static _ValidateUri;
  79331. private static _GetDrawMode;
  79332. private _compileMaterialsAsync;
  79333. private _compileShadowGeneratorsAsync;
  79334. private _forEachExtensions;
  79335. private _applyExtensions;
  79336. private _extensionsOnLoading;
  79337. private _extensionsOnReady;
  79338. private _extensionsLoadSceneAsync;
  79339. private _extensionsLoadNodeAsync;
  79340. private _extensionsLoadCameraAsync;
  79341. private _extensionsLoadVertexDataAsync;
  79342. private _extensionsLoadMeshPrimitiveAsync;
  79343. private _extensionsLoadMaterialAsync;
  79344. private _extensionsCreateMaterial;
  79345. private _extensionsLoadMaterialPropertiesAsync;
  79346. private _extensionsLoadTextureInfoAsync;
  79347. private _extensionsLoadTextureAsync;
  79348. private _extensionsLoadAnimationAsync;
  79349. private _extensionsLoadSkinAsync;
  79350. private _extensionsLoadUriAsync;
  79351. private _extensionsLoadBufferViewAsync;
  79352. private _extensionsLoadBufferAsync;
  79353. /**
  79354. * Helper method called by a loader extension to load an glTF extension.
  79355. * @param context The context when loading the asset
  79356. * @param property The glTF property to load the extension from
  79357. * @param extensionName The name of the extension to load
  79358. * @param actionAsync The action to run
  79359. * @returns The promise returned by actionAsync or null if the extension does not exist
  79360. */
  79361. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79362. /**
  79363. * Helper method called by a loader extension to load a glTF extra.
  79364. * @param context The context when loading the asset
  79365. * @param property The glTF property to load the extra from
  79366. * @param extensionName The name of the extension to load
  79367. * @param actionAsync The action to run
  79368. * @returns The promise returned by actionAsync or null if the extra does not exist
  79369. */
  79370. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79371. /**
  79372. * Checks for presence of an extension.
  79373. * @param name The name of the extension to check
  79374. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  79375. */
  79376. isExtensionUsed(name: string): boolean;
  79377. /**
  79378. * Increments the indentation level and logs a message.
  79379. * @param message The message to log
  79380. */
  79381. logOpen(message: string): void;
  79382. /**
  79383. * Decrements the indentation level.
  79384. */
  79385. logClose(): void;
  79386. /**
  79387. * Logs a message
  79388. * @param message The message to log
  79389. */
  79390. log(message: string): void;
  79391. /**
  79392. * Starts a performance counter.
  79393. * @param counterName The name of the performance counter
  79394. */
  79395. startPerformanceCounter(counterName: string): void;
  79396. /**
  79397. * Ends a performance counter.
  79398. * @param counterName The name of the performance counter
  79399. */
  79400. endPerformanceCounter(counterName: string): void;
  79401. }
  79402. }
  79403. declare module BABYLON.GLTF2.Loader.Extensions {
  79404. /**
  79405. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  79406. */
  79407. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  79408. /**
  79409. * The name of this extension.
  79410. */
  79411. readonly name: string;
  79412. /**
  79413. * Defines whether this extension is enabled.
  79414. */
  79415. enabled: boolean;
  79416. private _loader;
  79417. private _lights?;
  79418. /** @hidden */
  79419. constructor(loader: GLTFLoader);
  79420. /** @hidden */
  79421. dispose(): void;
  79422. /** @hidden */
  79423. onLoading(): void;
  79424. /** @hidden */
  79425. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79426. private _loadLightAsync;
  79427. }
  79428. }
  79429. declare module BABYLON.GLTF2.Loader.Extensions {
  79430. /**
  79431. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  79432. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  79433. * !!! Experimental Extension Subject to Changes !!!
  79434. */
  79435. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  79436. /**
  79437. * The name of this extension.
  79438. */
  79439. readonly name: string;
  79440. /**
  79441. * Defines whether this extension is enabled.
  79442. */
  79443. enabled: boolean;
  79444. private _loader;
  79445. /** @hidden */
  79446. constructor(loader: GLTFLoader);
  79447. /** @hidden */
  79448. dispose(): void;
  79449. /** @hidden */
  79450. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79451. }
  79452. }
  79453. declare module BABYLON.GLTF2.Loader.Extensions {
  79454. /**
  79455. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  79456. */
  79457. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  79458. /**
  79459. * The name of this extension.
  79460. */
  79461. readonly name: string;
  79462. /**
  79463. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  79464. */
  79465. dracoCompression?: DracoCompression;
  79466. /**
  79467. * Defines whether this extension is enabled.
  79468. */
  79469. enabled: boolean;
  79470. private _loader;
  79471. /** @hidden */
  79472. constructor(loader: GLTFLoader);
  79473. /** @hidden */
  79474. dispose(): void;
  79475. /** @hidden */
  79476. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79477. }
  79478. }
  79479. declare module BABYLON.GLTF2.Loader.Extensions {
  79480. /**
  79481. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  79482. */
  79483. export class KHR_lights implements IGLTFLoaderExtension {
  79484. /**
  79485. * The name of this extension.
  79486. */
  79487. readonly name: string;
  79488. /**
  79489. * Defines whether this extension is enabled.
  79490. */
  79491. enabled: boolean;
  79492. private _loader;
  79493. private _lights?;
  79494. /** @hidden */
  79495. constructor(loader: GLTFLoader);
  79496. /** @hidden */
  79497. dispose(): void;
  79498. /** @hidden */
  79499. onLoading(): void;
  79500. /** @hidden */
  79501. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79502. }
  79503. }
  79504. declare module BABYLON.GLTF2.Loader.Extensions {
  79505. /**
  79506. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  79507. */
  79508. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  79509. /**
  79510. * The name of this extension.
  79511. */
  79512. readonly name: string;
  79513. /**
  79514. * Defines whether this extension is enabled.
  79515. */
  79516. enabled: boolean;
  79517. /**
  79518. * Defines a number that determines the order the extensions are applied.
  79519. */
  79520. order: number;
  79521. private _loader;
  79522. /** @hidden */
  79523. constructor(loader: GLTFLoader);
  79524. /** @hidden */
  79525. dispose(): void;
  79526. /** @hidden */
  79527. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79528. private _loadSpecularGlossinessPropertiesAsync;
  79529. }
  79530. }
  79531. declare module BABYLON.GLTF2.Loader.Extensions {
  79532. /**
  79533. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  79534. */
  79535. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  79536. /**
  79537. * The name of this extension.
  79538. */
  79539. readonly name: string;
  79540. /**
  79541. * Defines whether this extension is enabled.
  79542. */
  79543. enabled: boolean;
  79544. /**
  79545. * Defines a number that determines the order the extensions are applied.
  79546. */
  79547. order: number;
  79548. private _loader;
  79549. /** @hidden */
  79550. constructor(loader: GLTFLoader);
  79551. /** @hidden */
  79552. dispose(): void;
  79553. /** @hidden */
  79554. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79555. private _loadUnlitPropertiesAsync;
  79556. }
  79557. }
  79558. declare module BABYLON.GLTF2.Loader.Extensions {
  79559. /**
  79560. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  79561. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  79562. * !!! Experimental Extension Subject to Changes !!!
  79563. */
  79564. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  79565. /**
  79566. * The name of this extension.
  79567. */
  79568. readonly name: string;
  79569. /**
  79570. * Defines whether this extension is enabled.
  79571. */
  79572. enabled: boolean;
  79573. /**
  79574. * Defines a number that determines the order the extensions are applied.
  79575. */
  79576. order: number;
  79577. private _loader;
  79578. /** @hidden */
  79579. constructor(loader: GLTFLoader);
  79580. /** @hidden */
  79581. dispose(): void;
  79582. /** @hidden */
  79583. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79584. private _loadClearCoatPropertiesAsync;
  79585. }
  79586. }
  79587. declare module BABYLON.GLTF2.Loader.Extensions {
  79588. /**
  79589. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  79590. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  79591. * !!! Experimental Extension Subject to Changes !!!
  79592. */
  79593. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  79594. /**
  79595. * The name of this extension.
  79596. */
  79597. readonly name: string;
  79598. /**
  79599. * Defines whether this extension is enabled.
  79600. */
  79601. enabled: boolean;
  79602. /**
  79603. * Defines a number that determines the order the extensions are applied.
  79604. */
  79605. order: number;
  79606. private _loader;
  79607. /** @hidden */
  79608. constructor(loader: GLTFLoader);
  79609. /** @hidden */
  79610. dispose(): void;
  79611. /** @hidden */
  79612. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79613. private _loadSheenPropertiesAsync;
  79614. }
  79615. }
  79616. declare module BABYLON.GLTF2.Loader.Extensions {
  79617. /**
  79618. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  79619. * !!! Experimental Extension Subject to Changes !!!
  79620. */
  79621. export class KHR_materials_specular implements IGLTFLoaderExtension {
  79622. /**
  79623. * The name of this extension.
  79624. */
  79625. readonly name: string;
  79626. /**
  79627. * Defines whether this extension is enabled.
  79628. */
  79629. enabled: boolean;
  79630. /**
  79631. * Defines a number that determines the order the extensions are applied.
  79632. */
  79633. order: number;
  79634. private _loader;
  79635. /** @hidden */
  79636. constructor(loader: GLTFLoader);
  79637. /** @hidden */
  79638. dispose(): void;
  79639. /** @hidden */
  79640. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79641. private _loadSpecularPropertiesAsync;
  79642. }
  79643. }
  79644. declare module BABYLON.GLTF2.Loader.Extensions {
  79645. /**
  79646. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  79647. * !!! Experimental Extension Subject to Changes !!!
  79648. */
  79649. export class KHR_materials_ior implements IGLTFLoaderExtension {
  79650. /**
  79651. * Default ior Value from the spec.
  79652. */
  79653. private static readonly _DEFAULT_IOR;
  79654. /**
  79655. * The name of this extension.
  79656. */
  79657. readonly name: string;
  79658. /**
  79659. * Defines whether this extension is enabled.
  79660. */
  79661. enabled: boolean;
  79662. /**
  79663. * Defines a number that determines the order the extensions are applied.
  79664. */
  79665. order: number;
  79666. private _loader;
  79667. /** @hidden */
  79668. constructor(loader: GLTFLoader);
  79669. /** @hidden */
  79670. dispose(): void;
  79671. /** @hidden */
  79672. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79673. private _loadIorPropertiesAsync;
  79674. }
  79675. }
  79676. declare module BABYLON.GLTF2.Loader.Extensions {
  79677. /**
  79678. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  79679. */
  79680. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  79681. /**
  79682. * The name of this extension.
  79683. */
  79684. readonly name: string;
  79685. /**
  79686. * Defines whether this extension is enabled.
  79687. */
  79688. enabled: boolean;
  79689. /** @hidden */
  79690. constructor(loader: GLTFLoader);
  79691. /** @hidden */
  79692. dispose(): void;
  79693. }
  79694. }
  79695. declare module BABYLON.GLTF2.Loader.Extensions {
  79696. /**
  79697. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  79698. * !!! Experimental Extension Subject to Changes !!!
  79699. */
  79700. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  79701. /** The name of this extension. */
  79702. readonly name: string;
  79703. /** Defines whether this extension is enabled. */
  79704. enabled: boolean;
  79705. private _loader;
  79706. /** @hidden */
  79707. constructor(loader: GLTFLoader);
  79708. /** @hidden */
  79709. dispose(): void;
  79710. /** @hidden */
  79711. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79712. }
  79713. }
  79714. declare module BABYLON.GLTF2.Loader.Extensions {
  79715. /**
  79716. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  79717. */
  79718. export class KHR_texture_transform implements IGLTFLoaderExtension {
  79719. /**
  79720. * The name of this extension.
  79721. */
  79722. readonly name: string;
  79723. /**
  79724. * Defines whether this extension is enabled.
  79725. */
  79726. enabled: boolean;
  79727. private _loader;
  79728. /** @hidden */
  79729. constructor(loader: GLTFLoader);
  79730. /** @hidden */
  79731. dispose(): void;
  79732. /** @hidden */
  79733. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79734. }
  79735. }
  79736. declare module BABYLON.GLTF2.Loader.Extensions {
  79737. /**
  79738. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  79739. * !!! Experimental Extension Subject to Changes !!!
  79740. */
  79741. export class KHR_xmp implements IGLTFLoaderExtension {
  79742. /**
  79743. * The name of this extension.
  79744. */
  79745. readonly name: string;
  79746. /**
  79747. * Defines whether this extension is enabled.
  79748. */
  79749. enabled: boolean;
  79750. /**
  79751. * Defines a number that determines the order the extensions are applied.
  79752. */
  79753. order: number;
  79754. private _loader;
  79755. /** @hidden */
  79756. constructor(loader: GLTFLoader);
  79757. /** @hidden */
  79758. dispose(): void;
  79759. /**
  79760. * Called after the loader state changes to LOADING.
  79761. */
  79762. onLoading(): void;
  79763. }
  79764. }
  79765. declare module BABYLON.GLTF2.Loader.Extensions {
  79766. /**
  79767. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  79768. */
  79769. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  79770. /**
  79771. * The name of this extension.
  79772. */
  79773. readonly name: string;
  79774. /**
  79775. * Defines whether this extension is enabled.
  79776. */
  79777. enabled: boolean;
  79778. private _loader;
  79779. private _clips;
  79780. private _emitters;
  79781. /** @hidden */
  79782. constructor(loader: GLTFLoader);
  79783. /** @hidden */
  79784. dispose(): void;
  79785. /** @hidden */
  79786. onLoading(): void;
  79787. /** @hidden */
  79788. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79789. /** @hidden */
  79790. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79791. /** @hidden */
  79792. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79793. private _loadClipAsync;
  79794. private _loadEmitterAsync;
  79795. private _getEventAction;
  79796. private _loadAnimationEventAsync;
  79797. }
  79798. }
  79799. declare module BABYLON.GLTF2.Loader.Extensions {
  79800. /**
  79801. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  79802. */
  79803. export class MSFT_lod implements IGLTFLoaderExtension {
  79804. /**
  79805. * The name of this extension.
  79806. */
  79807. readonly name: string;
  79808. /**
  79809. * Defines whether this extension is enabled.
  79810. */
  79811. enabled: boolean;
  79812. /**
  79813. * Defines a number that determines the order the extensions are applied.
  79814. */
  79815. order: number;
  79816. /**
  79817. * Maximum number of LODs to load, starting from the lowest LOD.
  79818. */
  79819. maxLODsToLoad: number;
  79820. /**
  79821. * Observable raised when all node LODs of one level are loaded.
  79822. * The event data is the index of the loaded LOD starting from zero.
  79823. * Dispose the loader to cancel the loading of the next level of LODs.
  79824. */
  79825. onNodeLODsLoadedObservable: Observable<number>;
  79826. /**
  79827. * Observable raised when all material LODs of one level are loaded.
  79828. * The event data is the index of the loaded LOD starting from zero.
  79829. * Dispose the loader to cancel the loading of the next level of LODs.
  79830. */
  79831. onMaterialLODsLoadedObservable: Observable<number>;
  79832. private _loader;
  79833. private _nodeIndexLOD;
  79834. private _nodeSignalLODs;
  79835. private _nodePromiseLODs;
  79836. private _materialIndexLOD;
  79837. private _materialSignalLODs;
  79838. private _materialPromiseLODs;
  79839. private _indexLOD;
  79840. private _bufferLODs;
  79841. /** @hidden */
  79842. constructor(loader: GLTFLoader);
  79843. /** @hidden */
  79844. dispose(): void;
  79845. /** @hidden */
  79846. onReady(): void;
  79847. /** @hidden */
  79848. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79849. /** @hidden */
  79850. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79851. /** @hidden */
  79852. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79853. /** @hidden */
  79854. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79855. /** @hidden */
  79856. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79857. private _loadBufferLOD;
  79858. /**
  79859. * Gets an array of LOD properties from lowest to highest.
  79860. */
  79861. private _getLODs;
  79862. private _disposeTransformNode;
  79863. private _disposeMaterials;
  79864. }
  79865. }
  79866. declare module BABYLON.GLTF2.Loader.Extensions {
  79867. /** @hidden */
  79868. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  79869. readonly name: string;
  79870. enabled: boolean;
  79871. private _loader;
  79872. constructor(loader: GLTFLoader);
  79873. dispose(): void;
  79874. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79875. }
  79876. }
  79877. declare module BABYLON.GLTF2.Loader.Extensions {
  79878. /** @hidden */
  79879. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  79880. readonly name: string;
  79881. enabled: boolean;
  79882. private _loader;
  79883. constructor(loader: GLTFLoader);
  79884. dispose(): void;
  79885. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79886. }
  79887. }
  79888. declare module BABYLON.GLTF2.Loader.Extensions {
  79889. /**
  79890. * Store glTF extras (if present) in BJS objects' metadata
  79891. */
  79892. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  79893. /**
  79894. * The name of this extension.
  79895. */
  79896. readonly name: string;
  79897. /**
  79898. * Defines whether this extension is enabled.
  79899. */
  79900. enabled: boolean;
  79901. private _loader;
  79902. private _assignExtras;
  79903. /** @hidden */
  79904. constructor(loader: GLTFLoader);
  79905. /** @hidden */
  79906. dispose(): void;
  79907. /** @hidden */
  79908. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79909. /** @hidden */
  79910. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79911. /** @hidden */
  79912. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79913. }
  79914. }
  79915. declare module BABYLON {
  79916. /**
  79917. * Class reading and parsing the MTL file bundled with the obj file.
  79918. */
  79919. export class MTLFileLoader {
  79920. /**
  79921. * Invert Y-Axis of referenced textures on load
  79922. */
  79923. static INVERT_TEXTURE_Y: boolean;
  79924. /**
  79925. * All material loaded from the mtl will be set here
  79926. */
  79927. materials: StandardMaterial[];
  79928. /**
  79929. * This function will read the mtl file and create each material described inside
  79930. * This function could be improve by adding :
  79931. * -some component missing (Ni, Tf...)
  79932. * -including the specific options available
  79933. *
  79934. * @param scene defines the scene the material will be created in
  79935. * @param data defines the mtl data to parse
  79936. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  79937. * @param forAssetContainer defines if the material should be registered in the scene
  79938. */
  79939. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  79940. /**
  79941. * Gets the texture for the material.
  79942. *
  79943. * If the material is imported from input file,
  79944. * We sanitize the url to ensure it takes the textre from aside the material.
  79945. *
  79946. * @param rootUrl The root url to load from
  79947. * @param value The value stored in the mtl
  79948. * @return The Texture
  79949. */
  79950. private static _getTexture;
  79951. }
  79952. }
  79953. declare module BABYLON {
  79954. /**
  79955. * Options for loading OBJ/MTL files
  79956. */
  79957. type MeshLoadOptions = {
  79958. /**
  79959. * Defines if UVs are optimized by default during load.
  79960. */
  79961. OptimizeWithUV: boolean;
  79962. /**
  79963. * Defines custom scaling of UV coordinates of loaded meshes.
  79964. */
  79965. UVScaling: Vector2;
  79966. /**
  79967. * Invert model on y-axis (does a model scaling inversion)
  79968. */
  79969. InvertY: boolean;
  79970. /**
  79971. * Invert Y-Axis of referenced textures on load
  79972. */
  79973. InvertTextureY: boolean;
  79974. /**
  79975. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  79976. */
  79977. ImportVertexColors: boolean;
  79978. /**
  79979. * Compute the normals for the model, even if normals are present in the file.
  79980. */
  79981. ComputeNormals: boolean;
  79982. /**
  79983. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  79984. */
  79985. SkipMaterials: boolean;
  79986. /**
  79987. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  79988. */
  79989. MaterialLoadingFailsSilently: boolean;
  79990. };
  79991. /**
  79992. * OBJ file type loader.
  79993. * This is a babylon scene loader plugin.
  79994. */
  79995. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79996. /**
  79997. * Defines if UVs are optimized by default during load.
  79998. */
  79999. static OPTIMIZE_WITH_UV: boolean;
  80000. /**
  80001. * Invert model on y-axis (does a model scaling inversion)
  80002. */
  80003. static INVERT_Y: boolean;
  80004. /**
  80005. * Invert Y-Axis of referenced textures on load
  80006. */
  80007. static get INVERT_TEXTURE_Y(): boolean;
  80008. static set INVERT_TEXTURE_Y(value: boolean);
  80009. /**
  80010. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80011. */
  80012. static IMPORT_VERTEX_COLORS: boolean;
  80013. /**
  80014. * Compute the normals for the model, even if normals are present in the file.
  80015. */
  80016. static COMPUTE_NORMALS: boolean;
  80017. /**
  80018. * Defines custom scaling of UV coordinates of loaded meshes.
  80019. */
  80020. static UV_SCALING: Vector2;
  80021. /**
  80022. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80023. */
  80024. static SKIP_MATERIALS: boolean;
  80025. /**
  80026. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80027. *
  80028. * Defaults to true for backwards compatibility.
  80029. */
  80030. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  80031. /**
  80032. * Defines the name of the plugin.
  80033. */
  80034. name: string;
  80035. /**
  80036. * Defines the extension the plugin is able to load.
  80037. */
  80038. extensions: string;
  80039. /** @hidden */
  80040. obj: RegExp;
  80041. /** @hidden */
  80042. group: RegExp;
  80043. /** @hidden */
  80044. mtllib: RegExp;
  80045. /** @hidden */
  80046. usemtl: RegExp;
  80047. /** @hidden */
  80048. smooth: RegExp;
  80049. /** @hidden */
  80050. vertexPattern: RegExp;
  80051. /** @hidden */
  80052. normalPattern: RegExp;
  80053. /** @hidden */
  80054. uvPattern: RegExp;
  80055. /** @hidden */
  80056. facePattern1: RegExp;
  80057. /** @hidden */
  80058. facePattern2: RegExp;
  80059. /** @hidden */
  80060. facePattern3: RegExp;
  80061. /** @hidden */
  80062. facePattern4: RegExp;
  80063. /** @hidden */
  80064. facePattern5: RegExp;
  80065. private _forAssetContainer;
  80066. private _meshLoadOptions;
  80067. /**
  80068. * Creates loader for .OBJ files
  80069. *
  80070. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  80071. */
  80072. constructor(meshLoadOptions?: MeshLoadOptions);
  80073. private static get currentMeshLoadOptions();
  80074. /**
  80075. * Calls synchronously the MTL file attached to this obj.
  80076. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  80077. * Without this function materials are not displayed in the first frame (but displayed after).
  80078. * In consequence it is impossible to get material information in your HTML file
  80079. *
  80080. * @param url The URL of the MTL file
  80081. * @param rootUrl
  80082. * @param onSuccess Callback function to be called when the MTL file is loaded
  80083. * @private
  80084. */
  80085. private _loadMTL;
  80086. /**
  80087. * Instantiates a OBJ file loader plugin.
  80088. * @returns the created plugin
  80089. */
  80090. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  80091. /**
  80092. * If the data string can be loaded directly.
  80093. *
  80094. * @param data string containing the file data
  80095. * @returns if the data can be loaded directly
  80096. */
  80097. canDirectLoad(data: string): boolean;
  80098. /**
  80099. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  80100. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80101. * @param scene the scene the meshes should be added to
  80102. * @param data the OBJ data to load
  80103. * @param rootUrl root url to load from
  80104. * @param onProgress event that fires when loading progress has occured
  80105. * @param fileName Defines the name of the file to load
  80106. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80107. */
  80108. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80109. meshes: AbstractMesh[];
  80110. particleSystems: IParticleSystem[];
  80111. skeletons: Skeleton[];
  80112. animationGroups: AnimationGroup[];
  80113. }>;
  80114. /**
  80115. * Imports all objects from the loaded OBJ data and adds them to the scene
  80116. * @param scene the scene the objects should be added to
  80117. * @param data the OBJ data to load
  80118. * @param rootUrl root url to load from
  80119. * @param onProgress event that fires when loading progress has occured
  80120. * @param fileName Defines the name of the file to load
  80121. * @returns a promise which completes when objects have been loaded to the scene
  80122. */
  80123. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80124. /**
  80125. * Load into an asset container.
  80126. * @param scene The scene to load into
  80127. * @param data The data to import
  80128. * @param rootUrl The root url for scene and resources
  80129. * @param onProgress The callback when the load progresses
  80130. * @param fileName Defines the name of the file to load
  80131. * @returns The loaded asset container
  80132. */
  80133. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80134. /**
  80135. * Read the OBJ file and create an Array of meshes.
  80136. * Each mesh contains all information given by the OBJ and the MTL file.
  80137. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  80138. *
  80139. * @param meshesNames
  80140. * @param scene Scene The scene where are displayed the data
  80141. * @param data String The content of the obj file
  80142. * @param rootUrl String The path to the folder
  80143. * @returns Array<AbstractMesh>
  80144. * @private
  80145. */
  80146. private _parseSolid;
  80147. }
  80148. }
  80149. declare module BABYLON {
  80150. /**
  80151. * STL file type loader.
  80152. * This is a babylon scene loader plugin.
  80153. */
  80154. export class STLFileLoader implements ISceneLoaderPlugin {
  80155. /** @hidden */
  80156. solidPattern: RegExp;
  80157. /** @hidden */
  80158. facetsPattern: RegExp;
  80159. /** @hidden */
  80160. normalPattern: RegExp;
  80161. /** @hidden */
  80162. vertexPattern: RegExp;
  80163. /**
  80164. * Defines the name of the plugin.
  80165. */
  80166. name: string;
  80167. /**
  80168. * Defines the extensions the stl loader is able to load.
  80169. * force data to come in as an ArrayBuffer
  80170. * we'll convert to string if it looks like it's an ASCII .stl
  80171. */
  80172. extensions: ISceneLoaderPluginExtensions;
  80173. /**
  80174. * Import meshes into a scene.
  80175. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  80176. * @param scene The scene to import into
  80177. * @param data The data to import
  80178. * @param rootUrl The root url for scene and resources
  80179. * @param meshes The meshes array to import into
  80180. * @param particleSystems The particle systems array to import into
  80181. * @param skeletons The skeletons array to import into
  80182. * @param onError The callback when import fails
  80183. * @returns True if successful or false otherwise
  80184. */
  80185. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  80186. /**
  80187. * Load into a scene.
  80188. * @param scene The scene to load into
  80189. * @param data The data to import
  80190. * @param rootUrl The root url for scene and resources
  80191. * @param onError The callback when import fails
  80192. * @returns true if successful or false otherwise
  80193. */
  80194. load(scene: Scene, data: any, rootUrl: string): boolean;
  80195. /**
  80196. * Load into an asset container.
  80197. * @param scene The scene to load into
  80198. * @param data The data to import
  80199. * @param rootUrl The root url for scene and resources
  80200. * @param onError The callback when import fails
  80201. * @returns The loaded asset container
  80202. */
  80203. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  80204. private _isBinary;
  80205. private _parseBinary;
  80206. private _parseASCII;
  80207. }
  80208. }
  80209. declare module BABYLON {
  80210. /**
  80211. * Class for generating OBJ data from a Babylon scene.
  80212. */
  80213. export class OBJExport {
  80214. /**
  80215. * Exports the geometry of a Mesh array in .OBJ file format (text)
  80216. * @param mesh defines the list of meshes to serialize
  80217. * @param materials defines if materials should be exported
  80218. * @param matlibname defines the name of the associated mtl file
  80219. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  80220. * @returns the OBJ content
  80221. */
  80222. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  80223. /**
  80224. * Exports the material(s) of a mesh in .MTL file format (text)
  80225. * @param mesh defines the mesh to extract the material from
  80226. * @returns the mtl content
  80227. */
  80228. static MTL(mesh: Mesh): string;
  80229. }
  80230. }
  80231. declare module BABYLON {
  80232. /** @hidden */
  80233. export var __IGLTFExporterExtension: number;
  80234. /**
  80235. * Interface for extending the exporter
  80236. * @hidden
  80237. */
  80238. export interface IGLTFExporterExtension {
  80239. /**
  80240. * The name of this extension
  80241. */
  80242. readonly name: string;
  80243. /**
  80244. * Defines whether this extension is enabled
  80245. */
  80246. enabled: boolean;
  80247. /**
  80248. * Defines whether this extension is required
  80249. */
  80250. required: boolean;
  80251. }
  80252. }
  80253. declare module BABYLON.GLTF2.Exporter {
  80254. /** @hidden */
  80255. export var __IGLTFExporterExtensionV2: number;
  80256. /**
  80257. * Interface for a glTF exporter extension
  80258. * @hidden
  80259. */
  80260. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  80261. /**
  80262. * Define this method to modify the default behavior before exporting a texture
  80263. * @param context The context when loading the asset
  80264. * @param babylonTexture The Babylon.js texture
  80265. * @param mimeType The mime-type of the generated image
  80266. * @returns A promise that resolves with the exported texture
  80267. */
  80268. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  80269. /**
  80270. * Define this method to get notified when a texture info is created
  80271. * @param context The context when loading the asset
  80272. * @param textureInfo The glTF texture info
  80273. * @param babylonTexture The Babylon.js texture
  80274. */
  80275. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80276. /**
  80277. * Define this method to modify the default behavior when exporting texture info
  80278. * @param context The context when loading the asset
  80279. * @param meshPrimitive glTF mesh primitive
  80280. * @param babylonSubMesh Babylon submesh
  80281. * @param binaryWriter glTF serializer binary writer instance
  80282. * @returns nullable IMeshPrimitive promise
  80283. */
  80284. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  80285. /**
  80286. * Define this method to modify the default behavior when exporting a node
  80287. * @param context The context when exporting the node
  80288. * @param node glTF node
  80289. * @param babylonNode BabylonJS node
  80290. * @returns nullable INode promise
  80291. */
  80292. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80293. [key: number]: number;
  80294. }): Promise<Nullable<INode>>;
  80295. /**
  80296. * Define this method to modify the default behavior when exporting a material
  80297. * @param material glTF material
  80298. * @param babylonMaterial BabylonJS material
  80299. * @returns nullable IMaterial promise
  80300. */
  80301. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  80302. /**
  80303. * Define this method to return additional textures to export from a material
  80304. * @param material glTF material
  80305. * @param babylonMaterial BabylonJS material
  80306. * @returns List of textures
  80307. */
  80308. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80309. /** Gets a boolean indicating that this extension was used */
  80310. wasUsed: boolean;
  80311. /** Gets a boolean indicating that this extension is required for the file to work */
  80312. required: boolean;
  80313. /**
  80314. * Called after the exporter state changes to EXPORTING
  80315. */
  80316. onExporting?(): void;
  80317. }
  80318. }
  80319. declare module BABYLON.GLTF2.Exporter {
  80320. /**
  80321. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  80322. * @hidden
  80323. */
  80324. export class _GLTFMaterialExporter {
  80325. /**
  80326. * Represents the dielectric specular values for R, G and B
  80327. */
  80328. private static readonly _DielectricSpecular;
  80329. /**
  80330. * Allows the maximum specular power to be defined for material calculations
  80331. */
  80332. private static readonly _MaxSpecularPower;
  80333. /**
  80334. * Mapping to store textures
  80335. */
  80336. private _textureMap;
  80337. /**
  80338. * Numeric tolerance value
  80339. */
  80340. private static readonly _Epsilon;
  80341. /**
  80342. * Reference to the glTF Exporter
  80343. */
  80344. private _exporter;
  80345. constructor(exporter: _Exporter);
  80346. /**
  80347. * Specifies if two colors are approximately equal in value
  80348. * @param color1 first color to compare to
  80349. * @param color2 second color to compare to
  80350. * @param epsilon threshold value
  80351. */
  80352. private static FuzzyEquals;
  80353. /**
  80354. * Gets the materials from a Babylon scene and converts them to glTF materials
  80355. * @param scene babylonjs scene
  80356. * @param mimeType texture mime type
  80357. * @param images array of images
  80358. * @param textures array of textures
  80359. * @param materials array of materials
  80360. * @param imageData mapping of texture names to base64 textures
  80361. * @param hasTextureCoords specifies if texture coordinates are present on the material
  80362. */
  80363. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  80364. /**
  80365. * Makes a copy of the glTF material without the texture parameters
  80366. * @param originalMaterial original glTF material
  80367. * @returns glTF material without texture parameters
  80368. */
  80369. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  80370. /**
  80371. * Specifies if the material has any texture parameters present
  80372. * @param material glTF Material
  80373. * @returns boolean specifying if texture parameters are present
  80374. */
  80375. _hasTexturesPresent(material: IMaterial): boolean;
  80376. /**
  80377. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  80378. * @param babylonStandardMaterial
  80379. * @returns glTF Metallic Roughness Material representation
  80380. */
  80381. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  80382. /**
  80383. * Computes the metallic factor
  80384. * @param diffuse diffused value
  80385. * @param specular specular value
  80386. * @param oneMinusSpecularStrength one minus the specular strength
  80387. * @returns metallic value
  80388. */
  80389. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  80390. /**
  80391. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  80392. * @param glTFMaterial glTF material
  80393. * @param babylonMaterial Babylon material
  80394. */
  80395. private static _SetAlphaMode;
  80396. /**
  80397. * Converts a Babylon Standard Material to a glTF Material
  80398. * @param babylonStandardMaterial BJS Standard Material
  80399. * @param mimeType mime type to use for the textures
  80400. * @param images array of glTF image interfaces
  80401. * @param textures array of glTF texture interfaces
  80402. * @param materials array of glTF material interfaces
  80403. * @param imageData map of image file name to data
  80404. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80405. */
  80406. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80407. private _finishMaterial;
  80408. /**
  80409. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80410. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  80411. * @param mimeType mime type to use for the textures
  80412. * @param images array of glTF image interfaces
  80413. * @param textures array of glTF texture interfaces
  80414. * @param materials array of glTF material interfaces
  80415. * @param imageData map of image file name to data
  80416. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80417. */
  80418. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80419. /**
  80420. * Converts an image typed array buffer to a base64 image
  80421. * @param buffer typed array buffer
  80422. * @param width width of the image
  80423. * @param height height of the image
  80424. * @param mimeType mimetype of the image
  80425. * @returns base64 image string
  80426. */
  80427. private _createBase64FromCanvasAsync;
  80428. /**
  80429. * Generates a white texture based on the specified width and height
  80430. * @param width width of the texture in pixels
  80431. * @param height height of the texture in pixels
  80432. * @param scene babylonjs scene
  80433. * @returns white texture
  80434. */
  80435. private _createWhiteTexture;
  80436. /**
  80437. * 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
  80438. * @param texture1 first texture to resize
  80439. * @param texture2 second texture to resize
  80440. * @param scene babylonjs scene
  80441. * @returns resized textures or null
  80442. */
  80443. private _resizeTexturesToSameDimensions;
  80444. /**
  80445. * Converts an array of pixels to a Float32Array
  80446. * Throws an error if the pixel format is not supported
  80447. * @param pixels - array buffer containing pixel values
  80448. * @returns Float32 of pixels
  80449. */
  80450. private _convertPixelArrayToFloat32;
  80451. /**
  80452. * Convert Specular Glossiness Textures to Metallic Roughness
  80453. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  80454. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  80455. * @param diffuseTexture texture used to store diffuse information
  80456. * @param specularGlossinessTexture texture used to store specular and glossiness information
  80457. * @param factors specular glossiness material factors
  80458. * @param mimeType the mime type to use for the texture
  80459. * @returns pbr metallic roughness interface or null
  80460. */
  80461. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  80462. /**
  80463. * Converts specular glossiness material properties to metallic roughness
  80464. * @param specularGlossiness interface with specular glossiness material properties
  80465. * @returns interface with metallic roughness material properties
  80466. */
  80467. private _convertSpecularGlossinessToMetallicRoughness;
  80468. /**
  80469. * Calculates the surface reflectance, independent of lighting conditions
  80470. * @param color Color source to calculate brightness from
  80471. * @returns number representing the perceived brightness, or zero if color is undefined
  80472. */
  80473. private _getPerceivedBrightness;
  80474. /**
  80475. * Returns the maximum color component value
  80476. * @param color
  80477. * @returns maximum color component value, or zero if color is null or undefined
  80478. */
  80479. private _getMaxComponent;
  80480. /**
  80481. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  80482. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80483. * @param mimeType mime type to use for the textures
  80484. * @param images array of glTF image interfaces
  80485. * @param textures array of glTF texture interfaces
  80486. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80487. * @param imageData map of image file name to data
  80488. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80489. * @returns glTF PBR Metallic Roughness factors
  80490. */
  80491. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  80492. private _getGLTFTextureSampler;
  80493. private _getGLTFTextureWrapMode;
  80494. private _getGLTFTextureWrapModesSampler;
  80495. /**
  80496. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  80497. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80498. * @param mimeType mime type to use for the textures
  80499. * @param images array of glTF image interfaces
  80500. * @param textures array of glTF texture interfaces
  80501. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80502. * @param imageData map of image file name to data
  80503. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80504. * @returns glTF PBR Metallic Roughness factors
  80505. */
  80506. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  80507. /**
  80508. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80509. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80510. * @param mimeType mime type to use for the textures
  80511. * @param images array of glTF image interfaces
  80512. * @param textures array of glTF texture interfaces
  80513. * @param materials array of glTF material interfaces
  80514. * @param imageData map of image file name to data
  80515. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80516. */
  80517. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80518. private setMetallicRoughnessPbrMaterial;
  80519. private getPixelsFromTexture;
  80520. /**
  80521. * Extracts a texture from a Babylon texture into file data and glTF data
  80522. * @param babylonTexture Babylon texture to extract
  80523. * @param mimeType Mime Type of the babylonTexture
  80524. * @return glTF texture info, or null if the texture format is not supported
  80525. */
  80526. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80527. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80528. /**
  80529. * Builds a texture from base64 string
  80530. * @param base64Texture base64 texture string
  80531. * @param baseTextureName Name to use for the texture
  80532. * @param mimeType image mime type for the texture
  80533. * @param images array of images
  80534. * @param textures array of textures
  80535. * @param imageData map of image data
  80536. * @returns glTF texture info, or null if the texture format is not supported
  80537. */
  80538. private _getTextureInfoFromBase64;
  80539. }
  80540. }
  80541. declare module BABYLON {
  80542. /**
  80543. * Class for holding and downloading glTF file data
  80544. */
  80545. export class GLTFData {
  80546. /**
  80547. * Object which contains the file name as the key and its data as the value
  80548. */
  80549. glTFFiles: {
  80550. [fileName: string]: string | Blob;
  80551. };
  80552. /**
  80553. * Initializes the glTF file object
  80554. */
  80555. constructor();
  80556. /**
  80557. * Downloads the glTF data as files based on their names and data
  80558. */
  80559. downloadFiles(): void;
  80560. }
  80561. }
  80562. declare module BABYLON {
  80563. /**
  80564. * Holds a collection of exporter options and parameters
  80565. */
  80566. export interface IExportOptions {
  80567. /**
  80568. * Function which indicates whether a babylon node should be exported or not
  80569. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  80570. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  80571. */
  80572. shouldExportNode?(node: Node): boolean;
  80573. /**
  80574. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  80575. * @param metadata source metadata to read from
  80576. * @returns the data to store to glTF node extras
  80577. */
  80578. metadataSelector?(metadata: any): any;
  80579. /**
  80580. * The sample rate to bake animation curves
  80581. */
  80582. animationSampleRate?: number;
  80583. /**
  80584. * Begin serialization without waiting for the scene to be ready
  80585. */
  80586. exportWithoutWaitingForScene?: boolean;
  80587. /**
  80588. * Indicates if coordinate system swapping root nodes should be included in export
  80589. */
  80590. includeCoordinateSystemConversionNodes?: boolean;
  80591. }
  80592. /**
  80593. * Class for generating glTF data from a Babylon scene.
  80594. */
  80595. export class GLTF2Export {
  80596. /**
  80597. * Exports the geometry of the scene to .gltf file format asynchronously
  80598. * @param scene Babylon scene with scene hierarchy information
  80599. * @param filePrefix File prefix to use when generating the glTF file
  80600. * @param options Exporter options
  80601. * @returns Returns an object with a .gltf file and associates texture names
  80602. * as keys and their data and paths as values
  80603. */
  80604. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  80605. private static _PreExportAsync;
  80606. private static _PostExportAsync;
  80607. /**
  80608. * Exports the geometry of the scene to .glb file format asychronously
  80609. * @param scene Babylon scene with scene hierarchy information
  80610. * @param filePrefix File prefix to use when generating glb file
  80611. * @param options Exporter options
  80612. * @returns Returns an object with a .glb filename as key and data as value
  80613. */
  80614. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  80615. }
  80616. }
  80617. declare module BABYLON.GLTF2.Exporter {
  80618. /**
  80619. * @hidden
  80620. */
  80621. export class _GLTFUtilities {
  80622. /**
  80623. * Creates a buffer view based on the supplied arguments
  80624. * @param bufferIndex index value of the specified buffer
  80625. * @param byteOffset byte offset value
  80626. * @param byteLength byte length of the bufferView
  80627. * @param byteStride byte distance between conequential elements
  80628. * @param name name of the buffer view
  80629. * @returns bufferView for glTF
  80630. */
  80631. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  80632. /**
  80633. * Creates an accessor based on the supplied arguments
  80634. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  80635. * @param name The name of the accessor
  80636. * @param type The type of the accessor
  80637. * @param componentType The datatype of components in the attribute
  80638. * @param count The number of attributes referenced by this accessor
  80639. * @param byteOffset The offset relative to the start of the bufferView in bytes
  80640. * @param min Minimum value of each component in this attribute
  80641. * @param max Maximum value of each component in this attribute
  80642. * @returns accessor for glTF
  80643. */
  80644. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  80645. /**
  80646. * Calculates the minimum and maximum values of an array of position floats
  80647. * @param positions Positions array of a mesh
  80648. * @param vertexStart Starting vertex offset to calculate min and max values
  80649. * @param vertexCount Number of vertices to check for min and max values
  80650. * @returns min number array and max number array
  80651. */
  80652. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  80653. min: number[];
  80654. max: number[];
  80655. };
  80656. /**
  80657. * Converts a new right-handed Vector3
  80658. * @param vector vector3 array
  80659. * @returns right-handed Vector3
  80660. */
  80661. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  80662. /**
  80663. * Converts a Vector3 to right-handed
  80664. * @param vector Vector3 to convert to right-handed
  80665. */
  80666. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  80667. /**
  80668. * Converts a three element number array to right-handed
  80669. * @param vector number array to convert to right-handed
  80670. */
  80671. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  80672. /**
  80673. * Converts a new right-handed Vector3
  80674. * @param vector vector3 array
  80675. * @returns right-handed Vector3
  80676. */
  80677. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  80678. /**
  80679. * Converts a Vector3 to right-handed
  80680. * @param vector Vector3 to convert to right-handed
  80681. */
  80682. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  80683. /**
  80684. * Converts a three element number array to right-handed
  80685. * @param vector number array to convert to right-handed
  80686. */
  80687. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  80688. /**
  80689. * Converts a Vector4 to right-handed
  80690. * @param vector Vector4 to convert to right-handed
  80691. */
  80692. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  80693. /**
  80694. * Converts a Vector4 to right-handed
  80695. * @param vector Vector4 to convert to right-handed
  80696. */
  80697. static _GetRightHandedArray4FromRef(vector: number[]): void;
  80698. /**
  80699. * Converts a Quaternion to right-handed
  80700. * @param quaternion Source quaternion to convert to right-handed
  80701. */
  80702. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  80703. /**
  80704. * Converts a Quaternion to right-handed
  80705. * @param quaternion Source quaternion to convert to right-handed
  80706. */
  80707. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  80708. static _NormalizeTangentFromRef(tangent: Vector4): void;
  80709. }
  80710. }
  80711. declare module BABYLON.GLTF2.Exporter {
  80712. /**
  80713. * Converts Babylon Scene into glTF 2.0.
  80714. * @hidden
  80715. */
  80716. export class _Exporter {
  80717. /**
  80718. * Stores the glTF to export
  80719. */
  80720. _glTF: IGLTF;
  80721. /**
  80722. * Stores all generated buffer views, which represents views into the main glTF buffer data
  80723. */
  80724. _bufferViews: IBufferView[];
  80725. /**
  80726. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  80727. */
  80728. _accessors: IAccessor[];
  80729. /**
  80730. * Stores all the generated nodes, which contains transform and/or mesh information per node
  80731. */
  80732. _nodes: INode[];
  80733. /**
  80734. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  80735. */
  80736. private _scenes;
  80737. /**
  80738. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  80739. */
  80740. private _meshes;
  80741. /**
  80742. * Stores all the generated material information, which represents the appearance of each primitive
  80743. */
  80744. _materials: IMaterial[];
  80745. _materialMap: {
  80746. [materialID: number]: number;
  80747. };
  80748. /**
  80749. * Stores all the generated texture information, which is referenced by glTF materials
  80750. */
  80751. _textures: ITexture[];
  80752. /**
  80753. * Stores all the generated image information, which is referenced by glTF textures
  80754. */
  80755. _images: IImage[];
  80756. /**
  80757. * Stores all the texture samplers
  80758. */
  80759. _samplers: ISampler[];
  80760. /**
  80761. * Stores all the generated animation samplers, which is referenced by glTF animations
  80762. */
  80763. /**
  80764. * Stores the animations for glTF models
  80765. */
  80766. private _animations;
  80767. /**
  80768. * Stores the total amount of bytes stored in the glTF buffer
  80769. */
  80770. private _totalByteLength;
  80771. /**
  80772. * Stores a reference to the Babylon scene containing the source geometry and material information
  80773. */
  80774. _babylonScene: Scene;
  80775. /**
  80776. * Stores a map of the image data, where the key is the file name and the value
  80777. * is the image data
  80778. */
  80779. _imageData: {
  80780. [fileName: string]: {
  80781. data: Uint8Array;
  80782. mimeType: ImageMimeType;
  80783. };
  80784. };
  80785. /**
  80786. * Stores a map of the unique id of a node to its index in the node array
  80787. */
  80788. _nodeMap: {
  80789. [key: number]: number;
  80790. };
  80791. /**
  80792. * Specifies if the source Babylon scene was left handed, and needed conversion.
  80793. */
  80794. _convertToRightHandedSystem: boolean;
  80795. /**
  80796. * Specifies if a Babylon node should be converted to right-handed on export
  80797. */
  80798. _convertToRightHandedSystemMap: {
  80799. [nodeId: number]: boolean;
  80800. };
  80801. _includeCoordinateSystemConversionNodes: boolean;
  80802. /**
  80803. * Baked animation sample rate
  80804. */
  80805. private _animationSampleRate;
  80806. private _options;
  80807. private _localEngine;
  80808. _glTFMaterialExporter: _GLTFMaterialExporter;
  80809. private _extensions;
  80810. private static _ExtensionNames;
  80811. private static _ExtensionFactories;
  80812. private _applyExtension;
  80813. private _applyExtensions;
  80814. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  80815. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  80816. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80817. [key: number]: number;
  80818. }): Promise<Nullable<INode>>;
  80819. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  80820. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  80821. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80822. private _forEachExtensions;
  80823. private _extensionsOnExporting;
  80824. /**
  80825. * Load glTF serializer extensions
  80826. */
  80827. private _loadExtensions;
  80828. /**
  80829. * Creates a glTF Exporter instance, which can accept optional exporter options
  80830. * @param babylonScene Babylon scene object
  80831. * @param options Options to modify the behavior of the exporter
  80832. */
  80833. constructor(babylonScene: Scene, options?: IExportOptions);
  80834. dispose(): void;
  80835. /**
  80836. * Registers a glTF exporter extension
  80837. * @param name Name of the extension to export
  80838. * @param factory The factory function that creates the exporter extension
  80839. */
  80840. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  80841. /**
  80842. * Un-registers an exporter extension
  80843. * @param name The name fo the exporter extension
  80844. * @returns A boolean indicating whether the extension has been un-registered
  80845. */
  80846. static UnregisterExtension(name: string): boolean;
  80847. /**
  80848. * Lazy load a local engine
  80849. */
  80850. _getLocalEngine(): Engine;
  80851. private reorderIndicesBasedOnPrimitiveMode;
  80852. /**
  80853. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  80854. * clock-wise during export to glTF
  80855. * @param submesh BabylonJS submesh
  80856. * @param primitiveMode Primitive mode of the mesh
  80857. * @param sideOrientation the winding order of the submesh
  80858. * @param vertexBufferKind The type of vertex attribute
  80859. * @param meshAttributeArray The vertex attribute data
  80860. * @param byteOffset The offset to the binary data
  80861. * @param binaryWriter The binary data for the glTF file
  80862. * @param convertToRightHandedSystem Converts the values to right-handed
  80863. */
  80864. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  80865. /**
  80866. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  80867. * clock-wise during export to glTF
  80868. * @param submesh BabylonJS submesh
  80869. * @param primitiveMode Primitive mode of the mesh
  80870. * @param sideOrientation the winding order of the submesh
  80871. * @param vertexBufferKind The type of vertex attribute
  80872. * @param meshAttributeArray The vertex attribute data
  80873. * @param byteOffset The offset to the binary data
  80874. * @param binaryWriter The binary data for the glTF file
  80875. * @param convertToRightHandedSystem Converts the values to right-handed
  80876. */
  80877. private reorderTriangleFillMode;
  80878. /**
  80879. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  80880. * clock-wise during export to glTF
  80881. * @param submesh BabylonJS submesh
  80882. * @param primitiveMode Primitive mode of the mesh
  80883. * @param sideOrientation the winding order of the submesh
  80884. * @param vertexBufferKind The type of vertex attribute
  80885. * @param meshAttributeArray The vertex attribute data
  80886. * @param byteOffset The offset to the binary data
  80887. * @param binaryWriter The binary data for the glTF file
  80888. * @param convertToRightHandedSystem Converts the values to right-handed
  80889. */
  80890. private reorderTriangleStripDrawMode;
  80891. /**
  80892. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  80893. * clock-wise during export to glTF
  80894. * @param submesh BabylonJS submesh
  80895. * @param primitiveMode Primitive mode of the mesh
  80896. * @param sideOrientation the winding order of the submesh
  80897. * @param vertexBufferKind The type of vertex attribute
  80898. * @param meshAttributeArray The vertex attribute data
  80899. * @param byteOffset The offset to the binary data
  80900. * @param binaryWriter The binary data for the glTF file
  80901. * @param convertToRightHandedSystem Converts the values to right-handed
  80902. */
  80903. private reorderTriangleFanMode;
  80904. /**
  80905. * Writes the vertex attribute data to binary
  80906. * @param vertices The vertices to write to the binary writer
  80907. * @param byteOffset The offset into the binary writer to overwrite binary data
  80908. * @param vertexAttributeKind The vertex attribute type
  80909. * @param meshAttributeArray The vertex attribute data
  80910. * @param binaryWriter The writer containing the binary data
  80911. * @param convertToRightHandedSystem Converts the values to right-handed
  80912. */
  80913. private writeVertexAttributeData;
  80914. /**
  80915. * Writes mesh attribute data to a data buffer
  80916. * Returns the bytelength of the data
  80917. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  80918. * @param meshAttributeArray Array containing the attribute data
  80919. * @param binaryWriter The buffer to write the binary data to
  80920. * @param indices Used to specify the order of the vertex data
  80921. * @param convertToRightHandedSystem Converts the values to right-handed
  80922. */
  80923. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  80924. /**
  80925. * Generates glTF json data
  80926. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  80927. * @param glTFPrefix Text to use when prefixing a glTF file
  80928. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  80929. * @returns json data as string
  80930. */
  80931. private generateJSON;
  80932. /**
  80933. * Generates data for .gltf and .bin files based on the glTF prefix string
  80934. * @param glTFPrefix Text to use when prefixing a glTF file
  80935. * @param dispose Dispose the exporter
  80936. * @returns GLTFData with glTF file data
  80937. */
  80938. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  80939. /**
  80940. * Creates a binary buffer for glTF
  80941. * @returns array buffer for binary data
  80942. */
  80943. private _generateBinaryAsync;
  80944. /**
  80945. * Pads the number to a multiple of 4
  80946. * @param num number to pad
  80947. * @returns padded number
  80948. */
  80949. private _getPadding;
  80950. /**
  80951. * @hidden
  80952. */
  80953. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  80954. /**
  80955. * Sets the TRS for each node
  80956. * @param node glTF Node for storing the transformation data
  80957. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  80958. * @param convertToRightHandedSystem Converts the values to right-handed
  80959. */
  80960. private setNodeTransformation;
  80961. private getVertexBufferFromMesh;
  80962. /**
  80963. * Creates a bufferview based on the vertices type for the Babylon mesh
  80964. * @param kind Indicates the type of vertices data
  80965. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  80966. * @param binaryWriter The buffer to write the bufferview data to
  80967. * @param convertToRightHandedSystem Converts the values to right-handed
  80968. */
  80969. private createBufferViewKind;
  80970. /**
  80971. * The primitive mode of the Babylon mesh
  80972. * @param babylonMesh The BabylonJS mesh
  80973. */
  80974. private getMeshPrimitiveMode;
  80975. /**
  80976. * Sets the primitive mode of the glTF mesh primitive
  80977. * @param meshPrimitive glTF mesh primitive
  80978. * @param primitiveMode The primitive mode
  80979. */
  80980. private setPrimitiveMode;
  80981. /**
  80982. * Sets the vertex attribute accessor based of the glTF mesh primitive
  80983. * @param meshPrimitive glTF mesh primitive
  80984. * @param attributeKind vertex attribute
  80985. * @returns boolean specifying if uv coordinates are present
  80986. */
  80987. private setAttributeKind;
  80988. /**
  80989. * Sets data for the primitive attributes of each submesh
  80990. * @param mesh glTF Mesh object to store the primitive attribute information
  80991. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  80992. * @param binaryWriter Buffer to write the attribute data to
  80993. * @param convertToRightHandedSystem Converts the values to right-handed
  80994. */
  80995. private setPrimitiveAttributesAsync;
  80996. /**
  80997. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  80998. * @param node The node to check
  80999. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  81000. */
  81001. private isBabylonCoordinateSystemConvertingNode;
  81002. /**
  81003. * Creates a glTF scene based on the array of meshes
  81004. * Returns the the total byte offset
  81005. * @param babylonScene Babylon scene to get the mesh data from
  81006. * @param binaryWriter Buffer to write binary data to
  81007. */
  81008. private createSceneAsync;
  81009. /**
  81010. * Creates a mapping of Node unique id to node index and handles animations
  81011. * @param babylonScene Babylon Scene
  81012. * @param nodes Babylon transform nodes
  81013. * @param binaryWriter Buffer to write binary data to
  81014. * @returns Node mapping of unique id to index
  81015. */
  81016. private createNodeMapAndAnimationsAsync;
  81017. /**
  81018. * Creates a glTF node from a Babylon mesh
  81019. * @param babylonMesh Source Babylon mesh
  81020. * @param binaryWriter Buffer for storing geometry data
  81021. * @param convertToRightHandedSystem Converts the values to right-handed
  81022. * @param nodeMap Node mapping of unique id to glTF node index
  81023. * @returns glTF node
  81024. */
  81025. private createNodeAsync;
  81026. }
  81027. /**
  81028. * @hidden
  81029. *
  81030. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  81031. */
  81032. export class _BinaryWriter {
  81033. /**
  81034. * Array buffer which stores all binary data
  81035. */
  81036. private _arrayBuffer;
  81037. /**
  81038. * View of the array buffer
  81039. */
  81040. private _dataView;
  81041. /**
  81042. * byte offset of data in array buffer
  81043. */
  81044. private _byteOffset;
  81045. /**
  81046. * Initialize binary writer with an initial byte length
  81047. * @param byteLength Initial byte length of the array buffer
  81048. */
  81049. constructor(byteLength: number);
  81050. /**
  81051. * Resize the array buffer to the specified byte length
  81052. * @param byteLength
  81053. */
  81054. private resizeBuffer;
  81055. /**
  81056. * Get an array buffer with the length of the byte offset
  81057. * @returns ArrayBuffer resized to the byte offset
  81058. */
  81059. getArrayBuffer(): ArrayBuffer;
  81060. /**
  81061. * Get the byte offset of the array buffer
  81062. * @returns byte offset
  81063. */
  81064. getByteOffset(): number;
  81065. /**
  81066. * Stores an UInt8 in the array buffer
  81067. * @param entry
  81068. * @param byteOffset If defined, specifies where to set the value as an offset.
  81069. */
  81070. setUInt8(entry: number, byteOffset?: number): void;
  81071. /**
  81072. * Gets an UInt32 in the array buffer
  81073. * @param entry
  81074. * @param byteOffset If defined, specifies where to set the value as an offset.
  81075. */
  81076. getUInt32(byteOffset: number): number;
  81077. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81078. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81079. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81080. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81081. /**
  81082. * Stores a Float32 in the array buffer
  81083. * @param entry
  81084. */
  81085. setFloat32(entry: number, byteOffset?: number): void;
  81086. /**
  81087. * Stores an UInt32 in the array buffer
  81088. * @param entry
  81089. * @param byteOffset If defined, specifies where to set the value as an offset.
  81090. */
  81091. setUInt32(entry: number, byteOffset?: number): void;
  81092. }
  81093. }
  81094. declare module BABYLON.GLTF2.Exporter {
  81095. /**
  81096. * @hidden
  81097. * Interface to store animation data.
  81098. */
  81099. export interface _IAnimationData {
  81100. /**
  81101. * Keyframe data.
  81102. */
  81103. inputs: number[];
  81104. /**
  81105. * Value data.
  81106. */
  81107. outputs: number[][];
  81108. /**
  81109. * Animation interpolation data.
  81110. */
  81111. samplerInterpolation: AnimationSamplerInterpolation;
  81112. /**
  81113. * Minimum keyframe value.
  81114. */
  81115. inputsMin: number;
  81116. /**
  81117. * Maximum keyframe value.
  81118. */
  81119. inputsMax: number;
  81120. }
  81121. /**
  81122. * @hidden
  81123. */
  81124. export interface _IAnimationInfo {
  81125. /**
  81126. * The target channel for the animation
  81127. */
  81128. animationChannelTargetPath: AnimationChannelTargetPath;
  81129. /**
  81130. * The glTF accessor type for the data.
  81131. */
  81132. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  81133. /**
  81134. * Specifies if quaternions should be used.
  81135. */
  81136. useQuaternion: boolean;
  81137. }
  81138. /**
  81139. * @hidden
  81140. * Utility class for generating glTF animation data from BabylonJS.
  81141. */
  81142. export class _GLTFAnimation {
  81143. /**
  81144. * @ignore
  81145. *
  81146. * Creates glTF channel animation from BabylonJS animation.
  81147. * @param babylonTransformNode - BabylonJS mesh.
  81148. * @param animation - animation.
  81149. * @param animationChannelTargetPath - The target animation channel.
  81150. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  81151. * @param useQuaternion - Specifies if quaternions are used.
  81152. * @returns nullable IAnimationData
  81153. */
  81154. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  81155. private static _DeduceAnimationInfo;
  81156. /**
  81157. * @ignore
  81158. * Create node animations from the transform node animations
  81159. * @param babylonNode
  81160. * @param runtimeGLTFAnimation
  81161. * @param idleGLTFAnimations
  81162. * @param nodeMap
  81163. * @param nodes
  81164. * @param binaryWriter
  81165. * @param bufferViews
  81166. * @param accessors
  81167. * @param convertToRightHandedSystem
  81168. * @param animationSampleRate
  81169. */
  81170. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  81171. [key: number]: number;
  81172. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  81173. /**
  81174. * @ignore
  81175. * Create node animations from the animation groups
  81176. * @param babylonScene
  81177. * @param glTFAnimations
  81178. * @param nodeMap
  81179. * @param nodes
  81180. * @param binaryWriter
  81181. * @param bufferViews
  81182. * @param accessors
  81183. * @param convertToRightHandedSystemMap
  81184. * @param animationSampleRate
  81185. */
  81186. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  81187. [key: number]: number;
  81188. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  81189. [nodeId: number]: boolean;
  81190. }, animationSampleRate: number): void;
  81191. private static AddAnimation;
  81192. /**
  81193. * Create a baked animation
  81194. * @param babylonTransformNode BabylonJS mesh
  81195. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  81196. * @param animationChannelTargetPath animation target channel
  81197. * @param minFrame minimum animation frame
  81198. * @param maxFrame maximum animation frame
  81199. * @param fps frames per second of the animation
  81200. * @param inputs input key frames of the animation
  81201. * @param outputs output key frame data of the animation
  81202. * @param convertToRightHandedSystem converts the values to right-handed
  81203. * @param useQuaternion specifies if quaternions should be used
  81204. */
  81205. private static _CreateBakedAnimation;
  81206. private static _ConvertFactorToVector3OrQuaternion;
  81207. private static _SetInterpolatedValue;
  81208. /**
  81209. * Creates linear animation from the animation key frames
  81210. * @param babylonTransformNode BabylonJS mesh
  81211. * @param animation BabylonJS animation
  81212. * @param animationChannelTargetPath The target animation channel
  81213. * @param frameDelta The difference between the last and first frame of the animation
  81214. * @param inputs Array to store the key frame times
  81215. * @param outputs Array to store the key frame data
  81216. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81217. * @param useQuaternion Specifies if quaternions are used in the animation
  81218. */
  81219. private static _CreateLinearOrStepAnimation;
  81220. /**
  81221. * Creates cubic spline animation from the animation key frames
  81222. * @param babylonTransformNode BabylonJS mesh
  81223. * @param animation BabylonJS animation
  81224. * @param animationChannelTargetPath The target animation channel
  81225. * @param frameDelta The difference between the last and first frame of the animation
  81226. * @param inputs Array to store the key frame times
  81227. * @param outputs Array to store the key frame data
  81228. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81229. * @param useQuaternion Specifies if quaternions are used in the animation
  81230. */
  81231. private static _CreateCubicSplineAnimation;
  81232. private static _GetBasePositionRotationOrScale;
  81233. /**
  81234. * Adds a key frame value
  81235. * @param keyFrame
  81236. * @param animation
  81237. * @param outputs
  81238. * @param animationChannelTargetPath
  81239. * @param basePositionRotationOrScale
  81240. * @param convertToRightHandedSystem
  81241. * @param useQuaternion
  81242. */
  81243. private static _AddKeyframeValue;
  81244. /**
  81245. * Determine the interpolation based on the key frames
  81246. * @param keyFrames
  81247. * @param animationChannelTargetPath
  81248. * @param useQuaternion
  81249. */
  81250. private static _DeduceInterpolation;
  81251. /**
  81252. * Adds an input tangent or output tangent to the output data
  81253. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  81254. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  81255. * @param outputs The animation data by keyframe
  81256. * @param animationChannelTargetPath The target animation channel
  81257. * @param interpolation The interpolation type
  81258. * @param keyFrame The key frame with the animation data
  81259. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  81260. * @param useQuaternion Specifies if quaternions are used
  81261. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  81262. */
  81263. private static AddSplineTangent;
  81264. /**
  81265. * Get the minimum and maximum key frames' frame values
  81266. * @param keyFrames animation key frames
  81267. * @returns the minimum and maximum key frame value
  81268. */
  81269. private static calculateMinMaxKeyFrames;
  81270. }
  81271. }
  81272. declare module BABYLON.GLTF2.Exporter {
  81273. /** @hidden */
  81274. export var textureTransformPixelShader: {
  81275. name: string;
  81276. shader: string;
  81277. };
  81278. }
  81279. declare module BABYLON.GLTF2.Exporter.Extensions {
  81280. /**
  81281. * @hidden
  81282. */
  81283. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  81284. private _recordedTextures;
  81285. /** Name of this extension */
  81286. readonly name: string;
  81287. /** Defines whether this extension is enabled */
  81288. enabled: boolean;
  81289. /** Defines whether this extension is required */
  81290. required: boolean;
  81291. /** Reference to the glTF exporter */
  81292. private _wasUsed;
  81293. constructor(exporter: _Exporter);
  81294. dispose(): void;
  81295. /** @hidden */
  81296. get wasUsed(): boolean;
  81297. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81298. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  81299. /**
  81300. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  81301. * @param babylonTexture
  81302. * @param offset
  81303. * @param rotation
  81304. * @param scale
  81305. * @param scene
  81306. */
  81307. private _textureTransformTextureAsync;
  81308. }
  81309. }
  81310. declare module BABYLON.GLTF2.Exporter.Extensions {
  81311. /**
  81312. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  81313. */
  81314. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  81315. /** The name of this extension. */
  81316. readonly name: string;
  81317. /** Defines whether this extension is enabled. */
  81318. enabled: boolean;
  81319. /** Defines whether this extension is required */
  81320. required: boolean;
  81321. /** Reference to the glTF exporter */
  81322. private _exporter;
  81323. private _lights;
  81324. /** @hidden */
  81325. constructor(exporter: _Exporter);
  81326. /** @hidden */
  81327. dispose(): void;
  81328. /** @hidden */
  81329. get wasUsed(): boolean;
  81330. /** @hidden */
  81331. onExporting(): void;
  81332. /**
  81333. * Define this method to modify the default behavior when exporting a node
  81334. * @param context The context when exporting the node
  81335. * @param node glTF node
  81336. * @param babylonNode BabylonJS node
  81337. * @param nodeMap Node mapping of unique id to glTF node index
  81338. * @returns nullable INode promise
  81339. */
  81340. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81341. [key: number]: number;
  81342. }): Promise<Nullable<INode>>;
  81343. }
  81344. }
  81345. declare module BABYLON.GLTF2.Exporter.Extensions {
  81346. /**
  81347. * @hidden
  81348. */
  81349. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  81350. /** Name of this extension */
  81351. readonly name: string;
  81352. /** Defines whether this extension is enabled */
  81353. enabled: boolean;
  81354. /** Defines whether this extension is required */
  81355. required: boolean;
  81356. /** Reference to the glTF exporter */
  81357. private _textureInfos;
  81358. private _exportedTextures;
  81359. private _wasUsed;
  81360. constructor(exporter: _Exporter);
  81361. dispose(): void;
  81362. /** @hidden */
  81363. get wasUsed(): boolean;
  81364. private _getTextureIndex;
  81365. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81366. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81367. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  81368. }
  81369. }
  81370. declare module BABYLON {
  81371. /**
  81372. * Class for generating STL data from a Babylon scene.
  81373. */
  81374. export class STLExport {
  81375. /**
  81376. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  81377. * @param meshes list defines the mesh to serialize
  81378. * @param download triggers the automatic download of the file.
  81379. * @param fileName changes the downloads fileName.
  81380. * @param binary changes the STL to a binary type.
  81381. * @param isLittleEndian toggle for binary type exporter.
  81382. * @returns the STL as UTF8 string
  81383. */
  81384. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  81385. }
  81386. }
  81387. declare module "babylonjs-gltf2interface" {
  81388. export = BABYLON.GLTF2;
  81389. }
  81390. /**
  81391. * Module for glTF 2.0 Interface
  81392. */
  81393. declare module BABYLON.GLTF2 {
  81394. /**
  81395. * The datatype of the components in the attribute
  81396. */
  81397. const enum AccessorComponentType {
  81398. /**
  81399. * Byte
  81400. */
  81401. BYTE = 5120,
  81402. /**
  81403. * Unsigned Byte
  81404. */
  81405. UNSIGNED_BYTE = 5121,
  81406. /**
  81407. * Short
  81408. */
  81409. SHORT = 5122,
  81410. /**
  81411. * Unsigned Short
  81412. */
  81413. UNSIGNED_SHORT = 5123,
  81414. /**
  81415. * Unsigned Int
  81416. */
  81417. UNSIGNED_INT = 5125,
  81418. /**
  81419. * Float
  81420. */
  81421. FLOAT = 5126,
  81422. }
  81423. /**
  81424. * Specifies if the attirbute is a scalar, vector, or matrix
  81425. */
  81426. const enum AccessorType {
  81427. /**
  81428. * Scalar
  81429. */
  81430. SCALAR = "SCALAR",
  81431. /**
  81432. * Vector2
  81433. */
  81434. VEC2 = "VEC2",
  81435. /**
  81436. * Vector3
  81437. */
  81438. VEC3 = "VEC3",
  81439. /**
  81440. * Vector4
  81441. */
  81442. VEC4 = "VEC4",
  81443. /**
  81444. * Matrix2x2
  81445. */
  81446. MAT2 = "MAT2",
  81447. /**
  81448. * Matrix3x3
  81449. */
  81450. MAT3 = "MAT3",
  81451. /**
  81452. * Matrix4x4
  81453. */
  81454. MAT4 = "MAT4",
  81455. }
  81456. /**
  81457. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81458. */
  81459. const enum AnimationChannelTargetPath {
  81460. /**
  81461. * Translation
  81462. */
  81463. TRANSLATION = "translation",
  81464. /**
  81465. * Rotation
  81466. */
  81467. ROTATION = "rotation",
  81468. /**
  81469. * Scale
  81470. */
  81471. SCALE = "scale",
  81472. /**
  81473. * Weights
  81474. */
  81475. WEIGHTS = "weights",
  81476. }
  81477. /**
  81478. * Interpolation algorithm
  81479. */
  81480. const enum AnimationSamplerInterpolation {
  81481. /**
  81482. * The animated values are linearly interpolated between keyframes
  81483. */
  81484. LINEAR = "LINEAR",
  81485. /**
  81486. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  81487. */
  81488. STEP = "STEP",
  81489. /**
  81490. * The animation's interpolation is computed using a cubic spline with specified tangents
  81491. */
  81492. CUBICSPLINE = "CUBICSPLINE",
  81493. }
  81494. /**
  81495. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81496. */
  81497. const enum CameraType {
  81498. /**
  81499. * A perspective camera containing properties to create a perspective projection matrix
  81500. */
  81501. PERSPECTIVE = "perspective",
  81502. /**
  81503. * An orthographic camera containing properties to create an orthographic projection matrix
  81504. */
  81505. ORTHOGRAPHIC = "orthographic",
  81506. }
  81507. /**
  81508. * The mime-type of the image
  81509. */
  81510. const enum ImageMimeType {
  81511. /**
  81512. * JPEG Mime-type
  81513. */
  81514. JPEG = "image/jpeg",
  81515. /**
  81516. * PNG Mime-type
  81517. */
  81518. PNG = "image/png",
  81519. }
  81520. /**
  81521. * The alpha rendering mode of the material
  81522. */
  81523. const enum MaterialAlphaMode {
  81524. /**
  81525. * The alpha value is ignored and the rendered output is fully opaque
  81526. */
  81527. OPAQUE = "OPAQUE",
  81528. /**
  81529. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  81530. */
  81531. MASK = "MASK",
  81532. /**
  81533. * 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)
  81534. */
  81535. BLEND = "BLEND",
  81536. }
  81537. /**
  81538. * The type of the primitives to render
  81539. */
  81540. const enum MeshPrimitiveMode {
  81541. /**
  81542. * Points
  81543. */
  81544. POINTS = 0,
  81545. /**
  81546. * Lines
  81547. */
  81548. LINES = 1,
  81549. /**
  81550. * Line Loop
  81551. */
  81552. LINE_LOOP = 2,
  81553. /**
  81554. * Line Strip
  81555. */
  81556. LINE_STRIP = 3,
  81557. /**
  81558. * Triangles
  81559. */
  81560. TRIANGLES = 4,
  81561. /**
  81562. * Triangle Strip
  81563. */
  81564. TRIANGLE_STRIP = 5,
  81565. /**
  81566. * Triangle Fan
  81567. */
  81568. TRIANGLE_FAN = 6,
  81569. }
  81570. /**
  81571. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  81572. */
  81573. const enum TextureMagFilter {
  81574. /**
  81575. * Nearest
  81576. */
  81577. NEAREST = 9728,
  81578. /**
  81579. * Linear
  81580. */
  81581. LINEAR = 9729,
  81582. }
  81583. /**
  81584. * Minification filter. All valid values correspond to WebGL enums
  81585. */
  81586. const enum TextureMinFilter {
  81587. /**
  81588. * Nearest
  81589. */
  81590. NEAREST = 9728,
  81591. /**
  81592. * Linear
  81593. */
  81594. LINEAR = 9729,
  81595. /**
  81596. * Nearest Mip-Map Nearest
  81597. */
  81598. NEAREST_MIPMAP_NEAREST = 9984,
  81599. /**
  81600. * Linear Mipmap Nearest
  81601. */
  81602. LINEAR_MIPMAP_NEAREST = 9985,
  81603. /**
  81604. * Nearest Mipmap Linear
  81605. */
  81606. NEAREST_MIPMAP_LINEAR = 9986,
  81607. /**
  81608. * Linear Mipmap Linear
  81609. */
  81610. LINEAR_MIPMAP_LINEAR = 9987,
  81611. }
  81612. /**
  81613. * S (U) wrapping mode. All valid values correspond to WebGL enums
  81614. */
  81615. const enum TextureWrapMode {
  81616. /**
  81617. * Clamp to Edge
  81618. */
  81619. CLAMP_TO_EDGE = 33071,
  81620. /**
  81621. * Mirrored Repeat
  81622. */
  81623. MIRRORED_REPEAT = 33648,
  81624. /**
  81625. * Repeat
  81626. */
  81627. REPEAT = 10497,
  81628. }
  81629. /**
  81630. * glTF Property
  81631. */
  81632. interface IProperty {
  81633. /**
  81634. * Dictionary object with extension-specific objects
  81635. */
  81636. extensions?: {
  81637. [key: string]: any;
  81638. };
  81639. /**
  81640. * Application-Specific data
  81641. */
  81642. extras?: any;
  81643. }
  81644. /**
  81645. * glTF Child of Root Property
  81646. */
  81647. interface IChildRootProperty extends IProperty {
  81648. /**
  81649. * The user-defined name of this object
  81650. */
  81651. name?: string;
  81652. }
  81653. /**
  81654. * Indices of those attributes that deviate from their initialization value
  81655. */
  81656. interface IAccessorSparseIndices extends IProperty {
  81657. /**
  81658. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81659. */
  81660. bufferView: number;
  81661. /**
  81662. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81663. */
  81664. byteOffset?: number;
  81665. /**
  81666. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  81667. */
  81668. componentType: AccessorComponentType;
  81669. }
  81670. /**
  81671. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  81672. */
  81673. interface IAccessorSparseValues extends IProperty {
  81674. /**
  81675. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81676. */
  81677. bufferView: number;
  81678. /**
  81679. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81680. */
  81681. byteOffset?: number;
  81682. }
  81683. /**
  81684. * Sparse storage of attributes that deviate from their initialization value
  81685. */
  81686. interface IAccessorSparse extends IProperty {
  81687. /**
  81688. * The number of attributes encoded in this sparse accessor
  81689. */
  81690. count: number;
  81691. /**
  81692. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  81693. */
  81694. indices: IAccessorSparseIndices;
  81695. /**
  81696. * 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
  81697. */
  81698. values: IAccessorSparseValues;
  81699. }
  81700. /**
  81701. * 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
  81702. */
  81703. interface IAccessor extends IChildRootProperty {
  81704. /**
  81705. * The index of the bufferview
  81706. */
  81707. bufferView?: number;
  81708. /**
  81709. * The offset relative to the start of the bufferView in bytes
  81710. */
  81711. byteOffset?: number;
  81712. /**
  81713. * The datatype of components in the attribute
  81714. */
  81715. componentType: AccessorComponentType;
  81716. /**
  81717. * Specifies whether integer data values should be normalized
  81718. */
  81719. normalized?: boolean;
  81720. /**
  81721. * The number of attributes referenced by this accessor
  81722. */
  81723. count: number;
  81724. /**
  81725. * Specifies if the attribute is a scalar, vector, or matrix
  81726. */
  81727. type: AccessorType;
  81728. /**
  81729. * Maximum value of each component in this attribute
  81730. */
  81731. max?: number[];
  81732. /**
  81733. * Minimum value of each component in this attribute
  81734. */
  81735. min?: number[];
  81736. /**
  81737. * Sparse storage of attributes that deviate from their initialization value
  81738. */
  81739. sparse?: IAccessorSparse;
  81740. }
  81741. /**
  81742. * Targets an animation's sampler at a node's property
  81743. */
  81744. interface IAnimationChannel extends IProperty {
  81745. /**
  81746. * The index of a sampler in this animation used to compute the value for the target
  81747. */
  81748. sampler: number;
  81749. /**
  81750. * The index of the node and TRS property to target
  81751. */
  81752. target: IAnimationChannelTarget;
  81753. }
  81754. /**
  81755. * The index of the node and TRS property that an animation channel targets
  81756. */
  81757. interface IAnimationChannelTarget extends IProperty {
  81758. /**
  81759. * The index of the node to target
  81760. */
  81761. node: number;
  81762. /**
  81763. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81764. */
  81765. path: AnimationChannelTargetPath;
  81766. }
  81767. /**
  81768. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81769. */
  81770. interface IAnimationSampler extends IProperty {
  81771. /**
  81772. * The index of an accessor containing keyframe input values, e.g., time
  81773. */
  81774. input: number;
  81775. /**
  81776. * Interpolation algorithm
  81777. */
  81778. interpolation?: AnimationSamplerInterpolation;
  81779. /**
  81780. * The index of an accessor, containing keyframe output values
  81781. */
  81782. output: number;
  81783. }
  81784. /**
  81785. * A keyframe animation
  81786. */
  81787. interface IAnimation extends IChildRootProperty {
  81788. /**
  81789. * An array of channels, each of which targets an animation's sampler at a node's property
  81790. */
  81791. channels: IAnimationChannel[];
  81792. /**
  81793. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81794. */
  81795. samplers: IAnimationSampler[];
  81796. }
  81797. /**
  81798. * Metadata about the glTF asset
  81799. */
  81800. interface IAsset extends IChildRootProperty {
  81801. /**
  81802. * A copyright message suitable for display to credit the content creator
  81803. */
  81804. copyright?: string;
  81805. /**
  81806. * Tool that generated this glTF model. Useful for debugging
  81807. */
  81808. generator?: string;
  81809. /**
  81810. * The glTF version that this asset targets
  81811. */
  81812. version: string;
  81813. /**
  81814. * The minimum glTF version that this asset targets
  81815. */
  81816. minVersion?: string;
  81817. }
  81818. /**
  81819. * A buffer points to binary geometry, animation, or skins
  81820. */
  81821. interface IBuffer extends IChildRootProperty {
  81822. /**
  81823. * 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
  81824. */
  81825. uri?: string;
  81826. /**
  81827. * The length of the buffer in bytes
  81828. */
  81829. byteLength: number;
  81830. }
  81831. /**
  81832. * A view into a buffer generally representing a subset of the buffer
  81833. */
  81834. interface IBufferView extends IChildRootProperty {
  81835. /**
  81836. * The index of the buffer
  81837. */
  81838. buffer: number;
  81839. /**
  81840. * The offset into the buffer in bytes
  81841. */
  81842. byteOffset?: number;
  81843. /**
  81844. * The lenth of the bufferView in bytes
  81845. */
  81846. byteLength: number;
  81847. /**
  81848. * The stride, in bytes
  81849. */
  81850. byteStride?: number;
  81851. }
  81852. /**
  81853. * An orthographic camera containing properties to create an orthographic projection matrix
  81854. */
  81855. interface ICameraOrthographic extends IProperty {
  81856. /**
  81857. * The floating-point horizontal magnification of the view. Must not be zero
  81858. */
  81859. xmag: number;
  81860. /**
  81861. * The floating-point vertical magnification of the view. Must not be zero
  81862. */
  81863. ymag: number;
  81864. /**
  81865. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  81866. */
  81867. zfar: number;
  81868. /**
  81869. * The floating-point distance to the near clipping plane
  81870. */
  81871. znear: number;
  81872. }
  81873. /**
  81874. * A perspective camera containing properties to create a perspective projection matrix
  81875. */
  81876. interface ICameraPerspective extends IProperty {
  81877. /**
  81878. * The floating-point aspect ratio of the field of view
  81879. */
  81880. aspectRatio?: number;
  81881. /**
  81882. * The floating-point vertical field of view in radians
  81883. */
  81884. yfov: number;
  81885. /**
  81886. * The floating-point distance to the far clipping plane
  81887. */
  81888. zfar?: number;
  81889. /**
  81890. * The floating-point distance to the near clipping plane
  81891. */
  81892. znear: number;
  81893. }
  81894. /**
  81895. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81896. */
  81897. interface ICamera extends IChildRootProperty {
  81898. /**
  81899. * An orthographic camera containing properties to create an orthographic projection matrix
  81900. */
  81901. orthographic?: ICameraOrthographic;
  81902. /**
  81903. * A perspective camera containing properties to create a perspective projection matrix
  81904. */
  81905. perspective?: ICameraPerspective;
  81906. /**
  81907. * Specifies if the camera uses a perspective or orthographic projection
  81908. */
  81909. type: CameraType;
  81910. }
  81911. /**
  81912. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  81913. */
  81914. interface IImage extends IChildRootProperty {
  81915. /**
  81916. * 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
  81917. */
  81918. uri?: string;
  81919. /**
  81920. * The image's MIME type
  81921. */
  81922. mimeType?: ImageMimeType;
  81923. /**
  81924. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  81925. */
  81926. bufferView?: number;
  81927. }
  81928. /**
  81929. * Material Normal Texture Info
  81930. */
  81931. interface IMaterialNormalTextureInfo extends ITextureInfo {
  81932. /**
  81933. * The scalar multiplier applied to each normal vector of the normal texture
  81934. */
  81935. scale?: number;
  81936. }
  81937. /**
  81938. * Material Occlusion Texture Info
  81939. */
  81940. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  81941. /**
  81942. * A scalar multiplier controlling the amount of occlusion applied
  81943. */
  81944. strength?: number;
  81945. }
  81946. /**
  81947. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  81948. */
  81949. interface IMaterialPbrMetallicRoughness {
  81950. /**
  81951. * The material's base color factor
  81952. */
  81953. baseColorFactor?: number[];
  81954. /**
  81955. * The base color texture
  81956. */
  81957. baseColorTexture?: ITextureInfo;
  81958. /**
  81959. * The metalness of the material
  81960. */
  81961. metallicFactor?: number;
  81962. /**
  81963. * The roughness of the material
  81964. */
  81965. roughnessFactor?: number;
  81966. /**
  81967. * The metallic-roughness texture
  81968. */
  81969. metallicRoughnessTexture?: ITextureInfo;
  81970. }
  81971. /**
  81972. * The material appearance of a primitive
  81973. */
  81974. interface IMaterial extends IChildRootProperty {
  81975. /**
  81976. * 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
  81977. */
  81978. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81979. /**
  81980. * The normal map texture
  81981. */
  81982. normalTexture?: IMaterialNormalTextureInfo;
  81983. /**
  81984. * The occlusion map texture
  81985. */
  81986. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81987. /**
  81988. * The emissive map texture
  81989. */
  81990. emissiveTexture?: ITextureInfo;
  81991. /**
  81992. * 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
  81993. */
  81994. emissiveFactor?: number[];
  81995. /**
  81996. * The alpha rendering mode of the material
  81997. */
  81998. alphaMode?: MaterialAlphaMode;
  81999. /**
  82000. * The alpha cutoff value of the material
  82001. */
  82002. alphaCutoff?: number;
  82003. /**
  82004. * Specifies whether the material is double sided
  82005. */
  82006. doubleSided?: boolean;
  82007. }
  82008. /**
  82009. * Geometry to be rendered with the given material
  82010. */
  82011. interface IMeshPrimitive extends IProperty {
  82012. /**
  82013. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  82014. */
  82015. attributes: {
  82016. [name: string]: number;
  82017. };
  82018. /**
  82019. * The index of the accessor that contains the indices
  82020. */
  82021. indices?: number;
  82022. /**
  82023. * The index of the material to apply to this primitive when rendering
  82024. */
  82025. material?: number;
  82026. /**
  82027. * The type of primitives to render. All valid values correspond to WebGL enums
  82028. */
  82029. mode?: MeshPrimitiveMode;
  82030. /**
  82031. * 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
  82032. */
  82033. targets?: {
  82034. [name: string]: number;
  82035. }[];
  82036. }
  82037. /**
  82038. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  82039. */
  82040. interface IMesh extends IChildRootProperty {
  82041. /**
  82042. * An array of primitives, each defining geometry to be rendered with a material
  82043. */
  82044. primitives: IMeshPrimitive[];
  82045. /**
  82046. * Array of weights to be applied to the Morph Targets
  82047. */
  82048. weights?: number[];
  82049. }
  82050. /**
  82051. * A node in the node hierarchy
  82052. */
  82053. interface INode extends IChildRootProperty {
  82054. /**
  82055. * The index of the camera referenced by this node
  82056. */
  82057. camera?: number;
  82058. /**
  82059. * The indices of this node's children
  82060. */
  82061. children?: number[];
  82062. /**
  82063. * The index of the skin referenced by this node
  82064. */
  82065. skin?: number;
  82066. /**
  82067. * A floating-point 4x4 transformation matrix stored in column-major order
  82068. */
  82069. matrix?: number[];
  82070. /**
  82071. * The index of the mesh in this node
  82072. */
  82073. mesh?: number;
  82074. /**
  82075. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  82076. */
  82077. rotation?: number[];
  82078. /**
  82079. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  82080. */
  82081. scale?: number[];
  82082. /**
  82083. * The node's translation along the x, y, and z axes
  82084. */
  82085. translation?: number[];
  82086. /**
  82087. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  82088. */
  82089. weights?: number[];
  82090. }
  82091. /**
  82092. * Texture sampler properties for filtering and wrapping modes
  82093. */
  82094. interface ISampler extends IChildRootProperty {
  82095. /**
  82096. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82097. */
  82098. magFilter?: TextureMagFilter;
  82099. /**
  82100. * Minification filter. All valid values correspond to WebGL enums
  82101. */
  82102. minFilter?: TextureMinFilter;
  82103. /**
  82104. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82105. */
  82106. wrapS?: TextureWrapMode;
  82107. /**
  82108. * T (V) wrapping mode. All valid values correspond to WebGL enums
  82109. */
  82110. wrapT?: TextureWrapMode;
  82111. }
  82112. /**
  82113. * The root nodes of a scene
  82114. */
  82115. interface IScene extends IChildRootProperty {
  82116. /**
  82117. * The indices of each root node
  82118. */
  82119. nodes: number[];
  82120. }
  82121. /**
  82122. * Joints and matrices defining a skin
  82123. */
  82124. interface ISkin extends IChildRootProperty {
  82125. /**
  82126. * 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
  82127. */
  82128. inverseBindMatrices?: number;
  82129. /**
  82130. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  82131. */
  82132. skeleton?: number;
  82133. /**
  82134. * 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)
  82135. */
  82136. joints: number[];
  82137. }
  82138. /**
  82139. * A texture and its sampler
  82140. */
  82141. interface ITexture extends IChildRootProperty {
  82142. /**
  82143. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  82144. */
  82145. sampler?: number;
  82146. /**
  82147. * The index of the image used by this texture
  82148. */
  82149. source: number;
  82150. }
  82151. /**
  82152. * Reference to a texture
  82153. */
  82154. interface ITextureInfo extends IProperty {
  82155. /**
  82156. * The index of the texture
  82157. */
  82158. index: number;
  82159. /**
  82160. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  82161. */
  82162. texCoord?: number;
  82163. }
  82164. /**
  82165. * The root object for a glTF asset
  82166. */
  82167. interface IGLTF extends IProperty {
  82168. /**
  82169. * An array of accessors. An accessor is a typed view into a bufferView
  82170. */
  82171. accessors?: IAccessor[];
  82172. /**
  82173. * An array of keyframe animations
  82174. */
  82175. animations?: IAnimation[];
  82176. /**
  82177. * Metadata about the glTF asset
  82178. */
  82179. asset: IAsset;
  82180. /**
  82181. * An array of buffers. A buffer points to binary geometry, animation, or skins
  82182. */
  82183. buffers?: IBuffer[];
  82184. /**
  82185. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  82186. */
  82187. bufferViews?: IBufferView[];
  82188. /**
  82189. * An array of cameras
  82190. */
  82191. cameras?: ICamera[];
  82192. /**
  82193. * Names of glTF extensions used somewhere in this asset
  82194. */
  82195. extensionsUsed?: string[];
  82196. /**
  82197. * Names of glTF extensions required to properly load this asset
  82198. */
  82199. extensionsRequired?: string[];
  82200. /**
  82201. * An array of images. An image defines data used to create a texture
  82202. */
  82203. images?: IImage[];
  82204. /**
  82205. * An array of materials. A material defines the appearance of a primitive
  82206. */
  82207. materials?: IMaterial[];
  82208. /**
  82209. * An array of meshes. A mesh is a set of primitives to be rendered
  82210. */
  82211. meshes?: IMesh[];
  82212. /**
  82213. * An array of nodes
  82214. */
  82215. nodes?: INode[];
  82216. /**
  82217. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  82218. */
  82219. samplers?: ISampler[];
  82220. /**
  82221. * The index of the default scene
  82222. */
  82223. scene?: number;
  82224. /**
  82225. * An array of scenes
  82226. */
  82227. scenes?: IScene[];
  82228. /**
  82229. * An array of skins. A skin is defined by joints and matrices
  82230. */
  82231. skins?: ISkin[];
  82232. /**
  82233. * An array of textures
  82234. */
  82235. textures?: ITexture[];
  82236. }
  82237. /**
  82238. * The glTF validation results
  82239. * @ignore
  82240. */
  82241. interface IGLTFValidationResults {
  82242. info: {
  82243. generator: string;
  82244. hasAnimations: boolean;
  82245. hasDefaultScene: boolean;
  82246. hasMaterials: boolean;
  82247. hasMorphTargets: boolean;
  82248. hasSkins: boolean;
  82249. hasTextures: boolean;
  82250. maxAttributesUsed: number;
  82251. primitivesCount: number
  82252. };
  82253. issues: {
  82254. messages: Array<string>;
  82255. numErrors: number;
  82256. numHints: number;
  82257. numInfos: number;
  82258. numWarnings: number;
  82259. truncated: boolean
  82260. };
  82261. mimeType: string;
  82262. uri: string;
  82263. validatedAt: string;
  82264. validatorVersion: string;
  82265. }
  82266. /**
  82267. * The glTF validation options
  82268. */
  82269. interface IGLTFValidationOptions {
  82270. /** Uri to use */
  82271. uri?: string;
  82272. /** Function used to load external resources */
  82273. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  82274. /** Boolean indicating that we need to validate accessor data */
  82275. validateAccessorData?: boolean;
  82276. /** max number of issues allowed */
  82277. maxIssues?: number;
  82278. /** Ignored issues */
  82279. ignoredIssues?: Array<string>;
  82280. /** Value to override severy settings */
  82281. severityOverrides?: Object;
  82282. }
  82283. /**
  82284. * The glTF validator object
  82285. * @ignore
  82286. */
  82287. interface IGLTFValidator {
  82288. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82289. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82290. }
  82291. }
  82292. declare module BABYLON {
  82293. /** @hidden */
  82294. export var cellPixelShader: {
  82295. name: string;
  82296. shader: string;
  82297. };
  82298. }
  82299. declare module BABYLON {
  82300. /** @hidden */
  82301. export var cellVertexShader: {
  82302. name: string;
  82303. shader: string;
  82304. };
  82305. }
  82306. declare module BABYLON {
  82307. export class CellMaterial extends BABYLON.PushMaterial {
  82308. private _diffuseTexture;
  82309. diffuseTexture: BABYLON.BaseTexture;
  82310. diffuseColor: BABYLON.Color3;
  82311. _computeHighLevel: boolean;
  82312. computeHighLevel: boolean;
  82313. private _disableLighting;
  82314. disableLighting: boolean;
  82315. private _maxSimultaneousLights;
  82316. maxSimultaneousLights: number;
  82317. constructor(name: string, scene: BABYLON.Scene);
  82318. needAlphaBlending(): boolean;
  82319. needAlphaTesting(): boolean;
  82320. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82321. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82322. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82323. getAnimatables(): BABYLON.IAnimatable[];
  82324. getActiveTextures(): BABYLON.BaseTexture[];
  82325. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82326. dispose(forceDisposeEffect?: boolean): void;
  82327. getClassName(): string;
  82328. clone(name: string): CellMaterial;
  82329. serialize(): any;
  82330. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  82331. }
  82332. }
  82333. declare module BABYLON {
  82334. export class CustomShaderStructure {
  82335. FragmentStore: string;
  82336. VertexStore: string;
  82337. constructor();
  82338. }
  82339. export class ShaderSpecialParts {
  82340. constructor();
  82341. Fragment_Begin: string;
  82342. Fragment_Definitions: string;
  82343. Fragment_MainBegin: string;
  82344. Fragment_Custom_Diffuse: string;
  82345. Fragment_Before_Lights: string;
  82346. Fragment_Before_Fog: string;
  82347. Fragment_Custom_Alpha: string;
  82348. Fragment_Before_FragColor: string;
  82349. Vertex_Begin: string;
  82350. Vertex_Definitions: string;
  82351. Vertex_MainBegin: string;
  82352. Vertex_Before_PositionUpdated: string;
  82353. Vertex_Before_NormalUpdated: string;
  82354. Vertex_After_WorldPosComputed: string;
  82355. Vertex_MainEnd: string;
  82356. }
  82357. export class CustomMaterial extends BABYLON.StandardMaterial {
  82358. static ShaderIndexer: number;
  82359. CustomParts: ShaderSpecialParts;
  82360. _isCreatedShader: boolean;
  82361. _createdShaderName: string;
  82362. _customUniform: string[];
  82363. _newUniforms: string[];
  82364. _newUniformInstances: {
  82365. [name: string]: any;
  82366. };
  82367. _newSamplerInstances: {
  82368. [name: string]: BABYLON.Texture;
  82369. };
  82370. _customAttributes: string[];
  82371. FragmentShader: string;
  82372. VertexShader: string;
  82373. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82374. ReviewUniform(name: string, arr: string[]): string[];
  82375. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82376. constructor(name: string, scene: BABYLON.Scene);
  82377. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  82378. AddAttribute(name: string): CustomMaterial;
  82379. Fragment_Begin(shaderPart: string): CustomMaterial;
  82380. Fragment_Definitions(shaderPart: string): CustomMaterial;
  82381. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  82382. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  82383. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  82384. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  82385. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  82386. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  82387. Vertex_Begin(shaderPart: string): CustomMaterial;
  82388. Vertex_Definitions(shaderPart: string): CustomMaterial;
  82389. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  82390. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  82391. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  82392. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  82393. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  82394. }
  82395. }
  82396. declare module BABYLON {
  82397. export class ShaderAlebdoParts {
  82398. constructor();
  82399. Fragment_Begin: string;
  82400. Fragment_Definitions: string;
  82401. Fragment_MainBegin: string;
  82402. Fragment_Custom_Albedo: string;
  82403. Fragment_Before_Lights: string;
  82404. Fragment_Custom_MetallicRoughness: string;
  82405. Fragment_Custom_MicroSurface: string;
  82406. Fragment_Before_Fog: string;
  82407. Fragment_Custom_Alpha: string;
  82408. Fragment_Before_FragColor: string;
  82409. Vertex_Begin: string;
  82410. Vertex_Definitions: string;
  82411. Vertex_MainBegin: string;
  82412. Vertex_Before_PositionUpdated: string;
  82413. Vertex_Before_NormalUpdated: string;
  82414. Vertex_After_WorldPosComputed: string;
  82415. Vertex_MainEnd: string;
  82416. }
  82417. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  82418. static ShaderIndexer: number;
  82419. CustomParts: ShaderAlebdoParts;
  82420. _isCreatedShader: boolean;
  82421. _createdShaderName: string;
  82422. _customUniform: string[];
  82423. _newUniforms: string[];
  82424. _newUniformInstances: {
  82425. [name: string]: any;
  82426. };
  82427. _newSamplerInstances: {
  82428. [name: string]: BABYLON.Texture;
  82429. };
  82430. _customAttributes: string[];
  82431. FragmentShader: string;
  82432. VertexShader: string;
  82433. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82434. ReviewUniform(name: string, arr: string[]): string[];
  82435. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82436. constructor(name: string, scene: BABYLON.Scene);
  82437. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  82438. AddAttribute(name: string): PBRCustomMaterial;
  82439. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  82440. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  82441. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  82442. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  82443. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  82444. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  82445. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  82446. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  82447. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  82448. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  82449. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  82450. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  82451. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  82452. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  82453. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  82454. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  82455. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  82456. }
  82457. }
  82458. declare module BABYLON {
  82459. /** @hidden */
  82460. export var firePixelShader: {
  82461. name: string;
  82462. shader: string;
  82463. };
  82464. }
  82465. declare module BABYLON {
  82466. /** @hidden */
  82467. export var fireVertexShader: {
  82468. name: string;
  82469. shader: string;
  82470. };
  82471. }
  82472. declare module BABYLON {
  82473. export class FireMaterial extends BABYLON.PushMaterial {
  82474. private _diffuseTexture;
  82475. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82476. private _distortionTexture;
  82477. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82478. private _opacityTexture;
  82479. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82480. diffuseColor: BABYLON.Color3;
  82481. speed: number;
  82482. private _scaledDiffuse;
  82483. private _lastTime;
  82484. constructor(name: string, scene: BABYLON.Scene);
  82485. needAlphaBlending(): boolean;
  82486. needAlphaTesting(): boolean;
  82487. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82488. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82489. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82490. getAnimatables(): BABYLON.IAnimatable[];
  82491. getActiveTextures(): BABYLON.BaseTexture[];
  82492. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82493. getClassName(): string;
  82494. dispose(forceDisposeEffect?: boolean): void;
  82495. clone(name: string): FireMaterial;
  82496. serialize(): any;
  82497. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  82498. }
  82499. }
  82500. declare module BABYLON {
  82501. /** @hidden */
  82502. export var furPixelShader: {
  82503. name: string;
  82504. shader: string;
  82505. };
  82506. }
  82507. declare module BABYLON {
  82508. /** @hidden */
  82509. export var furVertexShader: {
  82510. name: string;
  82511. shader: string;
  82512. };
  82513. }
  82514. declare module BABYLON {
  82515. export class FurMaterial extends BABYLON.PushMaterial {
  82516. private _diffuseTexture;
  82517. diffuseTexture: BABYLON.BaseTexture;
  82518. private _heightTexture;
  82519. heightTexture: BABYLON.BaseTexture;
  82520. diffuseColor: BABYLON.Color3;
  82521. furLength: number;
  82522. furAngle: number;
  82523. furColor: BABYLON.Color3;
  82524. furOffset: number;
  82525. furSpacing: number;
  82526. furGravity: BABYLON.Vector3;
  82527. furSpeed: number;
  82528. furDensity: number;
  82529. furOcclusion: number;
  82530. furTexture: BABYLON.DynamicTexture;
  82531. private _disableLighting;
  82532. disableLighting: boolean;
  82533. private _maxSimultaneousLights;
  82534. maxSimultaneousLights: number;
  82535. highLevelFur: boolean;
  82536. _meshes: BABYLON.AbstractMesh[];
  82537. private _furTime;
  82538. constructor(name: string, scene: BABYLON.Scene);
  82539. get furTime(): number;
  82540. set furTime(furTime: number);
  82541. needAlphaBlending(): boolean;
  82542. needAlphaTesting(): boolean;
  82543. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82544. updateFur(): void;
  82545. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82546. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82547. getAnimatables(): BABYLON.IAnimatable[];
  82548. getActiveTextures(): BABYLON.BaseTexture[];
  82549. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82550. dispose(forceDisposeEffect?: boolean): void;
  82551. clone(name: string): FurMaterial;
  82552. serialize(): any;
  82553. getClassName(): string;
  82554. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  82555. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  82556. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  82557. }
  82558. }
  82559. declare module BABYLON {
  82560. /** @hidden */
  82561. export var gradientPixelShader: {
  82562. name: string;
  82563. shader: string;
  82564. };
  82565. }
  82566. declare module BABYLON {
  82567. /** @hidden */
  82568. export var gradientVertexShader: {
  82569. name: string;
  82570. shader: string;
  82571. };
  82572. }
  82573. declare module BABYLON {
  82574. export class GradientMaterial extends BABYLON.PushMaterial {
  82575. private _maxSimultaneousLights;
  82576. maxSimultaneousLights: number;
  82577. topColor: BABYLON.Color3;
  82578. topColorAlpha: number;
  82579. bottomColor: BABYLON.Color3;
  82580. bottomColorAlpha: number;
  82581. offset: number;
  82582. scale: number;
  82583. smoothness: number;
  82584. private _disableLighting;
  82585. disableLighting: boolean;
  82586. constructor(name: string, scene: BABYLON.Scene);
  82587. needAlphaBlending(): boolean;
  82588. needAlphaTesting(): boolean;
  82589. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82590. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82591. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82592. getAnimatables(): BABYLON.IAnimatable[];
  82593. dispose(forceDisposeEffect?: boolean): void;
  82594. clone(name: string): GradientMaterial;
  82595. serialize(): any;
  82596. getClassName(): string;
  82597. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  82598. }
  82599. }
  82600. declare module BABYLON {
  82601. /** @hidden */
  82602. export var gridPixelShader: {
  82603. name: string;
  82604. shader: string;
  82605. };
  82606. }
  82607. declare module BABYLON {
  82608. /** @hidden */
  82609. export var gridVertexShader: {
  82610. name: string;
  82611. shader: string;
  82612. };
  82613. }
  82614. declare module BABYLON {
  82615. /**
  82616. * The grid materials allows you to wrap any shape with a grid.
  82617. * Colors are customizable.
  82618. */
  82619. export class GridMaterial extends BABYLON.PushMaterial {
  82620. /**
  82621. * Main color of the grid (e.g. between lines)
  82622. */
  82623. mainColor: BABYLON.Color3;
  82624. /**
  82625. * Color of the grid lines.
  82626. */
  82627. lineColor: BABYLON.Color3;
  82628. /**
  82629. * The scale of the grid compared to unit.
  82630. */
  82631. gridRatio: number;
  82632. /**
  82633. * Allows setting an offset for the grid lines.
  82634. */
  82635. gridOffset: BABYLON.Vector3;
  82636. /**
  82637. * The frequency of thicker lines.
  82638. */
  82639. majorUnitFrequency: number;
  82640. /**
  82641. * The visibility of minor units in the grid.
  82642. */
  82643. minorUnitVisibility: number;
  82644. /**
  82645. * The grid opacity outside of the lines.
  82646. */
  82647. opacity: number;
  82648. /**
  82649. * Determine RBG output is premultiplied by alpha value.
  82650. */
  82651. preMultiplyAlpha: boolean;
  82652. private _opacityTexture;
  82653. opacityTexture: BABYLON.BaseTexture;
  82654. private _gridControl;
  82655. /**
  82656. * constructor
  82657. * @param name The name given to the material in order to identify it afterwards.
  82658. * @param scene The scene the material is used in.
  82659. */
  82660. constructor(name: string, scene: BABYLON.Scene);
  82661. /**
  82662. * Returns wehter or not the grid requires alpha blending.
  82663. */
  82664. needAlphaBlending(): boolean;
  82665. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  82666. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82667. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82668. /**
  82669. * Dispose the material and its associated resources.
  82670. * @param forceDisposeEffect will also dispose the used effect when true
  82671. */
  82672. dispose(forceDisposeEffect?: boolean): void;
  82673. clone(name: string): GridMaterial;
  82674. serialize(): any;
  82675. getClassName(): string;
  82676. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  82677. }
  82678. }
  82679. declare module BABYLON {
  82680. /** @hidden */
  82681. export var lavaPixelShader: {
  82682. name: string;
  82683. shader: string;
  82684. };
  82685. }
  82686. declare module BABYLON {
  82687. /** @hidden */
  82688. export var lavaVertexShader: {
  82689. name: string;
  82690. shader: string;
  82691. };
  82692. }
  82693. declare module BABYLON {
  82694. export class LavaMaterial extends BABYLON.PushMaterial {
  82695. private _diffuseTexture;
  82696. diffuseTexture: BABYLON.BaseTexture;
  82697. noiseTexture: BABYLON.BaseTexture;
  82698. fogColor: BABYLON.Color3;
  82699. speed: number;
  82700. movingSpeed: number;
  82701. lowFrequencySpeed: number;
  82702. fogDensity: number;
  82703. private _lastTime;
  82704. diffuseColor: BABYLON.Color3;
  82705. private _disableLighting;
  82706. disableLighting: boolean;
  82707. private _unlit;
  82708. unlit: boolean;
  82709. private _maxSimultaneousLights;
  82710. maxSimultaneousLights: number;
  82711. private _scaledDiffuse;
  82712. constructor(name: string, scene: BABYLON.Scene);
  82713. needAlphaBlending(): boolean;
  82714. needAlphaTesting(): boolean;
  82715. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82716. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82717. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82718. getAnimatables(): BABYLON.IAnimatable[];
  82719. getActiveTextures(): BABYLON.BaseTexture[];
  82720. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82721. dispose(forceDisposeEffect?: boolean): void;
  82722. clone(name: string): LavaMaterial;
  82723. serialize(): any;
  82724. getClassName(): string;
  82725. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  82726. }
  82727. }
  82728. declare module BABYLON {
  82729. /** @hidden */
  82730. export var mixPixelShader: {
  82731. name: string;
  82732. shader: string;
  82733. };
  82734. }
  82735. declare module BABYLON {
  82736. /** @hidden */
  82737. export var mixVertexShader: {
  82738. name: string;
  82739. shader: string;
  82740. };
  82741. }
  82742. declare module BABYLON {
  82743. export class MixMaterial extends BABYLON.PushMaterial {
  82744. /**
  82745. * Mix textures
  82746. */
  82747. private _mixTexture1;
  82748. mixTexture1: BABYLON.BaseTexture;
  82749. private _mixTexture2;
  82750. mixTexture2: BABYLON.BaseTexture;
  82751. /**
  82752. * Diffuse textures
  82753. */
  82754. private _diffuseTexture1;
  82755. diffuseTexture1: BABYLON.Texture;
  82756. private _diffuseTexture2;
  82757. diffuseTexture2: BABYLON.Texture;
  82758. private _diffuseTexture3;
  82759. diffuseTexture3: BABYLON.Texture;
  82760. private _diffuseTexture4;
  82761. diffuseTexture4: BABYLON.Texture;
  82762. private _diffuseTexture5;
  82763. diffuseTexture5: BABYLON.Texture;
  82764. private _diffuseTexture6;
  82765. diffuseTexture6: BABYLON.Texture;
  82766. private _diffuseTexture7;
  82767. diffuseTexture7: BABYLON.Texture;
  82768. private _diffuseTexture8;
  82769. diffuseTexture8: BABYLON.Texture;
  82770. /**
  82771. * Uniforms
  82772. */
  82773. diffuseColor: BABYLON.Color3;
  82774. specularColor: BABYLON.Color3;
  82775. specularPower: number;
  82776. private _disableLighting;
  82777. disableLighting: boolean;
  82778. private _maxSimultaneousLights;
  82779. maxSimultaneousLights: number;
  82780. constructor(name: string, scene: BABYLON.Scene);
  82781. needAlphaBlending(): boolean;
  82782. needAlphaTesting(): boolean;
  82783. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82784. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82785. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82786. getAnimatables(): BABYLON.IAnimatable[];
  82787. getActiveTextures(): BABYLON.BaseTexture[];
  82788. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82789. dispose(forceDisposeEffect?: boolean): void;
  82790. clone(name: string): MixMaterial;
  82791. serialize(): any;
  82792. getClassName(): string;
  82793. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  82794. }
  82795. }
  82796. declare module BABYLON {
  82797. /** @hidden */
  82798. export var normalPixelShader: {
  82799. name: string;
  82800. shader: string;
  82801. };
  82802. }
  82803. declare module BABYLON {
  82804. /** @hidden */
  82805. export var normalVertexShader: {
  82806. name: string;
  82807. shader: string;
  82808. };
  82809. }
  82810. declare module BABYLON {
  82811. export class NormalMaterial extends BABYLON.PushMaterial {
  82812. private _diffuseTexture;
  82813. diffuseTexture: BABYLON.BaseTexture;
  82814. diffuseColor: BABYLON.Color3;
  82815. private _disableLighting;
  82816. disableLighting: boolean;
  82817. private _maxSimultaneousLights;
  82818. maxSimultaneousLights: number;
  82819. constructor(name: string, scene: BABYLON.Scene);
  82820. needAlphaBlending(): boolean;
  82821. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  82822. needAlphaTesting(): boolean;
  82823. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82824. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82825. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82826. getAnimatables(): BABYLON.IAnimatable[];
  82827. getActiveTextures(): BABYLON.BaseTexture[];
  82828. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82829. dispose(forceDisposeEffect?: boolean): void;
  82830. clone(name: string): NormalMaterial;
  82831. serialize(): any;
  82832. getClassName(): string;
  82833. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  82834. }
  82835. }
  82836. declare module BABYLON {
  82837. /** @hidden */
  82838. export var shadowOnlyPixelShader: {
  82839. name: string;
  82840. shader: string;
  82841. };
  82842. }
  82843. declare module BABYLON {
  82844. /** @hidden */
  82845. export var shadowOnlyVertexShader: {
  82846. name: string;
  82847. shader: string;
  82848. };
  82849. }
  82850. declare module BABYLON {
  82851. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  82852. private _activeLight;
  82853. private _needAlphaBlending;
  82854. constructor(name: string, scene: BABYLON.Scene);
  82855. shadowColor: BABYLON.Color3;
  82856. needAlphaBlending(): boolean;
  82857. needAlphaTesting(): boolean;
  82858. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82859. get activeLight(): BABYLON.IShadowLight;
  82860. set activeLight(light: BABYLON.IShadowLight);
  82861. private _getFirstShadowLightForMesh;
  82862. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82863. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82864. clone(name: string): ShadowOnlyMaterial;
  82865. serialize(): any;
  82866. getClassName(): string;
  82867. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  82868. }
  82869. }
  82870. declare module BABYLON {
  82871. /** @hidden */
  82872. export var simplePixelShader: {
  82873. name: string;
  82874. shader: string;
  82875. };
  82876. }
  82877. declare module BABYLON {
  82878. /** @hidden */
  82879. export var simpleVertexShader: {
  82880. name: string;
  82881. shader: string;
  82882. };
  82883. }
  82884. declare module BABYLON {
  82885. export class SimpleMaterial extends BABYLON.PushMaterial {
  82886. private _diffuseTexture;
  82887. diffuseTexture: BABYLON.BaseTexture;
  82888. diffuseColor: BABYLON.Color3;
  82889. private _disableLighting;
  82890. disableLighting: boolean;
  82891. private _maxSimultaneousLights;
  82892. maxSimultaneousLights: number;
  82893. constructor(name: string, scene: BABYLON.Scene);
  82894. needAlphaBlending(): boolean;
  82895. needAlphaTesting(): boolean;
  82896. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82897. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82898. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82899. getAnimatables(): BABYLON.IAnimatable[];
  82900. getActiveTextures(): BABYLON.BaseTexture[];
  82901. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82902. dispose(forceDisposeEffect?: boolean): void;
  82903. clone(name: string): SimpleMaterial;
  82904. serialize(): any;
  82905. getClassName(): string;
  82906. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  82907. }
  82908. }
  82909. declare module BABYLON {
  82910. /** @hidden */
  82911. export var skyPixelShader: {
  82912. name: string;
  82913. shader: string;
  82914. };
  82915. }
  82916. declare module BABYLON {
  82917. /** @hidden */
  82918. export var skyVertexShader: {
  82919. name: string;
  82920. shader: string;
  82921. };
  82922. }
  82923. declare module BABYLON {
  82924. /**
  82925. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  82926. * @see https://doc.babylonjs.com/extensions/sky
  82927. */
  82928. export class SkyMaterial extends BABYLON.PushMaterial {
  82929. /**
  82930. * Defines the overall luminance of sky in interval ]0, 1[.
  82931. */
  82932. luminance: number;
  82933. /**
  82934. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  82935. */
  82936. turbidity: number;
  82937. /**
  82938. * Defines the sky appearance (light intensity).
  82939. */
  82940. rayleigh: number;
  82941. /**
  82942. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  82943. */
  82944. mieCoefficient: number;
  82945. /**
  82946. * Defines the amount of haze particles following the Mie scattering theory.
  82947. */
  82948. mieDirectionalG: number;
  82949. /**
  82950. * Defines the distance of the sun according to the active scene camera.
  82951. */
  82952. distance: number;
  82953. /**
  82954. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  82955. * "inclined".
  82956. */
  82957. inclination: number;
  82958. /**
  82959. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  82960. * an object direction and a reference direction.
  82961. */
  82962. azimuth: number;
  82963. /**
  82964. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  82965. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  82966. */
  82967. sunPosition: BABYLON.Vector3;
  82968. /**
  82969. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  82970. * .sunPosition property.
  82971. */
  82972. useSunPosition: boolean;
  82973. /**
  82974. * Defines an offset vector used to get a horizon offset.
  82975. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  82976. */
  82977. cameraOffset: BABYLON.Vector3;
  82978. private _cameraPosition;
  82979. /**
  82980. * Instantiates a new sky material.
  82981. * This material allows to create dynamic and texture free
  82982. * effects for skyboxes by taking care of the atmosphere state.
  82983. * @see https://doc.babylonjs.com/extensions/sky
  82984. * @param name Define the name of the material in the scene
  82985. * @param scene Define the scene the material belong to
  82986. */
  82987. constructor(name: string, scene: BABYLON.Scene);
  82988. /**
  82989. * Specifies if the material will require alpha blending
  82990. * @returns a boolean specifying if alpha blending is needed
  82991. */
  82992. needAlphaBlending(): boolean;
  82993. /**
  82994. * Specifies if this material should be rendered in alpha test mode
  82995. * @returns false as the sky material doesn't need alpha testing.
  82996. */
  82997. needAlphaTesting(): boolean;
  82998. /**
  82999. * Get the texture used for alpha test purpose.
  83000. * @returns null as the sky material has no texture.
  83001. */
  83002. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83003. /**
  83004. * Get if the submesh is ready to be used and all its information available.
  83005. * Child classes can use it to update shaders
  83006. * @param mesh defines the mesh to check
  83007. * @param subMesh defines which submesh to check
  83008. * @param useInstances specifies that instances should be used
  83009. * @returns a boolean indicating that the submesh is ready or not
  83010. */
  83011. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83012. /**
  83013. * Binds the submesh to this material by preparing the effect and shader to draw
  83014. * @param world defines the world transformation matrix
  83015. * @param mesh defines the mesh containing the submesh
  83016. * @param subMesh defines the submesh to bind the material to
  83017. */
  83018. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83019. /**
  83020. * Get the list of animatables in the material.
  83021. * @returns the list of animatables object used in the material
  83022. */
  83023. getAnimatables(): BABYLON.IAnimatable[];
  83024. /**
  83025. * Disposes the material
  83026. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83027. */
  83028. dispose(forceDisposeEffect?: boolean): void;
  83029. /**
  83030. * Makes a duplicate of the material, and gives it a new name
  83031. * @param name defines the new name for the duplicated material
  83032. * @returns the cloned material
  83033. */
  83034. clone(name: string): SkyMaterial;
  83035. /**
  83036. * Serializes this material in a JSON representation
  83037. * @returns the serialized material object
  83038. */
  83039. serialize(): any;
  83040. /**
  83041. * Gets the current class name of the material e.g. "SkyMaterial"
  83042. * Mainly use in serialization.
  83043. * @returns the class name
  83044. */
  83045. getClassName(): string;
  83046. /**
  83047. * Creates a sky material from parsed material data
  83048. * @param source defines the JSON representation of the material
  83049. * @param scene defines the hosting scene
  83050. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83051. * @returns a new sky material
  83052. */
  83053. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  83054. }
  83055. }
  83056. declare module BABYLON {
  83057. /** @hidden */
  83058. export var terrainPixelShader: {
  83059. name: string;
  83060. shader: string;
  83061. };
  83062. }
  83063. declare module BABYLON {
  83064. /** @hidden */
  83065. export var terrainVertexShader: {
  83066. name: string;
  83067. shader: string;
  83068. };
  83069. }
  83070. declare module BABYLON {
  83071. export class TerrainMaterial extends BABYLON.PushMaterial {
  83072. private _mixTexture;
  83073. mixTexture: BABYLON.BaseTexture;
  83074. private _diffuseTexture1;
  83075. diffuseTexture1: BABYLON.Texture;
  83076. private _diffuseTexture2;
  83077. diffuseTexture2: BABYLON.Texture;
  83078. private _diffuseTexture3;
  83079. diffuseTexture3: BABYLON.Texture;
  83080. private _bumpTexture1;
  83081. bumpTexture1: BABYLON.Texture;
  83082. private _bumpTexture2;
  83083. bumpTexture2: BABYLON.Texture;
  83084. private _bumpTexture3;
  83085. bumpTexture3: BABYLON.Texture;
  83086. diffuseColor: BABYLON.Color3;
  83087. specularColor: BABYLON.Color3;
  83088. specularPower: number;
  83089. private _disableLighting;
  83090. disableLighting: boolean;
  83091. private _maxSimultaneousLights;
  83092. maxSimultaneousLights: number;
  83093. constructor(name: string, scene: BABYLON.Scene);
  83094. needAlphaBlending(): boolean;
  83095. needAlphaTesting(): boolean;
  83096. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83097. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83098. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83099. getAnimatables(): BABYLON.IAnimatable[];
  83100. getActiveTextures(): BABYLON.BaseTexture[];
  83101. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83102. dispose(forceDisposeEffect?: boolean): void;
  83103. clone(name: string): TerrainMaterial;
  83104. serialize(): any;
  83105. getClassName(): string;
  83106. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  83107. }
  83108. }
  83109. declare module BABYLON {
  83110. /** @hidden */
  83111. export var triplanarPixelShader: {
  83112. name: string;
  83113. shader: string;
  83114. };
  83115. }
  83116. declare module BABYLON {
  83117. /** @hidden */
  83118. export var triplanarVertexShader: {
  83119. name: string;
  83120. shader: string;
  83121. };
  83122. }
  83123. declare module BABYLON {
  83124. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  83125. mixTexture: BABYLON.BaseTexture;
  83126. private _diffuseTextureX;
  83127. diffuseTextureX: BABYLON.BaseTexture;
  83128. private _diffuseTextureY;
  83129. diffuseTextureY: BABYLON.BaseTexture;
  83130. private _diffuseTextureZ;
  83131. diffuseTextureZ: BABYLON.BaseTexture;
  83132. private _normalTextureX;
  83133. normalTextureX: BABYLON.BaseTexture;
  83134. private _normalTextureY;
  83135. normalTextureY: BABYLON.BaseTexture;
  83136. private _normalTextureZ;
  83137. normalTextureZ: BABYLON.BaseTexture;
  83138. tileSize: number;
  83139. diffuseColor: BABYLON.Color3;
  83140. specularColor: BABYLON.Color3;
  83141. specularPower: number;
  83142. private _disableLighting;
  83143. disableLighting: boolean;
  83144. private _maxSimultaneousLights;
  83145. maxSimultaneousLights: number;
  83146. constructor(name: string, scene: BABYLON.Scene);
  83147. needAlphaBlending(): boolean;
  83148. needAlphaTesting(): boolean;
  83149. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83150. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83151. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83152. getAnimatables(): BABYLON.IAnimatable[];
  83153. getActiveTextures(): BABYLON.BaseTexture[];
  83154. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83155. dispose(forceDisposeEffect?: boolean): void;
  83156. clone(name: string): TriPlanarMaterial;
  83157. serialize(): any;
  83158. getClassName(): string;
  83159. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  83160. }
  83161. }
  83162. declare module BABYLON {
  83163. /** @hidden */
  83164. export var waterPixelShader: {
  83165. name: string;
  83166. shader: string;
  83167. };
  83168. }
  83169. declare module BABYLON {
  83170. /** @hidden */
  83171. export var waterVertexShader: {
  83172. name: string;
  83173. shader: string;
  83174. };
  83175. }
  83176. declare module BABYLON {
  83177. export class WaterMaterial extends BABYLON.PushMaterial {
  83178. renderTargetSize: BABYLON.Vector2;
  83179. private _bumpTexture;
  83180. bumpTexture: BABYLON.BaseTexture;
  83181. diffuseColor: BABYLON.Color3;
  83182. specularColor: BABYLON.Color3;
  83183. specularPower: number;
  83184. private _disableLighting;
  83185. disableLighting: boolean;
  83186. private _maxSimultaneousLights;
  83187. maxSimultaneousLights: number;
  83188. /**
  83189. * @param {number}: Represents the wind force
  83190. */
  83191. windForce: number;
  83192. /**
  83193. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  83194. */
  83195. windDirection: BABYLON.Vector2;
  83196. /**
  83197. * @param {number}: Wave height, represents the height of the waves
  83198. */
  83199. waveHeight: number;
  83200. /**
  83201. * @param {number}: Bump height, represents the bump height related to the bump map
  83202. */
  83203. bumpHeight: number;
  83204. /**
  83205. * @param {boolean}: Add a smaller moving bump to less steady waves.
  83206. */
  83207. private _bumpSuperimpose;
  83208. bumpSuperimpose: boolean;
  83209. /**
  83210. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  83211. */
  83212. private _fresnelSeparate;
  83213. fresnelSeparate: boolean;
  83214. /**
  83215. * @param {boolean}: bump Waves modify the reflection.
  83216. */
  83217. private _bumpAffectsReflection;
  83218. bumpAffectsReflection: boolean;
  83219. /**
  83220. * @param {number}: The water color blended with the refraction (near)
  83221. */
  83222. waterColor: BABYLON.Color3;
  83223. /**
  83224. * @param {number}: The blend factor related to the water color
  83225. */
  83226. colorBlendFactor: number;
  83227. /**
  83228. * @param {number}: The water color blended with the reflection (far)
  83229. */
  83230. waterColor2: BABYLON.Color3;
  83231. /**
  83232. * @param {number}: The blend factor related to the water color (reflection, far)
  83233. */
  83234. colorBlendFactor2: number;
  83235. /**
  83236. * @param {number}: Represents the maximum length of a wave
  83237. */
  83238. waveLength: number;
  83239. /**
  83240. * @param {number}: Defines the waves speed
  83241. */
  83242. waveSpeed: number;
  83243. /**
  83244. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  83245. * will avoid calculating useless pixels in the pixel shader of the water material.
  83246. */
  83247. disableClipPlane: boolean;
  83248. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  83249. private _mesh;
  83250. private _refractionRTT;
  83251. private _reflectionRTT;
  83252. private _reflectionTransform;
  83253. private _lastTime;
  83254. private _lastDeltaTime;
  83255. private _useLogarithmicDepth;
  83256. private _waitingRenderList;
  83257. private _imageProcessingConfiguration;
  83258. private _imageProcessingObserver;
  83259. /**
  83260. * Gets a boolean indicating that current material needs to register RTT
  83261. */
  83262. get hasRenderTargetTextures(): boolean;
  83263. /**
  83264. * Constructor
  83265. */
  83266. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  83267. get useLogarithmicDepth(): boolean;
  83268. set useLogarithmicDepth(value: boolean);
  83269. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83270. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83271. addToRenderList(node: any): void;
  83272. enableRenderTargets(enable: boolean): void;
  83273. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  83274. get renderTargetsEnabled(): boolean;
  83275. needAlphaBlending(): boolean;
  83276. needAlphaTesting(): boolean;
  83277. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83278. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83279. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83280. private _createRenderTargets;
  83281. getAnimatables(): BABYLON.IAnimatable[];
  83282. getActiveTextures(): BABYLON.BaseTexture[];
  83283. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83284. dispose(forceDisposeEffect?: boolean): void;
  83285. clone(name: string): WaterMaterial;
  83286. serialize(): any;
  83287. getClassName(): string;
  83288. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  83289. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  83290. }
  83291. }
  83292. declare module BABYLON {
  83293. /** @hidden */
  83294. export var asciiartPixelShader: {
  83295. name: string;
  83296. shader: string;
  83297. };
  83298. }
  83299. declare module BABYLON {
  83300. /**
  83301. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  83302. *
  83303. * It basically takes care rendering the font front the given font size to a texture.
  83304. * This is used later on in the postprocess.
  83305. */
  83306. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  83307. private _font;
  83308. private _text;
  83309. private _charSize;
  83310. /**
  83311. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83312. */
  83313. get charSize(): number;
  83314. /**
  83315. * Create a new instance of the Ascii Art FontTexture class
  83316. * @param name the name of the texture
  83317. * @param font the font to use, use the W3C CSS notation
  83318. * @param text the caracter set to use in the rendering.
  83319. * @param scene the scene that owns the texture
  83320. */
  83321. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83322. /**
  83323. * Gets the max char width of a font.
  83324. * @param font the font to use, use the W3C CSS notation
  83325. * @return the max char width
  83326. */
  83327. private getFontWidth;
  83328. /**
  83329. * Gets the max char height of a font.
  83330. * @param font the font to use, use the W3C CSS notation
  83331. * @return the max char height
  83332. */
  83333. private getFontHeight;
  83334. /**
  83335. * Clones the current AsciiArtTexture.
  83336. * @return the clone of the texture.
  83337. */
  83338. clone(): AsciiArtFontTexture;
  83339. /**
  83340. * Parses a json object representing the texture and returns an instance of it.
  83341. * @param source the source JSON representation
  83342. * @param scene the scene to create the texture for
  83343. * @return the parsed texture
  83344. */
  83345. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  83346. }
  83347. /**
  83348. * Option available in the Ascii Art Post Process.
  83349. */
  83350. export interface IAsciiArtPostProcessOptions {
  83351. /**
  83352. * The font to use following the w3c font definition.
  83353. */
  83354. font?: string;
  83355. /**
  83356. * The character set to use in the postprocess.
  83357. */
  83358. characterSet?: string;
  83359. /**
  83360. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83361. * This number is defined between 0 and 1;
  83362. */
  83363. mixToTile?: number;
  83364. /**
  83365. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83366. * This number is defined between 0 and 1;
  83367. */
  83368. mixToNormal?: number;
  83369. }
  83370. /**
  83371. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  83372. *
  83373. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83374. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  83375. */
  83376. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  83377. /**
  83378. * The font texture used to render the char in the post process.
  83379. */
  83380. private _asciiArtFontTexture;
  83381. /**
  83382. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83383. * This number is defined between 0 and 1;
  83384. */
  83385. mixToTile: number;
  83386. /**
  83387. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83388. * This number is defined between 0 and 1;
  83389. */
  83390. mixToNormal: number;
  83391. /**
  83392. * Instantiates a new Ascii Art Post Process.
  83393. * @param name the name to give to the postprocess
  83394. * @camera the camera to apply the post process to.
  83395. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  83396. */
  83397. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  83398. }
  83399. }
  83400. declare module BABYLON {
  83401. /** @hidden */
  83402. export var digitalrainPixelShader: {
  83403. name: string;
  83404. shader: string;
  83405. };
  83406. }
  83407. declare module BABYLON {
  83408. /**
  83409. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  83410. *
  83411. * It basically takes care rendering the font front the given font size to a texture.
  83412. * This is used later on in the postprocess.
  83413. */
  83414. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  83415. private _font;
  83416. private _text;
  83417. private _charSize;
  83418. /**
  83419. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83420. */
  83421. get charSize(): number;
  83422. /**
  83423. * Create a new instance of the Digital Rain FontTexture class
  83424. * @param name the name of the texture
  83425. * @param font the font to use, use the W3C CSS notation
  83426. * @param text the caracter set to use in the rendering.
  83427. * @param scene the scene that owns the texture
  83428. */
  83429. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83430. /**
  83431. * Gets the max char width of a font.
  83432. * @param font the font to use, use the W3C CSS notation
  83433. * @return the max char width
  83434. */
  83435. private getFontWidth;
  83436. /**
  83437. * Gets the max char height of a font.
  83438. * @param font the font to use, use the W3C CSS notation
  83439. * @return the max char height
  83440. */
  83441. private getFontHeight;
  83442. /**
  83443. * Clones the current DigitalRainFontTexture.
  83444. * @return the clone of the texture.
  83445. */
  83446. clone(): DigitalRainFontTexture;
  83447. /**
  83448. * Parses a json object representing the texture and returns an instance of it.
  83449. * @param source the source JSON representation
  83450. * @param scene the scene to create the texture for
  83451. * @return the parsed texture
  83452. */
  83453. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  83454. }
  83455. /**
  83456. * Option available in the Digital Rain Post Process.
  83457. */
  83458. export interface IDigitalRainPostProcessOptions {
  83459. /**
  83460. * The font to use following the w3c font definition.
  83461. */
  83462. font?: string;
  83463. /**
  83464. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83465. * This number is defined between 0 and 1;
  83466. */
  83467. mixToTile?: number;
  83468. /**
  83469. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83470. * This number is defined between 0 and 1;
  83471. */
  83472. mixToNormal?: number;
  83473. }
  83474. /**
  83475. * DigitalRainPostProcess helps rendering everithing in digital rain.
  83476. *
  83477. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83478. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  83479. */
  83480. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  83481. /**
  83482. * The font texture used to render the char in the post process.
  83483. */
  83484. private _digitalRainFontTexture;
  83485. /**
  83486. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83487. * This number is defined between 0 and 1;
  83488. */
  83489. mixToTile: number;
  83490. /**
  83491. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83492. * This number is defined between 0 and 1;
  83493. */
  83494. mixToNormal: number;
  83495. /**
  83496. * Instantiates a new Digital Rain Post Process.
  83497. * @param name the name to give to the postprocess
  83498. * @camera the camera to apply the post process to.
  83499. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  83500. */
  83501. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  83502. }
  83503. }
  83504. declare module BABYLON {
  83505. /** @hidden */
  83506. export var brickProceduralTexturePixelShader: {
  83507. name: string;
  83508. shader: string;
  83509. };
  83510. }
  83511. declare module BABYLON {
  83512. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  83513. private _numberOfBricksHeight;
  83514. private _numberOfBricksWidth;
  83515. private _jointColor;
  83516. private _brickColor;
  83517. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83518. updateShaderUniforms(): void;
  83519. get numberOfBricksHeight(): number;
  83520. set numberOfBricksHeight(value: number);
  83521. get numberOfBricksWidth(): number;
  83522. set numberOfBricksWidth(value: number);
  83523. get jointColor(): BABYLON.Color3;
  83524. set jointColor(value: BABYLON.Color3);
  83525. get brickColor(): BABYLON.Color3;
  83526. set brickColor(value: BABYLON.Color3);
  83527. /**
  83528. * Serializes this brick procedural texture
  83529. * @returns a serialized brick procedural texture object
  83530. */
  83531. serialize(): any;
  83532. /**
  83533. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  83534. * @param parsedTexture defines parsed texture data
  83535. * @param scene defines the current scene
  83536. * @param rootUrl defines the root URL containing brick procedural texture information
  83537. * @returns a parsed Brick Procedural BABYLON.Texture
  83538. */
  83539. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  83540. }
  83541. }
  83542. declare module BABYLON {
  83543. /** @hidden */
  83544. export var cloudProceduralTexturePixelShader: {
  83545. name: string;
  83546. shader: string;
  83547. };
  83548. }
  83549. declare module BABYLON {
  83550. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  83551. private _skyColor;
  83552. private _cloudColor;
  83553. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83554. updateShaderUniforms(): void;
  83555. get skyColor(): BABYLON.Color4;
  83556. set skyColor(value: BABYLON.Color4);
  83557. get cloudColor(): BABYLON.Color4;
  83558. set cloudColor(value: BABYLON.Color4);
  83559. /**
  83560. * Serializes this cloud procedural texture
  83561. * @returns a serialized cloud procedural texture object
  83562. */
  83563. serialize(): any;
  83564. /**
  83565. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  83566. * @param parsedTexture defines parsed texture data
  83567. * @param scene defines the current scene
  83568. * @param rootUrl defines the root URL containing cloud procedural texture information
  83569. * @returns a parsed Cloud Procedural BABYLON.Texture
  83570. */
  83571. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  83572. }
  83573. }
  83574. declare module BABYLON {
  83575. /** @hidden */
  83576. export var fireProceduralTexturePixelShader: {
  83577. name: string;
  83578. shader: string;
  83579. };
  83580. }
  83581. declare module BABYLON {
  83582. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  83583. private _time;
  83584. private _speed;
  83585. private _autoGenerateTime;
  83586. private _fireColors;
  83587. private _alphaThreshold;
  83588. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83589. updateShaderUniforms(): void;
  83590. render(useCameraPostProcess?: boolean): void;
  83591. static get PurpleFireColors(): BABYLON.Color3[];
  83592. static get GreenFireColors(): BABYLON.Color3[];
  83593. static get RedFireColors(): BABYLON.Color3[];
  83594. static get BlueFireColors(): BABYLON.Color3[];
  83595. get autoGenerateTime(): boolean;
  83596. set autoGenerateTime(value: boolean);
  83597. get fireColors(): BABYLON.Color3[];
  83598. set fireColors(value: BABYLON.Color3[]);
  83599. get time(): number;
  83600. set time(value: number);
  83601. get speed(): BABYLON.Vector2;
  83602. set speed(value: BABYLON.Vector2);
  83603. get alphaThreshold(): number;
  83604. set alphaThreshold(value: number);
  83605. /**
  83606. * Serializes this fire procedural texture
  83607. * @returns a serialized fire procedural texture object
  83608. */
  83609. serialize(): any;
  83610. /**
  83611. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  83612. * @param parsedTexture defines parsed texture data
  83613. * @param scene defines the current scene
  83614. * @param rootUrl defines the root URL containing fire procedural texture information
  83615. * @returns a parsed Fire Procedural BABYLON.Texture
  83616. */
  83617. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  83618. }
  83619. }
  83620. declare module BABYLON {
  83621. /** @hidden */
  83622. export var grassProceduralTexturePixelShader: {
  83623. name: string;
  83624. shader: string;
  83625. };
  83626. }
  83627. declare module BABYLON {
  83628. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  83629. private _grassColors;
  83630. private _groundColor;
  83631. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83632. updateShaderUniforms(): void;
  83633. get grassColors(): BABYLON.Color3[];
  83634. set grassColors(value: BABYLON.Color3[]);
  83635. get groundColor(): BABYLON.Color3;
  83636. set groundColor(value: BABYLON.Color3);
  83637. /**
  83638. * Serializes this grass procedural texture
  83639. * @returns a serialized grass procedural texture object
  83640. */
  83641. serialize(): any;
  83642. /**
  83643. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  83644. * @param parsedTexture defines parsed texture data
  83645. * @param scene defines the current scene
  83646. * @param rootUrl defines the root URL containing grass procedural texture information
  83647. * @returns a parsed Grass Procedural BABYLON.Texture
  83648. */
  83649. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  83650. }
  83651. }
  83652. declare module BABYLON {
  83653. /** @hidden */
  83654. export var marbleProceduralTexturePixelShader: {
  83655. name: string;
  83656. shader: string;
  83657. };
  83658. }
  83659. declare module BABYLON {
  83660. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  83661. private _numberOfTilesHeight;
  83662. private _numberOfTilesWidth;
  83663. private _amplitude;
  83664. private _jointColor;
  83665. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83666. updateShaderUniforms(): void;
  83667. get numberOfTilesHeight(): number;
  83668. set numberOfTilesHeight(value: number);
  83669. get amplitude(): number;
  83670. set amplitude(value: number);
  83671. get numberOfTilesWidth(): number;
  83672. set numberOfTilesWidth(value: number);
  83673. get jointColor(): BABYLON.Color3;
  83674. set jointColor(value: BABYLON.Color3);
  83675. /**
  83676. * Serializes this marble procedural texture
  83677. * @returns a serialized marble procedural texture object
  83678. */
  83679. serialize(): any;
  83680. /**
  83681. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  83682. * @param parsedTexture defines parsed texture data
  83683. * @param scene defines the current scene
  83684. * @param rootUrl defines the root URL containing marble procedural texture information
  83685. * @returns a parsed Marble Procedural BABYLON.Texture
  83686. */
  83687. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  83688. }
  83689. }
  83690. declare module BABYLON {
  83691. /** @hidden */
  83692. export var normalMapProceduralTexturePixelShader: {
  83693. name: string;
  83694. shader: string;
  83695. };
  83696. }
  83697. declare module BABYLON {
  83698. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  83699. private _baseTexture;
  83700. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83701. updateShaderUniforms(): void;
  83702. render(useCameraPostProcess?: boolean): void;
  83703. resize(size: any, generateMipMaps: any): void;
  83704. get baseTexture(): BABYLON.Texture;
  83705. set baseTexture(texture: BABYLON.Texture);
  83706. /**
  83707. * Serializes this normal map procedural texture
  83708. * @returns a serialized normal map procedural texture object
  83709. */
  83710. serialize(): any;
  83711. /**
  83712. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  83713. * @param parsedTexture defines parsed texture data
  83714. * @param scene defines the current scene
  83715. * @param rootUrl defines the root URL containing normal map procedural texture information
  83716. * @returns a parsed Normal Map Procedural BABYLON.Texture
  83717. */
  83718. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  83719. }
  83720. }
  83721. declare module BABYLON {
  83722. /** @hidden */
  83723. export var perlinNoiseProceduralTexturePixelShader: {
  83724. name: string;
  83725. shader: string;
  83726. };
  83727. }
  83728. declare module BABYLON {
  83729. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  83730. time: number;
  83731. timeScale: number;
  83732. translationSpeed: number;
  83733. private _currentTranslation;
  83734. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83735. updateShaderUniforms(): void;
  83736. render(useCameraPostProcess?: boolean): void;
  83737. resize(size: any, generateMipMaps: any): void;
  83738. /**
  83739. * Serializes this perlin noise procedural texture
  83740. * @returns a serialized perlin noise procedural texture object
  83741. */
  83742. serialize(): any;
  83743. /**
  83744. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  83745. * @param parsedTexture defines parsed texture data
  83746. * @param scene defines the current scene
  83747. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  83748. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  83749. */
  83750. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  83751. }
  83752. }
  83753. declare module BABYLON {
  83754. /** @hidden */
  83755. export var roadProceduralTexturePixelShader: {
  83756. name: string;
  83757. shader: string;
  83758. };
  83759. }
  83760. declare module BABYLON {
  83761. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  83762. private _roadColor;
  83763. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83764. updateShaderUniforms(): void;
  83765. get roadColor(): BABYLON.Color3;
  83766. set roadColor(value: BABYLON.Color3);
  83767. /**
  83768. * Serializes this road procedural texture
  83769. * @returns a serialized road procedural texture object
  83770. */
  83771. serialize(): any;
  83772. /**
  83773. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  83774. * @param parsedTexture defines parsed texture data
  83775. * @param scene defines the current scene
  83776. * @param rootUrl defines the root URL containing road procedural texture information
  83777. * @returns a parsed Road Procedural BABYLON.Texture
  83778. */
  83779. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  83780. }
  83781. }
  83782. declare module BABYLON {
  83783. /** @hidden */
  83784. export var starfieldProceduralTexturePixelShader: {
  83785. name: string;
  83786. shader: string;
  83787. };
  83788. }
  83789. declare module BABYLON {
  83790. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  83791. private _time;
  83792. private _alpha;
  83793. private _beta;
  83794. private _zoom;
  83795. private _formuparam;
  83796. private _stepsize;
  83797. private _tile;
  83798. private _brightness;
  83799. private _darkmatter;
  83800. private _distfading;
  83801. private _saturation;
  83802. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83803. updateShaderUniforms(): void;
  83804. get time(): number;
  83805. set time(value: number);
  83806. get alpha(): number;
  83807. set alpha(value: number);
  83808. get beta(): number;
  83809. set beta(value: number);
  83810. get formuparam(): number;
  83811. set formuparam(value: number);
  83812. get stepsize(): number;
  83813. set stepsize(value: number);
  83814. get zoom(): number;
  83815. set zoom(value: number);
  83816. get tile(): number;
  83817. set tile(value: number);
  83818. get brightness(): number;
  83819. set brightness(value: number);
  83820. get darkmatter(): number;
  83821. set darkmatter(value: number);
  83822. get distfading(): number;
  83823. set distfading(value: number);
  83824. get saturation(): number;
  83825. set saturation(value: number);
  83826. /**
  83827. * Serializes this starfield procedural texture
  83828. * @returns a serialized starfield procedural texture object
  83829. */
  83830. serialize(): any;
  83831. /**
  83832. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  83833. * @param parsedTexture defines parsed texture data
  83834. * @param scene defines the current scene
  83835. * @param rootUrl defines the root URL containing startfield procedural texture information
  83836. * @returns a parsed Starfield Procedural BABYLON.Texture
  83837. */
  83838. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  83839. }
  83840. }
  83841. declare module BABYLON {
  83842. /** @hidden */
  83843. export var woodProceduralTexturePixelShader: {
  83844. name: string;
  83845. shader: string;
  83846. };
  83847. }
  83848. declare module BABYLON {
  83849. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  83850. private _ampScale;
  83851. private _woodColor;
  83852. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83853. updateShaderUniforms(): void;
  83854. get ampScale(): number;
  83855. set ampScale(value: number);
  83856. get woodColor(): BABYLON.Color3;
  83857. set woodColor(value: BABYLON.Color3);
  83858. /**
  83859. * Serializes this wood procedural texture
  83860. * @returns a serialized wood procedural texture object
  83861. */
  83862. serialize(): any;
  83863. /**
  83864. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  83865. * @param parsedTexture defines parsed texture data
  83866. * @param scene defines the current scene
  83867. * @param rootUrl defines the root URL containing wood procedural texture information
  83868. * @returns a parsed Wood Procedural BABYLON.Texture
  83869. */
  83870. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  83871. }
  83872. }