documentation.d.ts 3.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350
  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. /** @hidden */
  7757. _prefiltered: boolean;
  7758. /**
  7759. * Creates a cube texture from an array of image urls
  7760. * @param files defines an array of image urls
  7761. * @param scene defines the hosting scene
  7762. * @param noMipmap specifies if mip maps are not used
  7763. * @returns a cube texture
  7764. */
  7765. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7766. /**
  7767. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7768. * @param url defines the url of the prefiltered texture
  7769. * @param scene defines the scene the texture is attached to
  7770. * @param forcedExtension defines the extension of the file if different from the url
  7771. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7772. * @return the prefiltered texture
  7773. */
  7774. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7775. /**
  7776. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7777. * as prefiltered data.
  7778. * @param rootUrl defines the url of the texture or the root name of the six images
  7779. * @param null defines the scene or engine the texture is attached to
  7780. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7781. * @param noMipmap defines if mipmaps should be created or not
  7782. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7783. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7784. * @param onError defines a callback triggered in case of error during load
  7785. * @param format defines the internal format to use for the texture once loaded
  7786. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7787. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7788. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7789. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7790. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7791. * @return the cube texture
  7792. */
  7793. 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);
  7794. /**
  7795. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7796. */
  7797. get isPrefiltered(): boolean;
  7798. /**
  7799. * Get the current class name of the texture useful for serialization or dynamic coding.
  7800. * @returns "CubeTexture"
  7801. */
  7802. getClassName(): string;
  7803. /**
  7804. * Update the url (and optional buffer) of this texture if url was null during construction.
  7805. * @param url the url of the texture
  7806. * @param forcedExtension defines the extension to use
  7807. * @param onLoad callback called when the texture is loaded (defaults to null)
  7808. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7809. */
  7810. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7811. /**
  7812. * Delays loading of the cube texture
  7813. * @param forcedExtension defines the extension to use
  7814. */
  7815. delayLoad(forcedExtension?: string): void;
  7816. /**
  7817. * Returns the reflection texture matrix
  7818. * @returns the reflection texture matrix
  7819. */
  7820. getReflectionTextureMatrix(): Matrix;
  7821. /**
  7822. * Sets the reflection texture matrix
  7823. * @param value Reflection texture matrix
  7824. */
  7825. setReflectionTextureMatrix(value: Matrix): void;
  7826. /**
  7827. * Parses text to create a cube texture
  7828. * @param parsedTexture define the serialized text to read from
  7829. * @param scene defines the hosting scene
  7830. * @param rootUrl defines the root url of the cube texture
  7831. * @returns a cube texture
  7832. */
  7833. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7834. /**
  7835. * Makes a clone, or deep copy, of the cube texture
  7836. * @returns a new cube texture
  7837. */
  7838. clone(): CubeTexture;
  7839. }
  7840. }
  7841. declare module BABYLON {
  7842. /**
  7843. * Manages the defines for the Material
  7844. */
  7845. export class MaterialDefines {
  7846. /** @hidden */
  7847. protected _keys: string[];
  7848. private _isDirty;
  7849. /** @hidden */
  7850. _renderId: number;
  7851. /** @hidden */
  7852. _areLightsDirty: boolean;
  7853. /** @hidden */
  7854. _areLightsDisposed: boolean;
  7855. /** @hidden */
  7856. _areAttributesDirty: boolean;
  7857. /** @hidden */
  7858. _areTexturesDirty: boolean;
  7859. /** @hidden */
  7860. _areFresnelDirty: boolean;
  7861. /** @hidden */
  7862. _areMiscDirty: boolean;
  7863. /** @hidden */
  7864. _areImageProcessingDirty: boolean;
  7865. /** @hidden */
  7866. _normals: boolean;
  7867. /** @hidden */
  7868. _uvs: boolean;
  7869. /** @hidden */
  7870. _needNormals: boolean;
  7871. /** @hidden */
  7872. _needUVs: boolean;
  7873. [id: string]: any;
  7874. /**
  7875. * Specifies if the material needs to be re-calculated
  7876. */
  7877. get isDirty(): boolean;
  7878. /**
  7879. * Marks the material to indicate that it has been re-calculated
  7880. */
  7881. markAsProcessed(): void;
  7882. /**
  7883. * Marks the material to indicate that it needs to be re-calculated
  7884. */
  7885. markAsUnprocessed(): void;
  7886. /**
  7887. * Marks the material to indicate all of its defines need to be re-calculated
  7888. */
  7889. markAllAsDirty(): void;
  7890. /**
  7891. * Marks the material to indicate that image processing needs to be re-calculated
  7892. */
  7893. markAsImageProcessingDirty(): void;
  7894. /**
  7895. * Marks the material to indicate the lights need to be re-calculated
  7896. * @param disposed Defines whether the light is dirty due to dispose or not
  7897. */
  7898. markAsLightDirty(disposed?: boolean): void;
  7899. /**
  7900. * Marks the attribute state as changed
  7901. */
  7902. markAsAttributesDirty(): void;
  7903. /**
  7904. * Marks the texture state as changed
  7905. */
  7906. markAsTexturesDirty(): void;
  7907. /**
  7908. * Marks the fresnel state as changed
  7909. */
  7910. markAsFresnelDirty(): void;
  7911. /**
  7912. * Marks the misc state as changed
  7913. */
  7914. markAsMiscDirty(): void;
  7915. /**
  7916. * Rebuilds the material defines
  7917. */
  7918. rebuild(): void;
  7919. /**
  7920. * Specifies if two material defines are equal
  7921. * @param other - A material define instance to compare to
  7922. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7923. */
  7924. isEqual(other: MaterialDefines): boolean;
  7925. /**
  7926. * Clones this instance's defines to another instance
  7927. * @param other - material defines to clone values to
  7928. */
  7929. cloneTo(other: MaterialDefines): void;
  7930. /**
  7931. * Resets the material define values
  7932. */
  7933. reset(): void;
  7934. /**
  7935. * Converts the material define values to a string
  7936. * @returns - String of material define information
  7937. */
  7938. toString(): string;
  7939. }
  7940. }
  7941. declare module BABYLON {
  7942. /**
  7943. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7944. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7945. * 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;
  7946. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7947. */
  7948. export class ColorCurves {
  7949. private _dirty;
  7950. private _tempColor;
  7951. private _globalCurve;
  7952. private _highlightsCurve;
  7953. private _midtonesCurve;
  7954. private _shadowsCurve;
  7955. private _positiveCurve;
  7956. private _negativeCurve;
  7957. private _globalHue;
  7958. private _globalDensity;
  7959. private _globalSaturation;
  7960. private _globalExposure;
  7961. /**
  7962. * Gets the global Hue value.
  7963. * 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).
  7964. */
  7965. get globalHue(): number;
  7966. /**
  7967. * Sets the global Hue value.
  7968. * 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).
  7969. */
  7970. set globalHue(value: number);
  7971. /**
  7972. * Gets 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. get globalDensity(): number;
  7977. /**
  7978. * Sets the global Density value.
  7979. * 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.
  7980. * Values less than zero provide a filter of opposite hue.
  7981. */
  7982. set globalDensity(value: number);
  7983. /**
  7984. * Gets the global Saturation value.
  7985. * 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.
  7986. */
  7987. get globalSaturation(): number;
  7988. /**
  7989. * Sets the global Saturation value.
  7990. * 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.
  7991. */
  7992. set globalSaturation(value: number);
  7993. /**
  7994. * Gets the global Exposure value.
  7995. * 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.
  7996. */
  7997. get globalExposure(): number;
  7998. /**
  7999. * Sets the global Exposure value.
  8000. * 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.
  8001. */
  8002. set globalExposure(value: number);
  8003. private _highlightsHue;
  8004. private _highlightsDensity;
  8005. private _highlightsSaturation;
  8006. private _highlightsExposure;
  8007. /**
  8008. * Gets the highlights Hue value.
  8009. * 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).
  8010. */
  8011. get highlightsHue(): number;
  8012. /**
  8013. * Sets the highlights Hue value.
  8014. * 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).
  8015. */
  8016. set highlightsHue(value: number);
  8017. /**
  8018. * Gets 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. get highlightsDensity(): number;
  8023. /**
  8024. * Sets the highlights Density value.
  8025. * 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.
  8026. * Values less than zero provide a filter of opposite hue.
  8027. */
  8028. set highlightsDensity(value: number);
  8029. /**
  8030. * Gets the highlights Saturation value.
  8031. * 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.
  8032. */
  8033. get highlightsSaturation(): number;
  8034. /**
  8035. * Sets the highlights Saturation value.
  8036. * 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.
  8037. */
  8038. set highlightsSaturation(value: number);
  8039. /**
  8040. * Gets the highlights Exposure value.
  8041. * 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.
  8042. */
  8043. get highlightsExposure(): number;
  8044. /**
  8045. * Sets the highlights Exposure value.
  8046. * 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.
  8047. */
  8048. set highlightsExposure(value: number);
  8049. private _midtonesHue;
  8050. private _midtonesDensity;
  8051. private _midtonesSaturation;
  8052. private _midtonesExposure;
  8053. /**
  8054. * Gets the midtones Hue value.
  8055. * 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).
  8056. */
  8057. get midtonesHue(): number;
  8058. /**
  8059. * Sets the midtones Hue value.
  8060. * 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).
  8061. */
  8062. set midtonesHue(value: number);
  8063. /**
  8064. * Gets 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. get midtonesDensity(): number;
  8069. /**
  8070. * Sets the midtones Density value.
  8071. * 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.
  8072. * Values less than zero provide a filter of opposite hue.
  8073. */
  8074. set midtonesDensity(value: number);
  8075. /**
  8076. * Gets the midtones Saturation value.
  8077. * 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.
  8078. */
  8079. get midtonesSaturation(): number;
  8080. /**
  8081. * Sets the midtones Saturation value.
  8082. * 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.
  8083. */
  8084. set midtonesSaturation(value: number);
  8085. /**
  8086. * Gets the midtones Exposure value.
  8087. * 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.
  8088. */
  8089. get midtonesExposure(): number;
  8090. /**
  8091. * Sets the midtones Exposure value.
  8092. * 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.
  8093. */
  8094. set midtonesExposure(value: number);
  8095. private _shadowsHue;
  8096. private _shadowsDensity;
  8097. private _shadowsSaturation;
  8098. private _shadowsExposure;
  8099. /**
  8100. * Gets the shadows Hue value.
  8101. * 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).
  8102. */
  8103. get shadowsHue(): number;
  8104. /**
  8105. * Sets the shadows Hue value.
  8106. * 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).
  8107. */
  8108. set shadowsHue(value: number);
  8109. /**
  8110. * Gets 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. get shadowsDensity(): number;
  8115. /**
  8116. * Sets the shadows Density value.
  8117. * 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.
  8118. * Values less than zero provide a filter of opposite hue.
  8119. */
  8120. set shadowsDensity(value: number);
  8121. /**
  8122. * Gets the shadows Saturation value.
  8123. * 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.
  8124. */
  8125. get shadowsSaturation(): number;
  8126. /**
  8127. * Sets the shadows Saturation value.
  8128. * 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.
  8129. */
  8130. set shadowsSaturation(value: number);
  8131. /**
  8132. * Gets the shadows Exposure value.
  8133. * 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.
  8134. */
  8135. get shadowsExposure(): number;
  8136. /**
  8137. * Sets the shadows Exposure value.
  8138. * 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.
  8139. */
  8140. set shadowsExposure(value: number);
  8141. /**
  8142. * Returns the class name
  8143. * @returns The class name
  8144. */
  8145. getClassName(): string;
  8146. /**
  8147. * Binds the color curves to the shader.
  8148. * @param colorCurves The color curve to bind
  8149. * @param effect The effect to bind to
  8150. * @param positiveUniform The positive uniform shader parameter
  8151. * @param neutralUniform The neutral uniform shader parameter
  8152. * @param negativeUniform The negative uniform shader parameter
  8153. */
  8154. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8155. /**
  8156. * Prepare the list of uniforms associated with the ColorCurves effects.
  8157. * @param uniformsList The list of uniforms used in the effect
  8158. */
  8159. static PrepareUniforms(uniformsList: string[]): void;
  8160. /**
  8161. * Returns color grading data based on a hue, density, saturation and exposure value.
  8162. * @param filterHue The hue of the color filter.
  8163. * @param filterDensity The density of the color filter.
  8164. * @param saturation The saturation.
  8165. * @param exposure The exposure.
  8166. * @param result The result data container.
  8167. */
  8168. private getColorGradingDataToRef;
  8169. /**
  8170. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8171. * @param value The input slider value in range [-100,100].
  8172. * @returns Adjusted value.
  8173. */
  8174. private static applyColorGradingSliderNonlinear;
  8175. /**
  8176. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8177. * @param hue The hue (H) input.
  8178. * @param saturation The saturation (S) input.
  8179. * @param brightness The brightness (B) input.
  8180. * @result An RGBA color represented as Vector4.
  8181. */
  8182. private static fromHSBToRef;
  8183. /**
  8184. * Returns a value clamped between min and max
  8185. * @param value The value to clamp
  8186. * @param min The minimum of value
  8187. * @param max The maximum of value
  8188. * @returns The clamped value.
  8189. */
  8190. private static clamp;
  8191. /**
  8192. * Clones the current color curve instance.
  8193. * @return The cloned curves
  8194. */
  8195. clone(): ColorCurves;
  8196. /**
  8197. * Serializes the current color curve instance to a json representation.
  8198. * @return a JSON representation
  8199. */
  8200. serialize(): any;
  8201. /**
  8202. * Parses the color curve from a json representation.
  8203. * @param source the JSON source to parse
  8204. * @return The parsed curves
  8205. */
  8206. static Parse(source: any): ColorCurves;
  8207. }
  8208. }
  8209. declare module BABYLON {
  8210. /**
  8211. * Interface to follow in your material defines to integrate easily the
  8212. * Image proccessing functions.
  8213. * @hidden
  8214. */
  8215. export interface IImageProcessingConfigurationDefines {
  8216. IMAGEPROCESSING: boolean;
  8217. VIGNETTE: boolean;
  8218. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8219. VIGNETTEBLENDMODEOPAQUE: boolean;
  8220. TONEMAPPING: boolean;
  8221. TONEMAPPING_ACES: boolean;
  8222. CONTRAST: boolean;
  8223. EXPOSURE: boolean;
  8224. COLORCURVES: boolean;
  8225. COLORGRADING: boolean;
  8226. COLORGRADING3D: boolean;
  8227. SAMPLER3DGREENDEPTH: boolean;
  8228. SAMPLER3DBGRMAP: boolean;
  8229. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8230. }
  8231. /**
  8232. * @hidden
  8233. */
  8234. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8235. IMAGEPROCESSING: boolean;
  8236. VIGNETTE: boolean;
  8237. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8238. VIGNETTEBLENDMODEOPAQUE: boolean;
  8239. TONEMAPPING: boolean;
  8240. TONEMAPPING_ACES: boolean;
  8241. CONTRAST: boolean;
  8242. COLORCURVES: boolean;
  8243. COLORGRADING: boolean;
  8244. COLORGRADING3D: boolean;
  8245. SAMPLER3DGREENDEPTH: boolean;
  8246. SAMPLER3DBGRMAP: boolean;
  8247. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8248. EXPOSURE: boolean;
  8249. constructor();
  8250. }
  8251. /**
  8252. * This groups together the common properties used for image processing either in direct forward pass
  8253. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8254. * or not.
  8255. */
  8256. export class ImageProcessingConfiguration {
  8257. /**
  8258. * Default tone mapping applied in BabylonJS.
  8259. */
  8260. static readonly TONEMAPPING_STANDARD: number;
  8261. /**
  8262. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8263. * to other engines rendering to increase portability.
  8264. */
  8265. static readonly TONEMAPPING_ACES: number;
  8266. /**
  8267. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8268. */
  8269. colorCurves: Nullable<ColorCurves>;
  8270. private _colorCurvesEnabled;
  8271. /**
  8272. * Gets wether the color curves effect is enabled.
  8273. */
  8274. get colorCurvesEnabled(): boolean;
  8275. /**
  8276. * Sets wether the color curves effect is enabled.
  8277. */
  8278. set colorCurvesEnabled(value: boolean);
  8279. private _colorGradingTexture;
  8280. /**
  8281. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8282. */
  8283. get colorGradingTexture(): Nullable<BaseTexture>;
  8284. /**
  8285. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8286. */
  8287. set colorGradingTexture(value: Nullable<BaseTexture>);
  8288. private _colorGradingEnabled;
  8289. /**
  8290. * Gets wether the color grading effect is enabled.
  8291. */
  8292. get colorGradingEnabled(): boolean;
  8293. /**
  8294. * Sets wether the color grading effect is enabled.
  8295. */
  8296. set colorGradingEnabled(value: boolean);
  8297. private _colorGradingWithGreenDepth;
  8298. /**
  8299. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8300. */
  8301. get colorGradingWithGreenDepth(): boolean;
  8302. /**
  8303. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8304. */
  8305. set colorGradingWithGreenDepth(value: boolean);
  8306. private _colorGradingBGR;
  8307. /**
  8308. * Gets wether the color grading texture contains BGR values.
  8309. */
  8310. get colorGradingBGR(): boolean;
  8311. /**
  8312. * Sets wether the color grading texture contains BGR values.
  8313. */
  8314. set colorGradingBGR(value: boolean);
  8315. /** @hidden */
  8316. _exposure: number;
  8317. /**
  8318. * Gets the Exposure used in the effect.
  8319. */
  8320. get exposure(): number;
  8321. /**
  8322. * Sets the Exposure used in the effect.
  8323. */
  8324. set exposure(value: number);
  8325. private _toneMappingEnabled;
  8326. /**
  8327. * Gets wether the tone mapping effect is enabled.
  8328. */
  8329. get toneMappingEnabled(): boolean;
  8330. /**
  8331. * Sets wether the tone mapping effect is enabled.
  8332. */
  8333. set toneMappingEnabled(value: boolean);
  8334. private _toneMappingType;
  8335. /**
  8336. * Gets the type of tone mapping effect.
  8337. */
  8338. get toneMappingType(): number;
  8339. /**
  8340. * Sets the type of tone mapping effect used in BabylonJS.
  8341. */
  8342. set toneMappingType(value: number);
  8343. protected _contrast: number;
  8344. /**
  8345. * Gets the contrast used in the effect.
  8346. */
  8347. get contrast(): number;
  8348. /**
  8349. * Sets the contrast used in the effect.
  8350. */
  8351. set contrast(value: number);
  8352. /**
  8353. * Vignette stretch size.
  8354. */
  8355. vignetteStretch: number;
  8356. /**
  8357. * Vignette centre X Offset.
  8358. */
  8359. vignetteCentreX: number;
  8360. /**
  8361. * Vignette centre Y Offset.
  8362. */
  8363. vignetteCentreY: number;
  8364. /**
  8365. * Vignette weight or intensity of the vignette effect.
  8366. */
  8367. vignetteWeight: number;
  8368. /**
  8369. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8370. * if vignetteEnabled is set to true.
  8371. */
  8372. vignetteColor: Color4;
  8373. /**
  8374. * Camera field of view used by the Vignette effect.
  8375. */
  8376. vignetteCameraFov: number;
  8377. private _vignetteBlendMode;
  8378. /**
  8379. * Gets the vignette blend mode allowing different kind of effect.
  8380. */
  8381. get vignetteBlendMode(): number;
  8382. /**
  8383. * Sets the vignette blend mode allowing different kind of effect.
  8384. */
  8385. set vignetteBlendMode(value: number);
  8386. private _vignetteEnabled;
  8387. /**
  8388. * Gets wether the vignette effect is enabled.
  8389. */
  8390. get vignetteEnabled(): boolean;
  8391. /**
  8392. * Sets wether the vignette effect is enabled.
  8393. */
  8394. set vignetteEnabled(value: boolean);
  8395. private _applyByPostProcess;
  8396. /**
  8397. * Gets wether the image processing is applied through a post process or not.
  8398. */
  8399. get applyByPostProcess(): boolean;
  8400. /**
  8401. * Sets wether the image processing is applied through a post process or not.
  8402. */
  8403. set applyByPostProcess(value: boolean);
  8404. private _isEnabled;
  8405. /**
  8406. * Gets wether the image processing is enabled or not.
  8407. */
  8408. get isEnabled(): boolean;
  8409. /**
  8410. * Sets wether the image processing is enabled or not.
  8411. */
  8412. set isEnabled(value: boolean);
  8413. /**
  8414. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8415. */
  8416. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8417. /**
  8418. * Method called each time the image processing information changes requires to recompile the effect.
  8419. */
  8420. protected _updateParameters(): void;
  8421. /**
  8422. * Gets the current class name.
  8423. * @return "ImageProcessingConfiguration"
  8424. */
  8425. getClassName(): string;
  8426. /**
  8427. * Prepare the list of uniforms associated with the Image Processing effects.
  8428. * @param uniforms The list of uniforms used in the effect
  8429. * @param defines the list of defines currently in use
  8430. */
  8431. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8432. /**
  8433. * Prepare the list of samplers associated with the Image Processing effects.
  8434. * @param samplersList The list of uniforms used in the effect
  8435. * @param defines the list of defines currently in use
  8436. */
  8437. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8438. /**
  8439. * Prepare the list of defines associated to the shader.
  8440. * @param defines the list of defines to complete
  8441. * @param forPostProcess Define if we are currently in post process mode or not
  8442. */
  8443. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8444. /**
  8445. * Returns true if all the image processing information are ready.
  8446. * @returns True if ready, otherwise, false
  8447. */
  8448. isReady(): boolean;
  8449. /**
  8450. * Binds the image processing to the shader.
  8451. * @param effect The effect to bind to
  8452. * @param overrideAspectRatio Override the aspect ratio of the effect
  8453. */
  8454. bind(effect: Effect, overrideAspectRatio?: number): void;
  8455. /**
  8456. * Clones the current image processing instance.
  8457. * @return The cloned image processing
  8458. */
  8459. clone(): ImageProcessingConfiguration;
  8460. /**
  8461. * Serializes the current image processing instance to a json representation.
  8462. * @return a JSON representation
  8463. */
  8464. serialize(): any;
  8465. /**
  8466. * Parses the image processing from a json representation.
  8467. * @param source the JSON source to parse
  8468. * @return The parsed image processing
  8469. */
  8470. static Parse(source: any): ImageProcessingConfiguration;
  8471. private static _VIGNETTEMODE_MULTIPLY;
  8472. private static _VIGNETTEMODE_OPAQUE;
  8473. /**
  8474. * Used to apply the vignette as a mix with the pixel color.
  8475. */
  8476. static get VIGNETTEMODE_MULTIPLY(): number;
  8477. /**
  8478. * Used to apply the vignette as a replacement of the pixel color.
  8479. */
  8480. static get VIGNETTEMODE_OPAQUE(): number;
  8481. }
  8482. }
  8483. declare module BABYLON {
  8484. /** @hidden */
  8485. export var postprocessVertexShader: {
  8486. name: string;
  8487. shader: string;
  8488. };
  8489. }
  8490. declare module BABYLON {
  8491. interface ThinEngine {
  8492. /**
  8493. * Creates a new render target texture
  8494. * @param size defines the size of the texture
  8495. * @param options defines the options used to create the texture
  8496. * @returns a new render target texture stored in an InternalTexture
  8497. */
  8498. createRenderTargetTexture(size: number | {
  8499. width: number;
  8500. height: number;
  8501. layers?: number;
  8502. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8503. /**
  8504. * Creates a depth stencil texture.
  8505. * This is only available in WebGL 2 or with the depth texture extension available.
  8506. * @param size The size of face edge in the texture.
  8507. * @param options The options defining the texture.
  8508. * @returns The texture
  8509. */
  8510. createDepthStencilTexture(size: number | {
  8511. width: number;
  8512. height: number;
  8513. layers?: number;
  8514. }, options: DepthTextureCreationOptions): InternalTexture;
  8515. /** @hidden */
  8516. _createDepthStencilTexture(size: number | {
  8517. width: number;
  8518. height: number;
  8519. layers?: number;
  8520. }, options: DepthTextureCreationOptions): InternalTexture;
  8521. }
  8522. }
  8523. declare module BABYLON {
  8524. /**
  8525. * Defines the kind of connection point for node based material
  8526. */
  8527. export enum NodeMaterialBlockConnectionPointTypes {
  8528. /** Float */
  8529. Float = 1,
  8530. /** Int */
  8531. Int = 2,
  8532. /** Vector2 */
  8533. Vector2 = 4,
  8534. /** Vector3 */
  8535. Vector3 = 8,
  8536. /** Vector4 */
  8537. Vector4 = 16,
  8538. /** Color3 */
  8539. Color3 = 32,
  8540. /** Color4 */
  8541. Color4 = 64,
  8542. /** Matrix */
  8543. Matrix = 128,
  8544. /** Custom object */
  8545. Object = 256,
  8546. /** Detect type based on connection */
  8547. AutoDetect = 1024,
  8548. /** Output type that will be defined by input type */
  8549. BasedOnInput = 2048
  8550. }
  8551. }
  8552. declare module BABYLON {
  8553. /**
  8554. * Enum used to define the target of a block
  8555. */
  8556. export enum NodeMaterialBlockTargets {
  8557. /** Vertex shader */
  8558. Vertex = 1,
  8559. /** Fragment shader */
  8560. Fragment = 2,
  8561. /** Neutral */
  8562. Neutral = 4,
  8563. /** Vertex and Fragment */
  8564. VertexAndFragment = 3
  8565. }
  8566. }
  8567. declare module BABYLON {
  8568. /**
  8569. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8570. */
  8571. export enum NodeMaterialBlockConnectionPointMode {
  8572. /** Value is an uniform */
  8573. Uniform = 0,
  8574. /** Value is a mesh attribute */
  8575. Attribute = 1,
  8576. /** Value is a varying between vertex and fragment shaders */
  8577. Varying = 2,
  8578. /** Mode is undefined */
  8579. Undefined = 3
  8580. }
  8581. }
  8582. declare module BABYLON {
  8583. /**
  8584. * Enum used to define system values e.g. values automatically provided by the system
  8585. */
  8586. export enum NodeMaterialSystemValues {
  8587. /** World */
  8588. World = 1,
  8589. /** View */
  8590. View = 2,
  8591. /** Projection */
  8592. Projection = 3,
  8593. /** ViewProjection */
  8594. ViewProjection = 4,
  8595. /** WorldView */
  8596. WorldView = 5,
  8597. /** WorldViewProjection */
  8598. WorldViewProjection = 6,
  8599. /** CameraPosition */
  8600. CameraPosition = 7,
  8601. /** Fog Color */
  8602. FogColor = 8,
  8603. /** Delta time */
  8604. DeltaTime = 9
  8605. }
  8606. }
  8607. declare module BABYLON {
  8608. /** Defines supported spaces */
  8609. export enum Space {
  8610. /** Local (object) space */
  8611. LOCAL = 0,
  8612. /** World space */
  8613. WORLD = 1,
  8614. /** Bone space */
  8615. BONE = 2
  8616. }
  8617. /** Defines the 3 main axes */
  8618. export class Axis {
  8619. /** X axis */
  8620. static X: Vector3;
  8621. /** Y axis */
  8622. static Y: Vector3;
  8623. /** Z axis */
  8624. static Z: Vector3;
  8625. }
  8626. }
  8627. declare module BABYLON {
  8628. /**
  8629. * Represents a camera frustum
  8630. */
  8631. export class Frustum {
  8632. /**
  8633. * Gets the planes representing the frustum
  8634. * @param transform matrix to be applied to the returned planes
  8635. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8636. */
  8637. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8638. /**
  8639. * Gets the near 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 GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8644. /**
  8645. * Gets the far 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 GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8650. /**
  8651. * Gets the left 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 GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8656. /**
  8657. * Gets the right 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 GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8662. /**
  8663. * Gets the top 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 GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8668. /**
  8669. * Gets the bottom frustum plane transformed by the transform matrix
  8670. * @param transform transformation matrix to be applied to the resulting frustum plane
  8671. * @param frustumPlane the resuling frustum plane
  8672. */
  8673. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8674. /**
  8675. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8676. * @param transform transformation matrix to be applied to the resulting frustum planes
  8677. * @param frustumPlanes the resuling frustum planes
  8678. */
  8679. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8680. }
  8681. }
  8682. declare module BABYLON {
  8683. /**
  8684. * Interface for the size containing width and height
  8685. */
  8686. export interface ISize {
  8687. /**
  8688. * Width
  8689. */
  8690. width: number;
  8691. /**
  8692. * Heighht
  8693. */
  8694. height: number;
  8695. }
  8696. /**
  8697. * Size containing widht and height
  8698. */
  8699. export class Size implements ISize {
  8700. /**
  8701. * Width
  8702. */
  8703. width: number;
  8704. /**
  8705. * Height
  8706. */
  8707. height: number;
  8708. /**
  8709. * Creates a Size object from the given width and height (floats).
  8710. * @param width width of the new size
  8711. * @param height height of the new size
  8712. */
  8713. constructor(width: number, height: number);
  8714. /**
  8715. * Returns a string with the Size width and height
  8716. * @returns a string with the Size width and height
  8717. */
  8718. toString(): string;
  8719. /**
  8720. * "Size"
  8721. * @returns the string "Size"
  8722. */
  8723. getClassName(): string;
  8724. /**
  8725. * Returns the Size hash code.
  8726. * @returns a hash code for a unique width and height
  8727. */
  8728. getHashCode(): number;
  8729. /**
  8730. * Updates the current size from the given one.
  8731. * @param src the given size
  8732. */
  8733. copyFrom(src: Size): void;
  8734. /**
  8735. * Updates in place the current Size from the given floats.
  8736. * @param width width of the new size
  8737. * @param height height of the new size
  8738. * @returns the updated Size.
  8739. */
  8740. copyFromFloats(width: number, height: number): Size;
  8741. /**
  8742. * Updates in place the current Size from the given floats.
  8743. * @param width width to set
  8744. * @param height height to set
  8745. * @returns the updated Size.
  8746. */
  8747. set(width: number, height: number): Size;
  8748. /**
  8749. * Multiplies the width and height by numbers
  8750. * @param w factor to multiple the width by
  8751. * @param h factor to multiple the height by
  8752. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8753. */
  8754. multiplyByFloats(w: number, h: number): Size;
  8755. /**
  8756. * Clones the size
  8757. * @returns a new Size copied from the given one.
  8758. */
  8759. clone(): Size;
  8760. /**
  8761. * True if the current Size and the given one width and height are strictly equal.
  8762. * @param other the other size to compare against
  8763. * @returns True if the current Size and the given one width and height are strictly equal.
  8764. */
  8765. equals(other: Size): boolean;
  8766. /**
  8767. * The surface of the Size : width * height (float).
  8768. */
  8769. get surface(): number;
  8770. /**
  8771. * Create a new size of zero
  8772. * @returns a new Size set to (0.0, 0.0)
  8773. */
  8774. static Zero(): Size;
  8775. /**
  8776. * Sums the width and height of two sizes
  8777. * @param otherSize size to add to this size
  8778. * @returns a new Size set as the addition result of the current Size and the given one.
  8779. */
  8780. add(otherSize: Size): Size;
  8781. /**
  8782. * Subtracts the width and height of two
  8783. * @param otherSize size to subtract to this size
  8784. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8785. */
  8786. subtract(otherSize: Size): Size;
  8787. /**
  8788. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8789. * @param start starting size to lerp between
  8790. * @param end end size to lerp between
  8791. * @param amount amount to lerp between the start and end values
  8792. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8793. */
  8794. static Lerp(start: Size, end: Size, amount: number): Size;
  8795. }
  8796. }
  8797. declare module BABYLON {
  8798. /**
  8799. * Contains position and normal vectors for a vertex
  8800. */
  8801. export class PositionNormalVertex {
  8802. /** the position of the vertex (defaut: 0,0,0) */
  8803. position: Vector3;
  8804. /** the normal of the vertex (defaut: 0,1,0) */
  8805. normal: Vector3;
  8806. /**
  8807. * Creates a PositionNormalVertex
  8808. * @param position the position of the vertex (defaut: 0,0,0)
  8809. * @param normal the normal of the vertex (defaut: 0,1,0)
  8810. */
  8811. constructor(
  8812. /** the position of the vertex (defaut: 0,0,0) */
  8813. position?: Vector3,
  8814. /** the normal of the vertex (defaut: 0,1,0) */
  8815. normal?: Vector3);
  8816. /**
  8817. * Clones the PositionNormalVertex
  8818. * @returns the cloned PositionNormalVertex
  8819. */
  8820. clone(): PositionNormalVertex;
  8821. }
  8822. /**
  8823. * Contains position, normal and uv vectors for a vertex
  8824. */
  8825. export class PositionNormalTextureVertex {
  8826. /** the position of the vertex (defaut: 0,0,0) */
  8827. position: Vector3;
  8828. /** the normal of the vertex (defaut: 0,1,0) */
  8829. normal: Vector3;
  8830. /** the uv of the vertex (default: 0,0) */
  8831. uv: Vector2;
  8832. /**
  8833. * Creates a PositionNormalTextureVertex
  8834. * @param position the position of the vertex (defaut: 0,0,0)
  8835. * @param normal the normal of the vertex (defaut: 0,1,0)
  8836. * @param uv the uv of the vertex (default: 0,0)
  8837. */
  8838. constructor(
  8839. /** the position of the vertex (defaut: 0,0,0) */
  8840. position?: Vector3,
  8841. /** the normal of the vertex (defaut: 0,1,0) */
  8842. normal?: Vector3,
  8843. /** the uv of the vertex (default: 0,0) */
  8844. uv?: Vector2);
  8845. /**
  8846. * Clones the PositionNormalTextureVertex
  8847. * @returns the cloned PositionNormalTextureVertex
  8848. */
  8849. clone(): PositionNormalTextureVertex;
  8850. }
  8851. }
  8852. declare module BABYLON {
  8853. /**
  8854. * Enum defining the type of animations supported by InputBlock
  8855. */
  8856. export enum AnimatedInputBlockTypes {
  8857. /** No animation */
  8858. None = 0,
  8859. /** Time based animation. Will only work for floats */
  8860. Time = 1
  8861. }
  8862. }
  8863. declare module BABYLON {
  8864. /**
  8865. * Interface describing all the common properties and methods a shadow light needs to implement.
  8866. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8867. * as well as binding the different shadow properties to the effects.
  8868. */
  8869. export interface IShadowLight extends Light {
  8870. /**
  8871. * The light id in the scene (used in scene.findLighById for instance)
  8872. */
  8873. id: string;
  8874. /**
  8875. * The position the shdow will be casted from.
  8876. */
  8877. position: Vector3;
  8878. /**
  8879. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8880. */
  8881. direction: Vector3;
  8882. /**
  8883. * The transformed position. Position of the light in world space taking parenting in account.
  8884. */
  8885. transformedPosition: Vector3;
  8886. /**
  8887. * The transformed direction. Direction of the light in world space taking parenting in account.
  8888. */
  8889. transformedDirection: Vector3;
  8890. /**
  8891. * The friendly name of the light in the scene.
  8892. */
  8893. name: string;
  8894. /**
  8895. * Defines the shadow projection clipping minimum z value.
  8896. */
  8897. shadowMinZ: number;
  8898. /**
  8899. * Defines the shadow projection clipping maximum z value.
  8900. */
  8901. shadowMaxZ: number;
  8902. /**
  8903. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8904. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8905. */
  8906. computeTransformedInformation(): boolean;
  8907. /**
  8908. * Gets the scene the light belongs to.
  8909. * @returns The scene
  8910. */
  8911. getScene(): Scene;
  8912. /**
  8913. * Callback defining a custom Projection Matrix Builder.
  8914. * This can be used to override the default projection matrix computation.
  8915. */
  8916. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8917. /**
  8918. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8919. * @param matrix The materix to updated with the projection information
  8920. * @param viewMatrix The transform matrix of the light
  8921. * @param renderList The list of mesh to render in the map
  8922. * @returns The current light
  8923. */
  8924. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8925. /**
  8926. * Gets the current depth scale used in ESM.
  8927. * @returns The scale
  8928. */
  8929. getDepthScale(): number;
  8930. /**
  8931. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8932. * @returns true if a cube texture needs to be use
  8933. */
  8934. needCube(): boolean;
  8935. /**
  8936. * Detects if the projection matrix requires to be recomputed this frame.
  8937. * @returns true if it requires to be recomputed otherwise, false.
  8938. */
  8939. needProjectionMatrixCompute(): boolean;
  8940. /**
  8941. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8942. */
  8943. forceProjectionMatrixCompute(): void;
  8944. /**
  8945. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8946. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8947. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8948. */
  8949. getShadowDirection(faceIndex?: number): Vector3;
  8950. /**
  8951. * Gets the minZ used for shadow according to both the scene and the light.
  8952. * @param activeCamera The camera we are returning the min for
  8953. * @returns the depth min z
  8954. */
  8955. getDepthMinZ(activeCamera: Camera): number;
  8956. /**
  8957. * Gets the maxZ used for shadow according to both the scene and the light.
  8958. * @param activeCamera The camera we are returning the max for
  8959. * @returns the depth max z
  8960. */
  8961. getDepthMaxZ(activeCamera: Camera): number;
  8962. }
  8963. /**
  8964. * Base implementation IShadowLight
  8965. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8966. */
  8967. export abstract class ShadowLight extends Light implements IShadowLight {
  8968. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8969. protected _position: Vector3;
  8970. protected _setPosition(value: Vector3): void;
  8971. /**
  8972. * Sets the position the shadow will be casted from. Also use as the light position for both
  8973. * point and spot lights.
  8974. */
  8975. get position(): Vector3;
  8976. /**
  8977. * Sets the position the shadow will be casted from. Also use as the light position for both
  8978. * point and spot lights.
  8979. */
  8980. set position(value: Vector3);
  8981. protected _direction: Vector3;
  8982. protected _setDirection(value: Vector3): void;
  8983. /**
  8984. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8985. * Also use as the light direction on spot and directional lights.
  8986. */
  8987. get direction(): Vector3;
  8988. /**
  8989. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8990. * Also use as the light direction on spot and directional lights.
  8991. */
  8992. set direction(value: Vector3);
  8993. protected _shadowMinZ: number;
  8994. /**
  8995. * Gets the shadow projection clipping minimum z value.
  8996. */
  8997. get shadowMinZ(): number;
  8998. /**
  8999. * Sets the shadow projection clipping minimum z value.
  9000. */
  9001. set shadowMinZ(value: number);
  9002. protected _shadowMaxZ: number;
  9003. /**
  9004. * Sets the shadow projection clipping maximum z value.
  9005. */
  9006. get shadowMaxZ(): number;
  9007. /**
  9008. * Gets the shadow projection clipping maximum z value.
  9009. */
  9010. set shadowMaxZ(value: number);
  9011. /**
  9012. * Callback defining a custom Projection Matrix Builder.
  9013. * This can be used to override the default projection matrix computation.
  9014. */
  9015. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9016. /**
  9017. * The transformed position. Position of the light in world space taking parenting in account.
  9018. */
  9019. transformedPosition: Vector3;
  9020. /**
  9021. * The transformed direction. Direction of the light in world space taking parenting in account.
  9022. */
  9023. transformedDirection: Vector3;
  9024. private _needProjectionMatrixCompute;
  9025. /**
  9026. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9027. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9028. */
  9029. computeTransformedInformation(): boolean;
  9030. /**
  9031. * Return the depth scale used for the shadow map.
  9032. * @returns the depth scale.
  9033. */
  9034. getDepthScale(): number;
  9035. /**
  9036. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9037. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9038. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9039. */
  9040. getShadowDirection(faceIndex?: number): Vector3;
  9041. /**
  9042. * Returns the ShadowLight absolute position in the World.
  9043. * @returns the position vector in world space
  9044. */
  9045. getAbsolutePosition(): Vector3;
  9046. /**
  9047. * Sets the ShadowLight direction toward the passed target.
  9048. * @param target The point to target in local space
  9049. * @returns the updated ShadowLight direction
  9050. */
  9051. setDirectionToTarget(target: Vector3): Vector3;
  9052. /**
  9053. * Returns the light rotation in euler definition.
  9054. * @returns the x y z rotation in local space.
  9055. */
  9056. getRotation(): Vector3;
  9057. /**
  9058. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9059. * @returns true if a cube texture needs to be use
  9060. */
  9061. needCube(): boolean;
  9062. /**
  9063. * Detects if the projection matrix requires to be recomputed this frame.
  9064. * @returns true if it requires to be recomputed otherwise, false.
  9065. */
  9066. needProjectionMatrixCompute(): boolean;
  9067. /**
  9068. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9069. */
  9070. forceProjectionMatrixCompute(): void;
  9071. /** @hidden */
  9072. _initCache(): void;
  9073. /** @hidden */
  9074. _isSynchronized(): boolean;
  9075. /**
  9076. * Computes the world matrix of the node
  9077. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9078. * @returns the world matrix
  9079. */
  9080. computeWorldMatrix(force?: boolean): Matrix;
  9081. /**
  9082. * Gets the minZ used for shadow according to both the scene and the light.
  9083. * @param activeCamera The camera we are returning the min for
  9084. * @returns the depth min z
  9085. */
  9086. getDepthMinZ(activeCamera: Camera): number;
  9087. /**
  9088. * Gets the maxZ used for shadow according to both the scene and the light.
  9089. * @param activeCamera The camera we are returning the max for
  9090. * @returns the depth max z
  9091. */
  9092. getDepthMaxZ(activeCamera: Camera): number;
  9093. /**
  9094. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9095. * @param matrix The materix to updated with the projection information
  9096. * @param viewMatrix The transform matrix of the light
  9097. * @param renderList The list of mesh to render in the map
  9098. * @returns The current light
  9099. */
  9100. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9101. }
  9102. }
  9103. declare module BABYLON {
  9104. /** @hidden */
  9105. export var packingFunctions: {
  9106. name: string;
  9107. shader: string;
  9108. };
  9109. }
  9110. declare module BABYLON {
  9111. /** @hidden */
  9112. export var bayerDitherFunctions: {
  9113. name: string;
  9114. shader: string;
  9115. };
  9116. }
  9117. declare module BABYLON {
  9118. /** @hidden */
  9119. export var shadowMapFragmentDeclaration: {
  9120. name: string;
  9121. shader: string;
  9122. };
  9123. }
  9124. declare module BABYLON {
  9125. /** @hidden */
  9126. export var clipPlaneFragmentDeclaration: {
  9127. name: string;
  9128. shader: string;
  9129. };
  9130. }
  9131. declare module BABYLON {
  9132. /** @hidden */
  9133. export var clipPlaneFragment: {
  9134. name: string;
  9135. shader: string;
  9136. };
  9137. }
  9138. declare module BABYLON {
  9139. /** @hidden */
  9140. export var shadowMapFragment: {
  9141. name: string;
  9142. shader: string;
  9143. };
  9144. }
  9145. declare module BABYLON {
  9146. /** @hidden */
  9147. export var shadowMapPixelShader: {
  9148. name: string;
  9149. shader: string;
  9150. };
  9151. }
  9152. declare module BABYLON {
  9153. /** @hidden */
  9154. export var bonesDeclaration: {
  9155. name: string;
  9156. shader: string;
  9157. };
  9158. }
  9159. declare module BABYLON {
  9160. /** @hidden */
  9161. export var morphTargetsVertexGlobalDeclaration: {
  9162. name: string;
  9163. shader: string;
  9164. };
  9165. }
  9166. declare module BABYLON {
  9167. /** @hidden */
  9168. export var morphTargetsVertexDeclaration: {
  9169. name: string;
  9170. shader: string;
  9171. };
  9172. }
  9173. declare module BABYLON {
  9174. /** @hidden */
  9175. export var instancesDeclaration: {
  9176. name: string;
  9177. shader: string;
  9178. };
  9179. }
  9180. declare module BABYLON {
  9181. /** @hidden */
  9182. export var helperFunctions: {
  9183. name: string;
  9184. shader: string;
  9185. };
  9186. }
  9187. declare module BABYLON {
  9188. /** @hidden */
  9189. export var shadowMapVertexDeclaration: {
  9190. name: string;
  9191. shader: string;
  9192. };
  9193. }
  9194. declare module BABYLON {
  9195. /** @hidden */
  9196. export var clipPlaneVertexDeclaration: {
  9197. name: string;
  9198. shader: string;
  9199. };
  9200. }
  9201. declare module BABYLON {
  9202. /** @hidden */
  9203. export var morphTargetsVertex: {
  9204. name: string;
  9205. shader: string;
  9206. };
  9207. }
  9208. declare module BABYLON {
  9209. /** @hidden */
  9210. export var instancesVertex: {
  9211. name: string;
  9212. shader: string;
  9213. };
  9214. }
  9215. declare module BABYLON {
  9216. /** @hidden */
  9217. export var bonesVertex: {
  9218. name: string;
  9219. shader: string;
  9220. };
  9221. }
  9222. declare module BABYLON {
  9223. /** @hidden */
  9224. export var shadowMapVertexNormalBias: {
  9225. name: string;
  9226. shader: string;
  9227. };
  9228. }
  9229. declare module BABYLON {
  9230. /** @hidden */
  9231. export var shadowMapVertexMetric: {
  9232. name: string;
  9233. shader: string;
  9234. };
  9235. }
  9236. declare module BABYLON {
  9237. /** @hidden */
  9238. export var clipPlaneVertex: {
  9239. name: string;
  9240. shader: string;
  9241. };
  9242. }
  9243. declare module BABYLON {
  9244. /** @hidden */
  9245. export var shadowMapVertexShader: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module BABYLON {
  9251. /** @hidden */
  9252. export var depthBoxBlurPixelShader: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module BABYLON {
  9258. /** @hidden */
  9259. export var shadowMapFragmentSoftTransparentShadow: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module BABYLON {
  9265. /**
  9266. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9267. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9268. */
  9269. export class EffectFallbacks implements IEffectFallbacks {
  9270. private _defines;
  9271. private _currentRank;
  9272. private _maxRank;
  9273. private _mesh;
  9274. /**
  9275. * Removes the fallback from the bound mesh.
  9276. */
  9277. unBindMesh(): void;
  9278. /**
  9279. * Adds a fallback on the specified property.
  9280. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9281. * @param define The name of the define in the shader
  9282. */
  9283. addFallback(rank: number, define: string): void;
  9284. /**
  9285. * Sets the mesh to use CPU skinning when needing to fallback.
  9286. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9287. * @param mesh The mesh to use the fallbacks.
  9288. */
  9289. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9290. /**
  9291. * Checks to see if more fallbacks are still availible.
  9292. */
  9293. get hasMoreFallbacks(): boolean;
  9294. /**
  9295. * Removes the defines that should be removed when falling back.
  9296. * @param currentDefines defines the current define statements for the shader.
  9297. * @param effect defines the current effect we try to compile
  9298. * @returns The resulting defines with defines of the current rank removed.
  9299. */
  9300. reduce(currentDefines: string, effect: Effect): string;
  9301. }
  9302. }
  9303. declare module BABYLON {
  9304. /**
  9305. * Interface used to define Action
  9306. */
  9307. export interface IAction {
  9308. /**
  9309. * Trigger for the action
  9310. */
  9311. trigger: number;
  9312. /** Options of the trigger */
  9313. triggerOptions: any;
  9314. /**
  9315. * Gets the trigger parameters
  9316. * @returns the trigger parameters
  9317. */
  9318. getTriggerParameter(): any;
  9319. /**
  9320. * Internal only - executes current action event
  9321. * @hidden
  9322. */
  9323. _executeCurrent(evt?: ActionEvent): void;
  9324. /**
  9325. * Serialize placeholder for child classes
  9326. * @param parent of child
  9327. * @returns the serialized object
  9328. */
  9329. serialize(parent: any): any;
  9330. /**
  9331. * Internal only
  9332. * @hidden
  9333. */
  9334. _prepare(): void;
  9335. /**
  9336. * Internal only - manager for action
  9337. * @hidden
  9338. */
  9339. _actionManager: AbstractActionManager;
  9340. /**
  9341. * Adds action to chain of actions, may be a DoNothingAction
  9342. * @param action defines the next action to execute
  9343. * @returns The action passed in
  9344. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9345. */
  9346. then(action: IAction): IAction;
  9347. }
  9348. /**
  9349. * The action to be carried out following a trigger
  9350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9351. */
  9352. export class Action implements IAction {
  9353. /** the trigger, with or without parameters, for the action */
  9354. triggerOptions: any;
  9355. /**
  9356. * Trigger for the action
  9357. */
  9358. trigger: number;
  9359. /**
  9360. * Internal only - manager for action
  9361. * @hidden
  9362. */
  9363. _actionManager: ActionManager;
  9364. private _nextActiveAction;
  9365. private _child;
  9366. private _condition?;
  9367. private _triggerParameter;
  9368. /**
  9369. * An event triggered prior to action being executed.
  9370. */
  9371. onBeforeExecuteObservable: Observable<Action>;
  9372. /**
  9373. * Creates a new Action
  9374. * @param triggerOptions the trigger, with or without parameters, for the action
  9375. * @param condition an optional determinant of action
  9376. */
  9377. constructor(
  9378. /** the trigger, with or without parameters, for the action */
  9379. triggerOptions: any, condition?: Condition);
  9380. /**
  9381. * Internal only
  9382. * @hidden
  9383. */
  9384. _prepare(): void;
  9385. /**
  9386. * Gets the trigger parameters
  9387. * @returns the trigger parameters
  9388. */
  9389. getTriggerParameter(): any;
  9390. /**
  9391. * Internal only - executes current action event
  9392. * @hidden
  9393. */
  9394. _executeCurrent(evt?: ActionEvent): void;
  9395. /**
  9396. * Execute placeholder for child classes
  9397. * @param evt optional action event
  9398. */
  9399. execute(evt?: ActionEvent): void;
  9400. /**
  9401. * Skips to next active action
  9402. */
  9403. skipToNextActiveAction(): void;
  9404. /**
  9405. * Adds action to chain of actions, may be a DoNothingAction
  9406. * @param action defines the next action to execute
  9407. * @returns The action passed in
  9408. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9409. */
  9410. then(action: Action): Action;
  9411. /**
  9412. * Internal only
  9413. * @hidden
  9414. */
  9415. _getProperty(propertyPath: string): string;
  9416. /**
  9417. * Internal only
  9418. * @hidden
  9419. */
  9420. _getEffectiveTarget(target: any, propertyPath: string): any;
  9421. /**
  9422. * Serialize placeholder for child classes
  9423. * @param parent of child
  9424. * @returns the serialized object
  9425. */
  9426. serialize(parent: any): any;
  9427. /**
  9428. * Internal only called by serialize
  9429. * @hidden
  9430. */
  9431. protected _serialize(serializedAction: any, parent?: any): any;
  9432. /**
  9433. * Internal only
  9434. * @hidden
  9435. */
  9436. static _SerializeValueAsString: (value: any) => string;
  9437. /**
  9438. * Internal only
  9439. * @hidden
  9440. */
  9441. static _GetTargetProperty: (target: Node | Scene) => {
  9442. name: string;
  9443. targetType: string;
  9444. value: string;
  9445. };
  9446. }
  9447. }
  9448. declare module BABYLON {
  9449. /**
  9450. * A Condition applied to an Action
  9451. */
  9452. export class Condition {
  9453. /**
  9454. * Internal only - manager for action
  9455. * @hidden
  9456. */
  9457. _actionManager: ActionManager;
  9458. /**
  9459. * Internal only
  9460. * @hidden
  9461. */
  9462. _evaluationId: number;
  9463. /**
  9464. * Internal only
  9465. * @hidden
  9466. */
  9467. _currentResult: boolean;
  9468. /**
  9469. * Creates a new Condition
  9470. * @param actionManager the manager of the action the condition is applied to
  9471. */
  9472. constructor(actionManager: ActionManager);
  9473. /**
  9474. * Check if the current condition is valid
  9475. * @returns a boolean
  9476. */
  9477. isValid(): boolean;
  9478. /**
  9479. * Internal only
  9480. * @hidden
  9481. */
  9482. _getProperty(propertyPath: string): string;
  9483. /**
  9484. * Internal only
  9485. * @hidden
  9486. */
  9487. _getEffectiveTarget(target: any, propertyPath: string): any;
  9488. /**
  9489. * Serialize placeholder for child classes
  9490. * @returns the serialized object
  9491. */
  9492. serialize(): any;
  9493. /**
  9494. * Internal only
  9495. * @hidden
  9496. */
  9497. protected _serialize(serializedCondition: any): any;
  9498. }
  9499. /**
  9500. * Defines specific conditional operators as extensions of Condition
  9501. */
  9502. export class ValueCondition extends Condition {
  9503. /** path to specify the property of the target the conditional operator uses */
  9504. propertyPath: string;
  9505. /** the value compared by the conditional operator against the current value of the property */
  9506. value: any;
  9507. /** the conditional operator, default ValueCondition.IsEqual */
  9508. operator: number;
  9509. /**
  9510. * Internal only
  9511. * @hidden
  9512. */
  9513. private static _IsEqual;
  9514. /**
  9515. * Internal only
  9516. * @hidden
  9517. */
  9518. private static _IsDifferent;
  9519. /**
  9520. * Internal only
  9521. * @hidden
  9522. */
  9523. private static _IsGreater;
  9524. /**
  9525. * Internal only
  9526. * @hidden
  9527. */
  9528. private static _IsLesser;
  9529. /**
  9530. * returns the number for IsEqual
  9531. */
  9532. static get IsEqual(): number;
  9533. /**
  9534. * Returns the number for IsDifferent
  9535. */
  9536. static get IsDifferent(): number;
  9537. /**
  9538. * Returns the number for IsGreater
  9539. */
  9540. static get IsGreater(): number;
  9541. /**
  9542. * Returns the number for IsLesser
  9543. */
  9544. static get IsLesser(): number;
  9545. /**
  9546. * Internal only The action manager for the condition
  9547. * @hidden
  9548. */
  9549. _actionManager: ActionManager;
  9550. /**
  9551. * Internal only
  9552. * @hidden
  9553. */
  9554. private _target;
  9555. /**
  9556. * Internal only
  9557. * @hidden
  9558. */
  9559. private _effectiveTarget;
  9560. /**
  9561. * Internal only
  9562. * @hidden
  9563. */
  9564. private _property;
  9565. /**
  9566. * Creates a new ValueCondition
  9567. * @param actionManager manager for the action the condition applies to
  9568. * @param target for the action
  9569. * @param propertyPath path to specify the property of the target the conditional operator uses
  9570. * @param value the value compared by the conditional operator against the current value of the property
  9571. * @param operator the conditional operator, default ValueCondition.IsEqual
  9572. */
  9573. constructor(actionManager: ActionManager, target: any,
  9574. /** path to specify the property of the target the conditional operator uses */
  9575. propertyPath: string,
  9576. /** the value compared by the conditional operator against the current value of the property */
  9577. value: any,
  9578. /** the conditional operator, default ValueCondition.IsEqual */
  9579. operator?: number);
  9580. /**
  9581. * Compares the given value with the property value for the specified conditional operator
  9582. * @returns the result of the comparison
  9583. */
  9584. isValid(): boolean;
  9585. /**
  9586. * Serialize the ValueCondition into a JSON compatible object
  9587. * @returns serialization object
  9588. */
  9589. serialize(): any;
  9590. /**
  9591. * Gets the name of the conditional operator for the ValueCondition
  9592. * @param operator the conditional operator
  9593. * @returns the name
  9594. */
  9595. static GetOperatorName(operator: number): string;
  9596. }
  9597. /**
  9598. * Defines a predicate condition as an extension of Condition
  9599. */
  9600. export class PredicateCondition extends Condition {
  9601. /** defines the predicate function used to validate the condition */
  9602. predicate: () => boolean;
  9603. /**
  9604. * Internal only - manager for action
  9605. * @hidden
  9606. */
  9607. _actionManager: ActionManager;
  9608. /**
  9609. * Creates a new PredicateCondition
  9610. * @param actionManager manager for the action the condition applies to
  9611. * @param predicate defines the predicate function used to validate the condition
  9612. */
  9613. constructor(actionManager: ActionManager,
  9614. /** defines the predicate function used to validate the condition */
  9615. predicate: () => boolean);
  9616. /**
  9617. * @returns the validity of the predicate condition
  9618. */
  9619. isValid(): boolean;
  9620. }
  9621. /**
  9622. * Defines a state condition as an extension of Condition
  9623. */
  9624. export class StateCondition extends Condition {
  9625. /** Value to compare with target state */
  9626. value: string;
  9627. /**
  9628. * Internal only - manager for action
  9629. * @hidden
  9630. */
  9631. _actionManager: ActionManager;
  9632. /**
  9633. * Internal only
  9634. * @hidden
  9635. */
  9636. private _target;
  9637. /**
  9638. * Creates a new StateCondition
  9639. * @param actionManager manager for the action the condition applies to
  9640. * @param target of the condition
  9641. * @param value to compare with target state
  9642. */
  9643. constructor(actionManager: ActionManager, target: any,
  9644. /** Value to compare with target state */
  9645. value: string);
  9646. /**
  9647. * Gets a boolean indicating if the current condition is met
  9648. * @returns the validity of the state
  9649. */
  9650. isValid(): boolean;
  9651. /**
  9652. * Serialize the StateCondition into a JSON compatible object
  9653. * @returns serialization object
  9654. */
  9655. serialize(): any;
  9656. }
  9657. }
  9658. declare module BABYLON {
  9659. /**
  9660. * This defines an action responsible to toggle a boolean once triggered.
  9661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9662. */
  9663. export class SwitchBooleanAction extends Action {
  9664. /**
  9665. * The path to the boolean property in the target object
  9666. */
  9667. propertyPath: string;
  9668. private _target;
  9669. private _effectiveTarget;
  9670. private _property;
  9671. /**
  9672. * Instantiate the action
  9673. * @param triggerOptions defines the trigger options
  9674. * @param target defines the object containing the boolean
  9675. * @param propertyPath defines the path to the boolean property in the target object
  9676. * @param condition defines the trigger related conditions
  9677. */
  9678. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9679. /** @hidden */
  9680. _prepare(): void;
  9681. /**
  9682. * Execute the action toggle the boolean value.
  9683. */
  9684. execute(): void;
  9685. /**
  9686. * Serializes the actions and its related information.
  9687. * @param parent defines the object to serialize in
  9688. * @returns the serialized object
  9689. */
  9690. serialize(parent: any): any;
  9691. }
  9692. /**
  9693. * This defines an action responsible to set a the state field of the target
  9694. * to a desired value once triggered.
  9695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9696. */
  9697. export class SetStateAction extends Action {
  9698. /**
  9699. * The value to store in the state field.
  9700. */
  9701. value: string;
  9702. private _target;
  9703. /**
  9704. * Instantiate the action
  9705. * @param triggerOptions defines the trigger options
  9706. * @param target defines the object containing the state property
  9707. * @param value defines the value to store in the state field
  9708. * @param condition defines the trigger related conditions
  9709. */
  9710. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9711. /**
  9712. * Execute the action and store the value on the target state property.
  9713. */
  9714. execute(): void;
  9715. /**
  9716. * Serializes the actions and its related information.
  9717. * @param parent defines the object to serialize in
  9718. * @returns the serialized object
  9719. */
  9720. serialize(parent: any): any;
  9721. }
  9722. /**
  9723. * This defines an action responsible to set a property of the target
  9724. * to a desired value once triggered.
  9725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9726. */
  9727. export class SetValueAction extends Action {
  9728. /**
  9729. * The path of the property to set in the target.
  9730. */
  9731. propertyPath: string;
  9732. /**
  9733. * The value to set in the property
  9734. */
  9735. value: any;
  9736. private _target;
  9737. private _effectiveTarget;
  9738. private _property;
  9739. /**
  9740. * Instantiate the action
  9741. * @param triggerOptions defines the trigger options
  9742. * @param target defines the object containing the property
  9743. * @param propertyPath defines the path of the property to set in the target
  9744. * @param value defines the value to set in the property
  9745. * @param condition defines the trigger related conditions
  9746. */
  9747. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9748. /** @hidden */
  9749. _prepare(): void;
  9750. /**
  9751. * Execute the action and set the targetted property to the desired value.
  9752. */
  9753. execute(): void;
  9754. /**
  9755. * Serializes the actions and its related information.
  9756. * @param parent defines the object to serialize in
  9757. * @returns the serialized object
  9758. */
  9759. serialize(parent: any): any;
  9760. }
  9761. /**
  9762. * This defines an action responsible to increment the target value
  9763. * to a desired value once triggered.
  9764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9765. */
  9766. export class IncrementValueAction extends Action {
  9767. /**
  9768. * The path of the property to increment in the target.
  9769. */
  9770. propertyPath: string;
  9771. /**
  9772. * The value we should increment the property by.
  9773. */
  9774. value: any;
  9775. private _target;
  9776. private _effectiveTarget;
  9777. private _property;
  9778. /**
  9779. * Instantiate the action
  9780. * @param triggerOptions defines the trigger options
  9781. * @param target defines the object containing the property
  9782. * @param propertyPath defines the path of the property to increment in the target
  9783. * @param value defines the value value we should increment the property by
  9784. * @param condition defines the trigger related conditions
  9785. */
  9786. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9787. /** @hidden */
  9788. _prepare(): void;
  9789. /**
  9790. * Execute the action and increment the target of the value amount.
  9791. */
  9792. execute(): void;
  9793. /**
  9794. * Serializes the actions and its related information.
  9795. * @param parent defines the object to serialize in
  9796. * @returns the serialized object
  9797. */
  9798. serialize(parent: any): any;
  9799. }
  9800. /**
  9801. * This defines an action responsible to start an animation once triggered.
  9802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9803. */
  9804. export class PlayAnimationAction extends Action {
  9805. /**
  9806. * Where the animation should start (animation frame)
  9807. */
  9808. from: number;
  9809. /**
  9810. * Where the animation should stop (animation frame)
  9811. */
  9812. to: number;
  9813. /**
  9814. * Define if the animation should loop or stop after the first play.
  9815. */
  9816. loop?: boolean;
  9817. private _target;
  9818. /**
  9819. * Instantiate the action
  9820. * @param triggerOptions defines the trigger options
  9821. * @param target defines the target animation or animation name
  9822. * @param from defines from where the animation should start (animation frame)
  9823. * @param end defines where the animation should stop (animation frame)
  9824. * @param loop defines if the animation should loop or stop after the first play
  9825. * @param condition defines the trigger related conditions
  9826. */
  9827. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9828. /** @hidden */
  9829. _prepare(): void;
  9830. /**
  9831. * Execute the action and play the animation.
  9832. */
  9833. execute(): void;
  9834. /**
  9835. * Serializes the actions and its related information.
  9836. * @param parent defines the object to serialize in
  9837. * @returns the serialized object
  9838. */
  9839. serialize(parent: any): any;
  9840. }
  9841. /**
  9842. * This defines an action responsible to stop an animation once triggered.
  9843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9844. */
  9845. export class StopAnimationAction extends Action {
  9846. private _target;
  9847. /**
  9848. * Instantiate the action
  9849. * @param triggerOptions defines the trigger options
  9850. * @param target defines the target animation or animation name
  9851. * @param condition defines the trigger related conditions
  9852. */
  9853. constructor(triggerOptions: any, target: any, condition?: Condition);
  9854. /** @hidden */
  9855. _prepare(): void;
  9856. /**
  9857. * Execute the action and stop the animation.
  9858. */
  9859. execute(): void;
  9860. /**
  9861. * Serializes the actions and its related information.
  9862. * @param parent defines the object to serialize in
  9863. * @returns the serialized object
  9864. */
  9865. serialize(parent: any): any;
  9866. }
  9867. /**
  9868. * This defines an action responsible that does nothing once triggered.
  9869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9870. */
  9871. export class DoNothingAction extends Action {
  9872. /**
  9873. * Instantiate the action
  9874. * @param triggerOptions defines the trigger options
  9875. * @param condition defines the trigger related conditions
  9876. */
  9877. constructor(triggerOptions?: any, condition?: Condition);
  9878. /**
  9879. * Execute the action and do nothing.
  9880. */
  9881. execute(): void;
  9882. /**
  9883. * Serializes the actions and its related information.
  9884. * @param parent defines the object to serialize in
  9885. * @returns the serialized object
  9886. */
  9887. serialize(parent: any): any;
  9888. }
  9889. /**
  9890. * This defines an action responsible to trigger several actions once triggered.
  9891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9892. */
  9893. export class CombineAction extends Action {
  9894. /**
  9895. * The list of aggregated animations to run.
  9896. */
  9897. children: Action[];
  9898. /**
  9899. * Instantiate the action
  9900. * @param triggerOptions defines the trigger options
  9901. * @param children defines the list of aggregated animations to run
  9902. * @param condition defines the trigger related conditions
  9903. */
  9904. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9905. /** @hidden */
  9906. _prepare(): void;
  9907. /**
  9908. * Execute the action and executes all the aggregated actions.
  9909. */
  9910. execute(evt: ActionEvent): void;
  9911. /**
  9912. * Serializes the actions and its related information.
  9913. * @param parent defines the object to serialize in
  9914. * @returns the serialized object
  9915. */
  9916. serialize(parent: any): any;
  9917. }
  9918. /**
  9919. * This defines an action responsible to run code (external event) once triggered.
  9920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9921. */
  9922. export class ExecuteCodeAction extends Action {
  9923. /**
  9924. * The callback function to run.
  9925. */
  9926. func: (evt: ActionEvent) => void;
  9927. /**
  9928. * Instantiate the action
  9929. * @param triggerOptions defines the trigger options
  9930. * @param func defines the callback function to run
  9931. * @param condition defines the trigger related conditions
  9932. */
  9933. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  9934. /**
  9935. * Execute the action and run the attached code.
  9936. */
  9937. execute(evt: ActionEvent): void;
  9938. }
  9939. /**
  9940. * This defines an action responsible to set the parent property of the target once triggered.
  9941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9942. */
  9943. export class SetParentAction extends Action {
  9944. private _parent;
  9945. private _target;
  9946. /**
  9947. * Instantiate the action
  9948. * @param triggerOptions defines the trigger options
  9949. * @param target defines the target containing the parent property
  9950. * @param parent defines from where the animation should start (animation frame)
  9951. * @param condition defines the trigger related conditions
  9952. */
  9953. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  9954. /** @hidden */
  9955. _prepare(): void;
  9956. /**
  9957. * Execute the action and set the parent property.
  9958. */
  9959. execute(): void;
  9960. /**
  9961. * Serializes the actions and its related information.
  9962. * @param parent defines the object to serialize in
  9963. * @returns the serialized object
  9964. */
  9965. serialize(parent: any): any;
  9966. }
  9967. }
  9968. declare module BABYLON {
  9969. /**
  9970. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  9971. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  9972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9973. */
  9974. export class ActionManager extends AbstractActionManager {
  9975. /**
  9976. * Nothing
  9977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9978. */
  9979. static readonly NothingTrigger: number;
  9980. /**
  9981. * On pick
  9982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9983. */
  9984. static readonly OnPickTrigger: number;
  9985. /**
  9986. * On left pick
  9987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9988. */
  9989. static readonly OnLeftPickTrigger: number;
  9990. /**
  9991. * On right pick
  9992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9993. */
  9994. static readonly OnRightPickTrigger: number;
  9995. /**
  9996. * On center pick
  9997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9998. */
  9999. static readonly OnCenterPickTrigger: number;
  10000. /**
  10001. * On pick down
  10002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10003. */
  10004. static readonly OnPickDownTrigger: number;
  10005. /**
  10006. * On double pick
  10007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10008. */
  10009. static readonly OnDoublePickTrigger: number;
  10010. /**
  10011. * On pick up
  10012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10013. */
  10014. static readonly OnPickUpTrigger: number;
  10015. /**
  10016. * On pick out.
  10017. * This trigger will only be raised if you also declared a OnPickDown
  10018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10019. */
  10020. static readonly OnPickOutTrigger: number;
  10021. /**
  10022. * On long press
  10023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10024. */
  10025. static readonly OnLongPressTrigger: number;
  10026. /**
  10027. * On pointer over
  10028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10029. */
  10030. static readonly OnPointerOverTrigger: number;
  10031. /**
  10032. * On pointer out
  10033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10034. */
  10035. static readonly OnPointerOutTrigger: number;
  10036. /**
  10037. * On every frame
  10038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10039. */
  10040. static readonly OnEveryFrameTrigger: number;
  10041. /**
  10042. * On intersection enter
  10043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10044. */
  10045. static readonly OnIntersectionEnterTrigger: number;
  10046. /**
  10047. * On intersection exit
  10048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10049. */
  10050. static readonly OnIntersectionExitTrigger: number;
  10051. /**
  10052. * On key down
  10053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10054. */
  10055. static readonly OnKeyDownTrigger: number;
  10056. /**
  10057. * On key up
  10058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10059. */
  10060. static readonly OnKeyUpTrigger: number;
  10061. private _scene;
  10062. /**
  10063. * Creates a new action manager
  10064. * @param scene defines the hosting scene
  10065. */
  10066. constructor(scene: Scene);
  10067. /**
  10068. * Releases all associated resources
  10069. */
  10070. dispose(): void;
  10071. /**
  10072. * Gets hosting scene
  10073. * @returns the hosting scene
  10074. */
  10075. getScene(): Scene;
  10076. /**
  10077. * Does this action manager handles actions of any of the given triggers
  10078. * @param triggers defines the triggers to be tested
  10079. * @return a boolean indicating whether one (or more) of the triggers is handled
  10080. */
  10081. hasSpecificTriggers(triggers: number[]): boolean;
  10082. /**
  10083. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10084. * speed.
  10085. * @param triggerA defines the trigger to be tested
  10086. * @param triggerB defines the trigger to be tested
  10087. * @return a boolean indicating whether one (or more) of the triggers is handled
  10088. */
  10089. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10090. /**
  10091. * Does this action manager handles actions of a given trigger
  10092. * @param trigger defines the trigger to be tested
  10093. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10094. * @return whether the trigger is handled
  10095. */
  10096. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10097. /**
  10098. * Does this action manager has pointer triggers
  10099. */
  10100. get hasPointerTriggers(): boolean;
  10101. /**
  10102. * Does this action manager has pick triggers
  10103. */
  10104. get hasPickTriggers(): boolean;
  10105. /**
  10106. * Registers an action to this action manager
  10107. * @param action defines the action to be registered
  10108. * @return the action amended (prepared) after registration
  10109. */
  10110. registerAction(action: IAction): Nullable<IAction>;
  10111. /**
  10112. * Unregisters an action to this action manager
  10113. * @param action defines the action to be unregistered
  10114. * @return a boolean indicating whether the action has been unregistered
  10115. */
  10116. unregisterAction(action: IAction): Boolean;
  10117. /**
  10118. * Process a specific trigger
  10119. * @param trigger defines the trigger to process
  10120. * @param evt defines the event details to be processed
  10121. */
  10122. processTrigger(trigger: number, evt?: IActionEvent): void;
  10123. /** @hidden */
  10124. _getEffectiveTarget(target: any, propertyPath: string): any;
  10125. /** @hidden */
  10126. _getProperty(propertyPath: string): string;
  10127. /**
  10128. * Serialize this manager to a JSON object
  10129. * @param name defines the property name to store this manager
  10130. * @returns a JSON representation of this manager
  10131. */
  10132. serialize(name: string): any;
  10133. /**
  10134. * Creates a new ActionManager from a JSON data
  10135. * @param parsedActions defines the JSON data to read from
  10136. * @param object defines the hosting mesh
  10137. * @param scene defines the hosting scene
  10138. */
  10139. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10140. /**
  10141. * Get a trigger name by index
  10142. * @param trigger defines the trigger index
  10143. * @returns a trigger name
  10144. */
  10145. static GetTriggerName(trigger: number): string;
  10146. }
  10147. }
  10148. declare module BABYLON {
  10149. /**
  10150. * Class used to represent a sprite
  10151. * @see http://doc.babylonjs.com/babylon101/sprites
  10152. */
  10153. export class Sprite implements IAnimatable {
  10154. /** defines the name */
  10155. name: string;
  10156. /** Gets or sets the current world position */
  10157. position: Vector3;
  10158. /** Gets or sets the main color */
  10159. color: Color4;
  10160. /** Gets or sets the width */
  10161. width: number;
  10162. /** Gets or sets the height */
  10163. height: number;
  10164. /** Gets or sets rotation angle */
  10165. angle: number;
  10166. /** Gets or sets the cell index in the sprite sheet */
  10167. cellIndex: number;
  10168. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10169. cellRef: string;
  10170. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10171. invertU: boolean;
  10172. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10173. invertV: boolean;
  10174. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10175. disposeWhenFinishedAnimating: boolean;
  10176. /** Gets the list of attached animations */
  10177. animations: Nullable<Array<Animation>>;
  10178. /** Gets or sets a boolean indicating if the sprite can be picked */
  10179. isPickable: boolean;
  10180. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10181. useAlphaForPicking: boolean;
  10182. /** @hidden */
  10183. _xOffset: number;
  10184. /** @hidden */
  10185. _yOffset: number;
  10186. /** @hidden */
  10187. _xSize: number;
  10188. /** @hidden */
  10189. _ySize: number;
  10190. /**
  10191. * Gets or sets the associated action manager
  10192. */
  10193. actionManager: Nullable<ActionManager>;
  10194. /**
  10195. * An event triggered when the control has been disposed
  10196. */
  10197. onDisposeObservable: Observable<Sprite>;
  10198. private _animationStarted;
  10199. private _loopAnimation;
  10200. private _fromIndex;
  10201. private _toIndex;
  10202. private _delay;
  10203. private _direction;
  10204. private _manager;
  10205. private _time;
  10206. private _onAnimationEnd;
  10207. /**
  10208. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10209. */
  10210. isVisible: boolean;
  10211. /**
  10212. * Gets or sets the sprite size
  10213. */
  10214. get size(): number;
  10215. set size(value: number);
  10216. /**
  10217. * Gets or sets the unique id of the sprite
  10218. */
  10219. uniqueId: number;
  10220. /**
  10221. * Gets the manager of this sprite
  10222. */
  10223. get manager(): ISpriteManager;
  10224. /**
  10225. * Creates a new Sprite
  10226. * @param name defines the name
  10227. * @param manager defines the manager
  10228. */
  10229. constructor(
  10230. /** defines the name */
  10231. name: string, manager: ISpriteManager);
  10232. /**
  10233. * Returns the string "Sprite"
  10234. * @returns "Sprite"
  10235. */
  10236. getClassName(): string;
  10237. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10238. get fromIndex(): number;
  10239. set fromIndex(value: number);
  10240. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10241. get toIndex(): number;
  10242. set toIndex(value: number);
  10243. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10244. get loopAnimation(): boolean;
  10245. set loopAnimation(value: boolean);
  10246. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10247. get delay(): number;
  10248. set delay(value: number);
  10249. /**
  10250. * Starts an animation
  10251. * @param from defines the initial key
  10252. * @param to defines the end key
  10253. * @param loop defines if the animation must loop
  10254. * @param delay defines the start delay (in ms)
  10255. * @param onAnimationEnd defines a callback to call when animation ends
  10256. */
  10257. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  10258. /** Stops current animation (if any) */
  10259. stopAnimation(): void;
  10260. /** @hidden */
  10261. _animate(deltaTime: number): void;
  10262. /** Release associated resources */
  10263. dispose(): void;
  10264. }
  10265. }
  10266. declare module BABYLON {
  10267. /**
  10268. * Information about the result of picking within a scene
  10269. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10270. */
  10271. export class PickingInfo {
  10272. /** @hidden */
  10273. _pickingUnavailable: boolean;
  10274. /**
  10275. * If the pick collided with an object
  10276. */
  10277. hit: boolean;
  10278. /**
  10279. * Distance away where the pick collided
  10280. */
  10281. distance: number;
  10282. /**
  10283. * The location of pick collision
  10284. */
  10285. pickedPoint: Nullable<Vector3>;
  10286. /**
  10287. * The mesh corresponding the the pick collision
  10288. */
  10289. pickedMesh: Nullable<AbstractMesh>;
  10290. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10291. bu: number;
  10292. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10293. bv: number;
  10294. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10295. faceId: number;
  10296. /** Id of the the submesh that was picked */
  10297. subMeshId: number;
  10298. /** If a sprite was picked, this will be the sprite the pick collided with */
  10299. pickedSprite: Nullable<Sprite>;
  10300. /**
  10301. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10302. */
  10303. originMesh: Nullable<AbstractMesh>;
  10304. /**
  10305. * The ray that was used to perform the picking.
  10306. */
  10307. ray: Nullable<Ray>;
  10308. /**
  10309. * Gets the normal correspodning to the face the pick collided with
  10310. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10311. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10312. * @returns The normal correspodning to the face the pick collided with
  10313. */
  10314. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10315. /**
  10316. * Gets the texture coordinates of where the pick occured
  10317. * @returns the vector containing the coordnates of the texture
  10318. */
  10319. getTextureCoordinates(): Nullable<Vector2>;
  10320. }
  10321. }
  10322. declare module BABYLON {
  10323. /**
  10324. * Class representing a ray with position and direction
  10325. */
  10326. export class Ray {
  10327. /** origin point */
  10328. origin: Vector3;
  10329. /** direction */
  10330. direction: Vector3;
  10331. /** length of the ray */
  10332. length: number;
  10333. private static readonly TmpVector3;
  10334. private _tmpRay;
  10335. /**
  10336. * Creates a new ray
  10337. * @param origin origin point
  10338. * @param direction direction
  10339. * @param length length of the ray
  10340. */
  10341. constructor(
  10342. /** origin point */
  10343. origin: Vector3,
  10344. /** direction */
  10345. direction: Vector3,
  10346. /** length of the ray */
  10347. length?: number);
  10348. /**
  10349. * Checks if the ray intersects a box
  10350. * This does not account for the ray lenght by design to improve perfs.
  10351. * @param minimum bound of the box
  10352. * @param maximum bound of the box
  10353. * @param intersectionTreshold extra extend to be added to the box in all direction
  10354. * @returns if the box was hit
  10355. */
  10356. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10357. /**
  10358. * Checks if the ray intersects a box
  10359. * This does not account for the ray lenght by design to improve perfs.
  10360. * @param box the bounding box to check
  10361. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10362. * @returns if the box was hit
  10363. */
  10364. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10365. /**
  10366. * If the ray hits a sphere
  10367. * @param sphere the bounding sphere to check
  10368. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10369. * @returns true if it hits the sphere
  10370. */
  10371. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10372. /**
  10373. * If the ray hits a triange
  10374. * @param vertex0 triangle vertex
  10375. * @param vertex1 triangle vertex
  10376. * @param vertex2 triangle vertex
  10377. * @returns intersection information if hit
  10378. */
  10379. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10380. /**
  10381. * Checks if ray intersects a plane
  10382. * @param plane the plane to check
  10383. * @returns the distance away it was hit
  10384. */
  10385. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10386. /**
  10387. * Calculate the intercept of a ray on a given axis
  10388. * @param axis to check 'x' | 'y' | 'z'
  10389. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10390. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10391. */
  10392. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10393. /**
  10394. * Checks if ray intersects a mesh
  10395. * @param mesh the mesh to check
  10396. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10397. * @returns picking info of the intersecton
  10398. */
  10399. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10400. /**
  10401. * Checks if ray intersects a mesh
  10402. * @param meshes the meshes to check
  10403. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10404. * @param results array to store result in
  10405. * @returns Array of picking infos
  10406. */
  10407. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10408. private _comparePickingInfo;
  10409. private static smallnum;
  10410. private static rayl;
  10411. /**
  10412. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10413. * @param sega the first point of the segment to test the intersection against
  10414. * @param segb the second point of the segment to test the intersection against
  10415. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10416. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10417. */
  10418. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10419. /**
  10420. * Update the ray from viewport position
  10421. * @param x position
  10422. * @param y y position
  10423. * @param viewportWidth viewport width
  10424. * @param viewportHeight viewport height
  10425. * @param world world matrix
  10426. * @param view view matrix
  10427. * @param projection projection matrix
  10428. * @returns this ray updated
  10429. */
  10430. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10431. /**
  10432. * Creates a ray with origin and direction of 0,0,0
  10433. * @returns the new ray
  10434. */
  10435. static Zero(): Ray;
  10436. /**
  10437. * Creates a new ray from screen space and viewport
  10438. * @param x position
  10439. * @param y y position
  10440. * @param viewportWidth viewport width
  10441. * @param viewportHeight viewport height
  10442. * @param world world matrix
  10443. * @param view view matrix
  10444. * @param projection projection matrix
  10445. * @returns new ray
  10446. */
  10447. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10448. /**
  10449. * 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
  10450. * transformed to the given world matrix.
  10451. * @param origin The origin point
  10452. * @param end The end point
  10453. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10454. * @returns the new ray
  10455. */
  10456. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10457. /**
  10458. * Transforms a ray by a matrix
  10459. * @param ray ray to transform
  10460. * @param matrix matrix to apply
  10461. * @returns the resulting new ray
  10462. */
  10463. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10464. /**
  10465. * Transforms a ray by a matrix
  10466. * @param ray ray to transform
  10467. * @param matrix matrix to apply
  10468. * @param result ray to store result in
  10469. */
  10470. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10471. /**
  10472. * Unproject a ray from screen space to object space
  10473. * @param sourceX defines the screen space x coordinate to use
  10474. * @param sourceY defines the screen space y coordinate to use
  10475. * @param viewportWidth defines the current width of the viewport
  10476. * @param viewportHeight defines the current height of the viewport
  10477. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10478. * @param view defines the view matrix to use
  10479. * @param projection defines the projection matrix to use
  10480. */
  10481. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10482. }
  10483. /**
  10484. * Type used to define predicate used to select faces when a mesh intersection is detected
  10485. */
  10486. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10487. interface Scene {
  10488. /** @hidden */
  10489. _tempPickingRay: Nullable<Ray>;
  10490. /** @hidden */
  10491. _cachedRayForTransform: Ray;
  10492. /** @hidden */
  10493. _pickWithRayInverseMatrix: Matrix;
  10494. /** @hidden */
  10495. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10496. /** @hidden */
  10497. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10498. }
  10499. }
  10500. declare module BABYLON {
  10501. /**
  10502. * Groups all the scene component constants in one place to ease maintenance.
  10503. * @hidden
  10504. */
  10505. export class SceneComponentConstants {
  10506. static readonly NAME_EFFECTLAYER: string;
  10507. static readonly NAME_LAYER: string;
  10508. static readonly NAME_LENSFLARESYSTEM: string;
  10509. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10510. static readonly NAME_PARTICLESYSTEM: string;
  10511. static readonly NAME_GAMEPAD: string;
  10512. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10513. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10514. static readonly NAME_DEPTHRENDERER: string;
  10515. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10516. static readonly NAME_SPRITE: string;
  10517. static readonly NAME_OUTLINERENDERER: string;
  10518. static readonly NAME_PROCEDURALTEXTURE: string;
  10519. static readonly NAME_SHADOWGENERATOR: string;
  10520. static readonly NAME_OCTREE: string;
  10521. static readonly NAME_PHYSICSENGINE: string;
  10522. static readonly NAME_AUDIO: string;
  10523. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10524. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10525. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10526. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10527. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10528. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10529. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10530. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10531. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10532. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10533. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10534. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10535. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10536. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10537. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10538. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10539. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10540. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10541. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10542. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10543. static readonly STEP_AFTERRENDER_AUDIO: number;
  10544. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10545. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10546. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10547. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10548. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10549. static readonly STEP_POINTERMOVE_SPRITE: number;
  10550. static readonly STEP_POINTERDOWN_SPRITE: number;
  10551. static readonly STEP_POINTERUP_SPRITE: number;
  10552. }
  10553. /**
  10554. * This represents a scene component.
  10555. *
  10556. * This is used to decouple the dependency the scene is having on the different workloads like
  10557. * layers, post processes...
  10558. */
  10559. export interface ISceneComponent {
  10560. /**
  10561. * The name of the component. Each component must have a unique name.
  10562. */
  10563. name: string;
  10564. /**
  10565. * The scene the component belongs to.
  10566. */
  10567. scene: Scene;
  10568. /**
  10569. * Register the component to one instance of a scene.
  10570. */
  10571. register(): void;
  10572. /**
  10573. * Rebuilds the elements related to this component in case of
  10574. * context lost for instance.
  10575. */
  10576. rebuild(): void;
  10577. /**
  10578. * Disposes the component and the associated ressources.
  10579. */
  10580. dispose(): void;
  10581. }
  10582. /**
  10583. * This represents a SERIALIZABLE scene component.
  10584. *
  10585. * This extends Scene Component to add Serialization methods on top.
  10586. */
  10587. export interface ISceneSerializableComponent extends ISceneComponent {
  10588. /**
  10589. * Adds all the elements from the container to the scene
  10590. * @param container the container holding the elements
  10591. */
  10592. addFromContainer(container: AbstractScene): void;
  10593. /**
  10594. * Removes all the elements in the container from the scene
  10595. * @param container contains the elements to remove
  10596. * @param dispose if the removed element should be disposed (default: false)
  10597. */
  10598. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10599. /**
  10600. * Serializes the component data to the specified json object
  10601. * @param serializationObject The object to serialize to
  10602. */
  10603. serialize(serializationObject: any): void;
  10604. }
  10605. /**
  10606. * Strong typing of a Mesh related stage step action
  10607. */
  10608. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10609. /**
  10610. * Strong typing of a Evaluate Sub Mesh related stage step action
  10611. */
  10612. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10613. /**
  10614. * Strong typing of a Active Mesh related stage step action
  10615. */
  10616. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10617. /**
  10618. * Strong typing of a Camera related stage step action
  10619. */
  10620. export type CameraStageAction = (camera: Camera) => void;
  10621. /**
  10622. * Strong typing of a Camera Frame buffer related stage step action
  10623. */
  10624. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10625. /**
  10626. * Strong typing of a Render Target related stage step action
  10627. */
  10628. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10629. /**
  10630. * Strong typing of a RenderingGroup related stage step action
  10631. */
  10632. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10633. /**
  10634. * Strong typing of a Mesh Render related stage step action
  10635. */
  10636. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10637. /**
  10638. * Strong typing of a simple stage step action
  10639. */
  10640. export type SimpleStageAction = () => void;
  10641. /**
  10642. * Strong typing of a render target action.
  10643. */
  10644. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10645. /**
  10646. * Strong typing of a pointer move action.
  10647. */
  10648. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10649. /**
  10650. * Strong typing of a pointer up/down action.
  10651. */
  10652. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10653. /**
  10654. * Representation of a stage in the scene (Basically a list of ordered steps)
  10655. * @hidden
  10656. */
  10657. export class Stage<T extends Function> extends Array<{
  10658. index: number;
  10659. component: ISceneComponent;
  10660. action: T;
  10661. }> {
  10662. /**
  10663. * Hide ctor from the rest of the world.
  10664. * @param items The items to add.
  10665. */
  10666. private constructor();
  10667. /**
  10668. * Creates a new Stage.
  10669. * @returns A new instance of a Stage
  10670. */
  10671. static Create<T extends Function>(): Stage<T>;
  10672. /**
  10673. * Registers a step in an ordered way in the targeted stage.
  10674. * @param index Defines the position to register the step in
  10675. * @param component Defines the component attached to the step
  10676. * @param action Defines the action to launch during the step
  10677. */
  10678. registerStep(index: number, component: ISceneComponent, action: T): void;
  10679. /**
  10680. * Clears all the steps from the stage.
  10681. */
  10682. clear(): void;
  10683. }
  10684. }
  10685. declare module BABYLON {
  10686. interface Scene {
  10687. /** @hidden */
  10688. _pointerOverSprite: Nullable<Sprite>;
  10689. /** @hidden */
  10690. _pickedDownSprite: Nullable<Sprite>;
  10691. /** @hidden */
  10692. _tempSpritePickingRay: Nullable<Ray>;
  10693. /**
  10694. * All of the sprite managers added to this scene
  10695. * @see http://doc.babylonjs.com/babylon101/sprites
  10696. */
  10697. spriteManagers: Array<ISpriteManager>;
  10698. /**
  10699. * An event triggered when sprites rendering is about to start
  10700. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10701. */
  10702. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10703. /**
  10704. * An event triggered when sprites rendering is done
  10705. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10706. */
  10707. onAfterSpritesRenderingObservable: Observable<Scene>;
  10708. /** @hidden */
  10709. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10710. /** Launch a ray to try to pick a sprite in the scene
  10711. * @param x position on screen
  10712. * @param y position on screen
  10713. * @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
  10714. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10715. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10716. * @returns a PickingInfo
  10717. */
  10718. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10719. /** Use the given ray to pick a sprite in the scene
  10720. * @param ray The ray (in world space) to use to pick meshes
  10721. * @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
  10722. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10723. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10724. * @returns a PickingInfo
  10725. */
  10726. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10727. /** @hidden */
  10728. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10729. /** Launch a ray to try to pick sprites in the scene
  10730. * @param x position on screen
  10731. * @param y position on screen
  10732. * @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
  10733. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10734. * @returns a PickingInfo array
  10735. */
  10736. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10737. /** Use the given ray to pick sprites in the scene
  10738. * @param ray The ray (in world space) to use to pick meshes
  10739. * @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
  10740. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10741. * @returns a PickingInfo array
  10742. */
  10743. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10744. /**
  10745. * Force the sprite under the pointer
  10746. * @param sprite defines the sprite to use
  10747. */
  10748. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10749. /**
  10750. * Gets the sprite under the pointer
  10751. * @returns a Sprite or null if no sprite is under the pointer
  10752. */
  10753. getPointerOverSprite(): Nullable<Sprite>;
  10754. }
  10755. /**
  10756. * Defines the sprite scene component responsible to manage sprites
  10757. * in a given scene.
  10758. */
  10759. export class SpriteSceneComponent implements ISceneComponent {
  10760. /**
  10761. * The component name helpfull to identify the component in the list of scene components.
  10762. */
  10763. readonly name: string;
  10764. /**
  10765. * The scene the component belongs to.
  10766. */
  10767. scene: Scene;
  10768. /** @hidden */
  10769. private _spritePredicate;
  10770. /**
  10771. * Creates a new instance of the component for the given scene
  10772. * @param scene Defines the scene to register the component in
  10773. */
  10774. constructor(scene: Scene);
  10775. /**
  10776. * Registers the component in a given scene
  10777. */
  10778. register(): void;
  10779. /**
  10780. * Rebuilds the elements related to this component in case of
  10781. * context lost for instance.
  10782. */
  10783. rebuild(): void;
  10784. /**
  10785. * Disposes the component and the associated ressources.
  10786. */
  10787. dispose(): void;
  10788. private _pickSpriteButKeepRay;
  10789. private _pointerMove;
  10790. private _pointerDown;
  10791. private _pointerUp;
  10792. }
  10793. }
  10794. declare module BABYLON {
  10795. /** @hidden */
  10796. export var fogFragmentDeclaration: {
  10797. name: string;
  10798. shader: string;
  10799. };
  10800. }
  10801. declare module BABYLON {
  10802. /** @hidden */
  10803. export var fogFragment: {
  10804. name: string;
  10805. shader: string;
  10806. };
  10807. }
  10808. declare module BABYLON {
  10809. /** @hidden */
  10810. export var spritesPixelShader: {
  10811. name: string;
  10812. shader: string;
  10813. };
  10814. }
  10815. declare module BABYLON {
  10816. /** @hidden */
  10817. export var fogVertexDeclaration: {
  10818. name: string;
  10819. shader: string;
  10820. };
  10821. }
  10822. declare module BABYLON {
  10823. /** @hidden */
  10824. export var spritesVertexShader: {
  10825. name: string;
  10826. shader: string;
  10827. };
  10828. }
  10829. declare module BABYLON {
  10830. /**
  10831. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10832. */
  10833. export interface ISpriteManager extends IDisposable {
  10834. /**
  10835. * Gets manager's name
  10836. */
  10837. name: string;
  10838. /**
  10839. * Restricts the camera to viewing objects with the same layerMask.
  10840. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10841. */
  10842. layerMask: number;
  10843. /**
  10844. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10845. */
  10846. isPickable: boolean;
  10847. /**
  10848. * Gets the hosting scene
  10849. */
  10850. scene: Scene;
  10851. /**
  10852. * Specifies the rendering group id for this mesh (0 by default)
  10853. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10854. */
  10855. renderingGroupId: number;
  10856. /**
  10857. * Defines the list of sprites managed by the manager.
  10858. */
  10859. sprites: Array<Sprite>;
  10860. /**
  10861. * Gets or sets the spritesheet texture
  10862. */
  10863. texture: Texture;
  10864. /** Defines the default width of a cell in the spritesheet */
  10865. cellWidth: number;
  10866. /** Defines the default height of a cell in the spritesheet */
  10867. cellHeight: number;
  10868. /**
  10869. * Tests the intersection of a sprite with a specific ray.
  10870. * @param ray The ray we are sending to test the collision
  10871. * @param camera The camera space we are sending rays in
  10872. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10873. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10874. * @returns picking info or null.
  10875. */
  10876. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10877. /**
  10878. * Intersects the sprites with a ray
  10879. * @param ray defines the ray to intersect with
  10880. * @param camera defines the current active camera
  10881. * @param predicate defines a predicate used to select candidate sprites
  10882. * @returns null if no hit or a PickingInfo array
  10883. */
  10884. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10885. /**
  10886. * Renders the list of sprites on screen.
  10887. */
  10888. render(): void;
  10889. }
  10890. /**
  10891. * Class used to manage multiple sprites on the same spritesheet
  10892. * @see http://doc.babylonjs.com/babylon101/sprites
  10893. */
  10894. export class SpriteManager implements ISpriteManager {
  10895. /** defines the manager's name */
  10896. name: string;
  10897. /** Gets the list of sprites */
  10898. sprites: Sprite[];
  10899. /** Gets or sets the rendering group id (0 by default) */
  10900. renderingGroupId: number;
  10901. /** Gets or sets camera layer mask */
  10902. layerMask: number;
  10903. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10904. fogEnabled: boolean;
  10905. /** Gets or sets a boolean indicating if the sprites are pickable */
  10906. isPickable: boolean;
  10907. /** Defines the default width of a cell in the spritesheet */
  10908. cellWidth: number;
  10909. /** Defines the default height of a cell in the spritesheet */
  10910. cellHeight: number;
  10911. /** Associative array from JSON sprite data file */
  10912. private _cellData;
  10913. /** Array of sprite names from JSON sprite data file */
  10914. private _spriteMap;
  10915. /** True when packed cell data from JSON file is ready*/
  10916. private _packedAndReady;
  10917. private _textureContent;
  10918. /**
  10919. * An event triggered when the manager is disposed.
  10920. */
  10921. onDisposeObservable: Observable<SpriteManager>;
  10922. private _onDisposeObserver;
  10923. /**
  10924. * Callback called when the manager is disposed
  10925. */
  10926. set onDispose(callback: () => void);
  10927. private _capacity;
  10928. private _fromPacked;
  10929. private _spriteTexture;
  10930. private _epsilon;
  10931. private _scene;
  10932. private _vertexData;
  10933. private _buffer;
  10934. private _vertexBuffers;
  10935. private _indexBuffer;
  10936. private _effectBase;
  10937. private _effectFog;
  10938. /**
  10939. * Gets or sets the unique id of the sprite
  10940. */
  10941. uniqueId: number;
  10942. /**
  10943. * Gets the array of sprites
  10944. */
  10945. get children(): Sprite[];
  10946. /**
  10947. * Gets the hosting scene
  10948. */
  10949. get scene(): Scene;
  10950. /**
  10951. * Gets or sets the capacity of the manager
  10952. */
  10953. get capacity(): number;
  10954. set capacity(value: number);
  10955. /**
  10956. * Gets or sets the spritesheet texture
  10957. */
  10958. get texture(): Texture;
  10959. set texture(value: Texture);
  10960. private _blendMode;
  10961. /**
  10962. * Blend mode use to render the particle, it can be any of
  10963. * the static Constants.ALPHA_x properties provided in this class.
  10964. * Default value is Constants.ALPHA_COMBINE
  10965. */
  10966. get blendMode(): number;
  10967. set blendMode(blendMode: number);
  10968. /** Disables writing to the depth buffer when rendering the sprites.
  10969. * It can be handy to disable depth writing when using textures without alpha channel
  10970. * and setting some specific blend modes.
  10971. */
  10972. disableDepthWrite: boolean;
  10973. /**
  10974. * Creates a new sprite manager
  10975. * @param name defines the manager's name
  10976. * @param imgUrl defines the sprite sheet url
  10977. * @param capacity defines the maximum allowed number of sprites
  10978. * @param cellSize defines the size of a sprite cell
  10979. * @param scene defines the hosting scene
  10980. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10981. * @param samplingMode defines the smapling mode to use with spritesheet
  10982. * @param fromPacked set to false; do not alter
  10983. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10984. */
  10985. constructor(
  10986. /** defines the manager's name */
  10987. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10988. /**
  10989. * Returns the string "SpriteManager"
  10990. * @returns "SpriteManager"
  10991. */
  10992. getClassName(): string;
  10993. private _makePacked;
  10994. private _appendSpriteVertex;
  10995. private _checkTextureAlpha;
  10996. /**
  10997. * Intersects the sprites with a ray
  10998. * @param ray defines the ray to intersect with
  10999. * @param camera defines the current active camera
  11000. * @param predicate defines a predicate used to select candidate sprites
  11001. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11002. * @returns null if no hit or a PickingInfo
  11003. */
  11004. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11005. /**
  11006. * Intersects the sprites with a ray
  11007. * @param ray defines the ray to intersect with
  11008. * @param camera defines the current active camera
  11009. * @param predicate defines a predicate used to select candidate sprites
  11010. * @returns null if no hit or a PickingInfo array
  11011. */
  11012. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11013. /**
  11014. * Render all child sprites
  11015. */
  11016. render(): void;
  11017. /**
  11018. * Release associated resources
  11019. */
  11020. dispose(): void;
  11021. }
  11022. }
  11023. declare module BABYLON {
  11024. /** Interface used by value gradients (color, factor, ...) */
  11025. export interface IValueGradient {
  11026. /**
  11027. * Gets or sets the gradient value (between 0 and 1)
  11028. */
  11029. gradient: number;
  11030. }
  11031. /** Class used to store color4 gradient */
  11032. export class ColorGradient implements IValueGradient {
  11033. /**
  11034. * Gets or sets the gradient value (between 0 and 1)
  11035. */
  11036. gradient: number;
  11037. /**
  11038. * Gets or sets first associated color
  11039. */
  11040. color1: Color4;
  11041. /**
  11042. * Gets or sets second associated color
  11043. */
  11044. color2?: Color4 | undefined;
  11045. /**
  11046. * Creates a new color4 gradient
  11047. * @param gradient gets or sets the gradient value (between 0 and 1)
  11048. * @param color1 gets or sets first associated color
  11049. * @param color2 gets or sets first second color
  11050. */
  11051. constructor(
  11052. /**
  11053. * Gets or sets the gradient value (between 0 and 1)
  11054. */
  11055. gradient: number,
  11056. /**
  11057. * Gets or sets first associated color
  11058. */
  11059. color1: Color4,
  11060. /**
  11061. * Gets or sets second associated color
  11062. */
  11063. color2?: Color4 | undefined);
  11064. /**
  11065. * Will get a color picked randomly between color1 and color2.
  11066. * If color2 is undefined then color1 will be used
  11067. * @param result defines the target Color4 to store the result in
  11068. */
  11069. getColorToRef(result: Color4): void;
  11070. }
  11071. /** Class used to store color 3 gradient */
  11072. export class Color3Gradient implements IValueGradient {
  11073. /**
  11074. * Gets or sets the gradient value (between 0 and 1)
  11075. */
  11076. gradient: number;
  11077. /**
  11078. * Gets or sets the associated color
  11079. */
  11080. color: Color3;
  11081. /**
  11082. * Creates a new color3 gradient
  11083. * @param gradient gets or sets the gradient value (between 0 and 1)
  11084. * @param color gets or sets associated color
  11085. */
  11086. constructor(
  11087. /**
  11088. * Gets or sets the gradient value (between 0 and 1)
  11089. */
  11090. gradient: number,
  11091. /**
  11092. * Gets or sets the associated color
  11093. */
  11094. color: Color3);
  11095. }
  11096. /** Class used to store factor gradient */
  11097. export class FactorGradient implements IValueGradient {
  11098. /**
  11099. * Gets or sets the gradient value (between 0 and 1)
  11100. */
  11101. gradient: number;
  11102. /**
  11103. * Gets or sets first associated factor
  11104. */
  11105. factor1: number;
  11106. /**
  11107. * Gets or sets second associated factor
  11108. */
  11109. factor2?: number | undefined;
  11110. /**
  11111. * Creates a new factor gradient
  11112. * @param gradient gets or sets the gradient value (between 0 and 1)
  11113. * @param factor1 gets or sets first associated factor
  11114. * @param factor2 gets or sets second associated factor
  11115. */
  11116. constructor(
  11117. /**
  11118. * Gets or sets the gradient value (between 0 and 1)
  11119. */
  11120. gradient: number,
  11121. /**
  11122. * Gets or sets first associated factor
  11123. */
  11124. factor1: number,
  11125. /**
  11126. * Gets or sets second associated factor
  11127. */
  11128. factor2?: number | undefined);
  11129. /**
  11130. * Will get a number picked randomly between factor1 and factor2.
  11131. * If factor2 is undefined then factor1 will be used
  11132. * @returns the picked number
  11133. */
  11134. getFactor(): number;
  11135. }
  11136. /**
  11137. * Helper used to simplify some generic gradient tasks
  11138. */
  11139. export class GradientHelper {
  11140. /**
  11141. * Gets the current gradient from an array of IValueGradient
  11142. * @param ratio defines the current ratio to get
  11143. * @param gradients defines the array of IValueGradient
  11144. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11145. */
  11146. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11147. }
  11148. }
  11149. declare module BABYLON {
  11150. interface ThinEngine {
  11151. /**
  11152. * Creates a dynamic texture
  11153. * @param width defines the width of the texture
  11154. * @param height defines the height of the texture
  11155. * @param generateMipMaps defines if the engine should generate the mip levels
  11156. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11157. * @returns the dynamic texture inside an InternalTexture
  11158. */
  11159. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11160. /**
  11161. * Update the content of a dynamic texture
  11162. * @param texture defines the texture to update
  11163. * @param canvas defines the canvas containing the source
  11164. * @param invertY defines if data must be stored with Y axis inverted
  11165. * @param premulAlpha defines if alpha is stored as premultiplied
  11166. * @param format defines the format of the data
  11167. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11168. */
  11169. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11170. }
  11171. }
  11172. declare module BABYLON {
  11173. /**
  11174. * Helper class used to generate a canvas to manipulate images
  11175. */
  11176. export class CanvasGenerator {
  11177. /**
  11178. * Create a new canvas (or offscreen canvas depending on the context)
  11179. * @param width defines the expected width
  11180. * @param height defines the expected height
  11181. * @return a new canvas or offscreen canvas
  11182. */
  11183. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11184. }
  11185. }
  11186. declare module BABYLON {
  11187. /**
  11188. * A class extending Texture allowing drawing on a texture
  11189. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11190. */
  11191. export class DynamicTexture extends Texture {
  11192. private _generateMipMaps;
  11193. private _canvas;
  11194. private _context;
  11195. /**
  11196. * Creates a DynamicTexture
  11197. * @param name defines the name of the texture
  11198. * @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
  11199. * @param scene defines the scene where you want the texture
  11200. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11201. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11202. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11203. */
  11204. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11205. /**
  11206. * Get the current class name of the texture useful for serialization or dynamic coding.
  11207. * @returns "DynamicTexture"
  11208. */
  11209. getClassName(): string;
  11210. /**
  11211. * Gets the current state of canRescale
  11212. */
  11213. get canRescale(): boolean;
  11214. private _recreate;
  11215. /**
  11216. * Scales the texture
  11217. * @param ratio the scale factor to apply to both width and height
  11218. */
  11219. scale(ratio: number): void;
  11220. /**
  11221. * Resizes the texture
  11222. * @param width the new width
  11223. * @param height the new height
  11224. */
  11225. scaleTo(width: number, height: number): void;
  11226. /**
  11227. * Gets the context of the canvas used by the texture
  11228. * @returns the canvas context of the dynamic texture
  11229. */
  11230. getContext(): CanvasRenderingContext2D;
  11231. /**
  11232. * Clears the texture
  11233. */
  11234. clear(): void;
  11235. /**
  11236. * Updates the texture
  11237. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11238. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11239. */
  11240. update(invertY?: boolean, premulAlpha?: boolean): void;
  11241. /**
  11242. * Draws text onto the texture
  11243. * @param text defines the text to be drawn
  11244. * @param x defines the placement of the text from the left
  11245. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11246. * @param font defines the font to be used with font-style, font-size, font-name
  11247. * @param color defines the color used for the text
  11248. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11249. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11250. * @param update defines whether texture is immediately update (default is true)
  11251. */
  11252. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11253. /**
  11254. * Clones the texture
  11255. * @returns the clone of the texture.
  11256. */
  11257. clone(): DynamicTexture;
  11258. /**
  11259. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11260. * @returns a serialized dynamic texture object
  11261. */
  11262. serialize(): any;
  11263. /** @hidden */
  11264. _rebuild(): void;
  11265. }
  11266. }
  11267. declare module BABYLON {
  11268. interface ThinEngine {
  11269. /**
  11270. * Creates a raw texture
  11271. * @param data defines the data to store in the texture
  11272. * @param width defines the width of the texture
  11273. * @param height defines the height of the texture
  11274. * @param format defines the format of the data
  11275. * @param generateMipMaps defines if the engine should generate the mip levels
  11276. * @param invertY defines if data must be stored with Y axis inverted
  11277. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11278. * @param compression defines the compression used (null by default)
  11279. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11280. * @returns the raw texture inside an InternalTexture
  11281. */
  11282. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11283. /**
  11284. * Update a raw texture
  11285. * @param texture defines the texture to update
  11286. * @param data defines the data to store in the texture
  11287. * @param format defines the format of the data
  11288. * @param invertY defines if data must be stored with Y axis inverted
  11289. */
  11290. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11291. /**
  11292. * Update a raw texture
  11293. * @param texture defines the texture to update
  11294. * @param data defines the data to store in the texture
  11295. * @param format defines the format of the data
  11296. * @param invertY defines if data must be stored with Y axis inverted
  11297. * @param compression defines the compression used (null by default)
  11298. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11299. */
  11300. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11301. /**
  11302. * Creates a new raw cube texture
  11303. * @param data defines the array of data to use to create each face
  11304. * @param size defines the size of the textures
  11305. * @param format defines the format of the data
  11306. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11307. * @param generateMipMaps defines if the engine should generate the mip levels
  11308. * @param invertY defines if data must be stored with Y axis inverted
  11309. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11310. * @param compression defines the compression used (null by default)
  11311. * @returns the cube texture as an InternalTexture
  11312. */
  11313. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11314. /**
  11315. * Update a raw cube texture
  11316. * @param texture defines the texture to udpdate
  11317. * @param data defines the data to store
  11318. * @param format defines the data format
  11319. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11320. * @param invertY defines if data must be stored with Y axis inverted
  11321. */
  11322. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11323. /**
  11324. * Update a raw cube texture
  11325. * @param texture defines the texture to udpdate
  11326. * @param data defines the data to store
  11327. * @param format defines the data format
  11328. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11329. * @param invertY defines if data must be stored with Y axis inverted
  11330. * @param compression defines the compression used (null by default)
  11331. */
  11332. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11333. /**
  11334. * Update a raw cube texture
  11335. * @param texture defines the texture to udpdate
  11336. * @param data defines the data to store
  11337. * @param format defines the data format
  11338. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11339. * @param invertY defines if data must be stored with Y axis inverted
  11340. * @param compression defines the compression used (null by default)
  11341. * @param level defines which level of the texture to update
  11342. */
  11343. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11344. /**
  11345. * Creates a new raw cube texture from a specified url
  11346. * @param url defines the url where the data is located
  11347. * @param scene defines the current scene
  11348. * @param size defines the size of the textures
  11349. * @param format defines the format of the data
  11350. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11351. * @param noMipmap defines if the engine should avoid generating the mip levels
  11352. * @param callback defines a callback used to extract texture data from loaded data
  11353. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11354. * @param onLoad defines a callback called when texture is loaded
  11355. * @param onError defines a callback called if there is an error
  11356. * @returns the cube texture as an InternalTexture
  11357. */
  11358. 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;
  11359. /**
  11360. * Creates a new raw cube texture from a specified url
  11361. * @param url defines the url where the data is located
  11362. * @param scene defines the current scene
  11363. * @param size defines the size of the textures
  11364. * @param format defines the format of the data
  11365. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11366. * @param noMipmap defines if the engine should avoid generating the mip levels
  11367. * @param callback defines a callback used to extract texture data from loaded data
  11368. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11369. * @param onLoad defines a callback called when texture is loaded
  11370. * @param onError defines a callback called if there is an error
  11371. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11372. * @param invertY defines if data must be stored with Y axis inverted
  11373. * @returns the cube texture as an InternalTexture
  11374. */
  11375. 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;
  11376. /**
  11377. * Creates a new raw 3D texture
  11378. * @param data defines the data used to create the texture
  11379. * @param width defines the width of the texture
  11380. * @param height defines the height of the texture
  11381. * @param depth defines the depth of the texture
  11382. * @param format defines the format of the texture
  11383. * @param generateMipMaps defines if the engine must generate mip levels
  11384. * @param invertY defines if data must be stored with Y axis inverted
  11385. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11386. * @param compression defines the compressed used (can be null)
  11387. * @param textureType defines the compressed used (can be null)
  11388. * @returns a new raw 3D texture (stored in an InternalTexture)
  11389. */
  11390. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11391. /**
  11392. * Update a raw 3D texture
  11393. * @param texture defines the texture to update
  11394. * @param data defines the data to store
  11395. * @param format defines the data format
  11396. * @param invertY defines if data must be stored with Y axis inverted
  11397. */
  11398. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11399. /**
  11400. * Update a raw 3D texture
  11401. * @param texture defines the texture to update
  11402. * @param data defines the data to store
  11403. * @param format defines the data format
  11404. * @param invertY defines if data must be stored with Y axis inverted
  11405. * @param compression defines the used compression (can be null)
  11406. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11407. */
  11408. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11409. /**
  11410. * Creates a new raw 2D array texture
  11411. * @param data defines the data used to create the texture
  11412. * @param width defines the width of the texture
  11413. * @param height defines the height of the texture
  11414. * @param depth defines the number of layers of the texture
  11415. * @param format defines the format of the texture
  11416. * @param generateMipMaps defines if the engine must generate mip levels
  11417. * @param invertY defines if data must be stored with Y axis inverted
  11418. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11419. * @param compression defines the compressed used (can be null)
  11420. * @param textureType defines the compressed used (can be null)
  11421. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11422. */
  11423. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11424. /**
  11425. * Update a raw 2D array texture
  11426. * @param texture defines the texture to update
  11427. * @param data defines the data to store
  11428. * @param format defines the data format
  11429. * @param invertY defines if data must be stored with Y axis inverted
  11430. */
  11431. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11432. /**
  11433. * Update a raw 2D array texture
  11434. * @param texture defines the texture to update
  11435. * @param data defines the data to store
  11436. * @param format defines the data format
  11437. * @param invertY defines if data must be stored with Y axis inverted
  11438. * @param compression defines the used compression (can be null)
  11439. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11440. */
  11441. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11442. }
  11443. }
  11444. declare module BABYLON {
  11445. /**
  11446. * Raw texture can help creating a texture directly from an array of data.
  11447. * This can be super useful if you either get the data from an uncompressed source or
  11448. * if you wish to create your texture pixel by pixel.
  11449. */
  11450. export class RawTexture extends Texture {
  11451. /**
  11452. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11453. */
  11454. format: number;
  11455. /**
  11456. * Instantiates a new RawTexture.
  11457. * Raw texture can help creating a texture directly from an array of data.
  11458. * This can be super useful if you either get the data from an uncompressed source or
  11459. * if you wish to create your texture pixel by pixel.
  11460. * @param data define the array of data to use to create the texture
  11461. * @param width define the width of the texture
  11462. * @param height define the height of the texture
  11463. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11464. * @param scene define the scene the texture belongs to
  11465. * @param generateMipMaps define whether mip maps should be generated or not
  11466. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11467. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11468. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11469. */
  11470. constructor(data: ArrayBufferView, width: number, height: number,
  11471. /**
  11472. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11473. */
  11474. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11475. /**
  11476. * Updates the texture underlying data.
  11477. * @param data Define the new data of the texture
  11478. */
  11479. update(data: ArrayBufferView): void;
  11480. /**
  11481. * Creates a luminance texture from some data.
  11482. * @param data Define the texture data
  11483. * @param width Define the width of the texture
  11484. * @param height Define the height of the texture
  11485. * @param scene Define the scene the texture belongs to
  11486. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11487. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11488. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11489. * @returns the luminance texture
  11490. */
  11491. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11492. /**
  11493. * Creates a luminance alpha texture from some data.
  11494. * @param data Define the texture data
  11495. * @param width Define the width of the texture
  11496. * @param height Define the height of the texture
  11497. * @param scene Define the scene the texture belongs to
  11498. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11499. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11500. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11501. * @returns the luminance alpha texture
  11502. */
  11503. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11504. /**
  11505. * Creates an alpha texture from some data.
  11506. * @param data Define the texture data
  11507. * @param width Define the width of the texture
  11508. * @param height Define the height of the texture
  11509. * @param scene Define the scene the texture belongs to
  11510. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11511. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11512. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11513. * @returns the alpha texture
  11514. */
  11515. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11516. /**
  11517. * Creates a RGB texture from some data.
  11518. * @param data Define the texture data
  11519. * @param width Define the width of the texture
  11520. * @param height Define the height of the texture
  11521. * @param scene Define the scene the texture belongs to
  11522. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11523. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11524. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11525. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11526. * @returns the RGB alpha texture
  11527. */
  11528. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11529. /**
  11530. * Creates a RGBA texture from some data.
  11531. * @param data Define the texture data
  11532. * @param width Define the width of the texture
  11533. * @param height Define the height of the texture
  11534. * @param scene Define the scene the texture belongs to
  11535. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11536. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11537. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11538. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11539. * @returns the RGBA texture
  11540. */
  11541. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11542. /**
  11543. * Creates a R texture from some data.
  11544. * @param data Define the texture data
  11545. * @param width Define the width of the texture
  11546. * @param height Define the height of the texture
  11547. * @param scene Define the scene the texture belongs to
  11548. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11549. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11550. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11551. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11552. * @returns the R texture
  11553. */
  11554. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11555. }
  11556. }
  11557. declare module BABYLON {
  11558. interface AbstractScene {
  11559. /**
  11560. * The list of procedural textures added to the scene
  11561. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11562. */
  11563. proceduralTextures: Array<ProceduralTexture>;
  11564. }
  11565. /**
  11566. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11567. * in a given scene.
  11568. */
  11569. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11570. /**
  11571. * The component name helpfull to identify the component in the list of scene components.
  11572. */
  11573. readonly name: string;
  11574. /**
  11575. * The scene the component belongs to.
  11576. */
  11577. scene: Scene;
  11578. /**
  11579. * Creates a new instance of the component for the given scene
  11580. * @param scene Defines the scene to register the component in
  11581. */
  11582. constructor(scene: Scene);
  11583. /**
  11584. * Registers the component in a given scene
  11585. */
  11586. register(): void;
  11587. /**
  11588. * Rebuilds the elements related to this component in case of
  11589. * context lost for instance.
  11590. */
  11591. rebuild(): void;
  11592. /**
  11593. * Disposes the component and the associated ressources.
  11594. */
  11595. dispose(): void;
  11596. private _beforeClear;
  11597. }
  11598. }
  11599. declare module BABYLON {
  11600. interface ThinEngine {
  11601. /**
  11602. * Creates a new render target cube texture
  11603. * @param size defines the size of the texture
  11604. * @param options defines the options used to create the texture
  11605. * @returns a new render target cube texture stored in an InternalTexture
  11606. */
  11607. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11608. }
  11609. }
  11610. declare module BABYLON {
  11611. /** @hidden */
  11612. export var proceduralVertexShader: {
  11613. name: string;
  11614. shader: string;
  11615. };
  11616. }
  11617. declare module BABYLON {
  11618. /**
  11619. * 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.
  11620. * This is the base class of any Procedural texture and contains most of the shareable code.
  11621. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11622. */
  11623. export class ProceduralTexture extends Texture {
  11624. isCube: boolean;
  11625. /**
  11626. * Define if the texture is enabled or not (disabled texture will not render)
  11627. */
  11628. isEnabled: boolean;
  11629. /**
  11630. * Define if the texture must be cleared before rendering (default is true)
  11631. */
  11632. autoClear: boolean;
  11633. /**
  11634. * Callback called when the texture is generated
  11635. */
  11636. onGenerated: () => void;
  11637. /**
  11638. * Event raised when the texture is generated
  11639. */
  11640. onGeneratedObservable: Observable<ProceduralTexture>;
  11641. /** @hidden */
  11642. _generateMipMaps: boolean;
  11643. /** @hidden **/
  11644. _effect: Effect;
  11645. /** @hidden */
  11646. _textures: {
  11647. [key: string]: Texture;
  11648. };
  11649. /** @hidden */
  11650. protected _fallbackTexture: Nullable<Texture>;
  11651. private _size;
  11652. private _currentRefreshId;
  11653. private _frameId;
  11654. private _refreshRate;
  11655. private _vertexBuffers;
  11656. private _indexBuffer;
  11657. private _uniforms;
  11658. private _samplers;
  11659. private _fragment;
  11660. private _floats;
  11661. private _ints;
  11662. private _floatsArrays;
  11663. private _colors3;
  11664. private _colors4;
  11665. private _vectors2;
  11666. private _vectors3;
  11667. private _matrices;
  11668. private _fallbackTextureUsed;
  11669. private _fullEngine;
  11670. private _cachedDefines;
  11671. private _contentUpdateId;
  11672. private _contentData;
  11673. /**
  11674. * Instantiates a new procedural texture.
  11675. * 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.
  11676. * This is the base class of any Procedural texture and contains most of the shareable code.
  11677. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11678. * @param name Define the name of the texture
  11679. * @param size Define the size of the texture to create
  11680. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11681. * @param scene Define the scene the texture belongs to
  11682. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11683. * @param generateMipMaps Define if the texture should creates mip maps or not
  11684. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11685. */
  11686. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11687. /**
  11688. * The effect that is created when initializing the post process.
  11689. * @returns The created effect corresponding the the postprocess.
  11690. */
  11691. getEffect(): Effect;
  11692. /**
  11693. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11694. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11695. */
  11696. getContent(): Nullable<ArrayBufferView>;
  11697. private _createIndexBuffer;
  11698. /** @hidden */
  11699. _rebuild(): void;
  11700. /**
  11701. * Resets the texture in order to recreate its associated resources.
  11702. * This can be called in case of context loss
  11703. */
  11704. reset(): void;
  11705. protected _getDefines(): string;
  11706. /**
  11707. * Is the texture ready to be used ? (rendered at least once)
  11708. * @returns true if ready, otherwise, false.
  11709. */
  11710. isReady(): boolean;
  11711. /**
  11712. * Resets the refresh counter of the texture and start bak from scratch.
  11713. * Could be useful to regenerate the texture if it is setup to render only once.
  11714. */
  11715. resetRefreshCounter(): void;
  11716. /**
  11717. * Set the fragment shader to use in order to render the texture.
  11718. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11719. */
  11720. setFragment(fragment: any): void;
  11721. /**
  11722. * Define the refresh rate of the texture or the rendering frequency.
  11723. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11724. */
  11725. get refreshRate(): number;
  11726. set refreshRate(value: number);
  11727. /** @hidden */
  11728. _shouldRender(): boolean;
  11729. /**
  11730. * Get the size the texture is rendering at.
  11731. * @returns the size (texture is always squared)
  11732. */
  11733. getRenderSize(): number;
  11734. /**
  11735. * Resize the texture to new value.
  11736. * @param size Define the new size the texture should have
  11737. * @param generateMipMaps Define whether the new texture should create mip maps
  11738. */
  11739. resize(size: number, generateMipMaps: boolean): void;
  11740. private _checkUniform;
  11741. /**
  11742. * Set a texture in the shader program used to render.
  11743. * @param name Define the name of the uniform samplers as defined in the shader
  11744. * @param texture Define the texture to bind to this sampler
  11745. * @return the texture itself allowing "fluent" like uniform updates
  11746. */
  11747. setTexture(name: string, texture: Texture): ProceduralTexture;
  11748. /**
  11749. * Set a float in the shader.
  11750. * @param name Define the name of the uniform as defined in the shader
  11751. * @param value Define the value to give to the uniform
  11752. * @return the texture itself allowing "fluent" like uniform updates
  11753. */
  11754. setFloat(name: string, value: number): ProceduralTexture;
  11755. /**
  11756. * Set a int in the shader.
  11757. * @param name Define the name of the uniform as defined in the shader
  11758. * @param value Define the value to give to the uniform
  11759. * @return the texture itself allowing "fluent" like uniform updates
  11760. */
  11761. setInt(name: string, value: number): ProceduralTexture;
  11762. /**
  11763. * Set an array of floats in the shader.
  11764. * @param name Define the name of the uniform as defined in the shader
  11765. * @param value Define the value to give to the uniform
  11766. * @return the texture itself allowing "fluent" like uniform updates
  11767. */
  11768. setFloats(name: string, value: number[]): ProceduralTexture;
  11769. /**
  11770. * Set a vec3 in the shader from a Color3.
  11771. * @param name Define the name of the uniform as defined in the shader
  11772. * @param value Define the value to give to the uniform
  11773. * @return the texture itself allowing "fluent" like uniform updates
  11774. */
  11775. setColor3(name: string, value: Color3): ProceduralTexture;
  11776. /**
  11777. * Set a vec4 in the shader from a Color4.
  11778. * @param name Define the name of the uniform as defined in the shader
  11779. * @param value Define the value to give to the uniform
  11780. * @return the texture itself allowing "fluent" like uniform updates
  11781. */
  11782. setColor4(name: string, value: Color4): ProceduralTexture;
  11783. /**
  11784. * Set a vec2 in the shader from a Vector2.
  11785. * @param name Define the name of the uniform as defined in the shader
  11786. * @param value Define the value to give to the uniform
  11787. * @return the texture itself allowing "fluent" like uniform updates
  11788. */
  11789. setVector2(name: string, value: Vector2): ProceduralTexture;
  11790. /**
  11791. * Set a vec3 in the shader from a Vector3.
  11792. * @param name Define the name of the uniform as defined in the shader
  11793. * @param value Define the value to give to the uniform
  11794. * @return the texture itself allowing "fluent" like uniform updates
  11795. */
  11796. setVector3(name: string, value: Vector3): ProceduralTexture;
  11797. /**
  11798. * Set a mat4 in the shader from a MAtrix.
  11799. * @param name Define the name of the uniform as defined in the shader
  11800. * @param value Define the value to give to the uniform
  11801. * @return the texture itself allowing "fluent" like uniform updates
  11802. */
  11803. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11804. /**
  11805. * Render the texture to its associated render target.
  11806. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11807. */
  11808. render(useCameraPostProcess?: boolean): void;
  11809. /**
  11810. * Clone the texture.
  11811. * @returns the cloned texture
  11812. */
  11813. clone(): ProceduralTexture;
  11814. /**
  11815. * Dispose the texture and release its asoociated resources.
  11816. */
  11817. dispose(): void;
  11818. }
  11819. }
  11820. declare module BABYLON {
  11821. /**
  11822. * This represents the base class for particle system in Babylon.
  11823. * 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.
  11824. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11825. * @example https://doc.babylonjs.com/babylon101/particles
  11826. */
  11827. export class BaseParticleSystem {
  11828. /**
  11829. * Source color is added to the destination color without alpha affecting the result
  11830. */
  11831. static BLENDMODE_ONEONE: number;
  11832. /**
  11833. * Blend current color and particle color using particle’s alpha
  11834. */
  11835. static BLENDMODE_STANDARD: number;
  11836. /**
  11837. * Add current color and particle color multiplied by particle’s alpha
  11838. */
  11839. static BLENDMODE_ADD: number;
  11840. /**
  11841. * Multiply current color with particle color
  11842. */
  11843. static BLENDMODE_MULTIPLY: number;
  11844. /**
  11845. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11846. */
  11847. static BLENDMODE_MULTIPLYADD: number;
  11848. /**
  11849. * List of animations used by the particle system.
  11850. */
  11851. animations: Animation[];
  11852. /**
  11853. * Gets or sets the unique id of the particle system
  11854. */
  11855. uniqueId: number;
  11856. /**
  11857. * The id of the Particle system.
  11858. */
  11859. id: string;
  11860. /**
  11861. * The friendly name of the Particle system.
  11862. */
  11863. name: string;
  11864. /**
  11865. * Snippet ID if the particle system was created from the snippet server
  11866. */
  11867. snippetId: string;
  11868. /**
  11869. * The rendering group used by the Particle system to chose when to render.
  11870. */
  11871. renderingGroupId: number;
  11872. /**
  11873. * The emitter represents the Mesh or position we are attaching the particle system to.
  11874. */
  11875. emitter: Nullable<AbstractMesh | Vector3>;
  11876. /**
  11877. * The maximum number of particles to emit per frame
  11878. */
  11879. emitRate: number;
  11880. /**
  11881. * If you want to launch only a few particles at once, that can be done, as well.
  11882. */
  11883. manualEmitCount: number;
  11884. /**
  11885. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11886. */
  11887. updateSpeed: number;
  11888. /**
  11889. * The amount of time the particle system is running (depends of the overall update speed).
  11890. */
  11891. targetStopDuration: number;
  11892. /**
  11893. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11894. */
  11895. disposeOnStop: boolean;
  11896. /**
  11897. * Minimum power of emitting particles.
  11898. */
  11899. minEmitPower: number;
  11900. /**
  11901. * Maximum power of emitting particles.
  11902. */
  11903. maxEmitPower: number;
  11904. /**
  11905. * Minimum life time of emitting particles.
  11906. */
  11907. minLifeTime: number;
  11908. /**
  11909. * Maximum life time of emitting particles.
  11910. */
  11911. maxLifeTime: number;
  11912. /**
  11913. * Minimum Size of emitting particles.
  11914. */
  11915. minSize: number;
  11916. /**
  11917. * Maximum Size of emitting particles.
  11918. */
  11919. maxSize: number;
  11920. /**
  11921. * Minimum scale of emitting particles on X axis.
  11922. */
  11923. minScaleX: number;
  11924. /**
  11925. * Maximum scale of emitting particles on X axis.
  11926. */
  11927. maxScaleX: number;
  11928. /**
  11929. * Minimum scale of emitting particles on Y axis.
  11930. */
  11931. minScaleY: number;
  11932. /**
  11933. * Maximum scale of emitting particles on Y axis.
  11934. */
  11935. maxScaleY: number;
  11936. /**
  11937. * Gets or sets the minimal initial rotation in radians.
  11938. */
  11939. minInitialRotation: number;
  11940. /**
  11941. * Gets or sets the maximal initial rotation in radians.
  11942. */
  11943. maxInitialRotation: number;
  11944. /**
  11945. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11946. */
  11947. minAngularSpeed: number;
  11948. /**
  11949. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11950. */
  11951. maxAngularSpeed: number;
  11952. /**
  11953. * The texture used to render each particle. (this can be a spritesheet)
  11954. */
  11955. particleTexture: Nullable<Texture>;
  11956. /**
  11957. * The layer mask we are rendering the particles through.
  11958. */
  11959. layerMask: number;
  11960. /**
  11961. * This can help using your own shader to render the particle system.
  11962. * The according effect will be created
  11963. */
  11964. customShader: any;
  11965. /**
  11966. * By default particle system starts as soon as they are created. This prevents the
  11967. * automatic start to happen and let you decide when to start emitting particles.
  11968. */
  11969. preventAutoStart: boolean;
  11970. private _noiseTexture;
  11971. /**
  11972. * Gets or sets a texture used to add random noise to particle positions
  11973. */
  11974. get noiseTexture(): Nullable<ProceduralTexture>;
  11975. set noiseTexture(value: Nullable<ProceduralTexture>);
  11976. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11977. noiseStrength: Vector3;
  11978. /**
  11979. * Callback triggered when the particle animation is ending.
  11980. */
  11981. onAnimationEnd: Nullable<() => void>;
  11982. /**
  11983. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11984. */
  11985. blendMode: number;
  11986. /**
  11987. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11988. * to override the particles.
  11989. */
  11990. forceDepthWrite: boolean;
  11991. /** 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 */
  11992. preWarmCycles: number;
  11993. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11994. preWarmStepOffset: number;
  11995. /**
  11996. * 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)
  11997. */
  11998. spriteCellChangeSpeed: number;
  11999. /**
  12000. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12001. */
  12002. startSpriteCellID: number;
  12003. /**
  12004. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12005. */
  12006. endSpriteCellID: number;
  12007. /**
  12008. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12009. */
  12010. spriteCellWidth: number;
  12011. /**
  12012. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12013. */
  12014. spriteCellHeight: number;
  12015. /**
  12016. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12017. */
  12018. spriteRandomStartCell: boolean;
  12019. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12020. translationPivot: Vector2;
  12021. /** @hidden */
  12022. protected _isAnimationSheetEnabled: boolean;
  12023. /**
  12024. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12025. */
  12026. beginAnimationOnStart: boolean;
  12027. /**
  12028. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12029. */
  12030. beginAnimationFrom: number;
  12031. /**
  12032. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12033. */
  12034. beginAnimationTo: number;
  12035. /**
  12036. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12037. */
  12038. beginAnimationLoop: boolean;
  12039. /**
  12040. * Gets or sets a world offset applied to all particles
  12041. */
  12042. worldOffset: Vector3;
  12043. /**
  12044. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12045. */
  12046. get isAnimationSheetEnabled(): boolean;
  12047. set isAnimationSheetEnabled(value: boolean);
  12048. /**
  12049. * Get hosting scene
  12050. * @returns the scene
  12051. */
  12052. getScene(): Scene;
  12053. /**
  12054. * You can use gravity if you want to give an orientation to your particles.
  12055. */
  12056. gravity: Vector3;
  12057. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12058. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12059. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12060. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12061. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12062. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12063. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12064. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12065. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12066. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12067. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12068. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12069. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12070. /**
  12071. * Defines the delay in milliseconds before starting the system (0 by default)
  12072. */
  12073. startDelay: number;
  12074. /**
  12075. * Gets the current list of drag gradients.
  12076. * You must use addDragGradient and removeDragGradient to udpate this list
  12077. * @returns the list of drag gradients
  12078. */
  12079. getDragGradients(): Nullable<Array<FactorGradient>>;
  12080. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12081. limitVelocityDamping: number;
  12082. /**
  12083. * Gets the current list of limit velocity gradients.
  12084. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12085. * @returns the list of limit velocity gradients
  12086. */
  12087. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12088. /**
  12089. * Gets the current list of color gradients.
  12090. * You must use addColorGradient and removeColorGradient to udpate this list
  12091. * @returns the list of color gradients
  12092. */
  12093. getColorGradients(): Nullable<Array<ColorGradient>>;
  12094. /**
  12095. * Gets the current list of size gradients.
  12096. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12097. * @returns the list of size gradients
  12098. */
  12099. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12100. /**
  12101. * Gets the current list of color remap gradients.
  12102. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12103. * @returns the list of color remap gradients
  12104. */
  12105. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12106. /**
  12107. * Gets the current list of alpha remap gradients.
  12108. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12109. * @returns the list of alpha remap gradients
  12110. */
  12111. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12112. /**
  12113. * Gets the current list of life time gradients.
  12114. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12115. * @returns the list of life time gradients
  12116. */
  12117. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12118. /**
  12119. * Gets the current list of angular speed gradients.
  12120. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12121. * @returns the list of angular speed gradients
  12122. */
  12123. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12124. /**
  12125. * Gets the current list of velocity gradients.
  12126. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12127. * @returns the list of velocity gradients
  12128. */
  12129. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12130. /**
  12131. * Gets the current list of start size gradients.
  12132. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12133. * @returns the list of start size gradients
  12134. */
  12135. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12136. /**
  12137. * Gets the current list of emit rate gradients.
  12138. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12139. * @returns the list of emit rate gradients
  12140. */
  12141. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12142. /**
  12143. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12144. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12145. */
  12146. get direction1(): Vector3;
  12147. set direction1(value: Vector3);
  12148. /**
  12149. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12150. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12151. */
  12152. get direction2(): Vector3;
  12153. set direction2(value: Vector3);
  12154. /**
  12155. * 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.
  12156. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12157. */
  12158. get minEmitBox(): Vector3;
  12159. set minEmitBox(value: Vector3);
  12160. /**
  12161. * 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.
  12162. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12163. */
  12164. get maxEmitBox(): Vector3;
  12165. set maxEmitBox(value: Vector3);
  12166. /**
  12167. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12168. */
  12169. color1: Color4;
  12170. /**
  12171. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12172. */
  12173. color2: Color4;
  12174. /**
  12175. * Color the particle will have at the end of its lifetime
  12176. */
  12177. colorDead: Color4;
  12178. /**
  12179. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12180. */
  12181. textureMask: Color4;
  12182. /**
  12183. * The particle emitter type defines the emitter used by the particle system.
  12184. * It can be for example box, sphere, or cone...
  12185. */
  12186. particleEmitterType: IParticleEmitterType;
  12187. /** @hidden */
  12188. _isSubEmitter: boolean;
  12189. /**
  12190. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12191. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12192. */
  12193. billboardMode: number;
  12194. protected _isBillboardBased: boolean;
  12195. /**
  12196. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12197. */
  12198. get isBillboardBased(): boolean;
  12199. set isBillboardBased(value: boolean);
  12200. /**
  12201. * The scene the particle system belongs to.
  12202. */
  12203. protected _scene: Scene;
  12204. /**
  12205. * Local cache of defines for image processing.
  12206. */
  12207. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12208. /**
  12209. * Default configuration related to image processing available in the standard Material.
  12210. */
  12211. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12212. /**
  12213. * Gets the image processing configuration used either in this material.
  12214. */
  12215. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12216. /**
  12217. * Sets the Default image processing configuration used either in the this material.
  12218. *
  12219. * If sets to null, the scene one is in use.
  12220. */
  12221. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12222. /**
  12223. * Attaches a new image processing configuration to the Standard Material.
  12224. * @param configuration
  12225. */
  12226. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12227. /** @hidden */
  12228. protected _reset(): void;
  12229. /** @hidden */
  12230. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12231. /**
  12232. * Instantiates a particle system.
  12233. * 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.
  12234. * @param name The name of the particle system
  12235. */
  12236. constructor(name: string);
  12237. /**
  12238. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12239. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12240. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12241. * @returns the emitter
  12242. */
  12243. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12244. /**
  12245. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12246. * @param radius The radius of the hemisphere to emit from
  12247. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12248. * @returns the emitter
  12249. */
  12250. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12251. /**
  12252. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12253. * @param radius The radius of the sphere to emit from
  12254. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12255. * @returns the emitter
  12256. */
  12257. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12258. /**
  12259. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12260. * @param radius The radius of the sphere to emit from
  12261. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12262. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12263. * @returns the emitter
  12264. */
  12265. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12266. /**
  12267. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12268. * @param radius The radius of the emission cylinder
  12269. * @param height The height of the emission cylinder
  12270. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12271. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12272. * @returns the emitter
  12273. */
  12274. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12275. /**
  12276. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12277. * @param radius The radius of the cylinder to emit from
  12278. * @param height The height of the emission cylinder
  12279. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12280. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12281. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12282. * @returns the emitter
  12283. */
  12284. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12285. /**
  12286. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12287. * @param radius The radius of the cone to emit from
  12288. * @param angle The base angle of the cone
  12289. * @returns the emitter
  12290. */
  12291. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12292. /**
  12293. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12294. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12295. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12296. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12297. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12298. * @returns the emitter
  12299. */
  12300. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12301. }
  12302. }
  12303. declare module BABYLON {
  12304. /**
  12305. * Type of sub emitter
  12306. */
  12307. export enum SubEmitterType {
  12308. /**
  12309. * Attached to the particle over it's lifetime
  12310. */
  12311. ATTACHED = 0,
  12312. /**
  12313. * Created when the particle dies
  12314. */
  12315. END = 1
  12316. }
  12317. /**
  12318. * Sub emitter class used to emit particles from an existing particle
  12319. */
  12320. export class SubEmitter {
  12321. /**
  12322. * the particle system to be used by the sub emitter
  12323. */
  12324. particleSystem: ParticleSystem;
  12325. /**
  12326. * Type of the submitter (Default: END)
  12327. */
  12328. type: SubEmitterType;
  12329. /**
  12330. * 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)
  12331. * Note: This only is supported when using an emitter of type Mesh
  12332. */
  12333. inheritDirection: boolean;
  12334. /**
  12335. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12336. */
  12337. inheritedVelocityAmount: number;
  12338. /**
  12339. * Creates a sub emitter
  12340. * @param particleSystem the particle system to be used by the sub emitter
  12341. */
  12342. constructor(
  12343. /**
  12344. * the particle system to be used by the sub emitter
  12345. */
  12346. particleSystem: ParticleSystem);
  12347. /**
  12348. * Clones the sub emitter
  12349. * @returns the cloned sub emitter
  12350. */
  12351. clone(): SubEmitter;
  12352. /**
  12353. * Serialize current object to a JSON object
  12354. * @returns the serialized object
  12355. */
  12356. serialize(): any;
  12357. /** @hidden */
  12358. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12359. /**
  12360. * Creates a new SubEmitter from a serialized JSON version
  12361. * @param serializationObject defines the JSON object to read from
  12362. * @param scene defines the hosting scene
  12363. * @param rootUrl defines the rootUrl for data loading
  12364. * @returns a new SubEmitter
  12365. */
  12366. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12367. /** Release associated resources */
  12368. dispose(): void;
  12369. }
  12370. }
  12371. declare module BABYLON {
  12372. /** @hidden */
  12373. export var imageProcessingDeclaration: {
  12374. name: string;
  12375. shader: string;
  12376. };
  12377. }
  12378. declare module BABYLON {
  12379. /** @hidden */
  12380. export var imageProcessingFunctions: {
  12381. name: string;
  12382. shader: string;
  12383. };
  12384. }
  12385. declare module BABYLON {
  12386. /** @hidden */
  12387. export var particlesPixelShader: {
  12388. name: string;
  12389. shader: string;
  12390. };
  12391. }
  12392. declare module BABYLON {
  12393. /** @hidden */
  12394. export var particlesVertexShader: {
  12395. name: string;
  12396. shader: string;
  12397. };
  12398. }
  12399. declare module BABYLON {
  12400. /**
  12401. * This represents a particle system in Babylon.
  12402. * 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.
  12403. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12404. * @example https://doc.babylonjs.com/babylon101/particles
  12405. */
  12406. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12407. /**
  12408. * Billboard mode will only apply to Y axis
  12409. */
  12410. static readonly BILLBOARDMODE_Y: number;
  12411. /**
  12412. * Billboard mode will apply to all axes
  12413. */
  12414. static readonly BILLBOARDMODE_ALL: number;
  12415. /**
  12416. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12417. */
  12418. static readonly BILLBOARDMODE_STRETCHED: number;
  12419. /**
  12420. * This function can be defined to provide custom update for active particles.
  12421. * This function will be called instead of regular update (age, position, color, etc.).
  12422. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12423. */
  12424. updateFunction: (particles: Particle[]) => void;
  12425. private _emitterWorldMatrix;
  12426. /**
  12427. * This function can be defined to specify initial direction for every new particle.
  12428. * It by default use the emitterType defined function
  12429. */
  12430. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12431. /**
  12432. * This function can be defined to specify initial position for every new particle.
  12433. * It by default use the emitterType defined function
  12434. */
  12435. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12436. /**
  12437. * @hidden
  12438. */
  12439. _inheritedVelocityOffset: Vector3;
  12440. /**
  12441. * An event triggered when the system is disposed
  12442. */
  12443. onDisposeObservable: Observable<IParticleSystem>;
  12444. private _onDisposeObserver;
  12445. /**
  12446. * Sets a callback that will be triggered when the system is disposed
  12447. */
  12448. set onDispose(callback: () => void);
  12449. private _particles;
  12450. private _epsilon;
  12451. private _capacity;
  12452. private _stockParticles;
  12453. private _newPartsExcess;
  12454. private _vertexData;
  12455. private _vertexBuffer;
  12456. private _vertexBuffers;
  12457. private _spriteBuffer;
  12458. private _indexBuffer;
  12459. private _effect;
  12460. private _customEffect;
  12461. private _cachedDefines;
  12462. private _scaledColorStep;
  12463. private _colorDiff;
  12464. private _scaledDirection;
  12465. private _scaledGravity;
  12466. private _currentRenderId;
  12467. private _alive;
  12468. private _useInstancing;
  12469. private _started;
  12470. private _stopped;
  12471. private _actualFrame;
  12472. private _scaledUpdateSpeed;
  12473. private _vertexBufferSize;
  12474. /** @hidden */
  12475. _currentEmitRateGradient: Nullable<FactorGradient>;
  12476. /** @hidden */
  12477. _currentEmitRate1: number;
  12478. /** @hidden */
  12479. _currentEmitRate2: number;
  12480. /** @hidden */
  12481. _currentStartSizeGradient: Nullable<FactorGradient>;
  12482. /** @hidden */
  12483. _currentStartSize1: number;
  12484. /** @hidden */
  12485. _currentStartSize2: number;
  12486. private readonly _rawTextureWidth;
  12487. private _rampGradientsTexture;
  12488. private _useRampGradients;
  12489. /** Gets or sets a boolean indicating that ramp gradients must be used
  12490. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12491. */
  12492. get useRampGradients(): boolean;
  12493. set useRampGradients(value: boolean);
  12494. /**
  12495. * 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.
  12496. * 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: [])
  12497. */
  12498. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12499. private _subEmitters;
  12500. /**
  12501. * @hidden
  12502. * If the particle systems emitter should be disposed when the particle system is disposed
  12503. */
  12504. _disposeEmitterOnDispose: boolean;
  12505. /**
  12506. * The current active Sub-systems, this property is used by the root particle system only.
  12507. */
  12508. activeSubSystems: Array<ParticleSystem>;
  12509. /**
  12510. * Specifies if the particles are updated in emitter local space or world space
  12511. */
  12512. isLocal: boolean;
  12513. private _rootParticleSystem;
  12514. /**
  12515. * Gets the current list of active particles
  12516. */
  12517. get particles(): Particle[];
  12518. /**
  12519. * Gets the number of particles active at the same time.
  12520. * @returns The number of active particles.
  12521. */
  12522. getActiveCount(): number;
  12523. /**
  12524. * Returns the string "ParticleSystem"
  12525. * @returns a string containing the class name
  12526. */
  12527. getClassName(): string;
  12528. /**
  12529. * Gets a boolean indicating that the system is stopping
  12530. * @returns true if the system is currently stopping
  12531. */
  12532. isStopping(): boolean;
  12533. /**
  12534. * Gets the custom effect used to render the particles
  12535. * @param blendMode Blend mode for which the effect should be retrieved
  12536. * @returns The effect
  12537. */
  12538. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12539. /**
  12540. * Sets the custom effect used to render the particles
  12541. * @param effect The effect to set
  12542. * @param blendMode Blend mode for which the effect should be set
  12543. */
  12544. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12545. /** @hidden */
  12546. private _onBeforeDrawParticlesObservable;
  12547. /**
  12548. * Observable that will be called just before the particles are drawn
  12549. */
  12550. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12551. /**
  12552. * Gets the name of the particle vertex shader
  12553. */
  12554. get vertexShaderName(): string;
  12555. /**
  12556. * Instantiates a particle system.
  12557. * 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.
  12558. * @param name The name of the particle system
  12559. * @param capacity The max number of particles alive at the same time
  12560. * @param scene The scene the particle system belongs to
  12561. * @param customEffect a custom effect used to change the way particles are rendered by default
  12562. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12563. * @param epsilon Offset used to render the particles
  12564. */
  12565. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12566. private _addFactorGradient;
  12567. private _removeFactorGradient;
  12568. /**
  12569. * Adds a new life time gradient
  12570. * @param gradient defines the gradient to use (between 0 and 1)
  12571. * @param factor defines the life time factor to affect to the specified gradient
  12572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12573. * @returns the current particle system
  12574. */
  12575. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12576. /**
  12577. * Remove a specific life time gradient
  12578. * @param gradient defines the gradient to remove
  12579. * @returns the current particle system
  12580. */
  12581. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12582. /**
  12583. * Adds a new size gradient
  12584. * @param gradient defines the gradient to use (between 0 and 1)
  12585. * @param factor defines the size factor to affect to the specified gradient
  12586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12587. * @returns the current particle system
  12588. */
  12589. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12590. /**
  12591. * Remove a specific size gradient
  12592. * @param gradient defines the gradient to remove
  12593. * @returns the current particle system
  12594. */
  12595. removeSizeGradient(gradient: number): IParticleSystem;
  12596. /**
  12597. * Adds a new color remap gradient
  12598. * @param gradient defines the gradient to use (between 0 and 1)
  12599. * @param min defines the color remap minimal range
  12600. * @param max defines the color remap maximal range
  12601. * @returns the current particle system
  12602. */
  12603. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12604. /**
  12605. * Remove a specific color remap gradient
  12606. * @param gradient defines the gradient to remove
  12607. * @returns the current particle system
  12608. */
  12609. removeColorRemapGradient(gradient: number): IParticleSystem;
  12610. /**
  12611. * Adds a new alpha remap gradient
  12612. * @param gradient defines the gradient to use (between 0 and 1)
  12613. * @param min defines the alpha remap minimal range
  12614. * @param max defines the alpha remap maximal range
  12615. * @returns the current particle system
  12616. */
  12617. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12618. /**
  12619. * Remove a specific alpha remap gradient
  12620. * @param gradient defines the gradient to remove
  12621. * @returns the current particle system
  12622. */
  12623. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12624. /**
  12625. * Adds a new angular speed gradient
  12626. * @param gradient defines the gradient to use (between 0 and 1)
  12627. * @param factor defines the angular speed to affect to the specified gradient
  12628. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12629. * @returns the current particle system
  12630. */
  12631. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12632. /**
  12633. * Remove a specific angular speed gradient
  12634. * @param gradient defines the gradient to remove
  12635. * @returns the current particle system
  12636. */
  12637. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12638. /**
  12639. * Adds a new velocity gradient
  12640. * @param gradient defines the gradient to use (between 0 and 1)
  12641. * @param factor defines the velocity to affect to the specified gradient
  12642. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12643. * @returns the current particle system
  12644. */
  12645. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12646. /**
  12647. * Remove a specific velocity gradient
  12648. * @param gradient defines the gradient to remove
  12649. * @returns the current particle system
  12650. */
  12651. removeVelocityGradient(gradient: number): IParticleSystem;
  12652. /**
  12653. * Adds a new limit velocity gradient
  12654. * @param gradient defines the gradient to use (between 0 and 1)
  12655. * @param factor defines the limit velocity value to affect to the specified gradient
  12656. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12657. * @returns the current particle system
  12658. */
  12659. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12660. /**
  12661. * Remove a specific limit velocity gradient
  12662. * @param gradient defines the gradient to remove
  12663. * @returns the current particle system
  12664. */
  12665. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12666. /**
  12667. * Adds a new drag gradient
  12668. * @param gradient defines the gradient to use (between 0 and 1)
  12669. * @param factor defines the drag value to affect to the specified gradient
  12670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12671. * @returns the current particle system
  12672. */
  12673. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12674. /**
  12675. * Remove a specific drag gradient
  12676. * @param gradient defines the gradient to remove
  12677. * @returns the current particle system
  12678. */
  12679. removeDragGradient(gradient: number): IParticleSystem;
  12680. /**
  12681. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12682. * @param gradient defines the gradient to use (between 0 and 1)
  12683. * @param factor defines the emit rate value to affect to the specified gradient
  12684. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12685. * @returns the current particle system
  12686. */
  12687. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12688. /**
  12689. * Remove a specific emit rate gradient
  12690. * @param gradient defines the gradient to remove
  12691. * @returns the current particle system
  12692. */
  12693. removeEmitRateGradient(gradient: number): IParticleSystem;
  12694. /**
  12695. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12696. * @param gradient defines the gradient to use (between 0 and 1)
  12697. * @param factor defines the start size value to affect to the specified gradient
  12698. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12699. * @returns the current particle system
  12700. */
  12701. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12702. /**
  12703. * Remove a specific start size gradient
  12704. * @param gradient defines the gradient to remove
  12705. * @returns the current particle system
  12706. */
  12707. removeStartSizeGradient(gradient: number): IParticleSystem;
  12708. private _createRampGradientTexture;
  12709. /**
  12710. * Gets the current list of ramp gradients.
  12711. * You must use addRampGradient and removeRampGradient to udpate this list
  12712. * @returns the list of ramp gradients
  12713. */
  12714. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12715. /** Force the system to rebuild all gradients that need to be resync */
  12716. forceRefreshGradients(): void;
  12717. private _syncRampGradientTexture;
  12718. /**
  12719. * Adds a new ramp gradient used to remap particle colors
  12720. * @param gradient defines the gradient to use (between 0 and 1)
  12721. * @param color defines the color to affect to the specified gradient
  12722. * @returns the current particle system
  12723. */
  12724. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12725. /**
  12726. * Remove a specific ramp gradient
  12727. * @param gradient defines the gradient to remove
  12728. * @returns the current particle system
  12729. */
  12730. removeRampGradient(gradient: number): ParticleSystem;
  12731. /**
  12732. * Adds a new color gradient
  12733. * @param gradient defines the gradient to use (between 0 and 1)
  12734. * @param color1 defines the color to affect to the specified gradient
  12735. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12736. * @returns this particle system
  12737. */
  12738. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12739. /**
  12740. * Remove a specific color gradient
  12741. * @param gradient defines the gradient to remove
  12742. * @returns this particle system
  12743. */
  12744. removeColorGradient(gradient: number): IParticleSystem;
  12745. private _fetchR;
  12746. protected _reset(): void;
  12747. private _resetEffect;
  12748. private _createVertexBuffers;
  12749. private _createIndexBuffer;
  12750. /**
  12751. * Gets the maximum number of particles active at the same time.
  12752. * @returns The max number of active particles.
  12753. */
  12754. getCapacity(): number;
  12755. /**
  12756. * Gets whether there are still active particles in the system.
  12757. * @returns True if it is alive, otherwise false.
  12758. */
  12759. isAlive(): boolean;
  12760. /**
  12761. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12762. * @returns True if it has been started, otherwise false.
  12763. */
  12764. isStarted(): boolean;
  12765. private _prepareSubEmitterInternalArray;
  12766. /**
  12767. * Starts the particle system and begins to emit
  12768. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12769. */
  12770. start(delay?: number): void;
  12771. /**
  12772. * Stops the particle system.
  12773. * @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.
  12774. */
  12775. stop(stopSubEmitters?: boolean): void;
  12776. /**
  12777. * Remove all active particles
  12778. */
  12779. reset(): void;
  12780. /**
  12781. * @hidden (for internal use only)
  12782. */
  12783. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12784. /**
  12785. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12786. * Its lifetime will start back at 0.
  12787. */
  12788. recycleParticle: (particle: Particle) => void;
  12789. private _stopSubEmitters;
  12790. private _createParticle;
  12791. private _removeFromRoot;
  12792. private _emitFromParticle;
  12793. private _update;
  12794. /** @hidden */
  12795. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12796. /** @hidden */
  12797. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12798. /**
  12799. * Fill the defines array according to the current settings of the particle system
  12800. * @param defines Array to be updated
  12801. * @param blendMode blend mode to take into account when updating the array
  12802. */
  12803. fillDefines(defines: Array<string>, blendMode: number): void;
  12804. /**
  12805. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12806. * @param uniforms Uniforms array to fill
  12807. * @param attributes Attributes array to fill
  12808. * @param samplers Samplers array to fill
  12809. */
  12810. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12811. /** @hidden */
  12812. private _getEffect;
  12813. /**
  12814. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12815. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12816. */
  12817. animate(preWarmOnly?: boolean): void;
  12818. private _appendParticleVertices;
  12819. /**
  12820. * Rebuilds the particle system.
  12821. */
  12822. rebuild(): void;
  12823. /**
  12824. * Is this system ready to be used/rendered
  12825. * @return true if the system is ready
  12826. */
  12827. isReady(): boolean;
  12828. private _render;
  12829. /**
  12830. * Renders the particle system in its current state.
  12831. * @returns the current number of particles
  12832. */
  12833. render(): number;
  12834. /**
  12835. * Disposes the particle system and free the associated resources
  12836. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12837. */
  12838. dispose(disposeTexture?: boolean): void;
  12839. /**
  12840. * Clones the particle system.
  12841. * @param name The name of the cloned object
  12842. * @param newEmitter The new emitter to use
  12843. * @returns the cloned particle system
  12844. */
  12845. clone(name: string, newEmitter: any): ParticleSystem;
  12846. /**
  12847. * Serializes the particle system to a JSON object
  12848. * @param serializeTexture defines if the texture must be serialized as well
  12849. * @returns the JSON object
  12850. */
  12851. serialize(serializeTexture?: boolean): any;
  12852. /** @hidden */
  12853. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12854. /** @hidden */
  12855. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12856. /**
  12857. * Parses a JSON object to create a particle system.
  12858. * @param parsedParticleSystem The JSON object to parse
  12859. * @param scene The scene to create the particle system in
  12860. * @param rootUrl The root url to use to load external dependencies like texture
  12861. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12862. * @returns the Parsed particle system
  12863. */
  12864. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12865. }
  12866. }
  12867. declare module BABYLON {
  12868. /**
  12869. * A particle represents one of the element emitted by a particle system.
  12870. * This is mainly define by its coordinates, direction, velocity and age.
  12871. */
  12872. export class Particle {
  12873. /**
  12874. * The particle system the particle belongs to.
  12875. */
  12876. particleSystem: ParticleSystem;
  12877. private static _Count;
  12878. /**
  12879. * Unique ID of the particle
  12880. */
  12881. id: number;
  12882. /**
  12883. * The world position of the particle in the scene.
  12884. */
  12885. position: Vector3;
  12886. /**
  12887. * The world direction of the particle in the scene.
  12888. */
  12889. direction: Vector3;
  12890. /**
  12891. * The color of the particle.
  12892. */
  12893. color: Color4;
  12894. /**
  12895. * The color change of the particle per step.
  12896. */
  12897. colorStep: Color4;
  12898. /**
  12899. * Defines how long will the life of the particle be.
  12900. */
  12901. lifeTime: number;
  12902. /**
  12903. * The current age of the particle.
  12904. */
  12905. age: number;
  12906. /**
  12907. * The current size of the particle.
  12908. */
  12909. size: number;
  12910. /**
  12911. * The current scale of the particle.
  12912. */
  12913. scale: Vector2;
  12914. /**
  12915. * The current angle of the particle.
  12916. */
  12917. angle: number;
  12918. /**
  12919. * Defines how fast is the angle changing.
  12920. */
  12921. angularSpeed: number;
  12922. /**
  12923. * Defines the cell index used by the particle to be rendered from a sprite.
  12924. */
  12925. cellIndex: number;
  12926. /**
  12927. * The information required to support color remapping
  12928. */
  12929. remapData: Vector4;
  12930. /** @hidden */
  12931. _randomCellOffset?: number;
  12932. /** @hidden */
  12933. _initialDirection: Nullable<Vector3>;
  12934. /** @hidden */
  12935. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12936. /** @hidden */
  12937. _initialStartSpriteCellID: number;
  12938. /** @hidden */
  12939. _initialEndSpriteCellID: number;
  12940. /** @hidden */
  12941. _currentColorGradient: Nullable<ColorGradient>;
  12942. /** @hidden */
  12943. _currentColor1: Color4;
  12944. /** @hidden */
  12945. _currentColor2: Color4;
  12946. /** @hidden */
  12947. _currentSizeGradient: Nullable<FactorGradient>;
  12948. /** @hidden */
  12949. _currentSize1: number;
  12950. /** @hidden */
  12951. _currentSize2: number;
  12952. /** @hidden */
  12953. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12954. /** @hidden */
  12955. _currentAngularSpeed1: number;
  12956. /** @hidden */
  12957. _currentAngularSpeed2: number;
  12958. /** @hidden */
  12959. _currentVelocityGradient: Nullable<FactorGradient>;
  12960. /** @hidden */
  12961. _currentVelocity1: number;
  12962. /** @hidden */
  12963. _currentVelocity2: number;
  12964. /** @hidden */
  12965. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12966. /** @hidden */
  12967. _currentLimitVelocity1: number;
  12968. /** @hidden */
  12969. _currentLimitVelocity2: number;
  12970. /** @hidden */
  12971. _currentDragGradient: Nullable<FactorGradient>;
  12972. /** @hidden */
  12973. _currentDrag1: number;
  12974. /** @hidden */
  12975. _currentDrag2: number;
  12976. /** @hidden */
  12977. _randomNoiseCoordinates1: Vector3;
  12978. /** @hidden */
  12979. _randomNoiseCoordinates2: Vector3;
  12980. /** @hidden */
  12981. _localPosition?: Vector3;
  12982. /**
  12983. * Creates a new instance Particle
  12984. * @param particleSystem the particle system the particle belongs to
  12985. */
  12986. constructor(
  12987. /**
  12988. * The particle system the particle belongs to.
  12989. */
  12990. particleSystem: ParticleSystem);
  12991. private updateCellInfoFromSystem;
  12992. /**
  12993. * Defines how the sprite cell index is updated for the particle
  12994. */
  12995. updateCellIndex(): void;
  12996. /** @hidden */
  12997. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12998. /** @hidden */
  12999. _inheritParticleInfoToSubEmitters(): void;
  13000. /** @hidden */
  13001. _reset(): void;
  13002. /**
  13003. * Copy the properties of particle to another one.
  13004. * @param other the particle to copy the information to.
  13005. */
  13006. copyTo(other: Particle): void;
  13007. }
  13008. }
  13009. declare module BABYLON {
  13010. /**
  13011. * Particle emitter represents a volume emitting particles.
  13012. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13013. */
  13014. export interface IParticleEmitterType {
  13015. /**
  13016. * Called by the particle System when the direction is computed for the created particle.
  13017. * @param worldMatrix is the world matrix of the particle system
  13018. * @param directionToUpdate is the direction vector to update with the result
  13019. * @param particle is the particle we are computed the direction for
  13020. * @param isLocal defines if the direction should be set in local space
  13021. */
  13022. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13023. /**
  13024. * Called by the particle System when the position is computed for the created particle.
  13025. * @param worldMatrix is the world matrix of the particle system
  13026. * @param positionToUpdate is the position vector to update with the result
  13027. * @param particle is the particle we are computed the position for
  13028. * @param isLocal defines if the position should be set in local space
  13029. */
  13030. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13031. /**
  13032. * Clones the current emitter and returns a copy of it
  13033. * @returns the new emitter
  13034. */
  13035. clone(): IParticleEmitterType;
  13036. /**
  13037. * Called by the GPUParticleSystem to setup the update shader
  13038. * @param effect defines the update shader
  13039. */
  13040. applyToShader(effect: Effect): void;
  13041. /**
  13042. * Returns a string to use to update the GPU particles update shader
  13043. * @returns the effect defines string
  13044. */
  13045. getEffectDefines(): string;
  13046. /**
  13047. * Returns a string representing the class name
  13048. * @returns a string containing the class name
  13049. */
  13050. getClassName(): string;
  13051. /**
  13052. * Serializes the particle system to a JSON object.
  13053. * @returns the JSON object
  13054. */
  13055. serialize(): any;
  13056. /**
  13057. * Parse properties from a JSON object
  13058. * @param serializationObject defines the JSON object
  13059. * @param scene defines the hosting scene
  13060. */
  13061. parse(serializationObject: any, scene: Scene): void;
  13062. }
  13063. }
  13064. declare module BABYLON {
  13065. /**
  13066. * Particle emitter emitting particles from the inside of a box.
  13067. * It emits the particles randomly between 2 given directions.
  13068. */
  13069. export class BoxParticleEmitter implements IParticleEmitterType {
  13070. /**
  13071. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13072. */
  13073. direction1: Vector3;
  13074. /**
  13075. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13076. */
  13077. direction2: Vector3;
  13078. /**
  13079. * 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.
  13080. */
  13081. minEmitBox: Vector3;
  13082. /**
  13083. * 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.
  13084. */
  13085. maxEmitBox: Vector3;
  13086. /**
  13087. * Creates a new instance BoxParticleEmitter
  13088. */
  13089. constructor();
  13090. /**
  13091. * Called by the particle System when the direction is computed for the created particle.
  13092. * @param worldMatrix is the world matrix of the particle system
  13093. * @param directionToUpdate is the direction vector to update with the result
  13094. * @param particle is the particle we are computed the direction for
  13095. * @param isLocal defines if the direction should be set in local space
  13096. */
  13097. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13098. /**
  13099. * Called by the particle System when the position is computed for the created particle.
  13100. * @param worldMatrix is the world matrix of the particle system
  13101. * @param positionToUpdate is the position vector to update with the result
  13102. * @param particle is the particle we are computed the position for
  13103. * @param isLocal defines if the position should be set in local space
  13104. */
  13105. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13106. /**
  13107. * Clones the current emitter and returns a copy of it
  13108. * @returns the new emitter
  13109. */
  13110. clone(): BoxParticleEmitter;
  13111. /**
  13112. * Called by the GPUParticleSystem to setup the update shader
  13113. * @param effect defines the update shader
  13114. */
  13115. applyToShader(effect: Effect): void;
  13116. /**
  13117. * Returns a string to use to update the GPU particles update shader
  13118. * @returns a string containng the defines string
  13119. */
  13120. getEffectDefines(): string;
  13121. /**
  13122. * Returns the string "BoxParticleEmitter"
  13123. * @returns a string containing the class name
  13124. */
  13125. getClassName(): string;
  13126. /**
  13127. * Serializes the particle system to a JSON object.
  13128. * @returns the JSON object
  13129. */
  13130. serialize(): any;
  13131. /**
  13132. * Parse properties from a JSON object
  13133. * @param serializationObject defines the JSON object
  13134. */
  13135. parse(serializationObject: any): void;
  13136. }
  13137. }
  13138. declare module BABYLON {
  13139. /**
  13140. * Particle emitter emitting particles from the inside of a cone.
  13141. * It emits the particles alongside the cone volume from the base to the particle.
  13142. * The emission direction might be randomized.
  13143. */
  13144. export class ConeParticleEmitter implements IParticleEmitterType {
  13145. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13146. directionRandomizer: number;
  13147. private _radius;
  13148. private _angle;
  13149. private _height;
  13150. /**
  13151. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13152. */
  13153. radiusRange: number;
  13154. /**
  13155. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13156. */
  13157. heightRange: number;
  13158. /**
  13159. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13160. */
  13161. emitFromSpawnPointOnly: boolean;
  13162. /**
  13163. * Gets or sets the radius of the emission cone
  13164. */
  13165. get radius(): number;
  13166. set radius(value: number);
  13167. /**
  13168. * Gets or sets the angle of the emission cone
  13169. */
  13170. get angle(): number;
  13171. set angle(value: number);
  13172. private _buildHeight;
  13173. /**
  13174. * Creates a new instance ConeParticleEmitter
  13175. * @param radius the radius of the emission cone (1 by default)
  13176. * @param angle the cone base angle (PI by default)
  13177. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13178. */
  13179. constructor(radius?: number, angle?: number,
  13180. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13181. directionRandomizer?: number);
  13182. /**
  13183. * Called by the particle System when the direction is computed for the created particle.
  13184. * @param worldMatrix is the world matrix of the particle system
  13185. * @param directionToUpdate is the direction vector to update with the result
  13186. * @param particle is the particle we are computed the direction for
  13187. * @param isLocal defines if the direction should be set in local space
  13188. */
  13189. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13190. /**
  13191. * Called by the particle System when the position is computed for the created particle.
  13192. * @param worldMatrix is the world matrix of the particle system
  13193. * @param positionToUpdate is the position vector to update with the result
  13194. * @param particle is the particle we are computed the position for
  13195. * @param isLocal defines if the position should be set in local space
  13196. */
  13197. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13198. /**
  13199. * Clones the current emitter and returns a copy of it
  13200. * @returns the new emitter
  13201. */
  13202. clone(): ConeParticleEmitter;
  13203. /**
  13204. * Called by the GPUParticleSystem to setup the update shader
  13205. * @param effect defines the update shader
  13206. */
  13207. applyToShader(effect: Effect): void;
  13208. /**
  13209. * Returns a string to use to update the GPU particles update shader
  13210. * @returns a string containng the defines string
  13211. */
  13212. getEffectDefines(): string;
  13213. /**
  13214. * Returns the string "ConeParticleEmitter"
  13215. * @returns a string containing the class name
  13216. */
  13217. getClassName(): string;
  13218. /**
  13219. * Serializes the particle system to a JSON object.
  13220. * @returns the JSON object
  13221. */
  13222. serialize(): any;
  13223. /**
  13224. * Parse properties from a JSON object
  13225. * @param serializationObject defines the JSON object
  13226. */
  13227. parse(serializationObject: any): void;
  13228. }
  13229. }
  13230. declare module BABYLON {
  13231. /**
  13232. * Particle emitter emitting particles from the inside of a cylinder.
  13233. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13234. */
  13235. export class CylinderParticleEmitter implements IParticleEmitterType {
  13236. /**
  13237. * The radius of the emission cylinder.
  13238. */
  13239. radius: number;
  13240. /**
  13241. * The height of the emission cylinder.
  13242. */
  13243. height: number;
  13244. /**
  13245. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13246. */
  13247. radiusRange: number;
  13248. /**
  13249. * How much to randomize the particle direction [0-1].
  13250. */
  13251. directionRandomizer: number;
  13252. /**
  13253. * Creates a new instance CylinderParticleEmitter
  13254. * @param radius the radius of the emission cylinder (1 by default)
  13255. * @param height the height of the emission cylinder (1 by default)
  13256. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13257. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13258. */
  13259. constructor(
  13260. /**
  13261. * The radius of the emission cylinder.
  13262. */
  13263. radius?: number,
  13264. /**
  13265. * The height of the emission cylinder.
  13266. */
  13267. height?: number,
  13268. /**
  13269. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13270. */
  13271. radiusRange?: number,
  13272. /**
  13273. * How much to randomize the particle direction [0-1].
  13274. */
  13275. directionRandomizer?: number);
  13276. /**
  13277. * Called by the particle System when the direction is computed for the created particle.
  13278. * @param worldMatrix is the world matrix of the particle system
  13279. * @param directionToUpdate is the direction vector to update with the result
  13280. * @param particle is the particle we are computed the direction for
  13281. * @param isLocal defines if the direction should be set in local space
  13282. */
  13283. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13284. /**
  13285. * Called by the particle System when the position is computed for the created particle.
  13286. * @param worldMatrix is the world matrix of the particle system
  13287. * @param positionToUpdate is the position vector to update with the result
  13288. * @param particle is the particle we are computed the position for
  13289. * @param isLocal defines if the position should be set in local space
  13290. */
  13291. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13292. /**
  13293. * Clones the current emitter and returns a copy of it
  13294. * @returns the new emitter
  13295. */
  13296. clone(): CylinderParticleEmitter;
  13297. /**
  13298. * Called by the GPUParticleSystem to setup the update shader
  13299. * @param effect defines the update shader
  13300. */
  13301. applyToShader(effect: Effect): void;
  13302. /**
  13303. * Returns a string to use to update the GPU particles update shader
  13304. * @returns a string containng the defines string
  13305. */
  13306. getEffectDefines(): string;
  13307. /**
  13308. * Returns the string "CylinderParticleEmitter"
  13309. * @returns a string containing the class name
  13310. */
  13311. getClassName(): string;
  13312. /**
  13313. * Serializes the particle system to a JSON object.
  13314. * @returns the JSON object
  13315. */
  13316. serialize(): any;
  13317. /**
  13318. * Parse properties from a JSON object
  13319. * @param serializationObject defines the JSON object
  13320. */
  13321. parse(serializationObject: any): void;
  13322. }
  13323. /**
  13324. * Particle emitter emitting particles from the inside of a cylinder.
  13325. * It emits the particles randomly between two vectors.
  13326. */
  13327. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13328. /**
  13329. * The min limit of the emission direction.
  13330. */
  13331. direction1: Vector3;
  13332. /**
  13333. * The max limit of the emission direction.
  13334. */
  13335. direction2: Vector3;
  13336. /**
  13337. * Creates a new instance CylinderDirectedParticleEmitter
  13338. * @param radius the radius of the emission cylinder (1 by default)
  13339. * @param height the height of the emission cylinder (1 by default)
  13340. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13341. * @param direction1 the min limit of the emission direction (up vector by default)
  13342. * @param direction2 the max limit of the emission direction (up vector by default)
  13343. */
  13344. constructor(radius?: number, height?: number, radiusRange?: number,
  13345. /**
  13346. * The min limit of the emission direction.
  13347. */
  13348. direction1?: Vector3,
  13349. /**
  13350. * The max limit of the emission direction.
  13351. */
  13352. direction2?: Vector3);
  13353. /**
  13354. * Called by the particle System when the direction is computed for the created particle.
  13355. * @param worldMatrix is the world matrix of the particle system
  13356. * @param directionToUpdate is the direction vector to update with the result
  13357. * @param particle is the particle we are computed the direction for
  13358. */
  13359. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13360. /**
  13361. * Clones the current emitter and returns a copy of it
  13362. * @returns the new emitter
  13363. */
  13364. clone(): CylinderDirectedParticleEmitter;
  13365. /**
  13366. * Called by the GPUParticleSystem to setup the update shader
  13367. * @param effect defines the update shader
  13368. */
  13369. applyToShader(effect: Effect): void;
  13370. /**
  13371. * Returns a string to use to update the GPU particles update shader
  13372. * @returns a string containng the defines string
  13373. */
  13374. getEffectDefines(): string;
  13375. /**
  13376. * Returns the string "CylinderDirectedParticleEmitter"
  13377. * @returns a string containing the class name
  13378. */
  13379. getClassName(): string;
  13380. /**
  13381. * Serializes the particle system to a JSON object.
  13382. * @returns the JSON object
  13383. */
  13384. serialize(): any;
  13385. /**
  13386. * Parse properties from a JSON object
  13387. * @param serializationObject defines the JSON object
  13388. */
  13389. parse(serializationObject: any): void;
  13390. }
  13391. }
  13392. declare module BABYLON {
  13393. /**
  13394. * Particle emitter emitting particles from the inside of a hemisphere.
  13395. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13396. */
  13397. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13398. /**
  13399. * The radius of the emission hemisphere.
  13400. */
  13401. radius: number;
  13402. /**
  13403. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13404. */
  13405. radiusRange: number;
  13406. /**
  13407. * How much to randomize the particle direction [0-1].
  13408. */
  13409. directionRandomizer: number;
  13410. /**
  13411. * Creates a new instance HemisphericParticleEmitter
  13412. * @param radius the radius of the emission hemisphere (1 by default)
  13413. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13414. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13415. */
  13416. constructor(
  13417. /**
  13418. * The radius of the emission hemisphere.
  13419. */
  13420. radius?: number,
  13421. /**
  13422. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13423. */
  13424. radiusRange?: number,
  13425. /**
  13426. * How much to randomize the particle direction [0-1].
  13427. */
  13428. directionRandomizer?: number);
  13429. /**
  13430. * Called by the particle System when the direction is computed for the created particle.
  13431. * @param worldMatrix is the world matrix of the particle system
  13432. * @param directionToUpdate is the direction vector to update with the result
  13433. * @param particle is the particle we are computed the direction for
  13434. * @param isLocal defines if the direction should be set in local space
  13435. */
  13436. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13437. /**
  13438. * Called by the particle System when the position is computed for the created particle.
  13439. * @param worldMatrix is the world matrix of the particle system
  13440. * @param positionToUpdate is the position vector to update with the result
  13441. * @param particle is the particle we are computed the position for
  13442. * @param isLocal defines if the position should be set in local space
  13443. */
  13444. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13445. /**
  13446. * Clones the current emitter and returns a copy of it
  13447. * @returns the new emitter
  13448. */
  13449. clone(): HemisphericParticleEmitter;
  13450. /**
  13451. * Called by the GPUParticleSystem to setup the update shader
  13452. * @param effect defines the update shader
  13453. */
  13454. applyToShader(effect: Effect): void;
  13455. /**
  13456. * Returns a string to use to update the GPU particles update shader
  13457. * @returns a string containng the defines string
  13458. */
  13459. getEffectDefines(): string;
  13460. /**
  13461. * Returns the string "HemisphericParticleEmitter"
  13462. * @returns a string containing the class name
  13463. */
  13464. getClassName(): string;
  13465. /**
  13466. * Serializes the particle system to a JSON object.
  13467. * @returns the JSON object
  13468. */
  13469. serialize(): any;
  13470. /**
  13471. * Parse properties from a JSON object
  13472. * @param serializationObject defines the JSON object
  13473. */
  13474. parse(serializationObject: any): void;
  13475. }
  13476. }
  13477. declare module BABYLON {
  13478. /**
  13479. * Particle emitter emitting particles from a point.
  13480. * It emits the particles randomly between 2 given directions.
  13481. */
  13482. export class PointParticleEmitter implements IParticleEmitterType {
  13483. /**
  13484. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13485. */
  13486. direction1: Vector3;
  13487. /**
  13488. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13489. */
  13490. direction2: Vector3;
  13491. /**
  13492. * Creates a new instance PointParticleEmitter
  13493. */
  13494. constructor();
  13495. /**
  13496. * Called by the particle System when the direction is computed for the created particle.
  13497. * @param worldMatrix is the world matrix of the particle system
  13498. * @param directionToUpdate is the direction vector to update with the result
  13499. * @param particle is the particle we are computed the direction for
  13500. * @param isLocal defines if the direction should be set in local space
  13501. */
  13502. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13503. /**
  13504. * Called by the particle System when the position is computed for the created particle.
  13505. * @param worldMatrix is the world matrix of the particle system
  13506. * @param positionToUpdate is the position vector to update with the result
  13507. * @param particle is the particle we are computed the position for
  13508. * @param isLocal defines if the position should be set in local space
  13509. */
  13510. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13511. /**
  13512. * Clones the current emitter and returns a copy of it
  13513. * @returns the new emitter
  13514. */
  13515. clone(): PointParticleEmitter;
  13516. /**
  13517. * Called by the GPUParticleSystem to setup the update shader
  13518. * @param effect defines the update shader
  13519. */
  13520. applyToShader(effect: Effect): void;
  13521. /**
  13522. * Returns a string to use to update the GPU particles update shader
  13523. * @returns a string containng the defines string
  13524. */
  13525. getEffectDefines(): string;
  13526. /**
  13527. * Returns the string "PointParticleEmitter"
  13528. * @returns a string containing the class name
  13529. */
  13530. getClassName(): string;
  13531. /**
  13532. * Serializes the particle system to a JSON object.
  13533. * @returns the JSON object
  13534. */
  13535. serialize(): any;
  13536. /**
  13537. * Parse properties from a JSON object
  13538. * @param serializationObject defines the JSON object
  13539. */
  13540. parse(serializationObject: any): void;
  13541. }
  13542. }
  13543. declare module BABYLON {
  13544. /**
  13545. * Particle emitter emitting particles from the inside of a sphere.
  13546. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13547. */
  13548. export class SphereParticleEmitter implements IParticleEmitterType {
  13549. /**
  13550. * The radius of the emission sphere.
  13551. */
  13552. radius: number;
  13553. /**
  13554. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13555. */
  13556. radiusRange: number;
  13557. /**
  13558. * How much to randomize the particle direction [0-1].
  13559. */
  13560. directionRandomizer: number;
  13561. /**
  13562. * Creates a new instance SphereParticleEmitter
  13563. * @param radius the radius of the emission sphere (1 by default)
  13564. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13565. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13566. */
  13567. constructor(
  13568. /**
  13569. * The radius of the emission sphere.
  13570. */
  13571. radius?: number,
  13572. /**
  13573. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13574. */
  13575. radiusRange?: number,
  13576. /**
  13577. * How much to randomize the particle direction [0-1].
  13578. */
  13579. directionRandomizer?: number);
  13580. /**
  13581. * Called by the particle System when the direction is computed for the created particle.
  13582. * @param worldMatrix is the world matrix of the particle system
  13583. * @param directionToUpdate is the direction vector to update with the result
  13584. * @param particle is the particle we are computed the direction for
  13585. * @param isLocal defines if the direction should be set in local space
  13586. */
  13587. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13588. /**
  13589. * Called by the particle System when the position is computed for the created particle.
  13590. * @param worldMatrix is the world matrix of the particle system
  13591. * @param positionToUpdate is the position vector to update with the result
  13592. * @param particle is the particle we are computed the position for
  13593. * @param isLocal defines if the position should be set in local space
  13594. */
  13595. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13596. /**
  13597. * Clones the current emitter and returns a copy of it
  13598. * @returns the new emitter
  13599. */
  13600. clone(): SphereParticleEmitter;
  13601. /**
  13602. * Called by the GPUParticleSystem to setup the update shader
  13603. * @param effect defines the update shader
  13604. */
  13605. applyToShader(effect: Effect): void;
  13606. /**
  13607. * Returns a string to use to update the GPU particles update shader
  13608. * @returns a string containng the defines string
  13609. */
  13610. getEffectDefines(): string;
  13611. /**
  13612. * Returns the string "SphereParticleEmitter"
  13613. * @returns a string containing the class name
  13614. */
  13615. getClassName(): string;
  13616. /**
  13617. * Serializes the particle system to a JSON object.
  13618. * @returns the JSON object
  13619. */
  13620. serialize(): any;
  13621. /**
  13622. * Parse properties from a JSON object
  13623. * @param serializationObject defines the JSON object
  13624. */
  13625. parse(serializationObject: any): void;
  13626. }
  13627. /**
  13628. * Particle emitter emitting particles from the inside of a sphere.
  13629. * It emits the particles randomly between two vectors.
  13630. */
  13631. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13632. /**
  13633. * The min limit of the emission direction.
  13634. */
  13635. direction1: Vector3;
  13636. /**
  13637. * The max limit of the emission direction.
  13638. */
  13639. direction2: Vector3;
  13640. /**
  13641. * Creates a new instance SphereDirectedParticleEmitter
  13642. * @param radius the radius of the emission sphere (1 by default)
  13643. * @param direction1 the min limit of the emission direction (up vector by default)
  13644. * @param direction2 the max limit of the emission direction (up vector by default)
  13645. */
  13646. constructor(radius?: number,
  13647. /**
  13648. * The min limit of the emission direction.
  13649. */
  13650. direction1?: Vector3,
  13651. /**
  13652. * The max limit of the emission direction.
  13653. */
  13654. direction2?: Vector3);
  13655. /**
  13656. * Called by the particle System when the direction is computed for the created particle.
  13657. * @param worldMatrix is the world matrix of the particle system
  13658. * @param directionToUpdate is the direction vector to update with the result
  13659. * @param particle is the particle we are computed the direction for
  13660. */
  13661. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13662. /**
  13663. * Clones the current emitter and returns a copy of it
  13664. * @returns the new emitter
  13665. */
  13666. clone(): SphereDirectedParticleEmitter;
  13667. /**
  13668. * Called by the GPUParticleSystem to setup the update shader
  13669. * @param effect defines the update shader
  13670. */
  13671. applyToShader(effect: Effect): void;
  13672. /**
  13673. * Returns a string to use to update the GPU particles update shader
  13674. * @returns a string containng the defines string
  13675. */
  13676. getEffectDefines(): string;
  13677. /**
  13678. * Returns the string "SphereDirectedParticleEmitter"
  13679. * @returns a string containing the class name
  13680. */
  13681. getClassName(): string;
  13682. /**
  13683. * Serializes the particle system to a JSON object.
  13684. * @returns the JSON object
  13685. */
  13686. serialize(): any;
  13687. /**
  13688. * Parse properties from a JSON object
  13689. * @param serializationObject defines the JSON object
  13690. */
  13691. parse(serializationObject: any): void;
  13692. }
  13693. }
  13694. declare module BABYLON {
  13695. /**
  13696. * Particle emitter emitting particles from a custom list of positions.
  13697. */
  13698. export class CustomParticleEmitter implements IParticleEmitterType {
  13699. /**
  13700. * Gets or sets the position generator that will create the inital position of each particle.
  13701. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13702. */
  13703. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13704. /**
  13705. * Gets or sets the destination generator that will create the final destination of each particle.
  13706. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13707. */
  13708. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13709. /**
  13710. * Creates a new instance CustomParticleEmitter
  13711. */
  13712. constructor();
  13713. /**
  13714. * Called by the particle System when the direction is computed for the created particle.
  13715. * @param worldMatrix is the world matrix of the particle system
  13716. * @param directionToUpdate is the direction vector to update with the result
  13717. * @param particle is the particle we are computed the direction for
  13718. * @param isLocal defines if the direction should be set in local space
  13719. */
  13720. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13721. /**
  13722. * Called by the particle System when the position is computed for the created particle.
  13723. * @param worldMatrix is the world matrix of the particle system
  13724. * @param positionToUpdate is the position vector to update with the result
  13725. * @param particle is the particle we are computed the position for
  13726. * @param isLocal defines if the position should be set in local space
  13727. */
  13728. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13729. /**
  13730. * Clones the current emitter and returns a copy of it
  13731. * @returns the new emitter
  13732. */
  13733. clone(): CustomParticleEmitter;
  13734. /**
  13735. * Called by the GPUParticleSystem to setup the update shader
  13736. * @param effect defines the update shader
  13737. */
  13738. applyToShader(effect: Effect): void;
  13739. /**
  13740. * Returns a string to use to update the GPU particles update shader
  13741. * @returns a string containng the defines string
  13742. */
  13743. getEffectDefines(): string;
  13744. /**
  13745. * Returns the string "PointParticleEmitter"
  13746. * @returns a string containing the class name
  13747. */
  13748. getClassName(): string;
  13749. /**
  13750. * Serializes the particle system to a JSON object.
  13751. * @returns the JSON object
  13752. */
  13753. serialize(): any;
  13754. /**
  13755. * Parse properties from a JSON object
  13756. * @param serializationObject defines the JSON object
  13757. */
  13758. parse(serializationObject: any): void;
  13759. }
  13760. }
  13761. declare module BABYLON {
  13762. /**
  13763. * Particle emitter emitting particles from the inside of a box.
  13764. * It emits the particles randomly between 2 given directions.
  13765. */
  13766. export class MeshParticleEmitter implements IParticleEmitterType {
  13767. private _indices;
  13768. private _positions;
  13769. private _normals;
  13770. private _storedNormal;
  13771. private _mesh;
  13772. /**
  13773. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13774. */
  13775. direction1: Vector3;
  13776. /**
  13777. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13778. */
  13779. direction2: Vector3;
  13780. /**
  13781. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13782. */
  13783. useMeshNormalsForDirection: boolean;
  13784. /** Defines the mesh to use as source */
  13785. get mesh(): Nullable<AbstractMesh>;
  13786. set mesh(value: Nullable<AbstractMesh>);
  13787. /**
  13788. * Creates a new instance MeshParticleEmitter
  13789. * @param mesh defines the mesh to use as source
  13790. */
  13791. constructor(mesh?: Nullable<AbstractMesh>);
  13792. /**
  13793. * Called by the particle System when the direction is computed for the created particle.
  13794. * @param worldMatrix is the world matrix of the particle system
  13795. * @param directionToUpdate is the direction vector to update with the result
  13796. * @param particle is the particle we are computed the direction for
  13797. * @param isLocal defines if the direction should be set in local space
  13798. */
  13799. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13800. /**
  13801. * Called by the particle System when the position is computed for the created particle.
  13802. * @param worldMatrix is the world matrix of the particle system
  13803. * @param positionToUpdate is the position vector to update with the result
  13804. * @param particle is the particle we are computed the position for
  13805. * @param isLocal defines if the position should be set in local space
  13806. */
  13807. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13808. /**
  13809. * Clones the current emitter and returns a copy of it
  13810. * @returns the new emitter
  13811. */
  13812. clone(): MeshParticleEmitter;
  13813. /**
  13814. * Called by the GPUParticleSystem to setup the update shader
  13815. * @param effect defines the update shader
  13816. */
  13817. applyToShader(effect: Effect): void;
  13818. /**
  13819. * Returns a string to use to update the GPU particles update shader
  13820. * @returns a string containng the defines string
  13821. */
  13822. getEffectDefines(): string;
  13823. /**
  13824. * Returns the string "BoxParticleEmitter"
  13825. * @returns a string containing the class name
  13826. */
  13827. getClassName(): string;
  13828. /**
  13829. * Serializes the particle system to a JSON object.
  13830. * @returns the JSON object
  13831. */
  13832. serialize(): any;
  13833. /**
  13834. * Parse properties from a JSON object
  13835. * @param serializationObject defines the JSON object
  13836. * @param scene defines the hosting scene
  13837. */
  13838. parse(serializationObject: any, scene: Scene): void;
  13839. }
  13840. }
  13841. declare module BABYLON {
  13842. /**
  13843. * Interface representing a particle system in Babylon.js.
  13844. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13845. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13846. */
  13847. export interface IParticleSystem {
  13848. /**
  13849. * List of animations used by the particle system.
  13850. */
  13851. animations: Animation[];
  13852. /**
  13853. * The id of the Particle system.
  13854. */
  13855. id: string;
  13856. /**
  13857. * The name of the Particle system.
  13858. */
  13859. name: string;
  13860. /**
  13861. * The emitter represents the Mesh or position we are attaching the particle system to.
  13862. */
  13863. emitter: Nullable<AbstractMesh | Vector3>;
  13864. /**
  13865. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13866. */
  13867. isBillboardBased: boolean;
  13868. /**
  13869. * The rendering group used by the Particle system to chose when to render.
  13870. */
  13871. renderingGroupId: number;
  13872. /**
  13873. * The layer mask we are rendering the particles through.
  13874. */
  13875. layerMask: number;
  13876. /**
  13877. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13878. */
  13879. updateSpeed: number;
  13880. /**
  13881. * The amount of time the particle system is running (depends of the overall update speed).
  13882. */
  13883. targetStopDuration: number;
  13884. /**
  13885. * The texture used to render each particle. (this can be a spritesheet)
  13886. */
  13887. particleTexture: Nullable<Texture>;
  13888. /**
  13889. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13890. */
  13891. blendMode: number;
  13892. /**
  13893. * Minimum life time of emitting particles.
  13894. */
  13895. minLifeTime: number;
  13896. /**
  13897. * Maximum life time of emitting particles.
  13898. */
  13899. maxLifeTime: number;
  13900. /**
  13901. * Minimum Size of emitting particles.
  13902. */
  13903. minSize: number;
  13904. /**
  13905. * Maximum Size of emitting particles.
  13906. */
  13907. maxSize: number;
  13908. /**
  13909. * Minimum scale of emitting particles on X axis.
  13910. */
  13911. minScaleX: number;
  13912. /**
  13913. * Maximum scale of emitting particles on X axis.
  13914. */
  13915. maxScaleX: number;
  13916. /**
  13917. * Minimum scale of emitting particles on Y axis.
  13918. */
  13919. minScaleY: number;
  13920. /**
  13921. * Maximum scale of emitting particles on Y axis.
  13922. */
  13923. maxScaleY: number;
  13924. /**
  13925. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13926. */
  13927. color1: Color4;
  13928. /**
  13929. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13930. */
  13931. color2: Color4;
  13932. /**
  13933. * Color the particle will have at the end of its lifetime.
  13934. */
  13935. colorDead: Color4;
  13936. /**
  13937. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13938. */
  13939. emitRate: number;
  13940. /**
  13941. * You can use gravity if you want to give an orientation to your particles.
  13942. */
  13943. gravity: Vector3;
  13944. /**
  13945. * Minimum power of emitting particles.
  13946. */
  13947. minEmitPower: number;
  13948. /**
  13949. * Maximum power of emitting particles.
  13950. */
  13951. maxEmitPower: number;
  13952. /**
  13953. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13954. */
  13955. minAngularSpeed: number;
  13956. /**
  13957. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13958. */
  13959. maxAngularSpeed: number;
  13960. /**
  13961. * Gets or sets the minimal initial rotation in radians.
  13962. */
  13963. minInitialRotation: number;
  13964. /**
  13965. * Gets or sets the maximal initial rotation in radians.
  13966. */
  13967. maxInitialRotation: number;
  13968. /**
  13969. * The particle emitter type defines the emitter used by the particle system.
  13970. * It can be for example box, sphere, or cone...
  13971. */
  13972. particleEmitterType: Nullable<IParticleEmitterType>;
  13973. /**
  13974. * Defines the delay in milliseconds before starting the system (0 by default)
  13975. */
  13976. startDelay: number;
  13977. /**
  13978. * 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
  13979. */
  13980. preWarmCycles: number;
  13981. /**
  13982. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13983. */
  13984. preWarmStepOffset: number;
  13985. /**
  13986. * 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)
  13987. */
  13988. spriteCellChangeSpeed: number;
  13989. /**
  13990. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13991. */
  13992. startSpriteCellID: number;
  13993. /**
  13994. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13995. */
  13996. endSpriteCellID: number;
  13997. /**
  13998. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13999. */
  14000. spriteCellWidth: number;
  14001. /**
  14002. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14003. */
  14004. spriteCellHeight: number;
  14005. /**
  14006. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14007. */
  14008. spriteRandomStartCell: boolean;
  14009. /**
  14010. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14011. */
  14012. isAnimationSheetEnabled: boolean;
  14013. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14014. translationPivot: Vector2;
  14015. /**
  14016. * Gets or sets a texture used to add random noise to particle positions
  14017. */
  14018. noiseTexture: Nullable<BaseTexture>;
  14019. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14020. noiseStrength: Vector3;
  14021. /**
  14022. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14023. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14024. */
  14025. billboardMode: number;
  14026. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14027. limitVelocityDamping: number;
  14028. /**
  14029. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14030. */
  14031. beginAnimationOnStart: boolean;
  14032. /**
  14033. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14034. */
  14035. beginAnimationFrom: number;
  14036. /**
  14037. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14038. */
  14039. beginAnimationTo: number;
  14040. /**
  14041. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14042. */
  14043. beginAnimationLoop: boolean;
  14044. /**
  14045. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14046. */
  14047. disposeOnStop: boolean;
  14048. /**
  14049. * Specifies if the particles are updated in emitter local space or world space
  14050. */
  14051. isLocal: boolean;
  14052. /** Snippet ID if the particle system was created from the snippet server */
  14053. snippetId: string;
  14054. /**
  14055. * Gets the maximum number of particles active at the same time.
  14056. * @returns The max number of active particles.
  14057. */
  14058. getCapacity(): number;
  14059. /**
  14060. * Gets the number of particles active at the same time.
  14061. * @returns The number of active particles.
  14062. */
  14063. getActiveCount(): number;
  14064. /**
  14065. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14066. * @returns True if it has been started, otherwise false.
  14067. */
  14068. isStarted(): boolean;
  14069. /**
  14070. * Animates the particle system for this frame.
  14071. */
  14072. animate(): void;
  14073. /**
  14074. * Renders the particle system in its current state.
  14075. * @returns the current number of particles
  14076. */
  14077. render(): number;
  14078. /**
  14079. * Dispose the particle system and frees its associated resources.
  14080. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14081. */
  14082. dispose(disposeTexture?: boolean): void;
  14083. /**
  14084. * An event triggered when the system is disposed
  14085. */
  14086. onDisposeObservable: Observable<IParticleSystem>;
  14087. /**
  14088. * Clones the particle system.
  14089. * @param name The name of the cloned object
  14090. * @param newEmitter The new emitter to use
  14091. * @returns the cloned particle system
  14092. */
  14093. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14094. /**
  14095. * Serializes the particle system to a JSON object
  14096. * @param serializeTexture defines if the texture must be serialized as well
  14097. * @returns the JSON object
  14098. */
  14099. serialize(serializeTexture: boolean): any;
  14100. /**
  14101. * Rebuild the particle system
  14102. */
  14103. rebuild(): void;
  14104. /** Force the system to rebuild all gradients that need to be resync */
  14105. forceRefreshGradients(): void;
  14106. /**
  14107. * Starts the particle system and begins to emit
  14108. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14109. */
  14110. start(delay?: number): void;
  14111. /**
  14112. * Stops the particle system.
  14113. */
  14114. stop(): void;
  14115. /**
  14116. * Remove all active particles
  14117. */
  14118. reset(): void;
  14119. /**
  14120. * Gets a boolean indicating that the system is stopping
  14121. * @returns true if the system is currently stopping
  14122. */
  14123. isStopping(): boolean;
  14124. /**
  14125. * Is this system ready to be used/rendered
  14126. * @return true if the system is ready
  14127. */
  14128. isReady(): boolean;
  14129. /**
  14130. * Returns the string "ParticleSystem"
  14131. * @returns a string containing the class name
  14132. */
  14133. getClassName(): string;
  14134. /**
  14135. * Gets the custom effect used to render the particles
  14136. * @param blendMode Blend mode for which the effect should be retrieved
  14137. * @returns The effect
  14138. */
  14139. getCustomEffect(blendMode: number): Nullable<Effect>;
  14140. /**
  14141. * Sets the custom effect used to render the particles
  14142. * @param effect The effect to set
  14143. * @param blendMode Blend mode for which the effect should be set
  14144. */
  14145. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14146. /**
  14147. * Fill the defines array according to the current settings of the particle system
  14148. * @param defines Array to be updated
  14149. * @param blendMode blend mode to take into account when updating the array
  14150. */
  14151. fillDefines(defines: Array<string>, blendMode: number): void;
  14152. /**
  14153. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14154. * @param uniforms Uniforms array to fill
  14155. * @param attributes Attributes array to fill
  14156. * @param samplers Samplers array to fill
  14157. */
  14158. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14159. /**
  14160. * Observable that will be called just before the particles are drawn
  14161. */
  14162. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14163. /**
  14164. * Gets the name of the particle vertex shader
  14165. */
  14166. vertexShaderName: string;
  14167. /**
  14168. * Adds a new color gradient
  14169. * @param gradient defines the gradient to use (between 0 and 1)
  14170. * @param color1 defines the color to affect to the specified gradient
  14171. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14172. * @returns the current particle system
  14173. */
  14174. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14175. /**
  14176. * Remove a specific color gradient
  14177. * @param gradient defines the gradient to remove
  14178. * @returns the current particle system
  14179. */
  14180. removeColorGradient(gradient: number): IParticleSystem;
  14181. /**
  14182. * Adds a new size gradient
  14183. * @param gradient defines the gradient to use (between 0 and 1)
  14184. * @param factor defines the size factor to affect to the specified gradient
  14185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14186. * @returns the current particle system
  14187. */
  14188. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14189. /**
  14190. * Remove a specific size gradient
  14191. * @param gradient defines the gradient to remove
  14192. * @returns the current particle system
  14193. */
  14194. removeSizeGradient(gradient: number): IParticleSystem;
  14195. /**
  14196. * Gets the current list of color gradients.
  14197. * You must use addColorGradient and removeColorGradient to udpate this list
  14198. * @returns the list of color gradients
  14199. */
  14200. getColorGradients(): Nullable<Array<ColorGradient>>;
  14201. /**
  14202. * Gets the current list of size gradients.
  14203. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14204. * @returns the list of size gradients
  14205. */
  14206. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14207. /**
  14208. * Gets the current list of angular speed gradients.
  14209. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14210. * @returns the list of angular speed gradients
  14211. */
  14212. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14213. /**
  14214. * Adds a new angular speed gradient
  14215. * @param gradient defines the gradient to use (between 0 and 1)
  14216. * @param factor defines the angular speed to affect to the specified gradient
  14217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14218. * @returns the current particle system
  14219. */
  14220. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14221. /**
  14222. * Remove a specific angular speed gradient
  14223. * @param gradient defines the gradient to remove
  14224. * @returns the current particle system
  14225. */
  14226. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14227. /**
  14228. * Gets the current list of velocity gradients.
  14229. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14230. * @returns the list of velocity gradients
  14231. */
  14232. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14233. /**
  14234. * Adds a new velocity gradient
  14235. * @param gradient defines the gradient to use (between 0 and 1)
  14236. * @param factor defines the velocity to affect to the specified gradient
  14237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14238. * @returns the current particle system
  14239. */
  14240. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14241. /**
  14242. * Remove a specific velocity gradient
  14243. * @param gradient defines the gradient to remove
  14244. * @returns the current particle system
  14245. */
  14246. removeVelocityGradient(gradient: number): IParticleSystem;
  14247. /**
  14248. * Gets the current list of limit velocity gradients.
  14249. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14250. * @returns the list of limit velocity gradients
  14251. */
  14252. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14253. /**
  14254. * Adds a new limit velocity gradient
  14255. * @param gradient defines the gradient to use (between 0 and 1)
  14256. * @param factor defines the limit velocity to affect to the specified gradient
  14257. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14258. * @returns the current particle system
  14259. */
  14260. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14261. /**
  14262. * Remove a specific limit velocity gradient
  14263. * @param gradient defines the gradient to remove
  14264. * @returns the current particle system
  14265. */
  14266. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14267. /**
  14268. * Adds a new drag gradient
  14269. * @param gradient defines the gradient to use (between 0 and 1)
  14270. * @param factor defines the drag to affect to the specified gradient
  14271. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14272. * @returns the current particle system
  14273. */
  14274. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14275. /**
  14276. * Remove a specific drag gradient
  14277. * @param gradient defines the gradient to remove
  14278. * @returns the current particle system
  14279. */
  14280. removeDragGradient(gradient: number): IParticleSystem;
  14281. /**
  14282. * Gets the current list of drag gradients.
  14283. * You must use addDragGradient and removeDragGradient to udpate this list
  14284. * @returns the list of drag gradients
  14285. */
  14286. getDragGradients(): Nullable<Array<FactorGradient>>;
  14287. /**
  14288. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14289. * @param gradient defines the gradient to use (between 0 and 1)
  14290. * @param factor defines the emit rate to affect to the specified gradient
  14291. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14292. * @returns the current particle system
  14293. */
  14294. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14295. /**
  14296. * Remove a specific emit rate gradient
  14297. * @param gradient defines the gradient to remove
  14298. * @returns the current particle system
  14299. */
  14300. removeEmitRateGradient(gradient: number): IParticleSystem;
  14301. /**
  14302. * Gets the current list of emit rate gradients.
  14303. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14304. * @returns the list of emit rate gradients
  14305. */
  14306. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14307. /**
  14308. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14309. * @param gradient defines the gradient to use (between 0 and 1)
  14310. * @param factor defines the start size to affect to the specified gradient
  14311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14312. * @returns the current particle system
  14313. */
  14314. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14315. /**
  14316. * Remove a specific start size gradient
  14317. * @param gradient defines the gradient to remove
  14318. * @returns the current particle system
  14319. */
  14320. removeStartSizeGradient(gradient: number): IParticleSystem;
  14321. /**
  14322. * Gets the current list of start size gradients.
  14323. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14324. * @returns the list of start size gradients
  14325. */
  14326. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14327. /**
  14328. * Adds a new life time gradient
  14329. * @param gradient defines the gradient to use (between 0 and 1)
  14330. * @param factor defines the life time factor to affect to the specified gradient
  14331. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14332. * @returns the current particle system
  14333. */
  14334. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14335. /**
  14336. * Remove a specific life time gradient
  14337. * @param gradient defines the gradient to remove
  14338. * @returns the current particle system
  14339. */
  14340. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14341. /**
  14342. * Gets the current list of life time gradients.
  14343. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14344. * @returns the list of life time gradients
  14345. */
  14346. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14347. /**
  14348. * Gets the current list of color gradients.
  14349. * You must use addColorGradient and removeColorGradient to udpate this list
  14350. * @returns the list of color gradients
  14351. */
  14352. getColorGradients(): Nullable<Array<ColorGradient>>;
  14353. /**
  14354. * Adds a new ramp gradient used to remap particle colors
  14355. * @param gradient defines the gradient to use (between 0 and 1)
  14356. * @param color defines the color to affect to the specified gradient
  14357. * @returns the current particle system
  14358. */
  14359. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14360. /**
  14361. * Gets the current list of ramp gradients.
  14362. * You must use addRampGradient and removeRampGradient to udpate this list
  14363. * @returns the list of ramp gradients
  14364. */
  14365. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14366. /** Gets or sets a boolean indicating that ramp gradients must be used
  14367. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14368. */
  14369. useRampGradients: boolean;
  14370. /**
  14371. * Adds a new color remap gradient
  14372. * @param gradient defines the gradient to use (between 0 and 1)
  14373. * @param min defines the color remap minimal range
  14374. * @param max defines the color remap maximal range
  14375. * @returns the current particle system
  14376. */
  14377. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14378. /**
  14379. * Gets the current list of color remap gradients.
  14380. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14381. * @returns the list of color remap gradients
  14382. */
  14383. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14384. /**
  14385. * Adds a new alpha remap gradient
  14386. * @param gradient defines the gradient to use (between 0 and 1)
  14387. * @param min defines the alpha remap minimal range
  14388. * @param max defines the alpha remap maximal range
  14389. * @returns the current particle system
  14390. */
  14391. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14392. /**
  14393. * Gets the current list of alpha remap gradients.
  14394. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14395. * @returns the list of alpha remap gradients
  14396. */
  14397. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14398. /**
  14399. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14400. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14401. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14402. * @returns the emitter
  14403. */
  14404. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14405. /**
  14406. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14407. * @param radius The radius of the hemisphere to emit from
  14408. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14409. * @returns the emitter
  14410. */
  14411. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14412. /**
  14413. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14414. * @param radius The radius of the sphere to emit from
  14415. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14416. * @returns the emitter
  14417. */
  14418. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14419. /**
  14420. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14421. * @param radius The radius of the sphere to emit from
  14422. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14423. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14424. * @returns the emitter
  14425. */
  14426. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14427. /**
  14428. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14429. * @param radius The radius of the emission cylinder
  14430. * @param height The height of the emission cylinder
  14431. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14432. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14433. * @returns the emitter
  14434. */
  14435. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14436. /**
  14437. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14438. * @param radius The radius of the cylinder to emit from
  14439. * @param height The height of the emission cylinder
  14440. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14441. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14442. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14443. * @returns the emitter
  14444. */
  14445. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14446. /**
  14447. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14448. * @param radius The radius of the cone to emit from
  14449. * @param angle The base angle of the cone
  14450. * @returns the emitter
  14451. */
  14452. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14453. /**
  14454. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14455. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14456. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14457. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14458. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14459. * @returns the emitter
  14460. */
  14461. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14462. /**
  14463. * Get hosting scene
  14464. * @returns the scene
  14465. */
  14466. getScene(): Scene;
  14467. }
  14468. }
  14469. declare module BABYLON {
  14470. /**
  14471. * 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.
  14472. * @see https://doc.babylonjs.com/how_to/transformnode
  14473. */
  14474. export class TransformNode extends Node {
  14475. /**
  14476. * Object will not rotate to face the camera
  14477. */
  14478. static BILLBOARDMODE_NONE: number;
  14479. /**
  14480. * Object will rotate to face the camera but only on the x axis
  14481. */
  14482. static BILLBOARDMODE_X: number;
  14483. /**
  14484. * Object will rotate to face the camera but only on the y axis
  14485. */
  14486. static BILLBOARDMODE_Y: number;
  14487. /**
  14488. * Object will rotate to face the camera but only on the z axis
  14489. */
  14490. static BILLBOARDMODE_Z: number;
  14491. /**
  14492. * Object will rotate to face the camera
  14493. */
  14494. static BILLBOARDMODE_ALL: number;
  14495. /**
  14496. * Object will rotate to face the camera's position instead of orientation
  14497. */
  14498. static BILLBOARDMODE_USE_POSITION: number;
  14499. private _forward;
  14500. private _forwardInverted;
  14501. private _up;
  14502. private _right;
  14503. private _rightInverted;
  14504. private _position;
  14505. private _rotation;
  14506. private _rotationQuaternion;
  14507. protected _scaling: Vector3;
  14508. protected _isDirty: boolean;
  14509. private _transformToBoneReferal;
  14510. private _isAbsoluteSynced;
  14511. private _billboardMode;
  14512. /**
  14513. * Gets or sets the billboard mode. Default is 0.
  14514. *
  14515. * | Value | Type | Description |
  14516. * | --- | --- | --- |
  14517. * | 0 | BILLBOARDMODE_NONE | |
  14518. * | 1 | BILLBOARDMODE_X | |
  14519. * | 2 | BILLBOARDMODE_Y | |
  14520. * | 4 | BILLBOARDMODE_Z | |
  14521. * | 7 | BILLBOARDMODE_ALL | |
  14522. *
  14523. */
  14524. get billboardMode(): number;
  14525. set billboardMode(value: number);
  14526. private _preserveParentRotationForBillboard;
  14527. /**
  14528. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14529. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14530. */
  14531. get preserveParentRotationForBillboard(): boolean;
  14532. set preserveParentRotationForBillboard(value: boolean);
  14533. /**
  14534. * 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
  14535. */
  14536. scalingDeterminant: number;
  14537. private _infiniteDistance;
  14538. /**
  14539. * Gets or sets the distance of the object to max, often used by skybox
  14540. */
  14541. get infiniteDistance(): boolean;
  14542. set infiniteDistance(value: boolean);
  14543. /**
  14544. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14545. * By default the system will update normals to compensate
  14546. */
  14547. ignoreNonUniformScaling: boolean;
  14548. /**
  14549. * 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
  14550. */
  14551. reIntegrateRotationIntoRotationQuaternion: boolean;
  14552. /** @hidden */
  14553. _poseMatrix: Nullable<Matrix>;
  14554. /** @hidden */
  14555. _localMatrix: Matrix;
  14556. private _usePivotMatrix;
  14557. private _absolutePosition;
  14558. private _absoluteScaling;
  14559. private _absoluteRotationQuaternion;
  14560. private _pivotMatrix;
  14561. private _pivotMatrixInverse;
  14562. protected _postMultiplyPivotMatrix: boolean;
  14563. protected _isWorldMatrixFrozen: boolean;
  14564. /** @hidden */
  14565. _indexInSceneTransformNodesArray: number;
  14566. /**
  14567. * An event triggered after the world matrix is updated
  14568. */
  14569. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14570. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14571. /**
  14572. * Gets a string identifying the name of the class
  14573. * @returns "TransformNode" string
  14574. */
  14575. getClassName(): string;
  14576. /**
  14577. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14578. */
  14579. get position(): Vector3;
  14580. set position(newPosition: Vector3);
  14581. /**
  14582. * 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)).
  14583. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14584. */
  14585. get rotation(): Vector3;
  14586. set rotation(newRotation: Vector3);
  14587. /**
  14588. * 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)).
  14589. */
  14590. get scaling(): Vector3;
  14591. set scaling(newScaling: Vector3);
  14592. /**
  14593. * 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).
  14594. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14595. */
  14596. get rotationQuaternion(): Nullable<Quaternion>;
  14597. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14598. /**
  14599. * The forward direction of that transform in world space.
  14600. */
  14601. get forward(): Vector3;
  14602. /**
  14603. * The up direction of that transform in world space.
  14604. */
  14605. get up(): Vector3;
  14606. /**
  14607. * The right direction of that transform in world space.
  14608. */
  14609. get right(): Vector3;
  14610. /**
  14611. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14612. * @param matrix the matrix to copy the pose from
  14613. * @returns this TransformNode.
  14614. */
  14615. updatePoseMatrix(matrix: Matrix): TransformNode;
  14616. /**
  14617. * Returns the mesh Pose matrix.
  14618. * @returns the pose matrix
  14619. */
  14620. getPoseMatrix(): Matrix;
  14621. /** @hidden */
  14622. _isSynchronized(): boolean;
  14623. /** @hidden */
  14624. _initCache(): void;
  14625. /**
  14626. * Flag the transform node as dirty (Forcing it to update everything)
  14627. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14628. * @returns this transform node
  14629. */
  14630. markAsDirty(property: string): TransformNode;
  14631. /**
  14632. * Returns the current mesh absolute position.
  14633. * Returns a Vector3.
  14634. */
  14635. get absolutePosition(): Vector3;
  14636. /**
  14637. * Returns the current mesh absolute scaling.
  14638. * Returns a Vector3.
  14639. */
  14640. get absoluteScaling(): Vector3;
  14641. /**
  14642. * Returns the current mesh absolute rotation.
  14643. * Returns a Quaternion.
  14644. */
  14645. get absoluteRotationQuaternion(): Quaternion;
  14646. /**
  14647. * Sets a new matrix to apply before all other transformation
  14648. * @param matrix defines the transform matrix
  14649. * @returns the current TransformNode
  14650. */
  14651. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14652. /**
  14653. * Sets a new pivot matrix to the current node
  14654. * @param matrix defines the new pivot matrix to use
  14655. * @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
  14656. * @returns the current TransformNode
  14657. */
  14658. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14659. /**
  14660. * Returns the mesh pivot matrix.
  14661. * Default : Identity.
  14662. * @returns the matrix
  14663. */
  14664. getPivotMatrix(): Matrix;
  14665. /**
  14666. * Instantiate (when possible) or clone that node with its hierarchy
  14667. * @param newParent defines the new parent to use for the instance (or clone)
  14668. * @param options defines options to configure how copy is done
  14669. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14670. * @returns an instance (or a clone) of the current node with its hiearchy
  14671. */
  14672. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14673. doNotInstantiate: boolean;
  14674. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14675. /**
  14676. * Prevents the World matrix to be computed any longer
  14677. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14678. * @returns the TransformNode.
  14679. */
  14680. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14681. /**
  14682. * Allows back the World matrix computation.
  14683. * @returns the TransformNode.
  14684. */
  14685. unfreezeWorldMatrix(): this;
  14686. /**
  14687. * True if the World matrix has been frozen.
  14688. */
  14689. get isWorldMatrixFrozen(): boolean;
  14690. /**
  14691. * Retuns the mesh absolute position in the World.
  14692. * @returns a Vector3.
  14693. */
  14694. getAbsolutePosition(): Vector3;
  14695. /**
  14696. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14697. * @param absolutePosition the absolute position to set
  14698. * @returns the TransformNode.
  14699. */
  14700. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14701. /**
  14702. * Sets the mesh position in its local space.
  14703. * @param vector3 the position to set in localspace
  14704. * @returns the TransformNode.
  14705. */
  14706. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14707. /**
  14708. * Returns the mesh position in the local space from the current World matrix values.
  14709. * @returns a new Vector3.
  14710. */
  14711. getPositionExpressedInLocalSpace(): Vector3;
  14712. /**
  14713. * Translates the mesh along the passed Vector3 in its local space.
  14714. * @param vector3 the distance to translate in localspace
  14715. * @returns the TransformNode.
  14716. */
  14717. locallyTranslate(vector3: Vector3): TransformNode;
  14718. private static _lookAtVectorCache;
  14719. /**
  14720. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14721. * @param targetPoint the position (must be in same space as current mesh) to look at
  14722. * @param yawCor optional yaw (y-axis) correction in radians
  14723. * @param pitchCor optional pitch (x-axis) correction in radians
  14724. * @param rollCor optional roll (z-axis) correction in radians
  14725. * @param space the choosen space of the target
  14726. * @returns the TransformNode.
  14727. */
  14728. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14729. /**
  14730. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14731. * This Vector3 is expressed in the World space.
  14732. * @param localAxis axis to rotate
  14733. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14734. */
  14735. getDirection(localAxis: Vector3): Vector3;
  14736. /**
  14737. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14738. * localAxis is expressed in the mesh local space.
  14739. * result is computed in the Wordl space from the mesh World matrix.
  14740. * @param localAxis axis to rotate
  14741. * @param result the resulting transformnode
  14742. * @returns this TransformNode.
  14743. */
  14744. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14745. /**
  14746. * Sets this transform node rotation to the given local axis.
  14747. * @param localAxis the axis in local space
  14748. * @param yawCor optional yaw (y-axis) correction in radians
  14749. * @param pitchCor optional pitch (x-axis) correction in radians
  14750. * @param rollCor optional roll (z-axis) correction in radians
  14751. * @returns this TransformNode
  14752. */
  14753. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14754. /**
  14755. * Sets a new pivot point to the current node
  14756. * @param point defines the new pivot point to use
  14757. * @param space defines if the point is in world or local space (local by default)
  14758. * @returns the current TransformNode
  14759. */
  14760. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14761. /**
  14762. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14763. * @returns the pivot point
  14764. */
  14765. getPivotPoint(): Vector3;
  14766. /**
  14767. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14768. * @param result the vector3 to store the result
  14769. * @returns this TransformNode.
  14770. */
  14771. getPivotPointToRef(result: Vector3): TransformNode;
  14772. /**
  14773. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14774. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14775. */
  14776. getAbsolutePivotPoint(): Vector3;
  14777. /**
  14778. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14779. * @param result vector3 to store the result
  14780. * @returns this TransformNode.
  14781. */
  14782. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14783. /**
  14784. * Defines the passed node as the parent of the current node.
  14785. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14786. * @see https://doc.babylonjs.com/how_to/parenting
  14787. * @param node the node ot set as the parent
  14788. * @returns this TransformNode.
  14789. */
  14790. setParent(node: Nullable<Node>): TransformNode;
  14791. private _nonUniformScaling;
  14792. /**
  14793. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14794. */
  14795. get nonUniformScaling(): boolean;
  14796. /** @hidden */
  14797. _updateNonUniformScalingState(value: boolean): boolean;
  14798. /**
  14799. * Attach the current TransformNode to another TransformNode associated with a bone
  14800. * @param bone Bone affecting the TransformNode
  14801. * @param affectedTransformNode TransformNode associated with the bone
  14802. * @returns this object
  14803. */
  14804. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14805. /**
  14806. * Detach the transform node if its associated with a bone
  14807. * @returns this object
  14808. */
  14809. detachFromBone(): TransformNode;
  14810. private static _rotationAxisCache;
  14811. /**
  14812. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14813. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14814. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14815. * The passed axis is also normalized.
  14816. * @param axis the axis to rotate around
  14817. * @param amount the amount to rotate in radians
  14818. * @param space Space to rotate in (Default: local)
  14819. * @returns the TransformNode.
  14820. */
  14821. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14822. /**
  14823. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14824. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14825. * The passed axis is also normalized. .
  14826. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14827. * @param point the point to rotate around
  14828. * @param axis the axis to rotate around
  14829. * @param amount the amount to rotate in radians
  14830. * @returns the TransformNode
  14831. */
  14832. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14833. /**
  14834. * Translates the mesh along the axis vector for the passed distance in the given space.
  14835. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14836. * @param axis the axis to translate in
  14837. * @param distance the distance to translate
  14838. * @param space Space to rotate in (Default: local)
  14839. * @returns the TransformNode.
  14840. */
  14841. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14842. /**
  14843. * Adds a rotation step to the mesh current rotation.
  14844. * x, y, z are Euler angles expressed in radians.
  14845. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14846. * This means this rotation is made in the mesh local space only.
  14847. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14848. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14849. * ```javascript
  14850. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14851. * ```
  14852. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14853. * 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.
  14854. * @param x Rotation to add
  14855. * @param y Rotation to add
  14856. * @param z Rotation to add
  14857. * @returns the TransformNode.
  14858. */
  14859. addRotation(x: number, y: number, z: number): TransformNode;
  14860. /**
  14861. * @hidden
  14862. */
  14863. protected _getEffectiveParent(): Nullable<Node>;
  14864. /**
  14865. * Computes the world matrix of the node
  14866. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14867. * @returns the world matrix
  14868. */
  14869. computeWorldMatrix(force?: boolean): Matrix;
  14870. /**
  14871. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14872. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14873. */
  14874. resetLocalMatrix(independentOfChildren?: boolean): void;
  14875. protected _afterComputeWorldMatrix(): void;
  14876. /**
  14877. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14878. * @param func callback function to add
  14879. *
  14880. * @returns the TransformNode.
  14881. */
  14882. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14883. /**
  14884. * Removes a registered callback function.
  14885. * @param func callback function to remove
  14886. * @returns the TransformNode.
  14887. */
  14888. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14889. /**
  14890. * Gets the position of the current mesh in camera space
  14891. * @param camera defines the camera to use
  14892. * @returns a position
  14893. */
  14894. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14895. /**
  14896. * Returns the distance from the mesh to the active camera
  14897. * @param camera defines the camera to use
  14898. * @returns the distance
  14899. */
  14900. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14901. /**
  14902. * Clone the current transform node
  14903. * @param name Name of the new clone
  14904. * @param newParent New parent for the clone
  14905. * @param doNotCloneChildren Do not clone children hierarchy
  14906. * @returns the new transform node
  14907. */
  14908. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14909. /**
  14910. * Serializes the objects information.
  14911. * @param currentSerializationObject defines the object to serialize in
  14912. * @returns the serialized object
  14913. */
  14914. serialize(currentSerializationObject?: any): any;
  14915. /**
  14916. * Returns a new TransformNode object parsed from the source provided.
  14917. * @param parsedTransformNode is the source.
  14918. * @param scene the scne the object belongs to
  14919. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14920. * @returns a new TransformNode object parsed from the source provided.
  14921. */
  14922. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14923. /**
  14924. * Get all child-transformNodes of this node
  14925. * @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
  14926. * @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
  14927. * @returns an array of TransformNode
  14928. */
  14929. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14930. /**
  14931. * Releases resources associated with this transform node.
  14932. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14933. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14934. */
  14935. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14936. /**
  14937. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14938. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14939. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14940. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14941. * @returns the current mesh
  14942. */
  14943. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14944. private _syncAbsoluteScalingAndRotation;
  14945. }
  14946. }
  14947. declare module BABYLON {
  14948. /**
  14949. * Class used to override all child animations of a given target
  14950. */
  14951. export class AnimationPropertiesOverride {
  14952. /**
  14953. * Gets or sets a value indicating if animation blending must be used
  14954. */
  14955. enableBlending: boolean;
  14956. /**
  14957. * Gets or sets the blending speed to use when enableBlending is true
  14958. */
  14959. blendingSpeed: number;
  14960. /**
  14961. * Gets or sets the default loop mode to use
  14962. */
  14963. loopMode: number;
  14964. }
  14965. }
  14966. declare module BABYLON {
  14967. /**
  14968. * Class used to store bone information
  14969. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14970. */
  14971. export class Bone extends Node {
  14972. /**
  14973. * defines the bone name
  14974. */
  14975. name: string;
  14976. private static _tmpVecs;
  14977. private static _tmpQuat;
  14978. private static _tmpMats;
  14979. /**
  14980. * Gets the list of child bones
  14981. */
  14982. children: Bone[];
  14983. /** Gets the animations associated with this bone */
  14984. animations: Animation[];
  14985. /**
  14986. * Gets or sets bone length
  14987. */
  14988. length: number;
  14989. /**
  14990. * @hidden Internal only
  14991. * Set this value to map this bone to a different index in the transform matrices
  14992. * Set this value to -1 to exclude the bone from the transform matrices
  14993. */
  14994. _index: Nullable<number>;
  14995. private _skeleton;
  14996. private _localMatrix;
  14997. private _restPose;
  14998. private _baseMatrix;
  14999. private _absoluteTransform;
  15000. private _invertedAbsoluteTransform;
  15001. private _parent;
  15002. private _scalingDeterminant;
  15003. private _worldTransform;
  15004. private _localScaling;
  15005. private _localRotation;
  15006. private _localPosition;
  15007. private _needToDecompose;
  15008. private _needToCompose;
  15009. /** @hidden */
  15010. _linkedTransformNode: Nullable<TransformNode>;
  15011. /** @hidden */
  15012. _waitingTransformNodeId: Nullable<string>;
  15013. /** @hidden */
  15014. get _matrix(): Matrix;
  15015. /** @hidden */
  15016. set _matrix(value: Matrix);
  15017. /**
  15018. * Create a new bone
  15019. * @param name defines the bone name
  15020. * @param skeleton defines the parent skeleton
  15021. * @param parentBone defines the parent (can be null if the bone is the root)
  15022. * @param localMatrix defines the local matrix
  15023. * @param restPose defines the rest pose matrix
  15024. * @param baseMatrix defines the base matrix
  15025. * @param index defines index of the bone in the hiearchy
  15026. */
  15027. constructor(
  15028. /**
  15029. * defines the bone name
  15030. */
  15031. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15032. /**
  15033. * Gets the current object class name.
  15034. * @return the class name
  15035. */
  15036. getClassName(): string;
  15037. /**
  15038. * Gets the parent skeleton
  15039. * @returns a skeleton
  15040. */
  15041. getSkeleton(): Skeleton;
  15042. /**
  15043. * Gets parent bone
  15044. * @returns a bone or null if the bone is the root of the bone hierarchy
  15045. */
  15046. getParent(): Nullable<Bone>;
  15047. /**
  15048. * Returns an array containing the root bones
  15049. * @returns an array containing the root bones
  15050. */
  15051. getChildren(): Array<Bone>;
  15052. /**
  15053. * Gets the node index in matrix array generated for rendering
  15054. * @returns the node index
  15055. */
  15056. getIndex(): number;
  15057. /**
  15058. * Sets the parent bone
  15059. * @param parent defines the parent (can be null if the bone is the root)
  15060. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15061. */
  15062. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15063. /**
  15064. * Gets the local matrix
  15065. * @returns a matrix
  15066. */
  15067. getLocalMatrix(): Matrix;
  15068. /**
  15069. * Gets the base matrix (initial matrix which remains unchanged)
  15070. * @returns a matrix
  15071. */
  15072. getBaseMatrix(): Matrix;
  15073. /**
  15074. * Gets the rest pose matrix
  15075. * @returns a matrix
  15076. */
  15077. getRestPose(): Matrix;
  15078. /**
  15079. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15080. */
  15081. getWorldMatrix(): Matrix;
  15082. /**
  15083. * Sets the local matrix to rest pose matrix
  15084. */
  15085. returnToRest(): void;
  15086. /**
  15087. * Gets the inverse of the absolute transform matrix.
  15088. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15089. * @returns a matrix
  15090. */
  15091. getInvertedAbsoluteTransform(): Matrix;
  15092. /**
  15093. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15094. * @returns a matrix
  15095. */
  15096. getAbsoluteTransform(): Matrix;
  15097. /**
  15098. * Links with the given transform node.
  15099. * The local matrix of this bone is copied from the transform node every frame.
  15100. * @param transformNode defines the transform node to link to
  15101. */
  15102. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15103. /**
  15104. * Gets the node used to drive the bone's transformation
  15105. * @returns a transform node or null
  15106. */
  15107. getTransformNode(): Nullable<TransformNode>;
  15108. /** Gets or sets current position (in local space) */
  15109. get position(): Vector3;
  15110. set position(newPosition: Vector3);
  15111. /** Gets or sets current rotation (in local space) */
  15112. get rotation(): Vector3;
  15113. set rotation(newRotation: Vector3);
  15114. /** Gets or sets current rotation quaternion (in local space) */
  15115. get rotationQuaternion(): Quaternion;
  15116. set rotationQuaternion(newRotation: Quaternion);
  15117. /** Gets or sets current scaling (in local space) */
  15118. get scaling(): Vector3;
  15119. set scaling(newScaling: Vector3);
  15120. /**
  15121. * Gets the animation properties override
  15122. */
  15123. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15124. private _decompose;
  15125. private _compose;
  15126. /**
  15127. * Update the base and local matrices
  15128. * @param matrix defines the new base or local matrix
  15129. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15130. * @param updateLocalMatrix defines if the local matrix should be updated
  15131. */
  15132. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15133. /** @hidden */
  15134. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15135. /**
  15136. * Flag the bone as dirty (Forcing it to update everything)
  15137. */
  15138. markAsDirty(): void;
  15139. /** @hidden */
  15140. _markAsDirtyAndCompose(): void;
  15141. private _markAsDirtyAndDecompose;
  15142. /**
  15143. * Translate the bone in local or world space
  15144. * @param vec The amount to translate the bone
  15145. * @param space The space that the translation is in
  15146. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15147. */
  15148. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15149. /**
  15150. * Set the postion of the bone in local or world space
  15151. * @param position The position to set the bone
  15152. * @param space The space that the position is in
  15153. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15154. */
  15155. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15156. /**
  15157. * Set the absolute position of the bone (world space)
  15158. * @param position The position to set the bone
  15159. * @param mesh The mesh that this bone is attached to
  15160. */
  15161. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15162. /**
  15163. * Scale the bone on the x, y and z axes (in local space)
  15164. * @param x The amount to scale the bone on the x axis
  15165. * @param y The amount to scale the bone on the y axis
  15166. * @param z The amount to scale the bone on the z axis
  15167. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15168. */
  15169. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15170. /**
  15171. * Set the bone scaling in local space
  15172. * @param scale defines the scaling vector
  15173. */
  15174. setScale(scale: Vector3): void;
  15175. /**
  15176. * Gets the current scaling in local space
  15177. * @returns the current scaling vector
  15178. */
  15179. getScale(): Vector3;
  15180. /**
  15181. * Gets the current scaling in local space and stores it in a target vector
  15182. * @param result defines the target vector
  15183. */
  15184. getScaleToRef(result: Vector3): void;
  15185. /**
  15186. * Set the yaw, pitch, and roll of the bone in local or world space
  15187. * @param yaw The rotation of the bone on the y axis
  15188. * @param pitch The rotation of the bone on the x axis
  15189. * @param roll The rotation of the bone on the z axis
  15190. * @param space The space that the axes of rotation are in
  15191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15192. */
  15193. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15194. /**
  15195. * Add a rotation to the bone on an axis in local or world space
  15196. * @param axis The axis to rotate the bone on
  15197. * @param amount The amount to rotate the bone
  15198. * @param space The space that the axis is in
  15199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15200. */
  15201. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15202. /**
  15203. * Set the rotation of the bone to a particular axis angle in local or world space
  15204. * @param axis The axis to rotate the bone on
  15205. * @param angle The angle that the bone should be rotated to
  15206. * @param space The space that the axis is in
  15207. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15208. */
  15209. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15210. /**
  15211. * Set the euler rotation of the bone in local of world space
  15212. * @param rotation The euler rotation that the bone should be set to
  15213. * @param space The space that the rotation is in
  15214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15215. */
  15216. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15217. /**
  15218. * Set the quaternion rotation of the bone in local of world space
  15219. * @param quat The quaternion rotation that the bone should be set to
  15220. * @param space The space that the rotation is in
  15221. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15222. */
  15223. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15224. /**
  15225. * Set the rotation matrix of the bone in local of world space
  15226. * @param rotMat The rotation matrix that the bone should be set to
  15227. * @param space The space that the rotation is in
  15228. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15229. */
  15230. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15231. private _rotateWithMatrix;
  15232. private _getNegativeRotationToRef;
  15233. /**
  15234. * Get the position of the bone in local or world space
  15235. * @param space The space that the returned position is in
  15236. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15237. * @returns The position of the bone
  15238. */
  15239. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15240. /**
  15241. * Copy the position of the bone to a vector3 in local or world space
  15242. * @param space The space that the returned position is in
  15243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15244. * @param result The vector3 to copy the position to
  15245. */
  15246. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15247. /**
  15248. * Get the absolute position of the bone (world space)
  15249. * @param mesh The mesh that this bone is attached to
  15250. * @returns The absolute position of the bone
  15251. */
  15252. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15253. /**
  15254. * Copy the absolute position of the bone (world space) to the result param
  15255. * @param mesh The mesh that this bone is attached to
  15256. * @param result The vector3 to copy the absolute position to
  15257. */
  15258. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15259. /**
  15260. * Compute the absolute transforms of this bone and its children
  15261. */
  15262. computeAbsoluteTransforms(): void;
  15263. /**
  15264. * Get the world direction from an axis that is in the local space of the bone
  15265. * @param localAxis The local direction that is used to compute the world direction
  15266. * @param mesh The mesh that this bone is attached to
  15267. * @returns The world direction
  15268. */
  15269. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15270. /**
  15271. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15272. * @param localAxis The local direction that is used to compute the world direction
  15273. * @param mesh The mesh that this bone is attached to
  15274. * @param result The vector3 that the world direction will be copied to
  15275. */
  15276. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15277. /**
  15278. * Get the euler rotation of the bone in local or world space
  15279. * @param space The space that the rotation should be in
  15280. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15281. * @returns The euler rotation
  15282. */
  15283. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15284. /**
  15285. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15286. * @param space The space that the rotation should be in
  15287. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15288. * @param result The vector3 that the rotation should be copied to
  15289. */
  15290. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15291. /**
  15292. * Get the quaternion rotation of the bone in either local or world space
  15293. * @param space The space that the rotation should be in
  15294. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15295. * @returns The quaternion rotation
  15296. */
  15297. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15298. /**
  15299. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15300. * @param space The space that the rotation should be in
  15301. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15302. * @param result The quaternion that the rotation should be copied to
  15303. */
  15304. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15305. /**
  15306. * Get the rotation matrix of the bone in local or world space
  15307. * @param space The space that the rotation should be in
  15308. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15309. * @returns The rotation matrix
  15310. */
  15311. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15312. /**
  15313. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15314. * @param space The space that the rotation should be in
  15315. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15316. * @param result The quaternion that the rotation should be copied to
  15317. */
  15318. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15319. /**
  15320. * Get the world position of a point that is in the local space of the bone
  15321. * @param position The local position
  15322. * @param mesh The mesh that this bone is attached to
  15323. * @returns The world position
  15324. */
  15325. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15326. /**
  15327. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15328. * @param position The local position
  15329. * @param mesh The mesh that this bone is attached to
  15330. * @param result The vector3 that the world position should be copied to
  15331. */
  15332. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15333. /**
  15334. * Get the local position of a point that is in world space
  15335. * @param position The world position
  15336. * @param mesh The mesh that this bone is attached to
  15337. * @returns The local position
  15338. */
  15339. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15340. /**
  15341. * Get the local position of a point that is in world space and copy it to the result param
  15342. * @param position The world position
  15343. * @param mesh The mesh that this bone is attached to
  15344. * @param result The vector3 that the local position should be copied to
  15345. */
  15346. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15347. }
  15348. }
  15349. declare module BABYLON {
  15350. /**
  15351. * Defines a runtime animation
  15352. */
  15353. export class RuntimeAnimation {
  15354. private _events;
  15355. /**
  15356. * The current frame of the runtime animation
  15357. */
  15358. private _currentFrame;
  15359. /**
  15360. * The animation used by the runtime animation
  15361. */
  15362. private _animation;
  15363. /**
  15364. * The target of the runtime animation
  15365. */
  15366. private _target;
  15367. /**
  15368. * The initiating animatable
  15369. */
  15370. private _host;
  15371. /**
  15372. * The original value of the runtime animation
  15373. */
  15374. private _originalValue;
  15375. /**
  15376. * The original blend value of the runtime animation
  15377. */
  15378. private _originalBlendValue;
  15379. /**
  15380. * The offsets cache of the runtime animation
  15381. */
  15382. private _offsetsCache;
  15383. /**
  15384. * The high limits cache of the runtime animation
  15385. */
  15386. private _highLimitsCache;
  15387. /**
  15388. * Specifies if the runtime animation has been stopped
  15389. */
  15390. private _stopped;
  15391. /**
  15392. * The blending factor of the runtime animation
  15393. */
  15394. private _blendingFactor;
  15395. /**
  15396. * The BabylonJS scene
  15397. */
  15398. private _scene;
  15399. /**
  15400. * The current value of the runtime animation
  15401. */
  15402. private _currentValue;
  15403. /** @hidden */
  15404. _animationState: _IAnimationState;
  15405. /**
  15406. * The active target of the runtime animation
  15407. */
  15408. private _activeTargets;
  15409. private _currentActiveTarget;
  15410. private _directTarget;
  15411. /**
  15412. * The target path of the runtime animation
  15413. */
  15414. private _targetPath;
  15415. /**
  15416. * The weight of the runtime animation
  15417. */
  15418. private _weight;
  15419. /**
  15420. * The ratio offset of the runtime animation
  15421. */
  15422. private _ratioOffset;
  15423. /**
  15424. * The previous delay of the runtime animation
  15425. */
  15426. private _previousDelay;
  15427. /**
  15428. * The previous ratio of the runtime animation
  15429. */
  15430. private _previousRatio;
  15431. private _enableBlending;
  15432. private _keys;
  15433. private _minFrame;
  15434. private _maxFrame;
  15435. private _minValue;
  15436. private _maxValue;
  15437. private _targetIsArray;
  15438. /**
  15439. * Gets the current frame of the runtime animation
  15440. */
  15441. get currentFrame(): number;
  15442. /**
  15443. * Gets the weight of the runtime animation
  15444. */
  15445. get weight(): number;
  15446. /**
  15447. * Gets the current value of the runtime animation
  15448. */
  15449. get currentValue(): any;
  15450. /**
  15451. * Gets the target path of the runtime animation
  15452. */
  15453. get targetPath(): string;
  15454. /**
  15455. * Gets the actual target of the runtime animation
  15456. */
  15457. get target(): any;
  15458. /**
  15459. * Gets the additive state of the runtime animation
  15460. */
  15461. get isAdditive(): boolean;
  15462. /** @hidden */
  15463. _onLoop: () => void;
  15464. /**
  15465. * Create a new RuntimeAnimation object
  15466. * @param target defines the target of the animation
  15467. * @param animation defines the source animation object
  15468. * @param scene defines the hosting scene
  15469. * @param host defines the initiating Animatable
  15470. */
  15471. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15472. private _preparePath;
  15473. /**
  15474. * Gets the animation from the runtime animation
  15475. */
  15476. get animation(): Animation;
  15477. /**
  15478. * Resets the runtime animation to the beginning
  15479. * @param restoreOriginal defines whether to restore the target property to the original value
  15480. */
  15481. reset(restoreOriginal?: boolean): void;
  15482. /**
  15483. * Specifies if the runtime animation is stopped
  15484. * @returns Boolean specifying if the runtime animation is stopped
  15485. */
  15486. isStopped(): boolean;
  15487. /**
  15488. * Disposes of the runtime animation
  15489. */
  15490. dispose(): void;
  15491. /**
  15492. * Apply the interpolated value to the target
  15493. * @param currentValue defines the value computed by the animation
  15494. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15495. */
  15496. setValue(currentValue: any, weight: number): void;
  15497. private _getOriginalValues;
  15498. private _setValue;
  15499. /**
  15500. * Gets the loop pmode of the runtime animation
  15501. * @returns Loop Mode
  15502. */
  15503. private _getCorrectLoopMode;
  15504. /**
  15505. * Move the current animation to a given frame
  15506. * @param frame defines the frame to move to
  15507. */
  15508. goToFrame(frame: number): void;
  15509. /**
  15510. * @hidden Internal use only
  15511. */
  15512. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15513. /**
  15514. * Execute the current animation
  15515. * @param delay defines the delay to add to the current frame
  15516. * @param from defines the lower bound of the animation range
  15517. * @param to defines the upper bound of the animation range
  15518. * @param loop defines if the current animation must loop
  15519. * @param speedRatio defines the current speed ratio
  15520. * @param weight defines the weight of the animation (default is -1 so no weight)
  15521. * @param onLoop optional callback called when animation loops
  15522. * @returns a boolean indicating if the animation is running
  15523. */
  15524. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15525. }
  15526. }
  15527. declare module BABYLON {
  15528. /**
  15529. * Class used to store an actual running animation
  15530. */
  15531. export class Animatable {
  15532. /** defines the target object */
  15533. target: any;
  15534. /** defines the starting frame number (default is 0) */
  15535. fromFrame: number;
  15536. /** defines the ending frame number (default is 100) */
  15537. toFrame: number;
  15538. /** defines if the animation must loop (default is false) */
  15539. loopAnimation: boolean;
  15540. /** defines a callback to call when animation ends if it is not looping */
  15541. onAnimationEnd?: (() => void) | null | undefined;
  15542. /** defines a callback to call when animation loops */
  15543. onAnimationLoop?: (() => void) | null | undefined;
  15544. /** defines whether the animation should be evaluated additively */
  15545. isAdditive: boolean;
  15546. private _localDelayOffset;
  15547. private _pausedDelay;
  15548. private _runtimeAnimations;
  15549. private _paused;
  15550. private _scene;
  15551. private _speedRatio;
  15552. private _weight;
  15553. private _syncRoot;
  15554. /**
  15555. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15556. * This will only apply for non looping animation (default is true)
  15557. */
  15558. disposeOnEnd: boolean;
  15559. /**
  15560. * Gets a boolean indicating if the animation has started
  15561. */
  15562. animationStarted: boolean;
  15563. /**
  15564. * Observer raised when the animation ends
  15565. */
  15566. onAnimationEndObservable: Observable<Animatable>;
  15567. /**
  15568. * Observer raised when the animation loops
  15569. */
  15570. onAnimationLoopObservable: Observable<Animatable>;
  15571. /**
  15572. * Gets the root Animatable used to synchronize and normalize animations
  15573. */
  15574. get syncRoot(): Nullable<Animatable>;
  15575. /**
  15576. * Gets the current frame of the first RuntimeAnimation
  15577. * Used to synchronize Animatables
  15578. */
  15579. get masterFrame(): number;
  15580. /**
  15581. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15582. */
  15583. get weight(): number;
  15584. set weight(value: number);
  15585. /**
  15586. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15587. */
  15588. get speedRatio(): number;
  15589. set speedRatio(value: number);
  15590. /**
  15591. * Creates a new Animatable
  15592. * @param scene defines the hosting scene
  15593. * @param target defines the target object
  15594. * @param fromFrame defines the starting frame number (default is 0)
  15595. * @param toFrame defines the ending frame number (default is 100)
  15596. * @param loopAnimation defines if the animation must loop (default is false)
  15597. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15598. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15599. * @param animations defines a group of animation to add to the new Animatable
  15600. * @param onAnimationLoop defines a callback to call when animation loops
  15601. * @param isAdditive defines whether the animation should be evaluated additively
  15602. */
  15603. constructor(scene: Scene,
  15604. /** defines the target object */
  15605. target: any,
  15606. /** defines the starting frame number (default is 0) */
  15607. fromFrame?: number,
  15608. /** defines the ending frame number (default is 100) */
  15609. toFrame?: number,
  15610. /** defines if the animation must loop (default is false) */
  15611. loopAnimation?: boolean, speedRatio?: number,
  15612. /** defines a callback to call when animation ends if it is not looping */
  15613. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15614. /** defines a callback to call when animation loops */
  15615. onAnimationLoop?: (() => void) | null | undefined,
  15616. /** defines whether the animation should be evaluated additively */
  15617. isAdditive?: boolean);
  15618. /**
  15619. * Synchronize and normalize current Animatable with a source Animatable
  15620. * This is useful when using animation weights and when animations are not of the same length
  15621. * @param root defines the root Animatable to synchronize with
  15622. * @returns the current Animatable
  15623. */
  15624. syncWith(root: Animatable): Animatable;
  15625. /**
  15626. * Gets the list of runtime animations
  15627. * @returns an array of RuntimeAnimation
  15628. */
  15629. getAnimations(): RuntimeAnimation[];
  15630. /**
  15631. * Adds more animations to the current animatable
  15632. * @param target defines the target of the animations
  15633. * @param animations defines the new animations to add
  15634. */
  15635. appendAnimations(target: any, animations: Animation[]): void;
  15636. /**
  15637. * Gets the source animation for a specific property
  15638. * @param property defines the propertyu to look for
  15639. * @returns null or the source animation for the given property
  15640. */
  15641. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15642. /**
  15643. * Gets the runtime animation for a specific property
  15644. * @param property defines the propertyu to look for
  15645. * @returns null or the runtime animation for the given property
  15646. */
  15647. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15648. /**
  15649. * Resets the animatable to its original state
  15650. */
  15651. reset(): void;
  15652. /**
  15653. * Allows the animatable to blend with current running animations
  15654. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15655. * @param blendingSpeed defines the blending speed to use
  15656. */
  15657. enableBlending(blendingSpeed: number): void;
  15658. /**
  15659. * Disable animation blending
  15660. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15661. */
  15662. disableBlending(): void;
  15663. /**
  15664. * Jump directly to a given frame
  15665. * @param frame defines the frame to jump to
  15666. */
  15667. goToFrame(frame: number): void;
  15668. /**
  15669. * Pause the animation
  15670. */
  15671. pause(): void;
  15672. /**
  15673. * Restart the animation
  15674. */
  15675. restart(): void;
  15676. private _raiseOnAnimationEnd;
  15677. /**
  15678. * Stop and delete the current animation
  15679. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15680. * @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)
  15681. */
  15682. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15683. /**
  15684. * Wait asynchronously for the animation to end
  15685. * @returns a promise which will be fullfilled when the animation ends
  15686. */
  15687. waitAsync(): Promise<Animatable>;
  15688. /** @hidden */
  15689. _animate(delay: number): boolean;
  15690. }
  15691. interface Scene {
  15692. /** @hidden */
  15693. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15694. /** @hidden */
  15695. _processLateAnimationBindingsForMatrices(holder: {
  15696. totalWeight: number;
  15697. totalAdditiveWeight: number;
  15698. animations: RuntimeAnimation[];
  15699. additiveAnimations: RuntimeAnimation[];
  15700. originalValue: Matrix;
  15701. }): any;
  15702. /** @hidden */
  15703. _processLateAnimationBindingsForQuaternions(holder: {
  15704. totalWeight: number;
  15705. totalAdditiveWeight: number;
  15706. animations: RuntimeAnimation[];
  15707. additiveAnimations: RuntimeAnimation[];
  15708. originalValue: Quaternion;
  15709. }, refQuaternion: Quaternion): Quaternion;
  15710. /** @hidden */
  15711. _processLateAnimationBindings(): void;
  15712. /**
  15713. * Will start the animation sequence of a given target
  15714. * @param target defines the target
  15715. * @param from defines from which frame should animation start
  15716. * @param to defines until which frame should animation run.
  15717. * @param weight defines the weight to apply to the animation (1.0 by default)
  15718. * @param loop defines if the animation loops
  15719. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15720. * @param onAnimationEnd defines the function to be executed when the animation ends
  15721. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15722. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15723. * @param onAnimationLoop defines the callback to call when an animation loops
  15724. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15725. * @returns the animatable object created for this animation
  15726. */
  15727. 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;
  15728. /**
  15729. * Will start the animation sequence of a given target
  15730. * @param target defines the target
  15731. * @param from defines from which frame should animation start
  15732. * @param to defines until which frame should animation run.
  15733. * @param loop defines if the animation loops
  15734. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15735. * @param onAnimationEnd defines the function to be executed when the animation ends
  15736. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15737. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15738. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15739. * @param onAnimationLoop defines the callback to call when an animation loops
  15740. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15741. * @returns the animatable object created for this animation
  15742. */
  15743. 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;
  15744. /**
  15745. * Will start the animation sequence of a given target and its hierarchy
  15746. * @param target defines the target
  15747. * @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.
  15748. * @param from defines from which frame should animation start
  15749. * @param to defines until which frame should animation run.
  15750. * @param loop defines if the animation loops
  15751. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15752. * @param onAnimationEnd defines the function to be executed when the animation ends
  15753. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15754. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15755. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15756. * @param onAnimationLoop defines the callback to call when an animation loops
  15757. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15758. * @returns the list of created animatables
  15759. */
  15760. 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[];
  15761. /**
  15762. * Begin a new animation on a given node
  15763. * @param target defines the target where the animation will take place
  15764. * @param animations defines the list of animations to start
  15765. * @param from defines the initial value
  15766. * @param to defines the final value
  15767. * @param loop defines if you want animation to loop (off by default)
  15768. * @param speedRatio defines the speed ratio to apply to all animations
  15769. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15770. * @param onAnimationLoop defines the callback to call when an animation loops
  15771. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15772. * @returns the list of created animatables
  15773. */
  15774. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15775. /**
  15776. * Begin a new animation on a given node and its hierarchy
  15777. * @param target defines the root node where the animation will take place
  15778. * @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.
  15779. * @param animations defines the list of animations to start
  15780. * @param from defines the initial value
  15781. * @param to defines the final value
  15782. * @param loop defines if you want animation to loop (off by default)
  15783. * @param speedRatio defines the speed ratio to apply to all animations
  15784. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15785. * @param onAnimationLoop defines the callback to call when an animation loops
  15786. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15787. * @returns the list of animatables created for all nodes
  15788. */
  15789. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15790. /**
  15791. * Gets the animatable associated with a specific target
  15792. * @param target defines the target of the animatable
  15793. * @returns the required animatable if found
  15794. */
  15795. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15796. /**
  15797. * Gets all animatables associated with a given target
  15798. * @param target defines the target to look animatables for
  15799. * @returns an array of Animatables
  15800. */
  15801. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15802. /**
  15803. * Stops and removes all animations that have been applied to the scene
  15804. */
  15805. stopAllAnimations(): void;
  15806. /**
  15807. * Gets the current delta time used by animation engine
  15808. */
  15809. deltaTime: number;
  15810. }
  15811. interface Bone {
  15812. /**
  15813. * Copy an animation range from another bone
  15814. * @param source defines the source bone
  15815. * @param rangeName defines the range name to copy
  15816. * @param frameOffset defines the frame offset
  15817. * @param rescaleAsRequired defines if rescaling must be applied if required
  15818. * @param skelDimensionsRatio defines the scaling ratio
  15819. * @returns true if operation was successful
  15820. */
  15821. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15822. }
  15823. }
  15824. declare module BABYLON {
  15825. /**
  15826. * Class used to handle skinning animations
  15827. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15828. */
  15829. export class Skeleton implements IAnimatable {
  15830. /** defines the skeleton name */
  15831. name: string;
  15832. /** defines the skeleton Id */
  15833. id: string;
  15834. /**
  15835. * Defines the list of child bones
  15836. */
  15837. bones: Bone[];
  15838. /**
  15839. * Defines an estimate of the dimension of the skeleton at rest
  15840. */
  15841. dimensionsAtRest: Vector3;
  15842. /**
  15843. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15844. */
  15845. needInitialSkinMatrix: boolean;
  15846. /**
  15847. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15848. */
  15849. overrideMesh: Nullable<AbstractMesh>;
  15850. /**
  15851. * Gets the list of animations attached to this skeleton
  15852. */
  15853. animations: Array<Animation>;
  15854. private _scene;
  15855. private _isDirty;
  15856. private _transformMatrices;
  15857. private _transformMatrixTexture;
  15858. private _meshesWithPoseMatrix;
  15859. private _animatables;
  15860. private _identity;
  15861. private _synchronizedWithMesh;
  15862. private _ranges;
  15863. private _lastAbsoluteTransformsUpdateId;
  15864. private _canUseTextureForBones;
  15865. private _uniqueId;
  15866. /** @hidden */
  15867. _numBonesWithLinkedTransformNode: number;
  15868. /** @hidden */
  15869. _hasWaitingData: Nullable<boolean>;
  15870. /**
  15871. * Specifies if the skeleton should be serialized
  15872. */
  15873. doNotSerialize: boolean;
  15874. private _useTextureToStoreBoneMatrices;
  15875. /**
  15876. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15877. * Please note that this option is not available if the hardware does not support it
  15878. */
  15879. get useTextureToStoreBoneMatrices(): boolean;
  15880. set useTextureToStoreBoneMatrices(value: boolean);
  15881. private _animationPropertiesOverride;
  15882. /**
  15883. * Gets or sets the animation properties override
  15884. */
  15885. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15886. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15887. /**
  15888. * List of inspectable custom properties (used by the Inspector)
  15889. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15890. */
  15891. inspectableCustomProperties: IInspectable[];
  15892. /**
  15893. * An observable triggered before computing the skeleton's matrices
  15894. */
  15895. onBeforeComputeObservable: Observable<Skeleton>;
  15896. /**
  15897. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15898. */
  15899. get isUsingTextureForMatrices(): boolean;
  15900. /**
  15901. * Gets the unique ID of this skeleton
  15902. */
  15903. get uniqueId(): number;
  15904. /**
  15905. * Creates a new skeleton
  15906. * @param name defines the skeleton name
  15907. * @param id defines the skeleton Id
  15908. * @param scene defines the hosting scene
  15909. */
  15910. constructor(
  15911. /** defines the skeleton name */
  15912. name: string,
  15913. /** defines the skeleton Id */
  15914. id: string, scene: Scene);
  15915. /**
  15916. * Gets the current object class name.
  15917. * @return the class name
  15918. */
  15919. getClassName(): string;
  15920. /**
  15921. * Returns an array containing the root bones
  15922. * @returns an array containing the root bones
  15923. */
  15924. getChildren(): Array<Bone>;
  15925. /**
  15926. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15927. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15928. * @returns a Float32Array containing matrices data
  15929. */
  15930. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15931. /**
  15932. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15933. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15934. * @returns a raw texture containing the data
  15935. */
  15936. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15937. /**
  15938. * Gets the current hosting scene
  15939. * @returns a scene object
  15940. */
  15941. getScene(): Scene;
  15942. /**
  15943. * Gets a string representing the current skeleton data
  15944. * @param fullDetails defines a boolean indicating if we want a verbose version
  15945. * @returns a string representing the current skeleton data
  15946. */
  15947. toString(fullDetails?: boolean): string;
  15948. /**
  15949. * Get bone's index searching by name
  15950. * @param name defines bone's name to search for
  15951. * @return the indice of the bone. Returns -1 if not found
  15952. */
  15953. getBoneIndexByName(name: string): number;
  15954. /**
  15955. * Creater a new animation range
  15956. * @param name defines the name of the range
  15957. * @param from defines the start key
  15958. * @param to defines the end key
  15959. */
  15960. createAnimationRange(name: string, from: number, to: number): void;
  15961. /**
  15962. * Delete a specific animation range
  15963. * @param name defines the name of the range
  15964. * @param deleteFrames defines if frames must be removed as well
  15965. */
  15966. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15967. /**
  15968. * Gets a specific animation range
  15969. * @param name defines the name of the range to look for
  15970. * @returns the requested animation range or null if not found
  15971. */
  15972. getAnimationRange(name: string): Nullable<AnimationRange>;
  15973. /**
  15974. * Gets the list of all animation ranges defined on this skeleton
  15975. * @returns an array
  15976. */
  15977. getAnimationRanges(): Nullable<AnimationRange>[];
  15978. /**
  15979. * Copy animation range from a source skeleton.
  15980. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15981. * @param source defines the source skeleton
  15982. * @param name defines the name of the range to copy
  15983. * @param rescaleAsRequired defines if rescaling must be applied if required
  15984. * @returns true if operation was successful
  15985. */
  15986. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15987. /**
  15988. * Forces the skeleton to go to rest pose
  15989. */
  15990. returnToRest(): void;
  15991. private _getHighestAnimationFrame;
  15992. /**
  15993. * Begin a specific animation range
  15994. * @param name defines the name of the range to start
  15995. * @param loop defines if looping must be turned on (false by default)
  15996. * @param speedRatio defines the speed ratio to apply (1 by default)
  15997. * @param onAnimationEnd defines a callback which will be called when animation will end
  15998. * @returns a new animatable
  15999. */
  16000. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16001. /**
  16002. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16003. * @param skeleton defines the Skeleton containing the animation range to convert
  16004. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16005. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16006. * @returns the original skeleton
  16007. */
  16008. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16009. /** @hidden */
  16010. _markAsDirty(): void;
  16011. /** @hidden */
  16012. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16013. /** @hidden */
  16014. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16015. private _computeTransformMatrices;
  16016. /**
  16017. * Build all resources required to render a skeleton
  16018. */
  16019. prepare(): void;
  16020. /**
  16021. * Gets the list of animatables currently running for this skeleton
  16022. * @returns an array of animatables
  16023. */
  16024. getAnimatables(): IAnimatable[];
  16025. /**
  16026. * Clone the current skeleton
  16027. * @param name defines the name of the new skeleton
  16028. * @param id defines the id of the new skeleton
  16029. * @returns the new skeleton
  16030. */
  16031. clone(name: string, id?: string): Skeleton;
  16032. /**
  16033. * Enable animation blending for this skeleton
  16034. * @param blendingSpeed defines the blending speed to apply
  16035. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16036. */
  16037. enableBlending(blendingSpeed?: number): void;
  16038. /**
  16039. * Releases all resources associated with the current skeleton
  16040. */
  16041. dispose(): void;
  16042. /**
  16043. * Serialize the skeleton in a JSON object
  16044. * @returns a JSON object
  16045. */
  16046. serialize(): any;
  16047. /**
  16048. * Creates a new skeleton from serialized data
  16049. * @param parsedSkeleton defines the serialized data
  16050. * @param scene defines the hosting scene
  16051. * @returns a new skeleton
  16052. */
  16053. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16054. /**
  16055. * Compute all node absolute transforms
  16056. * @param forceUpdate defines if computation must be done even if cache is up to date
  16057. */
  16058. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16059. /**
  16060. * Gets the root pose matrix
  16061. * @returns a matrix
  16062. */
  16063. getPoseMatrix(): Nullable<Matrix>;
  16064. /**
  16065. * Sorts bones per internal index
  16066. */
  16067. sortBones(): void;
  16068. private _sortBones;
  16069. }
  16070. }
  16071. declare module BABYLON {
  16072. /**
  16073. * Creates an instance based on a source mesh.
  16074. */
  16075. export class InstancedMesh extends AbstractMesh {
  16076. private _sourceMesh;
  16077. private _currentLOD;
  16078. /** @hidden */
  16079. _indexInSourceMeshInstanceArray: number;
  16080. constructor(name: string, source: Mesh);
  16081. /**
  16082. * Returns the string "InstancedMesh".
  16083. */
  16084. getClassName(): string;
  16085. /** Gets the list of lights affecting that mesh */
  16086. get lightSources(): Light[];
  16087. _resyncLightSources(): void;
  16088. _resyncLightSource(light: Light): void;
  16089. _removeLightSource(light: Light, dispose: boolean): void;
  16090. /**
  16091. * If the source mesh receives shadows
  16092. */
  16093. get receiveShadows(): boolean;
  16094. /**
  16095. * The material of the source mesh
  16096. */
  16097. get material(): Nullable<Material>;
  16098. /**
  16099. * Visibility of the source mesh
  16100. */
  16101. get visibility(): number;
  16102. /**
  16103. * Skeleton of the source mesh
  16104. */
  16105. get skeleton(): Nullable<Skeleton>;
  16106. /**
  16107. * Rendering ground id of the source mesh
  16108. */
  16109. get renderingGroupId(): number;
  16110. set renderingGroupId(value: number);
  16111. /**
  16112. * Returns the total number of vertices (integer).
  16113. */
  16114. getTotalVertices(): number;
  16115. /**
  16116. * Returns a positive integer : the total number of indices in this mesh geometry.
  16117. * @returns the numner of indices or zero if the mesh has no geometry.
  16118. */
  16119. getTotalIndices(): number;
  16120. /**
  16121. * The source mesh of the instance
  16122. */
  16123. get sourceMesh(): Mesh;
  16124. /**
  16125. * Is this node ready to be used/rendered
  16126. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16127. * @return {boolean} is it ready
  16128. */
  16129. isReady(completeCheck?: boolean): boolean;
  16130. /**
  16131. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16132. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16133. * @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.
  16134. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16135. */
  16136. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16137. /**
  16138. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16139. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16140. * The `data` are either a numeric array either a Float32Array.
  16141. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16142. * 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).
  16143. * Note that a new underlying VertexBuffer object is created each call.
  16144. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16145. *
  16146. * Possible `kind` values :
  16147. * - VertexBuffer.PositionKind
  16148. * - VertexBuffer.UVKind
  16149. * - VertexBuffer.UV2Kind
  16150. * - VertexBuffer.UV3Kind
  16151. * - VertexBuffer.UV4Kind
  16152. * - VertexBuffer.UV5Kind
  16153. * - VertexBuffer.UV6Kind
  16154. * - VertexBuffer.ColorKind
  16155. * - VertexBuffer.MatricesIndicesKind
  16156. * - VertexBuffer.MatricesIndicesExtraKind
  16157. * - VertexBuffer.MatricesWeightsKind
  16158. * - VertexBuffer.MatricesWeightsExtraKind
  16159. *
  16160. * Returns the Mesh.
  16161. */
  16162. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16163. /**
  16164. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16165. * If the mesh has no geometry, it is simply returned as it is.
  16166. * The `data` are either a numeric array either a Float32Array.
  16167. * No new underlying VertexBuffer object is created.
  16168. * 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.
  16169. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16170. *
  16171. * Possible `kind` values :
  16172. * - VertexBuffer.PositionKind
  16173. * - VertexBuffer.UVKind
  16174. * - VertexBuffer.UV2Kind
  16175. * - VertexBuffer.UV3Kind
  16176. * - VertexBuffer.UV4Kind
  16177. * - VertexBuffer.UV5Kind
  16178. * - VertexBuffer.UV6Kind
  16179. * - VertexBuffer.ColorKind
  16180. * - VertexBuffer.MatricesIndicesKind
  16181. * - VertexBuffer.MatricesIndicesExtraKind
  16182. * - VertexBuffer.MatricesWeightsKind
  16183. * - VertexBuffer.MatricesWeightsExtraKind
  16184. *
  16185. * Returns the Mesh.
  16186. */
  16187. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16188. /**
  16189. * Sets the mesh indices.
  16190. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16191. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16192. * This method creates a new index buffer each call.
  16193. * Returns the Mesh.
  16194. */
  16195. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16196. /**
  16197. * Boolean : True if the mesh owns the requested kind of data.
  16198. */
  16199. isVerticesDataPresent(kind: string): boolean;
  16200. /**
  16201. * Returns an array of indices (IndicesArray).
  16202. */
  16203. getIndices(): Nullable<IndicesArray>;
  16204. get _positions(): Nullable<Vector3[]>;
  16205. /**
  16206. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16207. * This means the mesh underlying bounding box and sphere are recomputed.
  16208. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16209. * @returns the current mesh
  16210. */
  16211. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16212. /** @hidden */
  16213. _preActivate(): InstancedMesh;
  16214. /** @hidden */
  16215. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16216. /** @hidden */
  16217. _postActivate(): void;
  16218. getWorldMatrix(): Matrix;
  16219. get isAnInstance(): boolean;
  16220. /**
  16221. * Returns the current associated LOD AbstractMesh.
  16222. */
  16223. getLOD(camera: Camera): AbstractMesh;
  16224. /** @hidden */
  16225. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16226. /** @hidden */
  16227. _syncSubMeshes(): InstancedMesh;
  16228. /** @hidden */
  16229. _generatePointsArray(): boolean;
  16230. /**
  16231. * Creates a new InstancedMesh from the current mesh.
  16232. * - name (string) : the cloned mesh name
  16233. * - newParent (optional Node) : the optional Node to parent the clone to.
  16234. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16235. *
  16236. * Returns the clone.
  16237. */
  16238. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16239. /**
  16240. * Disposes the InstancedMesh.
  16241. * Returns nothing.
  16242. */
  16243. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16244. }
  16245. interface Mesh {
  16246. /**
  16247. * Register a custom buffer that will be instanced
  16248. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16249. * @param kind defines the buffer kind
  16250. * @param stride defines the stride in floats
  16251. */
  16252. registerInstancedBuffer(kind: string, stride: number): void;
  16253. /** @hidden */
  16254. _userInstancedBuffersStorage: {
  16255. data: {
  16256. [key: string]: Float32Array;
  16257. };
  16258. sizes: {
  16259. [key: string]: number;
  16260. };
  16261. vertexBuffers: {
  16262. [key: string]: Nullable<VertexBuffer>;
  16263. };
  16264. strides: {
  16265. [key: string]: number;
  16266. };
  16267. };
  16268. }
  16269. interface AbstractMesh {
  16270. /**
  16271. * Object used to store instanced buffers defined by user
  16272. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16273. */
  16274. instancedBuffers: {
  16275. [key: string]: any;
  16276. };
  16277. }
  16278. }
  16279. declare module BABYLON {
  16280. /**
  16281. * Defines the options associated with the creation of a shader material.
  16282. */
  16283. export interface IShaderMaterialOptions {
  16284. /**
  16285. * Does the material work in alpha blend mode
  16286. */
  16287. needAlphaBlending: boolean;
  16288. /**
  16289. * Does the material work in alpha test mode
  16290. */
  16291. needAlphaTesting: boolean;
  16292. /**
  16293. * The list of attribute names used in the shader
  16294. */
  16295. attributes: string[];
  16296. /**
  16297. * The list of unifrom names used in the shader
  16298. */
  16299. uniforms: string[];
  16300. /**
  16301. * The list of UBO names used in the shader
  16302. */
  16303. uniformBuffers: string[];
  16304. /**
  16305. * The list of sampler names used in the shader
  16306. */
  16307. samplers: string[];
  16308. /**
  16309. * The list of defines used in the shader
  16310. */
  16311. defines: string[];
  16312. }
  16313. /**
  16314. * 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.
  16315. *
  16316. * This returned material effects how the mesh will look based on the code in the shaders.
  16317. *
  16318. * @see http://doc.babylonjs.com/how_to/shader_material
  16319. */
  16320. export class ShaderMaterial extends Material {
  16321. private _shaderPath;
  16322. private _options;
  16323. private _textures;
  16324. private _textureArrays;
  16325. private _floats;
  16326. private _ints;
  16327. private _floatsArrays;
  16328. private _colors3;
  16329. private _colors3Arrays;
  16330. private _colors4;
  16331. private _colors4Arrays;
  16332. private _vectors2;
  16333. private _vectors3;
  16334. private _vectors4;
  16335. private _matrices;
  16336. private _matrixArrays;
  16337. private _matrices3x3;
  16338. private _matrices2x2;
  16339. private _vectors2Arrays;
  16340. private _vectors3Arrays;
  16341. private _vectors4Arrays;
  16342. private _cachedWorldViewMatrix;
  16343. private _cachedWorldViewProjectionMatrix;
  16344. private _renderId;
  16345. private _multiview;
  16346. private _cachedDefines;
  16347. /**
  16348. * Instantiate a new shader material.
  16349. * 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.
  16350. * This returned material effects how the mesh will look based on the code in the shaders.
  16351. * @see http://doc.babylonjs.com/how_to/shader_material
  16352. * @param name Define the name of the material in the scene
  16353. * @param scene Define the scene the material belongs to
  16354. * @param shaderPath Defines the route to the shader code in one of three ways:
  16355. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16356. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16357. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16358. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16359. * @param options Define the options used to create the shader
  16360. */
  16361. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16362. /**
  16363. * Gets the shader path used to define the shader code
  16364. * It can be modified to trigger a new compilation
  16365. */
  16366. get shaderPath(): any;
  16367. /**
  16368. * Sets the shader path used to define the shader code
  16369. * It can be modified to trigger a new compilation
  16370. */
  16371. set shaderPath(shaderPath: any);
  16372. /**
  16373. * Gets the options used to compile the shader.
  16374. * They can be modified to trigger a new compilation
  16375. */
  16376. get options(): IShaderMaterialOptions;
  16377. /**
  16378. * Gets the current class name of the material e.g. "ShaderMaterial"
  16379. * Mainly use in serialization.
  16380. * @returns the class name
  16381. */
  16382. getClassName(): string;
  16383. /**
  16384. * Specifies if the material will require alpha blending
  16385. * @returns a boolean specifying if alpha blending is needed
  16386. */
  16387. needAlphaBlending(): boolean;
  16388. /**
  16389. * Specifies if this material should be rendered in alpha test mode
  16390. * @returns a boolean specifying if an alpha test is needed.
  16391. */
  16392. needAlphaTesting(): boolean;
  16393. private _checkUniform;
  16394. /**
  16395. * Set a texture in the shader.
  16396. * @param name Define the name of the uniform samplers as defined in the shader
  16397. * @param texture Define the texture to bind to this sampler
  16398. * @return the material itself allowing "fluent" like uniform updates
  16399. */
  16400. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16401. /**
  16402. * Set a texture array in the shader.
  16403. * @param name Define the name of the uniform sampler array as defined in the shader
  16404. * @param textures Define the list of textures to bind to this sampler
  16405. * @return the material itself allowing "fluent" like uniform updates
  16406. */
  16407. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16408. /**
  16409. * Set a float in the shader.
  16410. * @param name Define the name of the uniform as defined in the shader
  16411. * @param value Define the value to give to the uniform
  16412. * @return the material itself allowing "fluent" like uniform updates
  16413. */
  16414. setFloat(name: string, value: number): ShaderMaterial;
  16415. /**
  16416. * Set a int in the shader.
  16417. * @param name Define the name of the uniform as defined in the shader
  16418. * @param value Define the value to give to the uniform
  16419. * @return the material itself allowing "fluent" like uniform updates
  16420. */
  16421. setInt(name: string, value: number): ShaderMaterial;
  16422. /**
  16423. * Set an array of floats in the shader.
  16424. * @param name Define the name of the uniform as defined in the shader
  16425. * @param value Define the value to give to the uniform
  16426. * @return the material itself allowing "fluent" like uniform updates
  16427. */
  16428. setFloats(name: string, value: number[]): ShaderMaterial;
  16429. /**
  16430. * Set a vec3 in the shader from a Color3.
  16431. * @param name Define the name of the uniform as defined in the shader
  16432. * @param value Define the value to give to the uniform
  16433. * @return the material itself allowing "fluent" like uniform updates
  16434. */
  16435. setColor3(name: string, value: Color3): ShaderMaterial;
  16436. /**
  16437. * Set a vec3 array in the shader from a Color3 array.
  16438. * @param name Define the name of the uniform as defined in the shader
  16439. * @param value Define the value to give to the uniform
  16440. * @return the material itself allowing "fluent" like uniform updates
  16441. */
  16442. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16443. /**
  16444. * Set a vec4 in the shader from a Color4.
  16445. * @param name Define the name of the uniform as defined in the shader
  16446. * @param value Define the value to give to the uniform
  16447. * @return the material itself allowing "fluent" like uniform updates
  16448. */
  16449. setColor4(name: string, value: Color4): ShaderMaterial;
  16450. /**
  16451. * Set a vec4 array in the shader from a Color4 array.
  16452. * @param name Define the name of the uniform as defined in the shader
  16453. * @param value Define the value to give to the uniform
  16454. * @return the material itself allowing "fluent" like uniform updates
  16455. */
  16456. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16457. /**
  16458. * Set a vec2 in the shader from a Vector2.
  16459. * @param name Define the name of the uniform as defined in the shader
  16460. * @param value Define the value to give to the uniform
  16461. * @return the material itself allowing "fluent" like uniform updates
  16462. */
  16463. setVector2(name: string, value: Vector2): ShaderMaterial;
  16464. /**
  16465. * Set a vec3 in the shader from a Vector3.
  16466. * @param name Define the name of the uniform as defined in the shader
  16467. * @param value Define the value to give to the uniform
  16468. * @return the material itself allowing "fluent" like uniform updates
  16469. */
  16470. setVector3(name: string, value: Vector3): ShaderMaterial;
  16471. /**
  16472. * Set a vec4 in the shader from a Vector4.
  16473. * @param name Define the name of the uniform as defined in the shader
  16474. * @param value Define the value to give to the uniform
  16475. * @return the material itself allowing "fluent" like uniform updates
  16476. */
  16477. setVector4(name: string, value: Vector4): ShaderMaterial;
  16478. /**
  16479. * Set a mat4 in the shader from a Matrix.
  16480. * @param name Define the name of the uniform as defined in the shader
  16481. * @param value Define the value to give to the uniform
  16482. * @return the material itself allowing "fluent" like uniform updates
  16483. */
  16484. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16485. /**
  16486. * Set a float32Array in the shader from a matrix array.
  16487. * @param name Define the name of the uniform as defined in the shader
  16488. * @param value Define the value to give to the uniform
  16489. * @return the material itself allowing "fluent" like uniform updates
  16490. */
  16491. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16492. /**
  16493. * Set a mat3 in the shader from a Float32Array.
  16494. * @param name Define the name of the uniform as defined in the shader
  16495. * @param value Define the value to give to the uniform
  16496. * @return the material itself allowing "fluent" like uniform updates
  16497. */
  16498. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16499. /**
  16500. * Set a mat2 in the shader from a Float32Array.
  16501. * @param name Define the name of the uniform as defined in the shader
  16502. * @param value Define the value to give to the uniform
  16503. * @return the material itself allowing "fluent" like uniform updates
  16504. */
  16505. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16506. /**
  16507. * Set a vec2 array in the shader from a number array.
  16508. * @param name Define the name of the uniform as defined in the shader
  16509. * @param value Define the value to give to the uniform
  16510. * @return the material itself allowing "fluent" like uniform updates
  16511. */
  16512. setArray2(name: string, value: number[]): ShaderMaterial;
  16513. /**
  16514. * Set a vec3 array in the shader from a number array.
  16515. * @param name Define the name of the uniform as defined in the shader
  16516. * @param value Define the value to give to the uniform
  16517. * @return the material itself allowing "fluent" like uniform updates
  16518. */
  16519. setArray3(name: string, value: number[]): ShaderMaterial;
  16520. /**
  16521. * Set a vec4 array in the shader from a number array.
  16522. * @param name Define the name of the uniform as defined in the shader
  16523. * @param value Define the value to give to the uniform
  16524. * @return the material itself allowing "fluent" like uniform updates
  16525. */
  16526. setArray4(name: string, value: number[]): ShaderMaterial;
  16527. private _checkCache;
  16528. /**
  16529. * Specifies that the submesh is ready to be used
  16530. * @param mesh defines the mesh to check
  16531. * @param subMesh defines which submesh to check
  16532. * @param useInstances specifies that instances should be used
  16533. * @returns a boolean indicating that the submesh is ready or not
  16534. */
  16535. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16536. /**
  16537. * Checks if the material is ready to render the requested mesh
  16538. * @param mesh Define the mesh to render
  16539. * @param useInstances Define whether or not the material is used with instances
  16540. * @returns true if ready, otherwise false
  16541. */
  16542. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16543. /**
  16544. * Binds the world matrix to the material
  16545. * @param world defines the world transformation matrix
  16546. * @param effectOverride - If provided, use this effect instead of internal effect
  16547. */
  16548. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16549. /**
  16550. * Binds the submesh to this material by preparing the effect and shader to draw
  16551. * @param world defines the world transformation matrix
  16552. * @param mesh defines the mesh containing the submesh
  16553. * @param subMesh defines the submesh to bind the material to
  16554. */
  16555. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16556. /**
  16557. * Binds the material to the mesh
  16558. * @param world defines the world transformation matrix
  16559. * @param mesh defines the mesh to bind the material to
  16560. * @param effectOverride - If provided, use this effect instead of internal effect
  16561. */
  16562. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16563. protected _afterBind(mesh?: Mesh): void;
  16564. /**
  16565. * Gets the active textures from the material
  16566. * @returns an array of textures
  16567. */
  16568. getActiveTextures(): BaseTexture[];
  16569. /**
  16570. * Specifies if the material uses a texture
  16571. * @param texture defines the texture to check against the material
  16572. * @returns a boolean specifying if the material uses the texture
  16573. */
  16574. hasTexture(texture: BaseTexture): boolean;
  16575. /**
  16576. * Makes a duplicate of the material, and gives it a new name
  16577. * @param name defines the new name for the duplicated material
  16578. * @returns the cloned material
  16579. */
  16580. clone(name: string): ShaderMaterial;
  16581. /**
  16582. * Disposes the material
  16583. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16584. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16585. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16586. */
  16587. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16588. /**
  16589. * Serializes this material in a JSON representation
  16590. * @returns the serialized material object
  16591. */
  16592. serialize(): any;
  16593. /**
  16594. * Creates a shader material from parsed shader material data
  16595. * @param source defines the JSON represnetation of the material
  16596. * @param scene defines the hosting scene
  16597. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16598. * @returns a new material
  16599. */
  16600. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16601. }
  16602. }
  16603. declare module BABYLON {
  16604. /** @hidden */
  16605. export var colorPixelShader: {
  16606. name: string;
  16607. shader: string;
  16608. };
  16609. }
  16610. declare module BABYLON {
  16611. /** @hidden */
  16612. export var colorVertexShader: {
  16613. name: string;
  16614. shader: string;
  16615. };
  16616. }
  16617. declare module BABYLON {
  16618. /**
  16619. * Line mesh
  16620. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16621. */
  16622. export class LinesMesh extends Mesh {
  16623. /**
  16624. * If vertex color should be applied to the mesh
  16625. */
  16626. readonly useVertexColor?: boolean | undefined;
  16627. /**
  16628. * If vertex alpha should be applied to the mesh
  16629. */
  16630. readonly useVertexAlpha?: boolean | undefined;
  16631. /**
  16632. * Color of the line (Default: White)
  16633. */
  16634. color: Color3;
  16635. /**
  16636. * Alpha of the line (Default: 1)
  16637. */
  16638. alpha: number;
  16639. /**
  16640. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16641. * This margin is expressed in world space coordinates, so its value may vary.
  16642. * Default value is 0.1
  16643. */
  16644. intersectionThreshold: number;
  16645. private _colorShader;
  16646. private color4;
  16647. /**
  16648. * Creates a new LinesMesh
  16649. * @param name defines the name
  16650. * @param scene defines the hosting scene
  16651. * @param parent defines the parent mesh if any
  16652. * @param source defines the optional source LinesMesh used to clone data from
  16653. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16654. * When false, achieved by calling a clone(), also passing False.
  16655. * This will make creation of children, recursive.
  16656. * @param useVertexColor defines if this LinesMesh supports vertex color
  16657. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16658. */
  16659. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16660. /**
  16661. * If vertex color should be applied to the mesh
  16662. */
  16663. useVertexColor?: boolean | undefined,
  16664. /**
  16665. * If vertex alpha should be applied to the mesh
  16666. */
  16667. useVertexAlpha?: boolean | undefined);
  16668. private _addClipPlaneDefine;
  16669. private _removeClipPlaneDefine;
  16670. isReady(): boolean;
  16671. /**
  16672. * Returns the string "LineMesh"
  16673. */
  16674. getClassName(): string;
  16675. /**
  16676. * @hidden
  16677. */
  16678. get material(): Material;
  16679. /**
  16680. * @hidden
  16681. */
  16682. set material(value: Material);
  16683. /**
  16684. * @hidden
  16685. */
  16686. get checkCollisions(): boolean;
  16687. /** @hidden */
  16688. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16689. /** @hidden */
  16690. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16691. /**
  16692. * Disposes of the line mesh
  16693. * @param doNotRecurse If children should be disposed
  16694. */
  16695. dispose(doNotRecurse?: boolean): void;
  16696. /**
  16697. * Returns a new LineMesh object cloned from the current one.
  16698. */
  16699. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16700. /**
  16701. * Creates a new InstancedLinesMesh object from the mesh model.
  16702. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16703. * @param name defines the name of the new instance
  16704. * @returns a new InstancedLinesMesh
  16705. */
  16706. createInstance(name: string): InstancedLinesMesh;
  16707. }
  16708. /**
  16709. * Creates an instance based on a source LinesMesh
  16710. */
  16711. export class InstancedLinesMesh extends InstancedMesh {
  16712. /**
  16713. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16714. * This margin is expressed in world space coordinates, so its value may vary.
  16715. * Initilized with the intersectionThreshold value of the source LinesMesh
  16716. */
  16717. intersectionThreshold: number;
  16718. constructor(name: string, source: LinesMesh);
  16719. /**
  16720. * Returns the string "InstancedLinesMesh".
  16721. */
  16722. getClassName(): string;
  16723. }
  16724. }
  16725. declare module BABYLON {
  16726. /** @hidden */
  16727. export var linePixelShader: {
  16728. name: string;
  16729. shader: string;
  16730. };
  16731. }
  16732. declare module BABYLON {
  16733. /** @hidden */
  16734. export var lineVertexShader: {
  16735. name: string;
  16736. shader: string;
  16737. };
  16738. }
  16739. declare module BABYLON {
  16740. interface AbstractMesh {
  16741. /**
  16742. * Gets the edgesRenderer associated with the mesh
  16743. */
  16744. edgesRenderer: Nullable<EdgesRenderer>;
  16745. }
  16746. interface LinesMesh {
  16747. /**
  16748. * Enables the edge rendering mode on the mesh.
  16749. * This mode makes the mesh edges visible
  16750. * @param epsilon defines the maximal distance between two angles to detect a face
  16751. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16752. * @returns the currentAbstractMesh
  16753. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16754. */
  16755. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16756. }
  16757. interface InstancedLinesMesh {
  16758. /**
  16759. * Enables the edge rendering mode on the mesh.
  16760. * This mode makes the mesh edges visible
  16761. * @param epsilon defines the maximal distance between two angles to detect a face
  16762. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16763. * @returns the current InstancedLinesMesh
  16764. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16765. */
  16766. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16767. }
  16768. /**
  16769. * Defines the minimum contract an Edges renderer should follow.
  16770. */
  16771. export interface IEdgesRenderer extends IDisposable {
  16772. /**
  16773. * Gets or sets a boolean indicating if the edgesRenderer is active
  16774. */
  16775. isEnabled: boolean;
  16776. /**
  16777. * Renders the edges of the attached mesh,
  16778. */
  16779. render(): void;
  16780. /**
  16781. * Checks wether or not the edges renderer is ready to render.
  16782. * @return true if ready, otherwise false.
  16783. */
  16784. isReady(): boolean;
  16785. }
  16786. /**
  16787. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16788. */
  16789. export class EdgesRenderer implements IEdgesRenderer {
  16790. /**
  16791. * Define the size of the edges with an orthographic camera
  16792. */
  16793. edgesWidthScalerForOrthographic: number;
  16794. /**
  16795. * Define the size of the edges with a perspective camera
  16796. */
  16797. edgesWidthScalerForPerspective: number;
  16798. protected _source: AbstractMesh;
  16799. protected _linesPositions: number[];
  16800. protected _linesNormals: number[];
  16801. protected _linesIndices: number[];
  16802. protected _epsilon: number;
  16803. protected _indicesCount: number;
  16804. protected _lineShader: ShaderMaterial;
  16805. protected _ib: DataBuffer;
  16806. protected _buffers: {
  16807. [key: string]: Nullable<VertexBuffer>;
  16808. };
  16809. protected _checkVerticesInsteadOfIndices: boolean;
  16810. private _meshRebuildObserver;
  16811. private _meshDisposeObserver;
  16812. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16813. isEnabled: boolean;
  16814. /**
  16815. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16816. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16817. * @param source Mesh used to create edges
  16818. * @param epsilon sum of angles in adjacency to check for edge
  16819. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16820. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16821. */
  16822. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16823. protected _prepareRessources(): void;
  16824. /** @hidden */
  16825. _rebuild(): void;
  16826. /**
  16827. * Releases the required resources for the edges renderer
  16828. */
  16829. dispose(): void;
  16830. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16831. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16832. /**
  16833. * Checks if the pair of p0 and p1 is en edge
  16834. * @param faceIndex
  16835. * @param edge
  16836. * @param faceNormals
  16837. * @param p0
  16838. * @param p1
  16839. * @private
  16840. */
  16841. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16842. /**
  16843. * push line into the position, normal and index buffer
  16844. * @protected
  16845. */
  16846. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16847. /**
  16848. * Generates lines edges from adjacencjes
  16849. * @private
  16850. */
  16851. _generateEdgesLines(): void;
  16852. /**
  16853. * Checks wether or not the edges renderer is ready to render.
  16854. * @return true if ready, otherwise false.
  16855. */
  16856. isReady(): boolean;
  16857. /**
  16858. * Renders the edges of the attached mesh,
  16859. */
  16860. render(): void;
  16861. }
  16862. /**
  16863. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16864. */
  16865. export class LineEdgesRenderer extends EdgesRenderer {
  16866. /**
  16867. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16868. * @param source LineMesh used to generate edges
  16869. * @param epsilon not important (specified angle for edge detection)
  16870. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16871. */
  16872. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16873. /**
  16874. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16875. */
  16876. _generateEdgesLines(): void;
  16877. }
  16878. }
  16879. declare module BABYLON {
  16880. /**
  16881. * This represents the object necessary to create a rendering group.
  16882. * This is exclusively used and created by the rendering manager.
  16883. * To modify the behavior, you use the available helpers in your scene or meshes.
  16884. * @hidden
  16885. */
  16886. export class RenderingGroup {
  16887. index: number;
  16888. private static _zeroVector;
  16889. private _scene;
  16890. private _opaqueSubMeshes;
  16891. private _transparentSubMeshes;
  16892. private _alphaTestSubMeshes;
  16893. private _depthOnlySubMeshes;
  16894. private _particleSystems;
  16895. private _spriteManagers;
  16896. private _opaqueSortCompareFn;
  16897. private _alphaTestSortCompareFn;
  16898. private _transparentSortCompareFn;
  16899. private _renderOpaque;
  16900. private _renderAlphaTest;
  16901. private _renderTransparent;
  16902. /** @hidden */
  16903. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16904. onBeforeTransparentRendering: () => void;
  16905. /**
  16906. * Set the opaque sort comparison function.
  16907. * If null the sub meshes will be render in the order they were created
  16908. */
  16909. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16910. /**
  16911. * Set the alpha test sort comparison function.
  16912. * If null the sub meshes will be render in the order they were created
  16913. */
  16914. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16915. /**
  16916. * Set the transparent sort comparison function.
  16917. * If null the sub meshes will be render in the order they were created
  16918. */
  16919. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16920. /**
  16921. * Creates a new rendering group.
  16922. * @param index The rendering group index
  16923. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16924. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16925. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16926. */
  16927. 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>);
  16928. /**
  16929. * Render all the sub meshes contained in the group.
  16930. * @param customRenderFunction Used to override the default render behaviour of the group.
  16931. * @returns true if rendered some submeshes.
  16932. */
  16933. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16934. /**
  16935. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16936. * @param subMeshes The submeshes to render
  16937. */
  16938. private renderOpaqueSorted;
  16939. /**
  16940. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16941. * @param subMeshes The submeshes to render
  16942. */
  16943. private renderAlphaTestSorted;
  16944. /**
  16945. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16946. * @param subMeshes The submeshes to render
  16947. */
  16948. private renderTransparentSorted;
  16949. /**
  16950. * Renders the submeshes in a specified order.
  16951. * @param subMeshes The submeshes to sort before render
  16952. * @param sortCompareFn The comparison function use to sort
  16953. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16954. * @param transparent Specifies to activate blending if true
  16955. */
  16956. private static renderSorted;
  16957. /**
  16958. * Renders the submeshes in the order they were dispatched (no sort applied).
  16959. * @param subMeshes The submeshes to render
  16960. */
  16961. private static renderUnsorted;
  16962. /**
  16963. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16964. * are rendered back to front if in the same alpha index.
  16965. *
  16966. * @param a The first submesh
  16967. * @param b The second submesh
  16968. * @returns The result of the comparison
  16969. */
  16970. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16971. /**
  16972. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16973. * are rendered back to front.
  16974. *
  16975. * @param a The first submesh
  16976. * @param b The second submesh
  16977. * @returns The result of the comparison
  16978. */
  16979. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16980. /**
  16981. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16982. * are rendered front to back (prevent overdraw).
  16983. *
  16984. * @param a The first submesh
  16985. * @param b The second submesh
  16986. * @returns The result of the comparison
  16987. */
  16988. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16989. /**
  16990. * Resets the different lists of submeshes to prepare a new frame.
  16991. */
  16992. prepare(): void;
  16993. dispose(): void;
  16994. /**
  16995. * Inserts the submesh in its correct queue depending on its material.
  16996. * @param subMesh The submesh to dispatch
  16997. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16998. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16999. */
  17000. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17001. dispatchSprites(spriteManager: ISpriteManager): void;
  17002. dispatchParticles(particleSystem: IParticleSystem): void;
  17003. private _renderParticles;
  17004. private _renderSprites;
  17005. }
  17006. }
  17007. declare module BABYLON {
  17008. /**
  17009. * Interface describing the different options available in the rendering manager
  17010. * regarding Auto Clear between groups.
  17011. */
  17012. export interface IRenderingManagerAutoClearSetup {
  17013. /**
  17014. * Defines whether or not autoclear is enable.
  17015. */
  17016. autoClear: boolean;
  17017. /**
  17018. * Defines whether or not to autoclear the depth buffer.
  17019. */
  17020. depth: boolean;
  17021. /**
  17022. * Defines whether or not to autoclear the stencil buffer.
  17023. */
  17024. stencil: boolean;
  17025. }
  17026. /**
  17027. * This class is used by the onRenderingGroupObservable
  17028. */
  17029. export class RenderingGroupInfo {
  17030. /**
  17031. * The Scene that being rendered
  17032. */
  17033. scene: Scene;
  17034. /**
  17035. * The camera currently used for the rendering pass
  17036. */
  17037. camera: Nullable<Camera>;
  17038. /**
  17039. * The ID of the renderingGroup being processed
  17040. */
  17041. renderingGroupId: number;
  17042. }
  17043. /**
  17044. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17045. * It is enable to manage the different groups as well as the different necessary sort functions.
  17046. * This should not be used directly aside of the few static configurations
  17047. */
  17048. export class RenderingManager {
  17049. /**
  17050. * The max id used for rendering groups (not included)
  17051. */
  17052. static MAX_RENDERINGGROUPS: number;
  17053. /**
  17054. * The min id used for rendering groups (included)
  17055. */
  17056. static MIN_RENDERINGGROUPS: number;
  17057. /**
  17058. * Used to globally prevent autoclearing scenes.
  17059. */
  17060. static AUTOCLEAR: boolean;
  17061. /**
  17062. * @hidden
  17063. */
  17064. _useSceneAutoClearSetup: boolean;
  17065. private _scene;
  17066. private _renderingGroups;
  17067. private _depthStencilBufferAlreadyCleaned;
  17068. private _autoClearDepthStencil;
  17069. private _customOpaqueSortCompareFn;
  17070. private _customAlphaTestSortCompareFn;
  17071. private _customTransparentSortCompareFn;
  17072. private _renderingGroupInfo;
  17073. /**
  17074. * Instantiates a new rendering group for a particular scene
  17075. * @param scene Defines the scene the groups belongs to
  17076. */
  17077. constructor(scene: Scene);
  17078. private _clearDepthStencilBuffer;
  17079. /**
  17080. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17081. * @hidden
  17082. */
  17083. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17084. /**
  17085. * Resets the different information of the group to prepare a new frame
  17086. * @hidden
  17087. */
  17088. reset(): void;
  17089. /**
  17090. * Dispose and release the group and its associated resources.
  17091. * @hidden
  17092. */
  17093. dispose(): void;
  17094. /**
  17095. * Clear the info related to rendering groups preventing retention points during dispose.
  17096. */
  17097. freeRenderingGroups(): void;
  17098. private _prepareRenderingGroup;
  17099. /**
  17100. * Add a sprite manager to the rendering manager in order to render it this frame.
  17101. * @param spriteManager Define the sprite manager to render
  17102. */
  17103. dispatchSprites(spriteManager: ISpriteManager): void;
  17104. /**
  17105. * Add a particle system to the rendering manager in order to render it this frame.
  17106. * @param particleSystem Define the particle system to render
  17107. */
  17108. dispatchParticles(particleSystem: IParticleSystem): void;
  17109. /**
  17110. * Add a submesh to the manager in order to render it this frame
  17111. * @param subMesh The submesh to dispatch
  17112. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17113. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17114. */
  17115. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17116. /**
  17117. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17118. * This allowed control for front to back rendering or reversly depending of the special needs.
  17119. *
  17120. * @param renderingGroupId The rendering group id corresponding to its index
  17121. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17122. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17123. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17124. */
  17125. 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;
  17126. /**
  17127. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17128. *
  17129. * @param renderingGroupId The rendering group id corresponding to its index
  17130. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17131. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17132. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17133. */
  17134. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17135. /**
  17136. * Gets the current auto clear configuration for one rendering group of the rendering
  17137. * manager.
  17138. * @param index the rendering group index to get the information for
  17139. * @returns The auto clear setup for the requested rendering group
  17140. */
  17141. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17142. }
  17143. }
  17144. declare module BABYLON {
  17145. /**
  17146. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17147. */
  17148. export interface ICustomShaderOptions {
  17149. /**
  17150. * Gets or sets the custom shader name to use
  17151. */
  17152. shaderName: string;
  17153. /**
  17154. * The list of attribute names used in the shader
  17155. */
  17156. attributes?: string[];
  17157. /**
  17158. * The list of unifrom names used in the shader
  17159. */
  17160. uniforms?: string[];
  17161. /**
  17162. * The list of sampler names used in the shader
  17163. */
  17164. samplers?: string[];
  17165. /**
  17166. * The list of defines used in the shader
  17167. */
  17168. defines?: string[];
  17169. }
  17170. /**
  17171. * Interface to implement to create a shadow generator compatible with BJS.
  17172. */
  17173. export interface IShadowGenerator {
  17174. /**
  17175. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17176. * @returns The render target texture if present otherwise, null
  17177. */
  17178. getShadowMap(): Nullable<RenderTargetTexture>;
  17179. /**
  17180. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17181. * @param subMesh The submesh we want to render in the shadow map
  17182. * @param useInstances Defines wether will draw in the map using instances
  17183. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17184. * @returns true if ready otherwise, false
  17185. */
  17186. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17187. /**
  17188. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17189. * @param defines Defines of the material we want to update
  17190. * @param lightIndex Index of the light in the enabled light list of the material
  17191. */
  17192. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17193. /**
  17194. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17195. * defined in the generator but impacting the effect).
  17196. * It implies the unifroms available on the materials are the standard BJS ones.
  17197. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17198. * @param effect The effect we are binfing the information for
  17199. */
  17200. bindShadowLight(lightIndex: string, effect: Effect): void;
  17201. /**
  17202. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17203. * (eq to shadow prjection matrix * light transform matrix)
  17204. * @returns The transform matrix used to create the shadow map
  17205. */
  17206. getTransformMatrix(): Matrix;
  17207. /**
  17208. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17209. * Cube and 2D textures for instance.
  17210. */
  17211. recreateShadowMap(): void;
  17212. /**
  17213. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17214. * @param onCompiled Callback triggered at the and of the effects compilation
  17215. * @param options Sets of optional options forcing the compilation with different modes
  17216. */
  17217. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17218. useInstances: boolean;
  17219. }>): void;
  17220. /**
  17221. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17222. * @param options Sets of optional options forcing the compilation with different modes
  17223. * @returns A promise that resolves when the compilation completes
  17224. */
  17225. forceCompilationAsync(options?: Partial<{
  17226. useInstances: boolean;
  17227. }>): Promise<void>;
  17228. /**
  17229. * Serializes the shadow generator setup to a json object.
  17230. * @returns The serialized JSON object
  17231. */
  17232. serialize(): any;
  17233. /**
  17234. * Disposes the Shadow map and related Textures and effects.
  17235. */
  17236. dispose(): void;
  17237. }
  17238. /**
  17239. * Default implementation IShadowGenerator.
  17240. * This is the main object responsible of generating shadows in the framework.
  17241. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17242. */
  17243. export class ShadowGenerator implements IShadowGenerator {
  17244. /**
  17245. * Name of the shadow generator class
  17246. */
  17247. static CLASSNAME: string;
  17248. /**
  17249. * Shadow generator mode None: no filtering applied.
  17250. */
  17251. static readonly FILTER_NONE: number;
  17252. /**
  17253. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17254. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17255. */
  17256. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17257. /**
  17258. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17259. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17260. */
  17261. static readonly FILTER_POISSONSAMPLING: number;
  17262. /**
  17263. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17264. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17265. */
  17266. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17267. /**
  17268. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17269. * edge artifacts on steep falloff.
  17270. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17271. */
  17272. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17273. /**
  17274. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17275. * edge artifacts on steep falloff.
  17276. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17277. */
  17278. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17279. /**
  17280. * Shadow generator mode PCF: Percentage Closer Filtering
  17281. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17282. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17283. */
  17284. static readonly FILTER_PCF: number;
  17285. /**
  17286. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17287. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17288. * Contact Hardening
  17289. */
  17290. static readonly FILTER_PCSS: number;
  17291. /**
  17292. * Reserved for PCF and PCSS
  17293. * Highest Quality.
  17294. *
  17295. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17296. *
  17297. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17298. */
  17299. static readonly QUALITY_HIGH: number;
  17300. /**
  17301. * Reserved for PCF and PCSS
  17302. * Good tradeoff for quality/perf cross devices
  17303. *
  17304. * Execute PCF on a 3*3 kernel.
  17305. *
  17306. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17307. */
  17308. static readonly QUALITY_MEDIUM: number;
  17309. /**
  17310. * Reserved for PCF and PCSS
  17311. * The lowest quality but the fastest.
  17312. *
  17313. * Execute PCF on a 1*1 kernel.
  17314. *
  17315. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17316. */
  17317. static readonly QUALITY_LOW: number;
  17318. /** Gets or sets the custom shader name to use */
  17319. customShaderOptions: ICustomShaderOptions;
  17320. /**
  17321. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17322. */
  17323. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17324. /**
  17325. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17326. */
  17327. onAfterShadowMapRenderObservable: Observable<Effect>;
  17328. /**
  17329. * Observable triggered before a mesh is rendered in the shadow map.
  17330. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17331. */
  17332. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17333. /**
  17334. * Observable triggered after a mesh is rendered in the shadow map.
  17335. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17336. */
  17337. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17338. protected _bias: number;
  17339. /**
  17340. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17341. */
  17342. get bias(): number;
  17343. /**
  17344. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17345. */
  17346. set bias(bias: number);
  17347. protected _normalBias: number;
  17348. /**
  17349. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17350. */
  17351. get normalBias(): number;
  17352. /**
  17353. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17354. */
  17355. set normalBias(normalBias: number);
  17356. protected _blurBoxOffset: number;
  17357. /**
  17358. * Gets the blur box offset: offset applied during the blur pass.
  17359. * Only useful if useKernelBlur = false
  17360. */
  17361. get blurBoxOffset(): number;
  17362. /**
  17363. * Sets the blur box offset: offset applied during the blur pass.
  17364. * Only useful if useKernelBlur = false
  17365. */
  17366. set blurBoxOffset(value: number);
  17367. protected _blurScale: number;
  17368. /**
  17369. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17370. * 2 means half of the size.
  17371. */
  17372. get blurScale(): number;
  17373. /**
  17374. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17375. * 2 means half of the size.
  17376. */
  17377. set blurScale(value: number);
  17378. protected _blurKernel: number;
  17379. /**
  17380. * Gets the blur kernel: kernel size of the blur pass.
  17381. * Only useful if useKernelBlur = true
  17382. */
  17383. get blurKernel(): number;
  17384. /**
  17385. * Sets the blur kernel: kernel size of the blur pass.
  17386. * Only useful if useKernelBlur = true
  17387. */
  17388. set blurKernel(value: number);
  17389. protected _useKernelBlur: boolean;
  17390. /**
  17391. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17392. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17393. */
  17394. get useKernelBlur(): boolean;
  17395. /**
  17396. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17397. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17398. */
  17399. set useKernelBlur(value: boolean);
  17400. protected _depthScale: number;
  17401. /**
  17402. * Gets the depth scale used in ESM mode.
  17403. */
  17404. get depthScale(): number;
  17405. /**
  17406. * Sets the depth scale used in ESM mode.
  17407. * This can override the scale stored on the light.
  17408. */
  17409. set depthScale(value: number);
  17410. protected _validateFilter(filter: number): number;
  17411. protected _filter: number;
  17412. /**
  17413. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17414. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17415. */
  17416. get filter(): number;
  17417. /**
  17418. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17419. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17420. */
  17421. set filter(value: number);
  17422. /**
  17423. * Gets if the current filter is set to Poisson Sampling.
  17424. */
  17425. get usePoissonSampling(): boolean;
  17426. /**
  17427. * Sets the current filter to Poisson Sampling.
  17428. */
  17429. set usePoissonSampling(value: boolean);
  17430. /**
  17431. * Gets if the current filter is set to ESM.
  17432. */
  17433. get useExponentialShadowMap(): boolean;
  17434. /**
  17435. * Sets the current filter is to ESM.
  17436. */
  17437. set useExponentialShadowMap(value: boolean);
  17438. /**
  17439. * Gets if the current filter is set to filtered ESM.
  17440. */
  17441. get useBlurExponentialShadowMap(): boolean;
  17442. /**
  17443. * Gets if the current filter is set to filtered ESM.
  17444. */
  17445. set useBlurExponentialShadowMap(value: boolean);
  17446. /**
  17447. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17448. * exponential to prevent steep falloff artifacts).
  17449. */
  17450. get useCloseExponentialShadowMap(): boolean;
  17451. /**
  17452. * Sets the current filter to "close ESM" (using the inverse of the
  17453. * exponential to prevent steep falloff artifacts).
  17454. */
  17455. set useCloseExponentialShadowMap(value: boolean);
  17456. /**
  17457. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17458. * exponential to prevent steep falloff artifacts).
  17459. */
  17460. get useBlurCloseExponentialShadowMap(): boolean;
  17461. /**
  17462. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17463. * exponential to prevent steep falloff artifacts).
  17464. */
  17465. set useBlurCloseExponentialShadowMap(value: boolean);
  17466. /**
  17467. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17468. */
  17469. get usePercentageCloserFiltering(): boolean;
  17470. /**
  17471. * Sets the current filter to "PCF" (percentage closer filtering).
  17472. */
  17473. set usePercentageCloserFiltering(value: boolean);
  17474. protected _filteringQuality: number;
  17475. /**
  17476. * Gets the PCF or PCSS Quality.
  17477. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17478. */
  17479. get filteringQuality(): number;
  17480. /**
  17481. * Sets the PCF or PCSS Quality.
  17482. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17483. */
  17484. set filteringQuality(filteringQuality: number);
  17485. /**
  17486. * Gets if the current filter is set to "PCSS" (contact hardening).
  17487. */
  17488. get useContactHardeningShadow(): boolean;
  17489. /**
  17490. * Sets the current filter to "PCSS" (contact hardening).
  17491. */
  17492. set useContactHardeningShadow(value: boolean);
  17493. protected _contactHardeningLightSizeUVRatio: number;
  17494. /**
  17495. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17496. * Using a ratio helps keeping shape stability independently of the map size.
  17497. *
  17498. * It does not account for the light projection as it was having too much
  17499. * instability during the light setup or during light position changes.
  17500. *
  17501. * Only valid if useContactHardeningShadow is true.
  17502. */
  17503. get contactHardeningLightSizeUVRatio(): number;
  17504. /**
  17505. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17506. * Using a ratio helps keeping shape stability independently of the map size.
  17507. *
  17508. * It does not account for the light projection as it was having too much
  17509. * instability during the light setup or during light position changes.
  17510. *
  17511. * Only valid if useContactHardeningShadow is true.
  17512. */
  17513. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17514. protected _darkness: number;
  17515. /** Gets or sets the actual darkness of a shadow */
  17516. get darkness(): number;
  17517. set darkness(value: number);
  17518. /**
  17519. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17520. * 0 means strongest and 1 would means no shadow.
  17521. * @returns the darkness.
  17522. */
  17523. getDarkness(): number;
  17524. /**
  17525. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17526. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17527. * @returns the shadow generator allowing fluent coding.
  17528. */
  17529. setDarkness(darkness: number): ShadowGenerator;
  17530. protected _transparencyShadow: boolean;
  17531. /** Gets or sets the ability to have transparent shadow */
  17532. get transparencyShadow(): boolean;
  17533. set transparencyShadow(value: boolean);
  17534. /**
  17535. * Sets the ability to have transparent shadow (boolean).
  17536. * @param transparent True if transparent else False
  17537. * @returns the shadow generator allowing fluent coding
  17538. */
  17539. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17540. /**
  17541. * Enables or disables shadows with varying strength based on the transparency
  17542. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17543. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17544. * mesh.visibility * alphaTexture.a
  17545. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17546. */
  17547. enableSoftTransparentShadow: boolean;
  17548. protected _shadowMap: Nullable<RenderTargetTexture>;
  17549. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17550. /**
  17551. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17552. * @returns The render target texture if present otherwise, null
  17553. */
  17554. getShadowMap(): Nullable<RenderTargetTexture>;
  17555. /**
  17556. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17557. * @returns The render target texture if the shadow map is present otherwise, null
  17558. */
  17559. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17560. /**
  17561. * Gets the class name of that object
  17562. * @returns "ShadowGenerator"
  17563. */
  17564. getClassName(): string;
  17565. /**
  17566. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17567. * @param mesh Mesh to add
  17568. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17569. * @returns the Shadow Generator itself
  17570. */
  17571. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17572. /**
  17573. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17574. * @param mesh Mesh to remove
  17575. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17576. * @returns the Shadow Generator itself
  17577. */
  17578. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17579. /**
  17580. * Controls the extent to which the shadows fade out at the edge of the frustum
  17581. */
  17582. frustumEdgeFalloff: number;
  17583. protected _light: IShadowLight;
  17584. /**
  17585. * Returns the associated light object.
  17586. * @returns the light generating the shadow
  17587. */
  17588. getLight(): IShadowLight;
  17589. /**
  17590. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17591. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17592. * It might on the other hand introduce peter panning.
  17593. */
  17594. forceBackFacesOnly: boolean;
  17595. protected _scene: Scene;
  17596. protected _lightDirection: Vector3;
  17597. protected _effect: Effect;
  17598. protected _viewMatrix: Matrix;
  17599. protected _projectionMatrix: Matrix;
  17600. protected _transformMatrix: Matrix;
  17601. protected _cachedPosition: Vector3;
  17602. protected _cachedDirection: Vector3;
  17603. protected _cachedDefines: string;
  17604. protected _currentRenderID: number;
  17605. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17606. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17607. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17608. protected _blurPostProcesses: PostProcess[];
  17609. protected _mapSize: number;
  17610. protected _currentFaceIndex: number;
  17611. protected _currentFaceIndexCache: number;
  17612. protected _textureType: number;
  17613. protected _defaultTextureMatrix: Matrix;
  17614. protected _storedUniqueId: Nullable<number>;
  17615. /** @hidden */
  17616. static _SceneComponentInitialization: (scene: Scene) => void;
  17617. /**
  17618. * Creates a ShadowGenerator object.
  17619. * A ShadowGenerator is the required tool to use the shadows.
  17620. * Each light casting shadows needs to use its own ShadowGenerator.
  17621. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17622. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17623. * @param light The light object generating the shadows.
  17624. * @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.
  17625. */
  17626. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17627. protected _initializeGenerator(): void;
  17628. protected _createTargetRenderTexture(): void;
  17629. protected _initializeShadowMap(): void;
  17630. protected _initializeBlurRTTAndPostProcesses(): void;
  17631. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17632. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17633. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17634. protected _applyFilterValues(): void;
  17635. /**
  17636. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17637. * @param onCompiled Callback triggered at the and of the effects compilation
  17638. * @param options Sets of optional options forcing the compilation with different modes
  17639. */
  17640. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17641. useInstances: boolean;
  17642. }>): void;
  17643. /**
  17644. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17645. * @param options Sets of optional options forcing the compilation with different modes
  17646. * @returns A promise that resolves when the compilation completes
  17647. */
  17648. forceCompilationAsync(options?: Partial<{
  17649. useInstances: boolean;
  17650. }>): Promise<void>;
  17651. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17652. private _prepareShadowDefines;
  17653. /**
  17654. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17655. * @param subMesh The submesh we want to render in the shadow map
  17656. * @param useInstances Defines wether will draw in the map using instances
  17657. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17658. * @returns true if ready otherwise, false
  17659. */
  17660. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17661. /**
  17662. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17663. * @param defines Defines of the material we want to update
  17664. * @param lightIndex Index of the light in the enabled light list of the material
  17665. */
  17666. prepareDefines(defines: any, lightIndex: number): void;
  17667. /**
  17668. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17669. * defined in the generator but impacting the effect).
  17670. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17671. * @param effect The effect we are binfing the information for
  17672. */
  17673. bindShadowLight(lightIndex: string, effect: Effect): void;
  17674. /**
  17675. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17676. * (eq to shadow prjection matrix * light transform matrix)
  17677. * @returns The transform matrix used to create the shadow map
  17678. */
  17679. getTransformMatrix(): Matrix;
  17680. /**
  17681. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17682. * Cube and 2D textures for instance.
  17683. */
  17684. recreateShadowMap(): void;
  17685. protected _disposeBlurPostProcesses(): void;
  17686. protected _disposeRTTandPostProcesses(): void;
  17687. /**
  17688. * Disposes the ShadowGenerator.
  17689. * Returns nothing.
  17690. */
  17691. dispose(): void;
  17692. /**
  17693. * Serializes the shadow generator setup to a json object.
  17694. * @returns The serialized JSON object
  17695. */
  17696. serialize(): any;
  17697. /**
  17698. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17699. * @param parsedShadowGenerator The JSON object to parse
  17700. * @param scene The scene to create the shadow map for
  17701. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17702. * @returns The parsed shadow generator
  17703. */
  17704. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17705. }
  17706. }
  17707. declare module BABYLON {
  17708. /**
  17709. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17710. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17711. * 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.
  17712. */
  17713. export abstract class Light extends Node {
  17714. /**
  17715. * Falloff Default: light is falling off following the material specification:
  17716. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17717. */
  17718. static readonly FALLOFF_DEFAULT: number;
  17719. /**
  17720. * Falloff Physical: light is falling off following the inverse squared distance law.
  17721. */
  17722. static readonly FALLOFF_PHYSICAL: number;
  17723. /**
  17724. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17725. * to enhance interoperability with other engines.
  17726. */
  17727. static readonly FALLOFF_GLTF: number;
  17728. /**
  17729. * Falloff Standard: light is falling off like in the standard material
  17730. * to enhance interoperability with other materials.
  17731. */
  17732. static readonly FALLOFF_STANDARD: number;
  17733. /**
  17734. * If every light affecting the material is in this lightmapMode,
  17735. * material.lightmapTexture adds or multiplies
  17736. * (depends on material.useLightmapAsShadowmap)
  17737. * after every other light calculations.
  17738. */
  17739. static readonly LIGHTMAP_DEFAULT: number;
  17740. /**
  17741. * material.lightmapTexture as only diffuse lighting from this light
  17742. * adds only specular lighting from this light
  17743. * adds dynamic shadows
  17744. */
  17745. static readonly LIGHTMAP_SPECULAR: number;
  17746. /**
  17747. * material.lightmapTexture as only lighting
  17748. * no light calculation from this light
  17749. * only adds dynamic shadows from this light
  17750. */
  17751. static readonly LIGHTMAP_SHADOWSONLY: number;
  17752. /**
  17753. * Each light type uses the default quantity according to its type:
  17754. * point/spot lights use luminous intensity
  17755. * directional lights use illuminance
  17756. */
  17757. static readonly INTENSITYMODE_AUTOMATIC: number;
  17758. /**
  17759. * lumen (lm)
  17760. */
  17761. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17762. /**
  17763. * candela (lm/sr)
  17764. */
  17765. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17766. /**
  17767. * lux (lm/m^2)
  17768. */
  17769. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17770. /**
  17771. * nit (cd/m^2)
  17772. */
  17773. static readonly INTENSITYMODE_LUMINANCE: number;
  17774. /**
  17775. * Light type const id of the point light.
  17776. */
  17777. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17778. /**
  17779. * Light type const id of the directional light.
  17780. */
  17781. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17782. /**
  17783. * Light type const id of the spot light.
  17784. */
  17785. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17786. /**
  17787. * Light type const id of the hemispheric light.
  17788. */
  17789. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17790. /**
  17791. * Diffuse gives the basic color to an object.
  17792. */
  17793. diffuse: Color3;
  17794. /**
  17795. * Specular produces a highlight color on an object.
  17796. * Note: This is note affecting PBR materials.
  17797. */
  17798. specular: Color3;
  17799. /**
  17800. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17801. * falling off base on range or angle.
  17802. * This can be set to any values in Light.FALLOFF_x.
  17803. *
  17804. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17805. * other types of materials.
  17806. */
  17807. falloffType: number;
  17808. /**
  17809. * Strength of the light.
  17810. * Note: By default it is define in the framework own unit.
  17811. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17812. */
  17813. intensity: number;
  17814. private _range;
  17815. protected _inverseSquaredRange: number;
  17816. /**
  17817. * Defines how far from the source the light is impacting in scene units.
  17818. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17819. */
  17820. get range(): number;
  17821. /**
  17822. * Defines how far from the source the light is impacting in scene units.
  17823. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17824. */
  17825. set range(value: number);
  17826. /**
  17827. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17828. * of light.
  17829. */
  17830. private _photometricScale;
  17831. private _intensityMode;
  17832. /**
  17833. * Gets the photometric scale used to interpret the intensity.
  17834. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17835. */
  17836. get intensityMode(): number;
  17837. /**
  17838. * Sets the photometric scale used to interpret the intensity.
  17839. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17840. */
  17841. set intensityMode(value: number);
  17842. private _radius;
  17843. /**
  17844. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17845. */
  17846. get radius(): number;
  17847. /**
  17848. * sets the light radius used by PBR Materials to simulate soft area lights.
  17849. */
  17850. set radius(value: number);
  17851. private _renderPriority;
  17852. /**
  17853. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17854. * exceeding the number allowed of the materials.
  17855. */
  17856. renderPriority: number;
  17857. private _shadowEnabled;
  17858. /**
  17859. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17860. * the current shadow generator.
  17861. */
  17862. get shadowEnabled(): boolean;
  17863. /**
  17864. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17865. * the current shadow generator.
  17866. */
  17867. set shadowEnabled(value: boolean);
  17868. private _includedOnlyMeshes;
  17869. /**
  17870. * Gets the only meshes impacted by this light.
  17871. */
  17872. get includedOnlyMeshes(): AbstractMesh[];
  17873. /**
  17874. * Sets the only meshes impacted by this light.
  17875. */
  17876. set includedOnlyMeshes(value: AbstractMesh[]);
  17877. private _excludedMeshes;
  17878. /**
  17879. * Gets the meshes not impacted by this light.
  17880. */
  17881. get excludedMeshes(): AbstractMesh[];
  17882. /**
  17883. * Sets the meshes not impacted by this light.
  17884. */
  17885. set excludedMeshes(value: AbstractMesh[]);
  17886. private _excludeWithLayerMask;
  17887. /**
  17888. * Gets the layer id use to find what meshes are not impacted by the light.
  17889. * Inactive if 0
  17890. */
  17891. get excludeWithLayerMask(): number;
  17892. /**
  17893. * Sets the layer id use to find what meshes are not impacted by the light.
  17894. * Inactive if 0
  17895. */
  17896. set excludeWithLayerMask(value: number);
  17897. private _includeOnlyWithLayerMask;
  17898. /**
  17899. * Gets the layer id use to find what meshes are impacted by the light.
  17900. * Inactive if 0
  17901. */
  17902. get includeOnlyWithLayerMask(): number;
  17903. /**
  17904. * Sets the layer id use to find what meshes are impacted by the light.
  17905. * Inactive if 0
  17906. */
  17907. set includeOnlyWithLayerMask(value: number);
  17908. private _lightmapMode;
  17909. /**
  17910. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17911. */
  17912. get lightmapMode(): number;
  17913. /**
  17914. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17915. */
  17916. set lightmapMode(value: number);
  17917. /**
  17918. * Shadow generator associted to the light.
  17919. * @hidden Internal use only.
  17920. */
  17921. _shadowGenerator: Nullable<IShadowGenerator>;
  17922. /**
  17923. * @hidden Internal use only.
  17924. */
  17925. _excludedMeshesIds: string[];
  17926. /**
  17927. * @hidden Internal use only.
  17928. */
  17929. _includedOnlyMeshesIds: string[];
  17930. /**
  17931. * The current light unifom buffer.
  17932. * @hidden Internal use only.
  17933. */
  17934. _uniformBuffer: UniformBuffer;
  17935. /** @hidden */
  17936. _renderId: number;
  17937. /**
  17938. * Creates a Light object in the scene.
  17939. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17940. * @param name The firendly name of the light
  17941. * @param scene The scene the light belongs too
  17942. */
  17943. constructor(name: string, scene: Scene);
  17944. protected abstract _buildUniformLayout(): void;
  17945. /**
  17946. * Sets the passed Effect "effect" with the Light information.
  17947. * @param effect The effect to update
  17948. * @param lightIndex The index of the light in the effect to update
  17949. * @returns The light
  17950. */
  17951. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17952. /**
  17953. * Sets the passed Effect "effect" with the Light textures.
  17954. * @param effect The effect to update
  17955. * @param lightIndex The index of the light in the effect to update
  17956. * @returns The light
  17957. */
  17958. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17959. /**
  17960. * Binds the lights information from the scene to the effect for the given mesh.
  17961. * @param lightIndex Light index
  17962. * @param scene The scene where the light belongs to
  17963. * @param effect The effect we are binding the data to
  17964. * @param useSpecular Defines if specular is supported
  17965. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17966. */
  17967. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17968. /**
  17969. * Sets the passed Effect "effect" with the Light information.
  17970. * @param effect The effect to update
  17971. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17972. * @returns The light
  17973. */
  17974. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17975. /**
  17976. * Returns the string "Light".
  17977. * @returns the class name
  17978. */
  17979. getClassName(): string;
  17980. /** @hidden */
  17981. readonly _isLight: boolean;
  17982. /**
  17983. * Converts the light information to a readable string for debug purpose.
  17984. * @param fullDetails Supports for multiple levels of logging within scene loading
  17985. * @returns the human readable light info
  17986. */
  17987. toString(fullDetails?: boolean): string;
  17988. /** @hidden */
  17989. protected _syncParentEnabledState(): void;
  17990. /**
  17991. * Set the enabled state of this node.
  17992. * @param value - the new enabled state
  17993. */
  17994. setEnabled(value: boolean): void;
  17995. /**
  17996. * Returns the Light associated shadow generator if any.
  17997. * @return the associated shadow generator.
  17998. */
  17999. getShadowGenerator(): Nullable<IShadowGenerator>;
  18000. /**
  18001. * Returns a Vector3, the absolute light position in the World.
  18002. * @returns the world space position of the light
  18003. */
  18004. getAbsolutePosition(): Vector3;
  18005. /**
  18006. * Specifies if the light will affect the passed mesh.
  18007. * @param mesh The mesh to test against the light
  18008. * @return true the mesh is affected otherwise, false.
  18009. */
  18010. canAffectMesh(mesh: AbstractMesh): boolean;
  18011. /**
  18012. * Sort function to order lights for rendering.
  18013. * @param a First Light object to compare to second.
  18014. * @param b Second Light object to compare first.
  18015. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18016. */
  18017. static CompareLightsPriority(a: Light, b: Light): number;
  18018. /**
  18019. * Releases resources associated with this node.
  18020. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18021. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18022. */
  18023. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18024. /**
  18025. * Returns the light type ID (integer).
  18026. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18027. */
  18028. getTypeID(): number;
  18029. /**
  18030. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18031. * @returns the scaled intensity in intensity mode unit
  18032. */
  18033. getScaledIntensity(): number;
  18034. /**
  18035. * Returns a new Light object, named "name", from the current one.
  18036. * @param name The name of the cloned light
  18037. * @param newParent The parent of this light, if it has one
  18038. * @returns the new created light
  18039. */
  18040. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18041. /**
  18042. * Serializes the current light into a Serialization object.
  18043. * @returns the serialized object.
  18044. */
  18045. serialize(): any;
  18046. /**
  18047. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18048. * This new light is named "name" and added to the passed scene.
  18049. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18050. * @param name The friendly name of the light
  18051. * @param scene The scene the new light will belong to
  18052. * @returns the constructor function
  18053. */
  18054. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18055. /**
  18056. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18057. * @param parsedLight The JSON representation of the light
  18058. * @param scene The scene to create the parsed light in
  18059. * @returns the created light after parsing
  18060. */
  18061. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18062. private _hookArrayForExcluded;
  18063. private _hookArrayForIncludedOnly;
  18064. private _resyncMeshes;
  18065. /**
  18066. * Forces the meshes to update their light related information in their rendering used effects
  18067. * @hidden Internal Use Only
  18068. */
  18069. _markMeshesAsLightDirty(): void;
  18070. /**
  18071. * Recomputes the cached photometric scale if needed.
  18072. */
  18073. private _computePhotometricScale;
  18074. /**
  18075. * Returns the Photometric Scale according to the light type and intensity mode.
  18076. */
  18077. private _getPhotometricScale;
  18078. /**
  18079. * Reorder the light in the scene according to their defined priority.
  18080. * @hidden Internal Use Only
  18081. */
  18082. _reorderLightsInScene(): void;
  18083. /**
  18084. * Prepares the list of defines specific to the light type.
  18085. * @param defines the list of defines
  18086. * @param lightIndex defines the index of the light for the effect
  18087. */
  18088. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18089. }
  18090. }
  18091. declare module BABYLON {
  18092. /**
  18093. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18094. * This is the base of the follow, arc rotate cameras and Free camera
  18095. * @see http://doc.babylonjs.com/features/cameras
  18096. */
  18097. export class TargetCamera extends Camera {
  18098. private static _RigCamTransformMatrix;
  18099. private static _TargetTransformMatrix;
  18100. private static _TargetFocalPoint;
  18101. /**
  18102. * Define the current direction the camera is moving to
  18103. */
  18104. cameraDirection: Vector3;
  18105. /**
  18106. * Define the current rotation the camera is rotating to
  18107. */
  18108. cameraRotation: Vector2;
  18109. /**
  18110. * When set, the up vector of the camera will be updated by the rotation of the camera
  18111. */
  18112. updateUpVectorFromRotation: boolean;
  18113. private _tmpQuaternion;
  18114. /**
  18115. * Define the current rotation of the camera
  18116. */
  18117. rotation: Vector3;
  18118. /**
  18119. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18120. */
  18121. rotationQuaternion: Quaternion;
  18122. /**
  18123. * Define the current speed of the camera
  18124. */
  18125. speed: number;
  18126. /**
  18127. * Add constraint to the camera to prevent it to move freely in all directions and
  18128. * around all axis.
  18129. */
  18130. noRotationConstraint: boolean;
  18131. /**
  18132. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18133. * panning
  18134. */
  18135. invertRotation: boolean;
  18136. /**
  18137. * Speed multiplier for inverse camera panning
  18138. */
  18139. inverseRotationSpeed: number;
  18140. /**
  18141. * Define the current target of the camera as an object or a position.
  18142. */
  18143. lockedTarget: any;
  18144. /** @hidden */
  18145. _currentTarget: Vector3;
  18146. /** @hidden */
  18147. _initialFocalDistance: number;
  18148. /** @hidden */
  18149. _viewMatrix: Matrix;
  18150. /** @hidden */
  18151. _camMatrix: Matrix;
  18152. /** @hidden */
  18153. _cameraTransformMatrix: Matrix;
  18154. /** @hidden */
  18155. _cameraRotationMatrix: Matrix;
  18156. /** @hidden */
  18157. _referencePoint: Vector3;
  18158. /** @hidden */
  18159. _transformedReferencePoint: Vector3;
  18160. protected _globalCurrentTarget: Vector3;
  18161. protected _globalCurrentUpVector: Vector3;
  18162. /** @hidden */
  18163. _reset: () => void;
  18164. private _defaultUp;
  18165. /**
  18166. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18167. * This is the base of the follow, arc rotate cameras and Free camera
  18168. * @see http://doc.babylonjs.com/features/cameras
  18169. * @param name Defines the name of the camera in the scene
  18170. * @param position Defines the start position of the camera in the scene
  18171. * @param scene Defines the scene the camera belongs to
  18172. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18173. */
  18174. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18175. /**
  18176. * Gets the position in front of the camera at a given distance.
  18177. * @param distance The distance from the camera we want the position to be
  18178. * @returns the position
  18179. */
  18180. getFrontPosition(distance: number): Vector3;
  18181. /** @hidden */
  18182. _getLockedTargetPosition(): Nullable<Vector3>;
  18183. private _storedPosition;
  18184. private _storedRotation;
  18185. private _storedRotationQuaternion;
  18186. /**
  18187. * Store current camera state of the camera (fov, position, rotation, etc..)
  18188. * @returns the camera
  18189. */
  18190. storeState(): Camera;
  18191. /**
  18192. * Restored camera state. You must call storeState() first
  18193. * @returns whether it was successful or not
  18194. * @hidden
  18195. */
  18196. _restoreStateValues(): boolean;
  18197. /** @hidden */
  18198. _initCache(): void;
  18199. /** @hidden */
  18200. _updateCache(ignoreParentClass?: boolean): void;
  18201. /** @hidden */
  18202. _isSynchronizedViewMatrix(): boolean;
  18203. /** @hidden */
  18204. _computeLocalCameraSpeed(): number;
  18205. /**
  18206. * Defines the target the camera should look at.
  18207. * @param target Defines the new target as a Vector or a mesh
  18208. */
  18209. setTarget(target: Vector3): void;
  18210. /**
  18211. * Return the current target position of the camera. This value is expressed in local space.
  18212. * @returns the target position
  18213. */
  18214. getTarget(): Vector3;
  18215. /** @hidden */
  18216. _decideIfNeedsToMove(): boolean;
  18217. /** @hidden */
  18218. _updatePosition(): void;
  18219. /** @hidden */
  18220. _checkInputs(): void;
  18221. protected _updateCameraRotationMatrix(): void;
  18222. /**
  18223. * 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)
  18224. * @returns the current camera
  18225. */
  18226. private _rotateUpVectorWithCameraRotationMatrix;
  18227. private _cachedRotationZ;
  18228. private _cachedQuaternionRotationZ;
  18229. /** @hidden */
  18230. _getViewMatrix(): Matrix;
  18231. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18232. /**
  18233. * @hidden
  18234. */
  18235. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18236. /**
  18237. * @hidden
  18238. */
  18239. _updateRigCameras(): void;
  18240. private _getRigCamPositionAndTarget;
  18241. /**
  18242. * Gets the current object class name.
  18243. * @return the class name
  18244. */
  18245. getClassName(): string;
  18246. }
  18247. }
  18248. declare module BABYLON {
  18249. /**
  18250. * Gather the list of keyboard event types as constants.
  18251. */
  18252. export class KeyboardEventTypes {
  18253. /**
  18254. * The keydown event is fired when a key becomes active (pressed).
  18255. */
  18256. static readonly KEYDOWN: number;
  18257. /**
  18258. * The keyup event is fired when a key has been released.
  18259. */
  18260. static readonly KEYUP: number;
  18261. }
  18262. /**
  18263. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18264. */
  18265. export class KeyboardInfo {
  18266. /**
  18267. * Defines the type of event (KeyboardEventTypes)
  18268. */
  18269. type: number;
  18270. /**
  18271. * Defines the related dom event
  18272. */
  18273. event: KeyboardEvent;
  18274. /**
  18275. * Instantiates a new keyboard info.
  18276. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18277. * @param type Defines the type of event (KeyboardEventTypes)
  18278. * @param event Defines the related dom event
  18279. */
  18280. constructor(
  18281. /**
  18282. * Defines the type of event (KeyboardEventTypes)
  18283. */
  18284. type: number,
  18285. /**
  18286. * Defines the related dom event
  18287. */
  18288. event: KeyboardEvent);
  18289. }
  18290. /**
  18291. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18292. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18293. */
  18294. export class KeyboardInfoPre extends KeyboardInfo {
  18295. /**
  18296. * Defines the type of event (KeyboardEventTypes)
  18297. */
  18298. type: number;
  18299. /**
  18300. * Defines the related dom event
  18301. */
  18302. event: KeyboardEvent;
  18303. /**
  18304. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18305. */
  18306. skipOnPointerObservable: boolean;
  18307. /**
  18308. * Instantiates a new keyboard pre info.
  18309. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18310. * @param type Defines the type of event (KeyboardEventTypes)
  18311. * @param event Defines the related dom event
  18312. */
  18313. constructor(
  18314. /**
  18315. * Defines the type of event (KeyboardEventTypes)
  18316. */
  18317. type: number,
  18318. /**
  18319. * Defines the related dom event
  18320. */
  18321. event: KeyboardEvent);
  18322. }
  18323. }
  18324. declare module BABYLON {
  18325. /**
  18326. * Manage the keyboard inputs to control the movement of a free camera.
  18327. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18328. */
  18329. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18330. /**
  18331. * Defines the camera the input is attached to.
  18332. */
  18333. camera: FreeCamera;
  18334. /**
  18335. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18336. */
  18337. keysUp: number[];
  18338. /**
  18339. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18340. */
  18341. keysUpward: number[];
  18342. /**
  18343. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18344. */
  18345. keysDown: number[];
  18346. /**
  18347. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18348. */
  18349. keysDownward: number[];
  18350. /**
  18351. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18352. */
  18353. keysLeft: number[];
  18354. /**
  18355. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18356. */
  18357. keysRight: number[];
  18358. private _keys;
  18359. private _onCanvasBlurObserver;
  18360. private _onKeyboardObserver;
  18361. private _engine;
  18362. private _scene;
  18363. /**
  18364. * Attach the input controls to a specific dom element to get the input from.
  18365. * @param element Defines the element the controls should be listened from
  18366. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18367. */
  18368. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18369. /**
  18370. * Detach the current controls from the specified dom element.
  18371. * @param element Defines the element to stop listening the inputs from
  18372. */
  18373. detachControl(element: Nullable<HTMLElement>): void;
  18374. /**
  18375. * Update the current camera state depending on the inputs that have been used this frame.
  18376. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18377. */
  18378. checkInputs(): void;
  18379. /**
  18380. * Gets the class name of the current intput.
  18381. * @returns the class name
  18382. */
  18383. getClassName(): string;
  18384. /** @hidden */
  18385. _onLostFocus(): void;
  18386. /**
  18387. * Get the friendly name associated with the input class.
  18388. * @returns the input friendly name
  18389. */
  18390. getSimpleName(): string;
  18391. }
  18392. }
  18393. declare module BABYLON {
  18394. /**
  18395. * Gather the list of pointer event types as constants.
  18396. */
  18397. export class PointerEventTypes {
  18398. /**
  18399. * 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.
  18400. */
  18401. static readonly POINTERDOWN: number;
  18402. /**
  18403. * The pointerup event is fired when a pointer is no longer active.
  18404. */
  18405. static readonly POINTERUP: number;
  18406. /**
  18407. * The pointermove event is fired when a pointer changes coordinates.
  18408. */
  18409. static readonly POINTERMOVE: number;
  18410. /**
  18411. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18412. */
  18413. static readonly POINTERWHEEL: number;
  18414. /**
  18415. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18416. */
  18417. static readonly POINTERPICK: number;
  18418. /**
  18419. * The pointertap event is fired when a the object has been touched and released without drag.
  18420. */
  18421. static readonly POINTERTAP: number;
  18422. /**
  18423. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18424. */
  18425. static readonly POINTERDOUBLETAP: number;
  18426. }
  18427. /**
  18428. * Base class of pointer info types.
  18429. */
  18430. export class PointerInfoBase {
  18431. /**
  18432. * Defines the type of event (PointerEventTypes)
  18433. */
  18434. type: number;
  18435. /**
  18436. * Defines the related dom event
  18437. */
  18438. event: PointerEvent | MouseWheelEvent;
  18439. /**
  18440. * Instantiates the base class of pointers info.
  18441. * @param type Defines the type of event (PointerEventTypes)
  18442. * @param event Defines the related dom event
  18443. */
  18444. constructor(
  18445. /**
  18446. * Defines the type of event (PointerEventTypes)
  18447. */
  18448. type: number,
  18449. /**
  18450. * Defines the related dom event
  18451. */
  18452. event: PointerEvent | MouseWheelEvent);
  18453. }
  18454. /**
  18455. * This class is used to store pointer related info for the onPrePointerObservable event.
  18456. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18457. */
  18458. export class PointerInfoPre extends PointerInfoBase {
  18459. /**
  18460. * Ray from a pointer if availible (eg. 6dof controller)
  18461. */
  18462. ray: Nullable<Ray>;
  18463. /**
  18464. * Defines the local position of the pointer on the canvas.
  18465. */
  18466. localPosition: Vector2;
  18467. /**
  18468. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18469. */
  18470. skipOnPointerObservable: boolean;
  18471. /**
  18472. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18473. * @param type Defines the type of event (PointerEventTypes)
  18474. * @param event Defines the related dom event
  18475. * @param localX Defines the local x coordinates of the pointer when the event occured
  18476. * @param localY Defines the local y coordinates of the pointer when the event occured
  18477. */
  18478. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18479. }
  18480. /**
  18481. * This type contains all the data related to a pointer event in Babylon.js.
  18482. * 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.
  18483. */
  18484. export class PointerInfo extends PointerInfoBase {
  18485. /**
  18486. * Defines the picking info associated to the info (if any)\
  18487. */
  18488. pickInfo: Nullable<PickingInfo>;
  18489. /**
  18490. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18491. * @param type Defines the type of event (PointerEventTypes)
  18492. * @param event Defines the related dom event
  18493. * @param pickInfo Defines the picking info associated to the info (if any)\
  18494. */
  18495. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18496. /**
  18497. * Defines the picking info associated to the info (if any)\
  18498. */
  18499. pickInfo: Nullable<PickingInfo>);
  18500. }
  18501. /**
  18502. * Data relating to a touch event on the screen.
  18503. */
  18504. export interface PointerTouch {
  18505. /**
  18506. * X coordinate of touch.
  18507. */
  18508. x: number;
  18509. /**
  18510. * Y coordinate of touch.
  18511. */
  18512. y: number;
  18513. /**
  18514. * Id of touch. Unique for each finger.
  18515. */
  18516. pointerId: number;
  18517. /**
  18518. * Event type passed from DOM.
  18519. */
  18520. type: any;
  18521. }
  18522. }
  18523. declare module BABYLON {
  18524. /**
  18525. * Manage the mouse inputs to control the movement of a free camera.
  18526. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18527. */
  18528. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18529. /**
  18530. * Define if touch is enabled in the mouse input
  18531. */
  18532. touchEnabled: boolean;
  18533. /**
  18534. * Defines the camera the input is attached to.
  18535. */
  18536. camera: FreeCamera;
  18537. /**
  18538. * Defines the buttons associated with the input to handle camera move.
  18539. */
  18540. buttons: number[];
  18541. /**
  18542. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18543. */
  18544. angularSensibility: number;
  18545. private _pointerInput;
  18546. private _onMouseMove;
  18547. private _observer;
  18548. private previousPosition;
  18549. /**
  18550. * Observable for when a pointer move event occurs containing the move offset
  18551. */
  18552. onPointerMovedObservable: Observable<{
  18553. offsetX: number;
  18554. offsetY: number;
  18555. }>;
  18556. /**
  18557. * @hidden
  18558. * If the camera should be rotated automatically based on pointer movement
  18559. */
  18560. _allowCameraRotation: boolean;
  18561. /**
  18562. * Manage the mouse inputs to control the movement of a free camera.
  18563. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18564. * @param touchEnabled Defines if touch is enabled or not
  18565. */
  18566. constructor(
  18567. /**
  18568. * Define if touch is enabled in the mouse input
  18569. */
  18570. touchEnabled?: boolean);
  18571. /**
  18572. * Attach the input controls to a specific dom element to get the input from.
  18573. * @param element Defines the element the controls should be listened from
  18574. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18575. */
  18576. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18577. /**
  18578. * Called on JS contextmenu event.
  18579. * Override this method to provide functionality.
  18580. */
  18581. protected onContextMenu(evt: PointerEvent): void;
  18582. /**
  18583. * Detach the current controls from the specified dom element.
  18584. * @param element Defines the element to stop listening the inputs from
  18585. */
  18586. detachControl(element: Nullable<HTMLElement>): void;
  18587. /**
  18588. * Gets the class name of the current intput.
  18589. * @returns the class name
  18590. */
  18591. getClassName(): string;
  18592. /**
  18593. * Get the friendly name associated with the input class.
  18594. * @returns the input friendly name
  18595. */
  18596. getSimpleName(): string;
  18597. }
  18598. }
  18599. declare module BABYLON {
  18600. /**
  18601. * Manage the touch inputs to control the movement of a free camera.
  18602. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18603. */
  18604. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18605. /**
  18606. * Defines the camera the input is attached to.
  18607. */
  18608. camera: FreeCamera;
  18609. /**
  18610. * Defines the touch sensibility for rotation.
  18611. * The higher the faster.
  18612. */
  18613. touchAngularSensibility: number;
  18614. /**
  18615. * Defines the touch sensibility for move.
  18616. * The higher the faster.
  18617. */
  18618. touchMoveSensibility: number;
  18619. private _offsetX;
  18620. private _offsetY;
  18621. private _pointerPressed;
  18622. private _pointerInput;
  18623. private _observer;
  18624. private _onLostFocus;
  18625. /**
  18626. * Attach the input controls to a specific dom element to get the input from.
  18627. * @param element Defines the element the controls should be listened from
  18628. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18629. */
  18630. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18631. /**
  18632. * Detach the current controls from the specified dom element.
  18633. * @param element Defines the element to stop listening the inputs from
  18634. */
  18635. detachControl(element: Nullable<HTMLElement>): void;
  18636. /**
  18637. * Update the current camera state depending on the inputs that have been used this frame.
  18638. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18639. */
  18640. checkInputs(): void;
  18641. /**
  18642. * Gets the class name of the current intput.
  18643. * @returns the class name
  18644. */
  18645. getClassName(): string;
  18646. /**
  18647. * Get the friendly name associated with the input class.
  18648. * @returns the input friendly name
  18649. */
  18650. getSimpleName(): string;
  18651. }
  18652. }
  18653. declare module BABYLON {
  18654. /**
  18655. * Default Inputs manager for the FreeCamera.
  18656. * It groups all the default supported inputs for ease of use.
  18657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18658. */
  18659. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18660. /**
  18661. * @hidden
  18662. */
  18663. _mouseInput: Nullable<FreeCameraMouseInput>;
  18664. /**
  18665. * Instantiates a new FreeCameraInputsManager.
  18666. * @param camera Defines the camera the inputs belong to
  18667. */
  18668. constructor(camera: FreeCamera);
  18669. /**
  18670. * Add keyboard input support to the input manager.
  18671. * @returns the current input manager
  18672. */
  18673. addKeyboard(): FreeCameraInputsManager;
  18674. /**
  18675. * Add mouse input support to the input manager.
  18676. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18677. * @returns the current input manager
  18678. */
  18679. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18680. /**
  18681. * Removes the mouse input support from the manager
  18682. * @returns the current input manager
  18683. */
  18684. removeMouse(): FreeCameraInputsManager;
  18685. /**
  18686. * Add touch input support to the input manager.
  18687. * @returns the current input manager
  18688. */
  18689. addTouch(): FreeCameraInputsManager;
  18690. /**
  18691. * Remove all attached input methods from a camera
  18692. */
  18693. clear(): void;
  18694. }
  18695. }
  18696. declare module BABYLON {
  18697. /**
  18698. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18699. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18700. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18701. */
  18702. export class FreeCamera extends TargetCamera {
  18703. /**
  18704. * Define the collision ellipsoid of the camera.
  18705. * This is helpful to simulate a camera body like the player body around the camera
  18706. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18707. */
  18708. ellipsoid: Vector3;
  18709. /**
  18710. * Define an offset for the position of the ellipsoid around the camera.
  18711. * This can be helpful to determine the center of the body near the gravity center of the body
  18712. * instead of its head.
  18713. */
  18714. ellipsoidOffset: Vector3;
  18715. /**
  18716. * Enable or disable collisions of the camera with the rest of the scene objects.
  18717. */
  18718. checkCollisions: boolean;
  18719. /**
  18720. * Enable or disable gravity on the camera.
  18721. */
  18722. applyGravity: boolean;
  18723. /**
  18724. * Define the input manager associated to the camera.
  18725. */
  18726. inputs: FreeCameraInputsManager;
  18727. /**
  18728. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18729. * Higher values reduce sensitivity.
  18730. */
  18731. get angularSensibility(): number;
  18732. /**
  18733. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18734. * Higher values reduce sensitivity.
  18735. */
  18736. set angularSensibility(value: number);
  18737. /**
  18738. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18739. */
  18740. get keysUp(): number[];
  18741. set keysUp(value: number[]);
  18742. /**
  18743. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18744. */
  18745. get keysUpward(): number[];
  18746. set keysUpward(value: number[]);
  18747. /**
  18748. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18749. */
  18750. get keysDown(): number[];
  18751. set keysDown(value: number[]);
  18752. /**
  18753. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18754. */
  18755. get keysDownward(): number[];
  18756. set keysDownward(value: number[]);
  18757. /**
  18758. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18759. */
  18760. get keysLeft(): number[];
  18761. set keysLeft(value: number[]);
  18762. /**
  18763. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18764. */
  18765. get keysRight(): number[];
  18766. set keysRight(value: number[]);
  18767. /**
  18768. * Event raised when the camera collide with a mesh in the scene.
  18769. */
  18770. onCollide: (collidedMesh: AbstractMesh) => void;
  18771. private _collider;
  18772. private _needMoveForGravity;
  18773. private _oldPosition;
  18774. private _diffPosition;
  18775. private _newPosition;
  18776. /** @hidden */
  18777. _localDirection: Vector3;
  18778. /** @hidden */
  18779. _transformedDirection: Vector3;
  18780. /**
  18781. * Instantiates a Free Camera.
  18782. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18783. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18784. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18785. * @param name Define the name of the camera in the scene
  18786. * @param position Define the start position of the camera in the scene
  18787. * @param scene Define the scene the camera belongs to
  18788. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18789. */
  18790. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18791. /**
  18792. * Attached controls to the current camera.
  18793. * @param element Defines the element the controls should be listened from
  18794. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18795. */
  18796. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18797. /**
  18798. * Detach the current controls from the camera.
  18799. * The camera will stop reacting to inputs.
  18800. * @param element Defines the element to stop listening the inputs from
  18801. */
  18802. detachControl(element: HTMLElement): void;
  18803. private _collisionMask;
  18804. /**
  18805. * Define a collision mask to limit the list of object the camera can collide with
  18806. */
  18807. get collisionMask(): number;
  18808. set collisionMask(mask: number);
  18809. /** @hidden */
  18810. _collideWithWorld(displacement: Vector3): void;
  18811. private _onCollisionPositionChange;
  18812. /** @hidden */
  18813. _checkInputs(): void;
  18814. /** @hidden */
  18815. _decideIfNeedsToMove(): boolean;
  18816. /** @hidden */
  18817. _updatePosition(): void;
  18818. /**
  18819. * Destroy the camera and release the current resources hold by it.
  18820. */
  18821. dispose(): void;
  18822. /**
  18823. * Gets the current object class name.
  18824. * @return the class name
  18825. */
  18826. getClassName(): string;
  18827. }
  18828. }
  18829. declare module BABYLON {
  18830. /**
  18831. * Represents a gamepad control stick position
  18832. */
  18833. export class StickValues {
  18834. /**
  18835. * The x component of the control stick
  18836. */
  18837. x: number;
  18838. /**
  18839. * The y component of the control stick
  18840. */
  18841. y: number;
  18842. /**
  18843. * Initializes the gamepad x and y control stick values
  18844. * @param x The x component of the gamepad control stick value
  18845. * @param y The y component of the gamepad control stick value
  18846. */
  18847. constructor(
  18848. /**
  18849. * The x component of the control stick
  18850. */
  18851. x: number,
  18852. /**
  18853. * The y component of the control stick
  18854. */
  18855. y: number);
  18856. }
  18857. /**
  18858. * An interface which manages callbacks for gamepad button changes
  18859. */
  18860. export interface GamepadButtonChanges {
  18861. /**
  18862. * Called when a gamepad has been changed
  18863. */
  18864. changed: boolean;
  18865. /**
  18866. * Called when a gamepad press event has been triggered
  18867. */
  18868. pressChanged: boolean;
  18869. /**
  18870. * Called when a touch event has been triggered
  18871. */
  18872. touchChanged: boolean;
  18873. /**
  18874. * Called when a value has changed
  18875. */
  18876. valueChanged: boolean;
  18877. }
  18878. /**
  18879. * Represents a gamepad
  18880. */
  18881. export class Gamepad {
  18882. /**
  18883. * The id of the gamepad
  18884. */
  18885. id: string;
  18886. /**
  18887. * The index of the gamepad
  18888. */
  18889. index: number;
  18890. /**
  18891. * The browser gamepad
  18892. */
  18893. browserGamepad: any;
  18894. /**
  18895. * Specifies what type of gamepad this represents
  18896. */
  18897. type: number;
  18898. private _leftStick;
  18899. private _rightStick;
  18900. /** @hidden */
  18901. _isConnected: boolean;
  18902. private _leftStickAxisX;
  18903. private _leftStickAxisY;
  18904. private _rightStickAxisX;
  18905. private _rightStickAxisY;
  18906. /**
  18907. * Triggered when the left control stick has been changed
  18908. */
  18909. private _onleftstickchanged;
  18910. /**
  18911. * Triggered when the right control stick has been changed
  18912. */
  18913. private _onrightstickchanged;
  18914. /**
  18915. * Represents a gamepad controller
  18916. */
  18917. static GAMEPAD: number;
  18918. /**
  18919. * Represents a generic controller
  18920. */
  18921. static GENERIC: number;
  18922. /**
  18923. * Represents an XBox controller
  18924. */
  18925. static XBOX: number;
  18926. /**
  18927. * Represents a pose-enabled controller
  18928. */
  18929. static POSE_ENABLED: number;
  18930. /**
  18931. * Represents an Dual Shock controller
  18932. */
  18933. static DUALSHOCK: number;
  18934. /**
  18935. * Specifies whether the left control stick should be Y-inverted
  18936. */
  18937. protected _invertLeftStickY: boolean;
  18938. /**
  18939. * Specifies if the gamepad has been connected
  18940. */
  18941. get isConnected(): boolean;
  18942. /**
  18943. * Initializes the gamepad
  18944. * @param id The id of the gamepad
  18945. * @param index The index of the gamepad
  18946. * @param browserGamepad The browser gamepad
  18947. * @param leftStickX The x component of the left joystick
  18948. * @param leftStickY The y component of the left joystick
  18949. * @param rightStickX The x component of the right joystick
  18950. * @param rightStickY The y component of the right joystick
  18951. */
  18952. constructor(
  18953. /**
  18954. * The id of the gamepad
  18955. */
  18956. id: string,
  18957. /**
  18958. * The index of the gamepad
  18959. */
  18960. index: number,
  18961. /**
  18962. * The browser gamepad
  18963. */
  18964. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18965. /**
  18966. * Callback triggered when the left joystick has changed
  18967. * @param callback
  18968. */
  18969. onleftstickchanged(callback: (values: StickValues) => void): void;
  18970. /**
  18971. * Callback triggered when the right joystick has changed
  18972. * @param callback
  18973. */
  18974. onrightstickchanged(callback: (values: StickValues) => void): void;
  18975. /**
  18976. * Gets the left joystick
  18977. */
  18978. get leftStick(): StickValues;
  18979. /**
  18980. * Sets the left joystick values
  18981. */
  18982. set leftStick(newValues: StickValues);
  18983. /**
  18984. * Gets the right joystick
  18985. */
  18986. get rightStick(): StickValues;
  18987. /**
  18988. * Sets the right joystick value
  18989. */
  18990. set rightStick(newValues: StickValues);
  18991. /**
  18992. * Updates the gamepad joystick positions
  18993. */
  18994. update(): void;
  18995. /**
  18996. * Disposes the gamepad
  18997. */
  18998. dispose(): void;
  18999. }
  19000. /**
  19001. * Represents a generic gamepad
  19002. */
  19003. export class GenericPad extends Gamepad {
  19004. private _buttons;
  19005. private _onbuttondown;
  19006. private _onbuttonup;
  19007. /**
  19008. * Observable triggered when a button has been pressed
  19009. */
  19010. onButtonDownObservable: Observable<number>;
  19011. /**
  19012. * Observable triggered when a button has been released
  19013. */
  19014. onButtonUpObservable: Observable<number>;
  19015. /**
  19016. * Callback triggered when a button has been pressed
  19017. * @param callback Called when a button has been pressed
  19018. */
  19019. onbuttondown(callback: (buttonPressed: number) => void): void;
  19020. /**
  19021. * Callback triggered when a button has been released
  19022. * @param callback Called when a button has been released
  19023. */
  19024. onbuttonup(callback: (buttonReleased: number) => void): void;
  19025. /**
  19026. * Initializes the generic gamepad
  19027. * @param id The id of the generic gamepad
  19028. * @param index The index of the generic gamepad
  19029. * @param browserGamepad The browser gamepad
  19030. */
  19031. constructor(id: string, index: number, browserGamepad: any);
  19032. private _setButtonValue;
  19033. /**
  19034. * Updates the generic gamepad
  19035. */
  19036. update(): void;
  19037. /**
  19038. * Disposes the generic gamepad
  19039. */
  19040. dispose(): void;
  19041. }
  19042. }
  19043. declare module BABYLON {
  19044. /**
  19045. * Defines the types of pose enabled controllers that are supported
  19046. */
  19047. export enum PoseEnabledControllerType {
  19048. /**
  19049. * HTC Vive
  19050. */
  19051. VIVE = 0,
  19052. /**
  19053. * Oculus Rift
  19054. */
  19055. OCULUS = 1,
  19056. /**
  19057. * Windows mixed reality
  19058. */
  19059. WINDOWS = 2,
  19060. /**
  19061. * Samsung gear VR
  19062. */
  19063. GEAR_VR = 3,
  19064. /**
  19065. * Google Daydream
  19066. */
  19067. DAYDREAM = 4,
  19068. /**
  19069. * Generic
  19070. */
  19071. GENERIC = 5
  19072. }
  19073. /**
  19074. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19075. */
  19076. export interface MutableGamepadButton {
  19077. /**
  19078. * Value of the button/trigger
  19079. */
  19080. value: number;
  19081. /**
  19082. * If the button/trigger is currently touched
  19083. */
  19084. touched: boolean;
  19085. /**
  19086. * If the button/trigger is currently pressed
  19087. */
  19088. pressed: boolean;
  19089. }
  19090. /**
  19091. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19092. * @hidden
  19093. */
  19094. export interface ExtendedGamepadButton extends GamepadButton {
  19095. /**
  19096. * If the button/trigger is currently pressed
  19097. */
  19098. readonly pressed: boolean;
  19099. /**
  19100. * If the button/trigger is currently touched
  19101. */
  19102. readonly touched: boolean;
  19103. /**
  19104. * Value of the button/trigger
  19105. */
  19106. readonly value: number;
  19107. }
  19108. /** @hidden */
  19109. export interface _GamePadFactory {
  19110. /**
  19111. * Returns whether or not the current gamepad can be created for this type of controller.
  19112. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19113. * @returns true if it can be created, otherwise false
  19114. */
  19115. canCreate(gamepadInfo: any): boolean;
  19116. /**
  19117. * Creates a new instance of the Gamepad.
  19118. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19119. * @returns the new gamepad instance
  19120. */
  19121. create(gamepadInfo: any): Gamepad;
  19122. }
  19123. /**
  19124. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19125. */
  19126. export class PoseEnabledControllerHelper {
  19127. /** @hidden */
  19128. static _ControllerFactories: _GamePadFactory[];
  19129. /** @hidden */
  19130. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19131. /**
  19132. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19133. * @param vrGamepad the gamepad to initialized
  19134. * @returns a vr controller of the type the gamepad identified as
  19135. */
  19136. static InitiateController(vrGamepad: any): Gamepad;
  19137. }
  19138. /**
  19139. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19140. */
  19141. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19142. /**
  19143. * If the controller is used in a webXR session
  19144. */
  19145. isXR: boolean;
  19146. private _deviceRoomPosition;
  19147. private _deviceRoomRotationQuaternion;
  19148. /**
  19149. * The device position in babylon space
  19150. */
  19151. devicePosition: Vector3;
  19152. /**
  19153. * The device rotation in babylon space
  19154. */
  19155. deviceRotationQuaternion: Quaternion;
  19156. /**
  19157. * The scale factor of the device in babylon space
  19158. */
  19159. deviceScaleFactor: number;
  19160. /**
  19161. * (Likely devicePosition should be used instead) The device position in its room space
  19162. */
  19163. position: Vector3;
  19164. /**
  19165. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19166. */
  19167. rotationQuaternion: Quaternion;
  19168. /**
  19169. * The type of controller (Eg. Windows mixed reality)
  19170. */
  19171. controllerType: PoseEnabledControllerType;
  19172. protected _calculatedPosition: Vector3;
  19173. private _calculatedRotation;
  19174. /**
  19175. * The raw pose from the device
  19176. */
  19177. rawPose: DevicePose;
  19178. private _trackPosition;
  19179. private _maxRotationDistFromHeadset;
  19180. private _draggedRoomRotation;
  19181. /**
  19182. * @hidden
  19183. */
  19184. _disableTrackPosition(fixedPosition: Vector3): void;
  19185. /**
  19186. * Internal, the mesh attached to the controller
  19187. * @hidden
  19188. */
  19189. _mesh: Nullable<AbstractMesh>;
  19190. private _poseControlledCamera;
  19191. private _leftHandSystemQuaternion;
  19192. /**
  19193. * Internal, matrix used to convert room space to babylon space
  19194. * @hidden
  19195. */
  19196. _deviceToWorld: Matrix;
  19197. /**
  19198. * Node to be used when casting a ray from the controller
  19199. * @hidden
  19200. */
  19201. _pointingPoseNode: Nullable<TransformNode>;
  19202. /**
  19203. * Name of the child mesh that can be used to cast a ray from the controller
  19204. */
  19205. static readonly POINTING_POSE: string;
  19206. /**
  19207. * Creates a new PoseEnabledController from a gamepad
  19208. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19209. */
  19210. constructor(browserGamepad: any);
  19211. private _workingMatrix;
  19212. /**
  19213. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19214. */
  19215. update(): void;
  19216. /**
  19217. * Updates only the pose device and mesh without doing any button event checking
  19218. */
  19219. protected _updatePoseAndMesh(): void;
  19220. /**
  19221. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19222. * @param poseData raw pose fromthe device
  19223. */
  19224. updateFromDevice(poseData: DevicePose): void;
  19225. /**
  19226. * @hidden
  19227. */
  19228. _meshAttachedObservable: Observable<AbstractMesh>;
  19229. /**
  19230. * Attaches a mesh to the controller
  19231. * @param mesh the mesh to be attached
  19232. */
  19233. attachToMesh(mesh: AbstractMesh): void;
  19234. /**
  19235. * Attaches the controllers mesh to a camera
  19236. * @param camera the camera the mesh should be attached to
  19237. */
  19238. attachToPoseControlledCamera(camera: TargetCamera): void;
  19239. /**
  19240. * Disposes of the controller
  19241. */
  19242. dispose(): void;
  19243. /**
  19244. * The mesh that is attached to the controller
  19245. */
  19246. get mesh(): Nullable<AbstractMesh>;
  19247. /**
  19248. * Gets the ray of the controller in the direction the controller is pointing
  19249. * @param length the length the resulting ray should be
  19250. * @returns a ray in the direction the controller is pointing
  19251. */
  19252. getForwardRay(length?: number): Ray;
  19253. }
  19254. }
  19255. declare module BABYLON {
  19256. /**
  19257. * Defines the WebVRController object that represents controllers tracked in 3D space
  19258. */
  19259. export abstract class WebVRController extends PoseEnabledController {
  19260. /**
  19261. * Internal, the default controller model for the controller
  19262. */
  19263. protected _defaultModel: Nullable<AbstractMesh>;
  19264. /**
  19265. * Fired when the trigger state has changed
  19266. */
  19267. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19268. /**
  19269. * Fired when the main button state has changed
  19270. */
  19271. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19272. /**
  19273. * Fired when the secondary button state has changed
  19274. */
  19275. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19276. /**
  19277. * Fired when the pad state has changed
  19278. */
  19279. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19280. /**
  19281. * Fired when controllers stick values have changed
  19282. */
  19283. onPadValuesChangedObservable: Observable<StickValues>;
  19284. /**
  19285. * Array of button availible on the controller
  19286. */
  19287. protected _buttons: Array<MutableGamepadButton>;
  19288. private _onButtonStateChange;
  19289. /**
  19290. * Fired when a controller button's state has changed
  19291. * @param callback the callback containing the button that was modified
  19292. */
  19293. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19294. /**
  19295. * X and Y axis corresponding to the controllers joystick
  19296. */
  19297. pad: StickValues;
  19298. /**
  19299. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19300. */
  19301. hand: string;
  19302. /**
  19303. * The default controller model for the controller
  19304. */
  19305. get defaultModel(): Nullable<AbstractMesh>;
  19306. /**
  19307. * Creates a new WebVRController from a gamepad
  19308. * @param vrGamepad the gamepad that the WebVRController should be created from
  19309. */
  19310. constructor(vrGamepad: any);
  19311. /**
  19312. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19313. */
  19314. update(): void;
  19315. /**
  19316. * Function to be called when a button is modified
  19317. */
  19318. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19319. /**
  19320. * Loads a mesh and attaches it to the controller
  19321. * @param scene the scene the mesh should be added to
  19322. * @param meshLoaded callback for when the mesh has been loaded
  19323. */
  19324. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19325. private _setButtonValue;
  19326. private _changes;
  19327. private _checkChanges;
  19328. /**
  19329. * Disposes of th webVRCOntroller
  19330. */
  19331. dispose(): void;
  19332. }
  19333. }
  19334. declare module BABYLON {
  19335. /**
  19336. * The HemisphericLight simulates the ambient environment light,
  19337. * so the passed direction is the light reflection direction, not the incoming direction.
  19338. */
  19339. export class HemisphericLight extends Light {
  19340. /**
  19341. * The groundColor is the light in the opposite direction to the one specified during creation.
  19342. * 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.
  19343. */
  19344. groundColor: Color3;
  19345. /**
  19346. * The light reflection direction, not the incoming direction.
  19347. */
  19348. direction: Vector3;
  19349. /**
  19350. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19351. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19352. * The HemisphericLight can't cast shadows.
  19353. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19354. * @param name The friendly name of the light
  19355. * @param direction The direction of the light reflection
  19356. * @param scene The scene the light belongs to
  19357. */
  19358. constructor(name: string, direction: Vector3, scene: Scene);
  19359. protected _buildUniformLayout(): void;
  19360. /**
  19361. * Returns the string "HemisphericLight".
  19362. * @return The class name
  19363. */
  19364. getClassName(): string;
  19365. /**
  19366. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19367. * Returns the updated direction.
  19368. * @param target The target the direction should point to
  19369. * @return The computed direction
  19370. */
  19371. setDirectionToTarget(target: Vector3): Vector3;
  19372. /**
  19373. * Returns the shadow generator associated to the light.
  19374. * @returns Always null for hemispheric lights because it does not support shadows.
  19375. */
  19376. getShadowGenerator(): Nullable<IShadowGenerator>;
  19377. /**
  19378. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19379. * @param effect The effect to update
  19380. * @param lightIndex The index of the light in the effect to update
  19381. * @returns The hemispheric light
  19382. */
  19383. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19384. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19385. /**
  19386. * Computes the world matrix of the node
  19387. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19388. * @param useWasUpdatedFlag defines a reserved property
  19389. * @returns the world matrix
  19390. */
  19391. computeWorldMatrix(): Matrix;
  19392. /**
  19393. * Returns the integer 3.
  19394. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19395. */
  19396. getTypeID(): number;
  19397. /**
  19398. * Prepares the list of defines specific to the light type.
  19399. * @param defines the list of defines
  19400. * @param lightIndex defines the index of the light for the effect
  19401. */
  19402. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19403. }
  19404. }
  19405. declare module BABYLON {
  19406. /** @hidden */
  19407. export var vrMultiviewToSingleviewPixelShader: {
  19408. name: string;
  19409. shader: string;
  19410. };
  19411. }
  19412. declare module BABYLON {
  19413. /**
  19414. * Renders to multiple views with a single draw call
  19415. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19416. */
  19417. export class MultiviewRenderTarget extends RenderTargetTexture {
  19418. /**
  19419. * Creates a multiview render target
  19420. * @param scene scene used with the render target
  19421. * @param size the size of the render target (used for each view)
  19422. */
  19423. constructor(scene: Scene, size?: number | {
  19424. width: number;
  19425. height: number;
  19426. } | {
  19427. ratio: number;
  19428. });
  19429. /**
  19430. * @hidden
  19431. * @param faceIndex the face index, if its a cube texture
  19432. */
  19433. _bindFrameBuffer(faceIndex?: number): void;
  19434. /**
  19435. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19436. * @returns the view count
  19437. */
  19438. getViewCount(): number;
  19439. }
  19440. }
  19441. declare module BABYLON {
  19442. interface Engine {
  19443. /**
  19444. * Creates a new multiview render target
  19445. * @param width defines the width of the texture
  19446. * @param height defines the height of the texture
  19447. * @returns the created multiview texture
  19448. */
  19449. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19450. /**
  19451. * Binds a multiview framebuffer to be drawn to
  19452. * @param multiviewTexture texture to bind
  19453. */
  19454. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19455. }
  19456. interface Camera {
  19457. /**
  19458. * @hidden
  19459. * 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)
  19460. */
  19461. _useMultiviewToSingleView: boolean;
  19462. /**
  19463. * @hidden
  19464. * 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)
  19465. */
  19466. _multiviewTexture: Nullable<RenderTargetTexture>;
  19467. /**
  19468. * @hidden
  19469. * ensures the multiview texture of the camera exists and has the specified width/height
  19470. * @param width height to set on the multiview texture
  19471. * @param height width to set on the multiview texture
  19472. */
  19473. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19474. }
  19475. interface Scene {
  19476. /** @hidden */
  19477. _transformMatrixR: Matrix;
  19478. /** @hidden */
  19479. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19480. /** @hidden */
  19481. _createMultiviewUbo(): void;
  19482. /** @hidden */
  19483. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19484. /** @hidden */
  19485. _renderMultiviewToSingleView(camera: Camera): void;
  19486. }
  19487. }
  19488. declare module BABYLON {
  19489. /**
  19490. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19491. * This will not be used for webXR as it supports displaying texture arrays directly
  19492. */
  19493. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19494. /**
  19495. * Initializes a VRMultiviewToSingleview
  19496. * @param name name of the post process
  19497. * @param camera camera to be applied to
  19498. * @param scaleFactor scaling factor to the size of the output texture
  19499. */
  19500. constructor(name: string, camera: Camera, scaleFactor: number);
  19501. }
  19502. }
  19503. declare module BABYLON {
  19504. /**
  19505. * Interface used to define additional presentation attributes
  19506. */
  19507. export interface IVRPresentationAttributes {
  19508. /**
  19509. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19510. */
  19511. highRefreshRate: boolean;
  19512. /**
  19513. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19514. */
  19515. foveationLevel: number;
  19516. }
  19517. interface Engine {
  19518. /** @hidden */
  19519. _vrDisplay: any;
  19520. /** @hidden */
  19521. _vrSupported: boolean;
  19522. /** @hidden */
  19523. _oldSize: Size;
  19524. /** @hidden */
  19525. _oldHardwareScaleFactor: number;
  19526. /** @hidden */
  19527. _vrExclusivePointerMode: boolean;
  19528. /** @hidden */
  19529. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19530. /** @hidden */
  19531. _onVRDisplayPointerRestricted: () => void;
  19532. /** @hidden */
  19533. _onVRDisplayPointerUnrestricted: () => void;
  19534. /** @hidden */
  19535. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19536. /** @hidden */
  19537. _onVrDisplayDisconnect: Nullable<() => void>;
  19538. /** @hidden */
  19539. _onVrDisplayPresentChange: Nullable<() => void>;
  19540. /**
  19541. * Observable signaled when VR display mode changes
  19542. */
  19543. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19544. /**
  19545. * Observable signaled when VR request present is complete
  19546. */
  19547. onVRRequestPresentComplete: Observable<boolean>;
  19548. /**
  19549. * Observable signaled when VR request present starts
  19550. */
  19551. onVRRequestPresentStart: Observable<Engine>;
  19552. /**
  19553. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19554. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19555. */
  19556. isInVRExclusivePointerMode: boolean;
  19557. /**
  19558. * Gets a boolean indicating if a webVR device was detected
  19559. * @returns true if a webVR device was detected
  19560. */
  19561. isVRDevicePresent(): boolean;
  19562. /**
  19563. * Gets the current webVR device
  19564. * @returns the current webVR device (or null)
  19565. */
  19566. getVRDevice(): any;
  19567. /**
  19568. * Initializes a webVR display and starts listening to display change events
  19569. * The onVRDisplayChangedObservable will be notified upon these changes
  19570. * @returns A promise containing a VRDisplay and if vr is supported
  19571. */
  19572. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19573. /** @hidden */
  19574. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19575. /**
  19576. * Gets or sets the presentation attributes used to configure VR rendering
  19577. */
  19578. vrPresentationAttributes?: IVRPresentationAttributes;
  19579. /**
  19580. * Call this function to switch to webVR mode
  19581. * Will do nothing if webVR is not supported or if there is no webVR device
  19582. * @param options the webvr options provided to the camera. mainly used for multiview
  19583. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19584. */
  19585. enableVR(options: WebVROptions): void;
  19586. /** @hidden */
  19587. _onVRFullScreenTriggered(): void;
  19588. }
  19589. }
  19590. declare module BABYLON {
  19591. /**
  19592. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19593. * IMPORTANT!! The data is right-hand data.
  19594. * @export
  19595. * @interface DevicePose
  19596. */
  19597. export interface DevicePose {
  19598. /**
  19599. * The position of the device, values in array are [x,y,z].
  19600. */
  19601. readonly position: Nullable<Float32Array>;
  19602. /**
  19603. * The linearVelocity of the device, values in array are [x,y,z].
  19604. */
  19605. readonly linearVelocity: Nullable<Float32Array>;
  19606. /**
  19607. * The linearAcceleration of the device, values in array are [x,y,z].
  19608. */
  19609. readonly linearAcceleration: Nullable<Float32Array>;
  19610. /**
  19611. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19612. */
  19613. readonly orientation: Nullable<Float32Array>;
  19614. /**
  19615. * The angularVelocity of the device, values in array are [x,y,z].
  19616. */
  19617. readonly angularVelocity: Nullable<Float32Array>;
  19618. /**
  19619. * The angularAcceleration of the device, values in array are [x,y,z].
  19620. */
  19621. readonly angularAcceleration: Nullable<Float32Array>;
  19622. }
  19623. /**
  19624. * Interface representing a pose controlled object in Babylon.
  19625. * A pose controlled object has both regular pose values as well as pose values
  19626. * from an external device such as a VR head mounted display
  19627. */
  19628. export interface PoseControlled {
  19629. /**
  19630. * The position of the object in babylon space.
  19631. */
  19632. position: Vector3;
  19633. /**
  19634. * The rotation quaternion of the object in babylon space.
  19635. */
  19636. rotationQuaternion: Quaternion;
  19637. /**
  19638. * The position of the device in babylon space.
  19639. */
  19640. devicePosition?: Vector3;
  19641. /**
  19642. * The rotation quaternion of the device in babylon space.
  19643. */
  19644. deviceRotationQuaternion: Quaternion;
  19645. /**
  19646. * The raw pose coming from the device.
  19647. */
  19648. rawPose: Nullable<DevicePose>;
  19649. /**
  19650. * The scale of the device to be used when translating from device space to babylon space.
  19651. */
  19652. deviceScaleFactor: number;
  19653. /**
  19654. * Updates the poseControlled values based on the input device pose.
  19655. * @param poseData the pose data to update the object with
  19656. */
  19657. updateFromDevice(poseData: DevicePose): void;
  19658. }
  19659. /**
  19660. * Set of options to customize the webVRCamera
  19661. */
  19662. export interface WebVROptions {
  19663. /**
  19664. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19665. */
  19666. trackPosition?: boolean;
  19667. /**
  19668. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19669. */
  19670. positionScale?: number;
  19671. /**
  19672. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19673. */
  19674. displayName?: string;
  19675. /**
  19676. * Should the native controller meshes be initialized. (default: true)
  19677. */
  19678. controllerMeshes?: boolean;
  19679. /**
  19680. * Creating a default HemiLight only on controllers. (default: true)
  19681. */
  19682. defaultLightingOnControllers?: boolean;
  19683. /**
  19684. * If you don't want to use the default VR button of the helper. (default: false)
  19685. */
  19686. useCustomVRButton?: boolean;
  19687. /**
  19688. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19689. */
  19690. customVRButton?: HTMLButtonElement;
  19691. /**
  19692. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19693. */
  19694. rayLength?: number;
  19695. /**
  19696. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19697. */
  19698. defaultHeight?: number;
  19699. /**
  19700. * If multiview should be used if availible (default: false)
  19701. */
  19702. useMultiview?: boolean;
  19703. }
  19704. /**
  19705. * This represents a WebVR camera.
  19706. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19707. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19708. */
  19709. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19710. private webVROptions;
  19711. /**
  19712. * @hidden
  19713. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19714. */
  19715. _vrDevice: any;
  19716. /**
  19717. * The rawPose of the vrDevice.
  19718. */
  19719. rawPose: Nullable<DevicePose>;
  19720. private _onVREnabled;
  19721. private _specsVersion;
  19722. private _attached;
  19723. private _frameData;
  19724. protected _descendants: Array<Node>;
  19725. private _deviceRoomPosition;
  19726. /** @hidden */
  19727. _deviceRoomRotationQuaternion: Quaternion;
  19728. private _standingMatrix;
  19729. /**
  19730. * Represents device position in babylon space.
  19731. */
  19732. devicePosition: Vector3;
  19733. /**
  19734. * Represents device rotation in babylon space.
  19735. */
  19736. deviceRotationQuaternion: Quaternion;
  19737. /**
  19738. * The scale of the device to be used when translating from device space to babylon space.
  19739. */
  19740. deviceScaleFactor: number;
  19741. private _deviceToWorld;
  19742. private _worldToDevice;
  19743. /**
  19744. * References to the webVR controllers for the vrDevice.
  19745. */
  19746. controllers: Array<WebVRController>;
  19747. /**
  19748. * Emits an event when a controller is attached.
  19749. */
  19750. onControllersAttachedObservable: Observable<WebVRController[]>;
  19751. /**
  19752. * Emits an event when a controller's mesh has been loaded;
  19753. */
  19754. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19755. /**
  19756. * Emits an event when the HMD's pose has been updated.
  19757. */
  19758. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19759. private _poseSet;
  19760. /**
  19761. * If the rig cameras be used as parent instead of this camera.
  19762. */
  19763. rigParenting: boolean;
  19764. private _lightOnControllers;
  19765. private _defaultHeight?;
  19766. /**
  19767. * Instantiates a WebVRFreeCamera.
  19768. * @param name The name of the WebVRFreeCamera
  19769. * @param position The starting anchor position for the camera
  19770. * @param scene The scene the camera belongs to
  19771. * @param webVROptions a set of customizable options for the webVRCamera
  19772. */
  19773. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19774. /**
  19775. * Gets the device distance from the ground in meters.
  19776. * @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.
  19777. */
  19778. deviceDistanceToRoomGround(): number;
  19779. /**
  19780. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19781. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19782. */
  19783. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19784. /**
  19785. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19786. * @returns A promise with a boolean set to if the standing matrix is supported.
  19787. */
  19788. useStandingMatrixAsync(): Promise<boolean>;
  19789. /**
  19790. * Disposes the camera
  19791. */
  19792. dispose(): void;
  19793. /**
  19794. * Gets a vrController by name.
  19795. * @param name The name of the controller to retreive
  19796. * @returns the controller matching the name specified or null if not found
  19797. */
  19798. getControllerByName(name: string): Nullable<WebVRController>;
  19799. private _leftController;
  19800. /**
  19801. * The controller corresponding to the users left hand.
  19802. */
  19803. get leftController(): Nullable<WebVRController>;
  19804. private _rightController;
  19805. /**
  19806. * The controller corresponding to the users right hand.
  19807. */
  19808. get rightController(): Nullable<WebVRController>;
  19809. /**
  19810. * Casts a ray forward from the vrCamera's gaze.
  19811. * @param length Length of the ray (default: 100)
  19812. * @returns the ray corresponding to the gaze
  19813. */
  19814. getForwardRay(length?: number): Ray;
  19815. /**
  19816. * @hidden
  19817. * Updates the camera based on device's frame data
  19818. */
  19819. _checkInputs(): void;
  19820. /**
  19821. * Updates the poseControlled values based on the input device pose.
  19822. * @param poseData Pose coming from the device
  19823. */
  19824. updateFromDevice(poseData: DevicePose): void;
  19825. private _htmlElementAttached;
  19826. private _detachIfAttached;
  19827. /**
  19828. * WebVR's attach control will start broadcasting frames to the device.
  19829. * Note that in certain browsers (chrome for example) this function must be called
  19830. * within a user-interaction callback. Example:
  19831. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19832. *
  19833. * @param element html element to attach the vrDevice to
  19834. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19835. */
  19836. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19837. /**
  19838. * Detaches the camera from the html element and disables VR
  19839. *
  19840. * @param element html element to detach from
  19841. */
  19842. detachControl(element: HTMLElement): void;
  19843. /**
  19844. * @returns the name of this class
  19845. */
  19846. getClassName(): string;
  19847. /**
  19848. * Calls resetPose on the vrDisplay
  19849. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19850. */
  19851. resetToCurrentRotation(): void;
  19852. /**
  19853. * @hidden
  19854. * Updates the rig cameras (left and right eye)
  19855. */
  19856. _updateRigCameras(): void;
  19857. private _workingVector;
  19858. private _oneVector;
  19859. private _workingMatrix;
  19860. private updateCacheCalled;
  19861. private _correctPositionIfNotTrackPosition;
  19862. /**
  19863. * @hidden
  19864. * Updates the cached values of the camera
  19865. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19866. */
  19867. _updateCache(ignoreParentClass?: boolean): void;
  19868. /**
  19869. * @hidden
  19870. * Get current device position in babylon world
  19871. */
  19872. _computeDevicePosition(): void;
  19873. /**
  19874. * Updates the current device position and rotation in the babylon world
  19875. */
  19876. update(): void;
  19877. /**
  19878. * @hidden
  19879. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19880. * @returns an identity matrix
  19881. */
  19882. _getViewMatrix(): Matrix;
  19883. private _tmpMatrix;
  19884. /**
  19885. * This function is called by the two RIG cameras.
  19886. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19887. * @hidden
  19888. */
  19889. _getWebVRViewMatrix(): Matrix;
  19890. /** @hidden */
  19891. _getWebVRProjectionMatrix(): Matrix;
  19892. private _onGamepadConnectedObserver;
  19893. private _onGamepadDisconnectedObserver;
  19894. private _updateCacheWhenTrackingDisabledObserver;
  19895. /**
  19896. * Initializes the controllers and their meshes
  19897. */
  19898. initControllers(): void;
  19899. }
  19900. }
  19901. declare module BABYLON {
  19902. /**
  19903. * "Static Class" containing the most commonly used helper while dealing with material for
  19904. * rendering purpose.
  19905. *
  19906. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19907. *
  19908. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  19909. */
  19910. export class MaterialHelper {
  19911. /**
  19912. * Bind the current view position to an effect.
  19913. * @param effect The effect to be bound
  19914. * @param scene The scene the eyes position is used from
  19915. * @param variableName name of the shader variable that will hold the eye position
  19916. */
  19917. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  19918. /**
  19919. * Helps preparing the defines values about the UVs in used in the effect.
  19920. * UVs are shared as much as we can accross channels in the shaders.
  19921. * @param texture The texture we are preparing the UVs for
  19922. * @param defines The defines to update
  19923. * @param key The channel key "diffuse", "specular"... used in the shader
  19924. */
  19925. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  19926. /**
  19927. * Binds a texture matrix value to its corrsponding uniform
  19928. * @param texture The texture to bind the matrix for
  19929. * @param uniformBuffer The uniform buffer receivin the data
  19930. * @param key The channel key "diffuse", "specular"... used in the shader
  19931. */
  19932. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  19933. /**
  19934. * Gets the current status of the fog (should it be enabled?)
  19935. * @param mesh defines the mesh to evaluate for fog support
  19936. * @param scene defines the hosting scene
  19937. * @returns true if fog must be enabled
  19938. */
  19939. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  19940. /**
  19941. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  19942. * @param mesh defines the current mesh
  19943. * @param scene defines the current scene
  19944. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  19945. * @param pointsCloud defines if point cloud rendering has to be turned on
  19946. * @param fogEnabled defines if fog has to be turned on
  19947. * @param alphaTest defines if alpha testing has to be turned on
  19948. * @param defines defines the current list of defines
  19949. */
  19950. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  19951. /**
  19952. * Helper used to prepare the list of defines associated with frame values for shader compilation
  19953. * @param scene defines the current scene
  19954. * @param engine defines the current engine
  19955. * @param defines specifies the list of active defines
  19956. * @param useInstances defines if instances have to be turned on
  19957. * @param useClipPlane defines if clip plane have to be turned on
  19958. */
  19959. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  19960. /**
  19961. * Prepares the defines for bones
  19962. * @param mesh The mesh containing the geometry data we will draw
  19963. * @param defines The defines to update
  19964. */
  19965. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  19966. /**
  19967. * Prepares the defines for morph targets
  19968. * @param mesh The mesh containing the geometry data we will draw
  19969. * @param defines The defines to update
  19970. */
  19971. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  19972. /**
  19973. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  19974. * @param mesh The mesh containing the geometry data we will draw
  19975. * @param defines The defines to update
  19976. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  19977. * @param useBones Precise whether bones should be used or not (override mesh info)
  19978. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  19979. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  19980. * @returns false if defines are considered not dirty and have not been checked
  19981. */
  19982. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  19983. /**
  19984. * Prepares the defines related to multiview
  19985. * @param scene The scene we are intending to draw
  19986. * @param defines The defines to update
  19987. */
  19988. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  19989. /**
  19990. * Prepares the defines related to the light information passed in parameter
  19991. * @param scene The scene we are intending to draw
  19992. * @param mesh The mesh the effect is compiling for
  19993. * @param light The light the effect is compiling for
  19994. * @param lightIndex The index of the light
  19995. * @param defines The defines to update
  19996. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  19997. * @param state Defines the current state regarding what is needed (normals, etc...)
  19998. */
  19999. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20000. needNormals: boolean;
  20001. needRebuild: boolean;
  20002. shadowEnabled: boolean;
  20003. specularEnabled: boolean;
  20004. lightmapMode: boolean;
  20005. }): void;
  20006. /**
  20007. * Prepares the defines related to the light information passed in parameter
  20008. * @param scene The scene we are intending to draw
  20009. * @param mesh The mesh the effect is compiling for
  20010. * @param defines The defines to update
  20011. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20012. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20013. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20014. * @returns true if normals will be required for the rest of the effect
  20015. */
  20016. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20017. /**
  20018. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20019. * @param lightIndex defines the light index
  20020. * @param uniformsList The uniform list
  20021. * @param samplersList The sampler list
  20022. * @param projectedLightTexture defines if projected texture must be used
  20023. * @param uniformBuffersList defines an optional list of uniform buffers
  20024. */
  20025. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20026. /**
  20027. * Prepares the uniforms and samplers list to be used in the effect
  20028. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20029. * @param samplersList The sampler list
  20030. * @param defines The defines helping in the list generation
  20031. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20032. */
  20033. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20034. /**
  20035. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20036. * @param defines The defines to update while falling back
  20037. * @param fallbacks The authorized effect fallbacks
  20038. * @param maxSimultaneousLights The maximum number of lights allowed
  20039. * @param rank the current rank of the Effect
  20040. * @returns The newly affected rank
  20041. */
  20042. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20043. private static _TmpMorphInfluencers;
  20044. /**
  20045. * Prepares the list of attributes required for morph targets according to the effect defines.
  20046. * @param attribs The current list of supported attribs
  20047. * @param mesh The mesh to prepare the morph targets attributes for
  20048. * @param influencers The number of influencers
  20049. */
  20050. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20051. /**
  20052. * Prepares the list of attributes required for morph targets according to the effect defines.
  20053. * @param attribs The current list of supported attribs
  20054. * @param mesh The mesh to prepare the morph targets attributes for
  20055. * @param defines The current Defines of the effect
  20056. */
  20057. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20058. /**
  20059. * Prepares the list of attributes required for bones according to the effect defines.
  20060. * @param attribs The current list of supported attribs
  20061. * @param mesh The mesh to prepare the bones attributes for
  20062. * @param defines The current Defines of the effect
  20063. * @param fallbacks The current efffect fallback strategy
  20064. */
  20065. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20066. /**
  20067. * Check and prepare the list of attributes required for instances according to the effect defines.
  20068. * @param attribs The current list of supported attribs
  20069. * @param defines The current MaterialDefines of the effect
  20070. */
  20071. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20072. /**
  20073. * Add the list of attributes required for instances to the attribs array.
  20074. * @param attribs The current list of supported attribs
  20075. */
  20076. static PushAttributesForInstances(attribs: string[]): void;
  20077. /**
  20078. * Binds the light information to the effect.
  20079. * @param light The light containing the generator
  20080. * @param effect The effect we are binding the data to
  20081. * @param lightIndex The light index in the effect used to render
  20082. */
  20083. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20084. /**
  20085. * Binds the lights information from the scene to the effect for the given mesh.
  20086. * @param light Light to bind
  20087. * @param lightIndex Light index
  20088. * @param scene The scene where the light belongs to
  20089. * @param effect The effect we are binding the data to
  20090. * @param useSpecular Defines if specular is supported
  20091. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20092. */
  20093. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20094. /**
  20095. * Binds the lights information from the scene to the effect for the given mesh.
  20096. * @param scene The scene the lights belongs to
  20097. * @param mesh The mesh we are binding the information to render
  20098. * @param effect The effect we are binding the data to
  20099. * @param defines The generated defines for the effect
  20100. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20101. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20102. */
  20103. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20104. private static _tempFogColor;
  20105. /**
  20106. * Binds the fog information from the scene to the effect for the given mesh.
  20107. * @param scene The scene the lights belongs to
  20108. * @param mesh The mesh we are binding the information to render
  20109. * @param effect The effect we are binding the data to
  20110. * @param linearSpace Defines if the fog effect is applied in linear space
  20111. */
  20112. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20113. /**
  20114. * Binds the bones information from the mesh to the effect.
  20115. * @param mesh The mesh we are binding the information to render
  20116. * @param effect The effect we are binding the data to
  20117. */
  20118. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20119. /**
  20120. * Binds the morph targets information from the mesh to the effect.
  20121. * @param abstractMesh The mesh we are binding the information to render
  20122. * @param effect The effect we are binding the data to
  20123. */
  20124. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20125. /**
  20126. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20127. * @param defines The generated defines used in the effect
  20128. * @param effect The effect we are binding the data to
  20129. * @param scene The scene we are willing to render with logarithmic scale for
  20130. */
  20131. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20132. /**
  20133. * Binds the clip plane information from the scene to the effect.
  20134. * @param scene The scene the clip plane information are extracted from
  20135. * @param effect The effect we are binding the data to
  20136. */
  20137. static BindClipPlane(effect: Effect, scene: Scene): void;
  20138. }
  20139. }
  20140. declare module BABYLON {
  20141. /**
  20142. * Block used to expose an input value
  20143. */
  20144. export class InputBlock extends NodeMaterialBlock {
  20145. private _mode;
  20146. private _associatedVariableName;
  20147. private _storedValue;
  20148. private _valueCallback;
  20149. private _type;
  20150. private _animationType;
  20151. /** Gets or set a value used to limit the range of float values */
  20152. min: number;
  20153. /** Gets or set a value used to limit the range of float values */
  20154. max: number;
  20155. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20156. isBoolean: boolean;
  20157. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20158. matrixMode: number;
  20159. /** @hidden */
  20160. _systemValue: Nullable<NodeMaterialSystemValues>;
  20161. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20162. visibleInInspector: boolean;
  20163. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20164. isConstant: boolean;
  20165. /** Gets or sets the group to use to display this block in the Inspector */
  20166. groupInInspector: string;
  20167. /** Gets an observable raised when the value is changed */
  20168. onValueChangedObservable: Observable<InputBlock>;
  20169. /**
  20170. * Gets or sets the connection point type (default is float)
  20171. */
  20172. get type(): NodeMaterialBlockConnectionPointTypes;
  20173. /**
  20174. * Creates a new InputBlock
  20175. * @param name defines the block name
  20176. * @param target defines the target of that block (Vertex by default)
  20177. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20178. */
  20179. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20180. /**
  20181. * Gets the output component
  20182. */
  20183. get output(): NodeMaterialConnectionPoint;
  20184. /**
  20185. * Set the source of this connection point to a vertex attribute
  20186. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20187. * @returns the current connection point
  20188. */
  20189. setAsAttribute(attributeName?: string): InputBlock;
  20190. /**
  20191. * Set the source of this connection point to a system value
  20192. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20193. * @returns the current connection point
  20194. */
  20195. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20196. /**
  20197. * Gets or sets the value of that point.
  20198. * Please note that this value will be ignored if valueCallback is defined
  20199. */
  20200. get value(): any;
  20201. set value(value: any);
  20202. /**
  20203. * Gets or sets a callback used to get the value of that point.
  20204. * Please note that setting this value will force the connection point to ignore the value property
  20205. */
  20206. get valueCallback(): () => any;
  20207. set valueCallback(value: () => any);
  20208. /**
  20209. * Gets or sets the associated variable name in the shader
  20210. */
  20211. get associatedVariableName(): string;
  20212. set associatedVariableName(value: string);
  20213. /** Gets or sets the type of animation applied to the input */
  20214. get animationType(): AnimatedInputBlockTypes;
  20215. set animationType(value: AnimatedInputBlockTypes);
  20216. /**
  20217. * Gets a boolean indicating that this connection point not defined yet
  20218. */
  20219. get isUndefined(): boolean;
  20220. /**
  20221. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20222. * In this case the connection point name must be the name of the uniform to use.
  20223. * Can only be set on inputs
  20224. */
  20225. get isUniform(): boolean;
  20226. set isUniform(value: boolean);
  20227. /**
  20228. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20229. * In this case the connection point name must be the name of the attribute to use
  20230. * Can only be set on inputs
  20231. */
  20232. get isAttribute(): boolean;
  20233. set isAttribute(value: boolean);
  20234. /**
  20235. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20236. * Can only be set on exit points
  20237. */
  20238. get isVarying(): boolean;
  20239. set isVarying(value: boolean);
  20240. /**
  20241. * Gets a boolean indicating that the current connection point is a system value
  20242. */
  20243. get isSystemValue(): boolean;
  20244. /**
  20245. * Gets or sets the current well known value or null if not defined as a system value
  20246. */
  20247. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20248. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20249. /**
  20250. * Gets the current class name
  20251. * @returns the class name
  20252. */
  20253. getClassName(): string;
  20254. /**
  20255. * Animate the input if animationType !== None
  20256. * @param scene defines the rendering scene
  20257. */
  20258. animate(scene: Scene): void;
  20259. private _emitDefine;
  20260. initialize(state: NodeMaterialBuildState): void;
  20261. /**
  20262. * Set the input block to its default value (based on its type)
  20263. */
  20264. setDefaultValue(): void;
  20265. private _emitConstant;
  20266. /** @hidden */
  20267. get _noContextSwitch(): boolean;
  20268. private _emit;
  20269. /** @hidden */
  20270. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20271. /** @hidden */
  20272. _transmit(effect: Effect, scene: Scene): void;
  20273. protected _buildBlock(state: NodeMaterialBuildState): void;
  20274. protected _dumpPropertiesCode(): string;
  20275. dispose(): void;
  20276. serialize(): any;
  20277. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20278. }
  20279. }
  20280. declare module BABYLON {
  20281. /**
  20282. * Enum used to define the compatibility state between two connection points
  20283. */
  20284. export enum NodeMaterialConnectionPointCompatibilityStates {
  20285. /** Points are compatibles */
  20286. Compatible = 0,
  20287. /** Points are incompatible because of their types */
  20288. TypeIncompatible = 1,
  20289. /** Points are incompatible because of their targets (vertex vs fragment) */
  20290. TargetIncompatible = 2
  20291. }
  20292. /**
  20293. * Defines the direction of a connection point
  20294. */
  20295. export enum NodeMaterialConnectionPointDirection {
  20296. /** Input */
  20297. Input = 0,
  20298. /** Output */
  20299. Output = 1
  20300. }
  20301. /**
  20302. * Defines a connection point for a block
  20303. */
  20304. export class NodeMaterialConnectionPoint {
  20305. /** @hidden */
  20306. _ownerBlock: NodeMaterialBlock;
  20307. /** @hidden */
  20308. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20309. private _endpoints;
  20310. private _associatedVariableName;
  20311. private _direction;
  20312. /** @hidden */
  20313. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20314. /** @hidden */
  20315. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20316. private _type;
  20317. /** @hidden */
  20318. _enforceAssociatedVariableName: boolean;
  20319. /** Gets the direction of the point */
  20320. get direction(): NodeMaterialConnectionPointDirection;
  20321. /** Indicates that this connection point needs dual validation before being connected to another point */
  20322. needDualDirectionValidation: boolean;
  20323. /**
  20324. * Gets or sets the additional types supported by this connection point
  20325. */
  20326. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20327. /**
  20328. * Gets or sets the additional types excluded by this connection point
  20329. */
  20330. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20331. /**
  20332. * Observable triggered when this point is connected
  20333. */
  20334. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20335. /**
  20336. * Gets or sets the associated variable name in the shader
  20337. */
  20338. get associatedVariableName(): string;
  20339. set associatedVariableName(value: string);
  20340. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20341. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20342. /**
  20343. * Gets or sets the connection point type (default is float)
  20344. */
  20345. get type(): NodeMaterialBlockConnectionPointTypes;
  20346. set type(value: NodeMaterialBlockConnectionPointTypes);
  20347. /**
  20348. * Gets or sets the connection point name
  20349. */
  20350. name: string;
  20351. /**
  20352. * Gets or sets the connection point name
  20353. */
  20354. displayName: string;
  20355. /**
  20356. * Gets or sets a boolean indicating that this connection point can be omitted
  20357. */
  20358. isOptional: boolean;
  20359. /**
  20360. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20361. */
  20362. define: string;
  20363. /** @hidden */
  20364. _prioritizeVertex: boolean;
  20365. private _target;
  20366. /** Gets or sets the target of that connection point */
  20367. get target(): NodeMaterialBlockTargets;
  20368. set target(value: NodeMaterialBlockTargets);
  20369. /**
  20370. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20371. */
  20372. get isConnected(): boolean;
  20373. /**
  20374. * Gets a boolean indicating that the current point is connected to an input block
  20375. */
  20376. get isConnectedToInputBlock(): boolean;
  20377. /**
  20378. * Gets a the connected input block (if any)
  20379. */
  20380. get connectInputBlock(): Nullable<InputBlock>;
  20381. /** Get the other side of the connection (if any) */
  20382. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20383. /** Get the block that owns this connection point */
  20384. get ownerBlock(): NodeMaterialBlock;
  20385. /** Get the block connected on the other side of this connection (if any) */
  20386. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20387. /** Get the block connected on the endpoints of this connection (if any) */
  20388. get connectedBlocks(): Array<NodeMaterialBlock>;
  20389. /** Gets the list of connected endpoints */
  20390. get endpoints(): NodeMaterialConnectionPoint[];
  20391. /** Gets a boolean indicating if that output point is connected to at least one input */
  20392. get hasEndpoints(): boolean;
  20393. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20394. get isConnectedInVertexShader(): boolean;
  20395. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20396. get isConnectedInFragmentShader(): boolean;
  20397. /**
  20398. * Creates a block suitable to be used as an input for this input point.
  20399. * If null is returned, a block based on the point type will be created.
  20400. * @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
  20401. */
  20402. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20403. /**
  20404. * Creates a new connection point
  20405. * @param name defines the connection point name
  20406. * @param ownerBlock defines the block hosting this connection point
  20407. * @param direction defines the direction of the connection point
  20408. */
  20409. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20410. /**
  20411. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20412. * @returns the class name
  20413. */
  20414. getClassName(): string;
  20415. /**
  20416. * Gets a boolean indicating if the current point can be connected to another point
  20417. * @param connectionPoint defines the other connection point
  20418. * @returns a boolean
  20419. */
  20420. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20421. /**
  20422. * Gets a number indicating if the current point can be connected to another point
  20423. * @param connectionPoint defines the other connection point
  20424. * @returns a number defining the compatibility state
  20425. */
  20426. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20427. /**
  20428. * Connect this point to another connection point
  20429. * @param connectionPoint defines the other connection point
  20430. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20431. * @returns the current connection point
  20432. */
  20433. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20434. /**
  20435. * Disconnect this point from one of his endpoint
  20436. * @param endpoint defines the other connection point
  20437. * @returns the current connection point
  20438. */
  20439. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20440. /**
  20441. * Serializes this point in a JSON representation
  20442. * @param isInput defines if the connection point is an input (default is true)
  20443. * @returns the serialized point object
  20444. */
  20445. serialize(isInput?: boolean): any;
  20446. /**
  20447. * Release resources
  20448. */
  20449. dispose(): void;
  20450. }
  20451. }
  20452. declare module BABYLON {
  20453. /**
  20454. * Enum used to define the material modes
  20455. */
  20456. export enum NodeMaterialModes {
  20457. /** Regular material */
  20458. Material = 0,
  20459. /** For post process */
  20460. PostProcess = 1,
  20461. /** For particle system */
  20462. Particle = 2
  20463. }
  20464. }
  20465. declare module BABYLON {
  20466. /**
  20467. * Block used to read a texture from a sampler
  20468. */
  20469. export class TextureBlock extends NodeMaterialBlock {
  20470. private _defineName;
  20471. private _linearDefineName;
  20472. private _gammaDefineName;
  20473. private _tempTextureRead;
  20474. private _samplerName;
  20475. private _transformedUVName;
  20476. private _textureTransformName;
  20477. private _textureInfoName;
  20478. private _mainUVName;
  20479. private _mainUVDefineName;
  20480. private _fragmentOnly;
  20481. /**
  20482. * Gets or sets the texture associated with the node
  20483. */
  20484. texture: Nullable<Texture>;
  20485. /**
  20486. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20487. */
  20488. convertToGammaSpace: boolean;
  20489. /**
  20490. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20491. */
  20492. convertToLinearSpace: boolean;
  20493. /**
  20494. * Create a new TextureBlock
  20495. * @param name defines the block name
  20496. */
  20497. constructor(name: string, fragmentOnly?: boolean);
  20498. /**
  20499. * Gets the current class name
  20500. * @returns the class name
  20501. */
  20502. getClassName(): string;
  20503. /**
  20504. * Gets the uv input component
  20505. */
  20506. get uv(): NodeMaterialConnectionPoint;
  20507. /**
  20508. * Gets the rgba output component
  20509. */
  20510. get rgba(): NodeMaterialConnectionPoint;
  20511. /**
  20512. * Gets the rgb output component
  20513. */
  20514. get rgb(): NodeMaterialConnectionPoint;
  20515. /**
  20516. * Gets the r output component
  20517. */
  20518. get r(): NodeMaterialConnectionPoint;
  20519. /**
  20520. * Gets the g output component
  20521. */
  20522. get g(): NodeMaterialConnectionPoint;
  20523. /**
  20524. * Gets the b output component
  20525. */
  20526. get b(): NodeMaterialConnectionPoint;
  20527. /**
  20528. * Gets the a output component
  20529. */
  20530. get a(): NodeMaterialConnectionPoint;
  20531. get target(): NodeMaterialBlockTargets;
  20532. autoConfigure(material: NodeMaterial): void;
  20533. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20534. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20535. isReady(): boolean;
  20536. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20537. private get _isMixed();
  20538. private _injectVertexCode;
  20539. private _writeTextureRead;
  20540. private _writeOutput;
  20541. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20542. protected _dumpPropertiesCode(): string;
  20543. serialize(): any;
  20544. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20545. }
  20546. }
  20547. declare module BABYLON {
  20548. /** @hidden */
  20549. export var reflectionFunction: {
  20550. name: string;
  20551. shader: string;
  20552. };
  20553. }
  20554. declare module BABYLON {
  20555. /**
  20556. * Base block used to read a reflection texture from a sampler
  20557. */
  20558. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20559. /** @hidden */
  20560. _define3DName: string;
  20561. /** @hidden */
  20562. _defineCubicName: string;
  20563. /** @hidden */
  20564. _defineExplicitName: string;
  20565. /** @hidden */
  20566. _defineProjectionName: string;
  20567. /** @hidden */
  20568. _defineLocalCubicName: string;
  20569. /** @hidden */
  20570. _defineSphericalName: string;
  20571. /** @hidden */
  20572. _definePlanarName: string;
  20573. /** @hidden */
  20574. _defineEquirectangularName: string;
  20575. /** @hidden */
  20576. _defineMirroredEquirectangularFixedName: string;
  20577. /** @hidden */
  20578. _defineEquirectangularFixedName: string;
  20579. /** @hidden */
  20580. _defineSkyboxName: string;
  20581. /** @hidden */
  20582. _defineOppositeZ: string;
  20583. /** @hidden */
  20584. _cubeSamplerName: string;
  20585. /** @hidden */
  20586. _2DSamplerName: string;
  20587. protected _positionUVWName: string;
  20588. protected _directionWName: string;
  20589. protected _reflectionVectorName: string;
  20590. /** @hidden */
  20591. _reflectionCoordsName: string;
  20592. /** @hidden */
  20593. _reflectionMatrixName: string;
  20594. protected _reflectionColorName: string;
  20595. /**
  20596. * Gets or sets the texture associated with the node
  20597. */
  20598. texture: Nullable<BaseTexture>;
  20599. /**
  20600. * Create a new ReflectionTextureBaseBlock
  20601. * @param name defines the block name
  20602. */
  20603. constructor(name: string);
  20604. /**
  20605. * Gets the current class name
  20606. * @returns the class name
  20607. */
  20608. getClassName(): string;
  20609. /**
  20610. * Gets the world position input component
  20611. */
  20612. abstract get position(): NodeMaterialConnectionPoint;
  20613. /**
  20614. * Gets the world position input component
  20615. */
  20616. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20617. /**
  20618. * Gets the world normal input component
  20619. */
  20620. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20621. /**
  20622. * Gets the world input component
  20623. */
  20624. abstract get world(): NodeMaterialConnectionPoint;
  20625. /**
  20626. * Gets the camera (or eye) position component
  20627. */
  20628. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20629. /**
  20630. * Gets the view input component
  20631. */
  20632. abstract get view(): NodeMaterialConnectionPoint;
  20633. protected _getTexture(): Nullable<BaseTexture>;
  20634. autoConfigure(material: NodeMaterial): void;
  20635. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20636. isReady(): boolean;
  20637. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20638. /**
  20639. * Gets the code to inject in the vertex shader
  20640. * @param state current state of the node material building
  20641. * @returns the shader code
  20642. */
  20643. handleVertexSide(state: NodeMaterialBuildState): string;
  20644. /**
  20645. * Handles the inits for the fragment code path
  20646. * @param state node material build state
  20647. */
  20648. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20649. /**
  20650. * Generates the reflection coords code for the fragment code path
  20651. * @param worldNormalVarName name of the world normal variable
  20652. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20653. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20654. * @returns the shader code
  20655. */
  20656. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20657. /**
  20658. * Generates the reflection color code for the fragment code path
  20659. * @param lodVarName name of the lod variable
  20660. * @param swizzleLookupTexture swizzle to use for the final color variable
  20661. * @returns the shader code
  20662. */
  20663. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20664. /**
  20665. * Generates the code corresponding to the connected output points
  20666. * @param state node material build state
  20667. * @param varName name of the variable to output
  20668. * @returns the shader code
  20669. */
  20670. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20671. protected _buildBlock(state: NodeMaterialBuildState): this;
  20672. protected _dumpPropertiesCode(): string;
  20673. serialize(): any;
  20674. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20675. }
  20676. }
  20677. declare module BABYLON {
  20678. /**
  20679. * Defines a connection point to be used for points with a custom object type
  20680. */
  20681. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20682. private _blockType;
  20683. private _blockName;
  20684. private _nameForCheking?;
  20685. /**
  20686. * Creates a new connection point
  20687. * @param name defines the connection point name
  20688. * @param ownerBlock defines the block hosting this connection point
  20689. * @param direction defines the direction of the connection point
  20690. */
  20691. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20692. /**
  20693. * Gets a number indicating if the current point can be connected to another point
  20694. * @param connectionPoint defines the other connection point
  20695. * @returns a number defining the compatibility state
  20696. */
  20697. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20698. /**
  20699. * Creates a block suitable to be used as an input for this input point.
  20700. * If null is returned, a block based on the point type will be created.
  20701. * @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
  20702. */
  20703. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20704. }
  20705. }
  20706. declare module BABYLON {
  20707. /**
  20708. * Enum defining the type of properties that can be edited in the property pages in the NME
  20709. */
  20710. export enum PropertyTypeForEdition {
  20711. /** property is a boolean */
  20712. Boolean = 0,
  20713. /** property is a float */
  20714. Float = 1,
  20715. /** property is a Vector2 */
  20716. Vector2 = 2,
  20717. /** property is a list of values */
  20718. List = 3
  20719. }
  20720. /**
  20721. * Interface that defines an option in a variable of type list
  20722. */
  20723. export interface IEditablePropertyListOption {
  20724. /** label of the option */
  20725. "label": string;
  20726. /** value of the option */
  20727. "value": number;
  20728. }
  20729. /**
  20730. * Interface that defines the options available for an editable property
  20731. */
  20732. export interface IEditablePropertyOption {
  20733. /** min value */
  20734. "min"?: number;
  20735. /** max value */
  20736. "max"?: number;
  20737. /** notifiers: indicates which actions to take when the property is changed */
  20738. "notifiers"?: {
  20739. /** the material should be rebuilt */
  20740. "rebuild"?: boolean;
  20741. /** the preview should be updated */
  20742. "update"?: boolean;
  20743. };
  20744. /** list of the options for a variable of type list */
  20745. "options"?: IEditablePropertyListOption[];
  20746. }
  20747. /**
  20748. * Interface that describes an editable property
  20749. */
  20750. export interface IPropertyDescriptionForEdition {
  20751. /** name of the property */
  20752. "propertyName": string;
  20753. /** display name of the property */
  20754. "displayName": string;
  20755. /** type of the property */
  20756. "type": PropertyTypeForEdition;
  20757. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20758. "groupName": string;
  20759. /** options for the property */
  20760. "options": IEditablePropertyOption;
  20761. }
  20762. /**
  20763. * Decorator that flags a property in a node material block as being editable
  20764. */
  20765. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20766. }
  20767. declare module BABYLON {
  20768. /**
  20769. * Block used to implement the refraction part of the sub surface module of the PBR material
  20770. */
  20771. export class RefractionBlock extends NodeMaterialBlock {
  20772. /** @hidden */
  20773. _define3DName: string;
  20774. /** @hidden */
  20775. _refractionMatrixName: string;
  20776. /** @hidden */
  20777. _defineLODRefractionAlpha: string;
  20778. /** @hidden */
  20779. _defineLinearSpecularRefraction: string;
  20780. /** @hidden */
  20781. _defineOppositeZ: string;
  20782. /** @hidden */
  20783. _cubeSamplerName: string;
  20784. /** @hidden */
  20785. _2DSamplerName: string;
  20786. /** @hidden */
  20787. _vRefractionMicrosurfaceInfosName: string;
  20788. /** @hidden */
  20789. _vRefractionInfosName: string;
  20790. private _scene;
  20791. /**
  20792. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20793. * Materials half opaque for instance using refraction could benefit from this control.
  20794. */
  20795. linkRefractionWithTransparency: boolean;
  20796. /**
  20797. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20798. */
  20799. invertRefractionY: boolean;
  20800. /**
  20801. * Gets or sets the texture associated with the node
  20802. */
  20803. texture: Nullable<BaseTexture>;
  20804. /**
  20805. * Create a new RefractionBlock
  20806. * @param name defines the block name
  20807. */
  20808. constructor(name: string);
  20809. /**
  20810. * Gets the current class name
  20811. * @returns the class name
  20812. */
  20813. getClassName(): string;
  20814. /**
  20815. * Gets the intensity input component
  20816. */
  20817. get intensity(): NodeMaterialConnectionPoint;
  20818. /**
  20819. * Gets the index of refraction input component
  20820. */
  20821. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20822. /**
  20823. * Gets the tint at distance input component
  20824. */
  20825. get tintAtDistance(): NodeMaterialConnectionPoint;
  20826. /**
  20827. * Gets the view input component
  20828. */
  20829. get view(): NodeMaterialConnectionPoint;
  20830. /**
  20831. * Gets the refraction object output component
  20832. */
  20833. get refraction(): NodeMaterialConnectionPoint;
  20834. /**
  20835. * Returns true if the block has a texture
  20836. */
  20837. get hasTexture(): boolean;
  20838. protected _getTexture(): Nullable<BaseTexture>;
  20839. autoConfigure(material: NodeMaterial): void;
  20840. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20841. isReady(): boolean;
  20842. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20843. /**
  20844. * Gets the main code of the block (fragment side)
  20845. * @param state current state of the node material building
  20846. * @returns the shader code
  20847. */
  20848. getCode(state: NodeMaterialBuildState): string;
  20849. protected _buildBlock(state: NodeMaterialBuildState): this;
  20850. protected _dumpPropertiesCode(): string;
  20851. serialize(): any;
  20852. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20853. }
  20854. }
  20855. declare module BABYLON {
  20856. /**
  20857. * Base block used as input for post process
  20858. */
  20859. export class CurrentScreenBlock extends NodeMaterialBlock {
  20860. private _samplerName;
  20861. private _linearDefineName;
  20862. private _gammaDefineName;
  20863. private _mainUVName;
  20864. private _tempTextureRead;
  20865. /**
  20866. * Gets or sets the texture associated with the node
  20867. */
  20868. texture: Nullable<BaseTexture>;
  20869. /**
  20870. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20871. */
  20872. convertToGammaSpace: boolean;
  20873. /**
  20874. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20875. */
  20876. convertToLinearSpace: boolean;
  20877. /**
  20878. * Create a new CurrentScreenBlock
  20879. * @param name defines the block name
  20880. */
  20881. constructor(name: string);
  20882. /**
  20883. * Gets the current class name
  20884. * @returns the class name
  20885. */
  20886. getClassName(): string;
  20887. /**
  20888. * Gets the uv input component
  20889. */
  20890. get uv(): NodeMaterialConnectionPoint;
  20891. /**
  20892. * Gets the rgba output component
  20893. */
  20894. get rgba(): NodeMaterialConnectionPoint;
  20895. /**
  20896. * Gets the rgb output component
  20897. */
  20898. get rgb(): NodeMaterialConnectionPoint;
  20899. /**
  20900. * Gets the r output component
  20901. */
  20902. get r(): NodeMaterialConnectionPoint;
  20903. /**
  20904. * Gets the g output component
  20905. */
  20906. get g(): NodeMaterialConnectionPoint;
  20907. /**
  20908. * Gets the b output component
  20909. */
  20910. get b(): NodeMaterialConnectionPoint;
  20911. /**
  20912. * Gets the a output component
  20913. */
  20914. get a(): NodeMaterialConnectionPoint;
  20915. /**
  20916. * Initialize the block and prepare the context for build
  20917. * @param state defines the state that will be used for the build
  20918. */
  20919. initialize(state: NodeMaterialBuildState): void;
  20920. get target(): NodeMaterialBlockTargets;
  20921. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20922. isReady(): boolean;
  20923. private _injectVertexCode;
  20924. private _writeTextureRead;
  20925. private _writeOutput;
  20926. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20927. serialize(): any;
  20928. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20929. }
  20930. }
  20931. declare module BABYLON {
  20932. /**
  20933. * Base block used for the particle texture
  20934. */
  20935. export class ParticleTextureBlock extends NodeMaterialBlock {
  20936. private _samplerName;
  20937. private _linearDefineName;
  20938. private _gammaDefineName;
  20939. private _tempTextureRead;
  20940. /**
  20941. * Gets or sets the texture associated with the node
  20942. */
  20943. texture: Nullable<BaseTexture>;
  20944. /**
  20945. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20946. */
  20947. convertToGammaSpace: boolean;
  20948. /**
  20949. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20950. */
  20951. convertToLinearSpace: boolean;
  20952. /**
  20953. * Create a new ParticleTextureBlock
  20954. * @param name defines the block name
  20955. */
  20956. constructor(name: string);
  20957. /**
  20958. * Gets the current class name
  20959. * @returns the class name
  20960. */
  20961. getClassName(): string;
  20962. /**
  20963. * Gets the uv input component
  20964. */
  20965. get uv(): NodeMaterialConnectionPoint;
  20966. /**
  20967. * Gets the rgba output component
  20968. */
  20969. get rgba(): NodeMaterialConnectionPoint;
  20970. /**
  20971. * Gets the rgb output component
  20972. */
  20973. get rgb(): NodeMaterialConnectionPoint;
  20974. /**
  20975. * Gets the r output component
  20976. */
  20977. get r(): NodeMaterialConnectionPoint;
  20978. /**
  20979. * Gets the g output component
  20980. */
  20981. get g(): NodeMaterialConnectionPoint;
  20982. /**
  20983. * Gets the b output component
  20984. */
  20985. get b(): NodeMaterialConnectionPoint;
  20986. /**
  20987. * Gets the a output component
  20988. */
  20989. get a(): NodeMaterialConnectionPoint;
  20990. /**
  20991. * Initialize the block and prepare the context for build
  20992. * @param state defines the state that will be used for the build
  20993. */
  20994. initialize(state: NodeMaterialBuildState): void;
  20995. autoConfigure(material: NodeMaterial): void;
  20996. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20997. isReady(): boolean;
  20998. private _writeOutput;
  20999. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21000. serialize(): any;
  21001. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21002. }
  21003. }
  21004. declare module BABYLON {
  21005. /**
  21006. * Class used to store shared data between 2 NodeMaterialBuildState
  21007. */
  21008. export class NodeMaterialBuildStateSharedData {
  21009. /**
  21010. * Gets the list of emitted varyings
  21011. */
  21012. temps: string[];
  21013. /**
  21014. * Gets the list of emitted varyings
  21015. */
  21016. varyings: string[];
  21017. /**
  21018. * Gets the varying declaration string
  21019. */
  21020. varyingDeclaration: string;
  21021. /**
  21022. * Input blocks
  21023. */
  21024. inputBlocks: InputBlock[];
  21025. /**
  21026. * Input blocks
  21027. */
  21028. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21029. /**
  21030. * Bindable blocks (Blocks that need to set data to the effect)
  21031. */
  21032. bindableBlocks: NodeMaterialBlock[];
  21033. /**
  21034. * List of blocks that can provide a compilation fallback
  21035. */
  21036. blocksWithFallbacks: NodeMaterialBlock[];
  21037. /**
  21038. * List of blocks that can provide a define update
  21039. */
  21040. blocksWithDefines: NodeMaterialBlock[];
  21041. /**
  21042. * List of blocks that can provide a repeatable content
  21043. */
  21044. repeatableContentBlocks: NodeMaterialBlock[];
  21045. /**
  21046. * List of blocks that can provide a dynamic list of uniforms
  21047. */
  21048. dynamicUniformBlocks: NodeMaterialBlock[];
  21049. /**
  21050. * List of blocks that can block the isReady function for the material
  21051. */
  21052. blockingBlocks: NodeMaterialBlock[];
  21053. /**
  21054. * Gets the list of animated inputs
  21055. */
  21056. animatedInputs: InputBlock[];
  21057. /**
  21058. * Build Id used to avoid multiple recompilations
  21059. */
  21060. buildId: number;
  21061. /** List of emitted variables */
  21062. variableNames: {
  21063. [key: string]: number;
  21064. };
  21065. /** List of emitted defines */
  21066. defineNames: {
  21067. [key: string]: number;
  21068. };
  21069. /** Should emit comments? */
  21070. emitComments: boolean;
  21071. /** Emit build activity */
  21072. verbose: boolean;
  21073. /** Gets or sets the hosting scene */
  21074. scene: Scene;
  21075. /**
  21076. * Gets the compilation hints emitted at compilation time
  21077. */
  21078. hints: {
  21079. needWorldViewMatrix: boolean;
  21080. needWorldViewProjectionMatrix: boolean;
  21081. needAlphaBlending: boolean;
  21082. needAlphaTesting: boolean;
  21083. };
  21084. /**
  21085. * List of compilation checks
  21086. */
  21087. checks: {
  21088. emitVertex: boolean;
  21089. emitFragment: boolean;
  21090. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21091. };
  21092. /**
  21093. * Is vertex program allowed to be empty?
  21094. */
  21095. allowEmptyVertexProgram: boolean;
  21096. /** Creates a new shared data */
  21097. constructor();
  21098. /**
  21099. * Emits console errors and exceptions if there is a failing check
  21100. */
  21101. emitErrors(): void;
  21102. }
  21103. }
  21104. declare module BABYLON {
  21105. /**
  21106. * Class used to store node based material build state
  21107. */
  21108. export class NodeMaterialBuildState {
  21109. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21110. supportUniformBuffers: boolean;
  21111. /**
  21112. * Gets the list of emitted attributes
  21113. */
  21114. attributes: string[];
  21115. /**
  21116. * Gets the list of emitted uniforms
  21117. */
  21118. uniforms: string[];
  21119. /**
  21120. * Gets the list of emitted constants
  21121. */
  21122. constants: string[];
  21123. /**
  21124. * Gets the list of emitted samplers
  21125. */
  21126. samplers: string[];
  21127. /**
  21128. * Gets the list of emitted functions
  21129. */
  21130. functions: {
  21131. [key: string]: string;
  21132. };
  21133. /**
  21134. * Gets the list of emitted extensions
  21135. */
  21136. extensions: {
  21137. [key: string]: string;
  21138. };
  21139. /**
  21140. * Gets the target of the compilation state
  21141. */
  21142. target: NodeMaterialBlockTargets;
  21143. /**
  21144. * Gets the list of emitted counters
  21145. */
  21146. counters: {
  21147. [key: string]: number;
  21148. };
  21149. /**
  21150. * Shared data between multiple NodeMaterialBuildState instances
  21151. */
  21152. sharedData: NodeMaterialBuildStateSharedData;
  21153. /** @hidden */
  21154. _vertexState: NodeMaterialBuildState;
  21155. /** @hidden */
  21156. _attributeDeclaration: string;
  21157. /** @hidden */
  21158. _uniformDeclaration: string;
  21159. /** @hidden */
  21160. _constantDeclaration: string;
  21161. /** @hidden */
  21162. _samplerDeclaration: string;
  21163. /** @hidden */
  21164. _varyingTransfer: string;
  21165. /** @hidden */
  21166. _injectAtEnd: string;
  21167. private _repeatableContentAnchorIndex;
  21168. /** @hidden */
  21169. _builtCompilationString: string;
  21170. /**
  21171. * Gets the emitted compilation strings
  21172. */
  21173. compilationString: string;
  21174. /**
  21175. * Finalize the compilation strings
  21176. * @param state defines the current compilation state
  21177. */
  21178. finalize(state: NodeMaterialBuildState): void;
  21179. /** @hidden */
  21180. get _repeatableContentAnchor(): string;
  21181. /** @hidden */
  21182. _getFreeVariableName(prefix: string): string;
  21183. /** @hidden */
  21184. _getFreeDefineName(prefix: string): string;
  21185. /** @hidden */
  21186. _excludeVariableName(name: string): void;
  21187. /** @hidden */
  21188. _emit2DSampler(name: string): void;
  21189. /** @hidden */
  21190. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21191. /** @hidden */
  21192. _emitExtension(name: string, extension: string, define?: string): void;
  21193. /** @hidden */
  21194. _emitFunction(name: string, code: string, comments: string): void;
  21195. /** @hidden */
  21196. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21197. replaceStrings?: {
  21198. search: RegExp;
  21199. replace: string;
  21200. }[];
  21201. repeatKey?: string;
  21202. }): string;
  21203. /** @hidden */
  21204. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21205. repeatKey?: string;
  21206. removeAttributes?: boolean;
  21207. removeUniforms?: boolean;
  21208. removeVaryings?: boolean;
  21209. removeIfDef?: boolean;
  21210. replaceStrings?: {
  21211. search: RegExp;
  21212. replace: string;
  21213. }[];
  21214. }, storeKey?: string): void;
  21215. /** @hidden */
  21216. _registerTempVariable(name: string): boolean;
  21217. /** @hidden */
  21218. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21219. /** @hidden */
  21220. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21221. /** @hidden */
  21222. _emitFloat(value: number): string;
  21223. }
  21224. }
  21225. declare module BABYLON {
  21226. /**
  21227. * Helper class used to generate session unique ID
  21228. */
  21229. export class UniqueIdGenerator {
  21230. private static _UniqueIdCounter;
  21231. /**
  21232. * Gets an unique (relatively to the current scene) Id
  21233. */
  21234. static get UniqueId(): number;
  21235. }
  21236. }
  21237. declare module BABYLON {
  21238. /**
  21239. * Defines a block that can be used inside a node based material
  21240. */
  21241. export class NodeMaterialBlock {
  21242. private _buildId;
  21243. private _buildTarget;
  21244. private _target;
  21245. private _isFinalMerger;
  21246. private _isInput;
  21247. protected _isUnique: boolean;
  21248. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21249. inputsAreExclusive: boolean;
  21250. /** @hidden */
  21251. _codeVariableName: string;
  21252. /** @hidden */
  21253. _inputs: NodeMaterialConnectionPoint[];
  21254. /** @hidden */
  21255. _outputs: NodeMaterialConnectionPoint[];
  21256. /** @hidden */
  21257. _preparationId: number;
  21258. /**
  21259. * Gets or sets the name of the block
  21260. */
  21261. name: string;
  21262. /**
  21263. * Gets or sets the unique id of the node
  21264. */
  21265. uniqueId: number;
  21266. /**
  21267. * Gets or sets the comments associated with this block
  21268. */
  21269. comments: string;
  21270. /**
  21271. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21272. */
  21273. get isUnique(): boolean;
  21274. /**
  21275. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21276. */
  21277. get isFinalMerger(): boolean;
  21278. /**
  21279. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21280. */
  21281. get isInput(): boolean;
  21282. /**
  21283. * Gets or sets the build Id
  21284. */
  21285. get buildId(): number;
  21286. set buildId(value: number);
  21287. /**
  21288. * Gets or sets the target of the block
  21289. */
  21290. get target(): NodeMaterialBlockTargets;
  21291. set target(value: NodeMaterialBlockTargets);
  21292. /**
  21293. * Gets the list of input points
  21294. */
  21295. get inputs(): NodeMaterialConnectionPoint[];
  21296. /** Gets the list of output points */
  21297. get outputs(): NodeMaterialConnectionPoint[];
  21298. /**
  21299. * Find an input by its name
  21300. * @param name defines the name of the input to look for
  21301. * @returns the input or null if not found
  21302. */
  21303. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21304. /**
  21305. * Find an output by its name
  21306. * @param name defines the name of the outputto look for
  21307. * @returns the output or null if not found
  21308. */
  21309. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21310. /**
  21311. * Creates a new NodeMaterialBlock
  21312. * @param name defines the block name
  21313. * @param target defines the target of that block (Vertex by default)
  21314. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21315. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21316. */
  21317. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21318. /**
  21319. * Initialize the block and prepare the context for build
  21320. * @param state defines the state that will be used for the build
  21321. */
  21322. initialize(state: NodeMaterialBuildState): void;
  21323. /**
  21324. * Bind data to effect. Will only be called for blocks with isBindable === true
  21325. * @param effect defines the effect to bind data to
  21326. * @param nodeMaterial defines the hosting NodeMaterial
  21327. * @param mesh defines the mesh that will be rendered
  21328. * @param subMesh defines the submesh that will be rendered
  21329. */
  21330. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21331. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21332. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21333. protected _writeFloat(value: number): string;
  21334. /**
  21335. * Gets the current class name e.g. "NodeMaterialBlock"
  21336. * @returns the class name
  21337. */
  21338. getClassName(): string;
  21339. /**
  21340. * Register a new input. Must be called inside a block constructor
  21341. * @param name defines the connection point name
  21342. * @param type defines the connection point type
  21343. * @param isOptional defines a boolean indicating that this input can be omitted
  21344. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21345. * @param point an already created connection point. If not provided, create a new one
  21346. * @returns the current block
  21347. */
  21348. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21349. /**
  21350. * Register a new output. Must be called inside a block constructor
  21351. * @param name defines the connection point name
  21352. * @param type defines the connection point type
  21353. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21354. * @param point an already created connection point. If not provided, create a new one
  21355. * @returns the current block
  21356. */
  21357. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21358. /**
  21359. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21360. * @param forOutput defines an optional connection point to check compatibility with
  21361. * @returns the first available input or null
  21362. */
  21363. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21364. /**
  21365. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21366. * @param forBlock defines an optional block to check compatibility with
  21367. * @returns the first available input or null
  21368. */
  21369. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21370. /**
  21371. * Gets the sibling of the given output
  21372. * @param current defines the current output
  21373. * @returns the next output in the list or null
  21374. */
  21375. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21376. /**
  21377. * Connect current block with another block
  21378. * @param other defines the block to connect with
  21379. * @param options define the various options to help pick the right connections
  21380. * @returns the current block
  21381. */
  21382. connectTo(other: NodeMaterialBlock, options?: {
  21383. input?: string;
  21384. output?: string;
  21385. outputSwizzle?: string;
  21386. }): this | undefined;
  21387. protected _buildBlock(state: NodeMaterialBuildState): void;
  21388. /**
  21389. * Add uniforms, samplers and uniform buffers at compilation time
  21390. * @param state defines the state to update
  21391. * @param nodeMaterial defines the node material requesting the update
  21392. * @param defines defines the material defines to update
  21393. * @param uniformBuffers defines the list of uniform buffer names
  21394. */
  21395. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21396. /**
  21397. * Add potential fallbacks if shader compilation fails
  21398. * @param mesh defines the mesh to be rendered
  21399. * @param fallbacks defines the current prioritized list of fallbacks
  21400. */
  21401. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21402. /**
  21403. * Initialize defines for shader compilation
  21404. * @param mesh defines the mesh to be rendered
  21405. * @param nodeMaterial defines the node material requesting the update
  21406. * @param defines defines the material defines to update
  21407. * @param useInstances specifies that instances should be used
  21408. */
  21409. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21410. /**
  21411. * Update defines for shader compilation
  21412. * @param mesh defines the mesh to be rendered
  21413. * @param nodeMaterial defines the node material requesting the update
  21414. * @param defines defines the material defines to update
  21415. * @param useInstances specifies that instances should be used
  21416. */
  21417. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21418. /**
  21419. * Lets the block try to connect some inputs automatically
  21420. * @param material defines the hosting NodeMaterial
  21421. */
  21422. autoConfigure(material: NodeMaterial): void;
  21423. /**
  21424. * Function called when a block is declared as repeatable content generator
  21425. * @param vertexShaderState defines the current compilation state for the vertex shader
  21426. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21427. * @param mesh defines the mesh to be rendered
  21428. * @param defines defines the material defines to update
  21429. */
  21430. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21431. /**
  21432. * Checks if the block is ready
  21433. * @param mesh defines the mesh to be rendered
  21434. * @param nodeMaterial defines the node material requesting the update
  21435. * @param defines defines the material defines to update
  21436. * @param useInstances specifies that instances should be used
  21437. * @returns true if the block is ready
  21438. */
  21439. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21440. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21441. private _processBuild;
  21442. /**
  21443. * Compile the current node and generate the shader code
  21444. * @param state defines the current compilation state (uniforms, samplers, current string)
  21445. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21446. * @returns true if already built
  21447. */
  21448. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21449. protected _inputRename(name: string): string;
  21450. protected _outputRename(name: string): string;
  21451. protected _dumpPropertiesCode(): string;
  21452. /** @hidden */
  21453. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21454. /** @hidden */
  21455. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21456. /**
  21457. * Clone the current block to a new identical block
  21458. * @param scene defines the hosting scene
  21459. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21460. * @returns a copy of the current block
  21461. */
  21462. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21463. /**
  21464. * Serializes this block in a JSON representation
  21465. * @returns the serialized block object
  21466. */
  21467. serialize(): any;
  21468. /** @hidden */
  21469. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21470. private _deserializePortDisplayNames;
  21471. /**
  21472. * Release resources
  21473. */
  21474. dispose(): void;
  21475. }
  21476. }
  21477. declare module BABYLON {
  21478. /**
  21479. * Base class of materials working in push mode in babylon JS
  21480. * @hidden
  21481. */
  21482. export class PushMaterial extends Material {
  21483. protected _activeEffect: Effect;
  21484. protected _normalMatrix: Matrix;
  21485. /**
  21486. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  21487. * This means that the material can keep using a previous shader while a new one is being compiled.
  21488. * This is mostly used when shader parallel compilation is supported (true by default)
  21489. */
  21490. allowShaderHotSwapping: boolean;
  21491. constructor(name: string, scene: Scene);
  21492. getEffect(): Effect;
  21493. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21494. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21495. /**
  21496. * Binds the given world matrix to the active effect
  21497. *
  21498. * @param world the matrix to bind
  21499. */
  21500. bindOnlyWorldMatrix(world: Matrix): void;
  21501. /**
  21502. * Binds the given normal matrix to the active effect
  21503. *
  21504. * @param normalMatrix the matrix to bind
  21505. */
  21506. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21507. bind(world: Matrix, mesh?: Mesh): void;
  21508. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21509. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21510. }
  21511. }
  21512. declare module BABYLON {
  21513. /**
  21514. * Root class for all node material optimizers
  21515. */
  21516. export class NodeMaterialOptimizer {
  21517. /**
  21518. * Function used to optimize a NodeMaterial graph
  21519. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21520. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21521. */
  21522. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21523. }
  21524. }
  21525. declare module BABYLON {
  21526. /**
  21527. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21528. */
  21529. export class TransformBlock extends NodeMaterialBlock {
  21530. /**
  21531. * Defines the value to use to complement W value to transform it to a Vector4
  21532. */
  21533. complementW: number;
  21534. /**
  21535. * Defines the value to use to complement z value to transform it to a Vector4
  21536. */
  21537. complementZ: number;
  21538. /**
  21539. * Creates a new TransformBlock
  21540. * @param name defines the block name
  21541. */
  21542. constructor(name: string);
  21543. /**
  21544. * Gets the current class name
  21545. * @returns the class name
  21546. */
  21547. getClassName(): string;
  21548. /**
  21549. * Gets the vector input
  21550. */
  21551. get vector(): NodeMaterialConnectionPoint;
  21552. /**
  21553. * Gets the output component
  21554. */
  21555. get output(): NodeMaterialConnectionPoint;
  21556. /**
  21557. * Gets the xyz output component
  21558. */
  21559. get xyz(): NodeMaterialConnectionPoint;
  21560. /**
  21561. * Gets the matrix transform input
  21562. */
  21563. get transform(): NodeMaterialConnectionPoint;
  21564. protected _buildBlock(state: NodeMaterialBuildState): this;
  21565. serialize(): any;
  21566. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21567. protected _dumpPropertiesCode(): string;
  21568. }
  21569. }
  21570. declare module BABYLON {
  21571. /**
  21572. * Block used to output the vertex position
  21573. */
  21574. export class VertexOutputBlock extends NodeMaterialBlock {
  21575. /**
  21576. * Creates a new VertexOutputBlock
  21577. * @param name defines the block name
  21578. */
  21579. constructor(name: string);
  21580. /**
  21581. * Gets the current class name
  21582. * @returns the class name
  21583. */
  21584. getClassName(): string;
  21585. /**
  21586. * Gets the vector input component
  21587. */
  21588. get vector(): NodeMaterialConnectionPoint;
  21589. protected _buildBlock(state: NodeMaterialBuildState): this;
  21590. }
  21591. }
  21592. declare module BABYLON {
  21593. /**
  21594. * Block used to output the final color
  21595. */
  21596. export class FragmentOutputBlock extends NodeMaterialBlock {
  21597. /**
  21598. * Create a new FragmentOutputBlock
  21599. * @param name defines the block name
  21600. */
  21601. constructor(name: string);
  21602. /**
  21603. * Gets the current class name
  21604. * @returns the class name
  21605. */
  21606. getClassName(): string;
  21607. /**
  21608. * Gets the rgba input component
  21609. */
  21610. get rgba(): NodeMaterialConnectionPoint;
  21611. /**
  21612. * Gets the rgb input component
  21613. */
  21614. get rgb(): NodeMaterialConnectionPoint;
  21615. /**
  21616. * Gets the a input component
  21617. */
  21618. get a(): NodeMaterialConnectionPoint;
  21619. protected _buildBlock(state: NodeMaterialBuildState): this;
  21620. }
  21621. }
  21622. declare module BABYLON {
  21623. /**
  21624. * Block used for the particle ramp gradient section
  21625. */
  21626. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21627. /**
  21628. * Create a new ParticleRampGradientBlock
  21629. * @param name defines the block name
  21630. */
  21631. constructor(name: string);
  21632. /**
  21633. * Gets the current class name
  21634. * @returns the class name
  21635. */
  21636. getClassName(): string;
  21637. /**
  21638. * Gets the color input component
  21639. */
  21640. get color(): NodeMaterialConnectionPoint;
  21641. /**
  21642. * Gets the rampColor output component
  21643. */
  21644. get rampColor(): NodeMaterialConnectionPoint;
  21645. /**
  21646. * Initialize the block and prepare the context for build
  21647. * @param state defines the state that will be used for the build
  21648. */
  21649. initialize(state: NodeMaterialBuildState): void;
  21650. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21651. }
  21652. }
  21653. declare module BABYLON {
  21654. /**
  21655. * Block used for the particle blend multiply section
  21656. */
  21657. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21658. /**
  21659. * Create a new ParticleBlendMultiplyBlock
  21660. * @param name defines the block name
  21661. */
  21662. constructor(name: string);
  21663. /**
  21664. * Gets the current class name
  21665. * @returns the class name
  21666. */
  21667. getClassName(): string;
  21668. /**
  21669. * Gets the color input component
  21670. */
  21671. get color(): NodeMaterialConnectionPoint;
  21672. /**
  21673. * Gets the alphaTexture input component
  21674. */
  21675. get alphaTexture(): NodeMaterialConnectionPoint;
  21676. /**
  21677. * Gets the alphaColor input component
  21678. */
  21679. get alphaColor(): NodeMaterialConnectionPoint;
  21680. /**
  21681. * Gets the blendColor output component
  21682. */
  21683. get blendColor(): NodeMaterialConnectionPoint;
  21684. /**
  21685. * Initialize the block and prepare the context for build
  21686. * @param state defines the state that will be used for the build
  21687. */
  21688. initialize(state: NodeMaterialBuildState): void;
  21689. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21690. }
  21691. }
  21692. declare module BABYLON {
  21693. /**
  21694. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21695. */
  21696. export class VectorMergerBlock extends NodeMaterialBlock {
  21697. /**
  21698. * Create a new VectorMergerBlock
  21699. * @param name defines the block name
  21700. */
  21701. constructor(name: string);
  21702. /**
  21703. * Gets the current class name
  21704. * @returns the class name
  21705. */
  21706. getClassName(): string;
  21707. /**
  21708. * Gets the xyz component (input)
  21709. */
  21710. get xyzIn(): NodeMaterialConnectionPoint;
  21711. /**
  21712. * Gets the xy component (input)
  21713. */
  21714. get xyIn(): NodeMaterialConnectionPoint;
  21715. /**
  21716. * Gets the x component (input)
  21717. */
  21718. get x(): NodeMaterialConnectionPoint;
  21719. /**
  21720. * Gets the y component (input)
  21721. */
  21722. get y(): NodeMaterialConnectionPoint;
  21723. /**
  21724. * Gets the z component (input)
  21725. */
  21726. get z(): NodeMaterialConnectionPoint;
  21727. /**
  21728. * Gets the w component (input)
  21729. */
  21730. get w(): NodeMaterialConnectionPoint;
  21731. /**
  21732. * Gets the xyzw component (output)
  21733. */
  21734. get xyzw(): NodeMaterialConnectionPoint;
  21735. /**
  21736. * Gets the xyz component (output)
  21737. */
  21738. get xyzOut(): NodeMaterialConnectionPoint;
  21739. /**
  21740. * Gets the xy component (output)
  21741. */
  21742. get xyOut(): NodeMaterialConnectionPoint;
  21743. /**
  21744. * Gets the xy component (output)
  21745. * @deprecated Please use xyOut instead.
  21746. */
  21747. get xy(): NodeMaterialConnectionPoint;
  21748. /**
  21749. * Gets the xyz component (output)
  21750. * @deprecated Please use xyzOut instead.
  21751. */
  21752. get xyz(): NodeMaterialConnectionPoint;
  21753. protected _buildBlock(state: NodeMaterialBuildState): this;
  21754. }
  21755. }
  21756. declare module BABYLON {
  21757. /**
  21758. * Block used to remap a float from a range to a new one
  21759. */
  21760. export class RemapBlock extends NodeMaterialBlock {
  21761. /**
  21762. * Gets or sets the source range
  21763. */
  21764. sourceRange: Vector2;
  21765. /**
  21766. * Gets or sets the target range
  21767. */
  21768. targetRange: Vector2;
  21769. /**
  21770. * Creates a new RemapBlock
  21771. * @param name defines the block name
  21772. */
  21773. constructor(name: string);
  21774. /**
  21775. * Gets the current class name
  21776. * @returns the class name
  21777. */
  21778. getClassName(): string;
  21779. /**
  21780. * Gets the input component
  21781. */
  21782. get input(): NodeMaterialConnectionPoint;
  21783. /**
  21784. * Gets the source min input component
  21785. */
  21786. get sourceMin(): NodeMaterialConnectionPoint;
  21787. /**
  21788. * Gets the source max input component
  21789. */
  21790. get sourceMax(): NodeMaterialConnectionPoint;
  21791. /**
  21792. * Gets the target min input component
  21793. */
  21794. get targetMin(): NodeMaterialConnectionPoint;
  21795. /**
  21796. * Gets the target max input component
  21797. */
  21798. get targetMax(): NodeMaterialConnectionPoint;
  21799. /**
  21800. * Gets the output component
  21801. */
  21802. get output(): NodeMaterialConnectionPoint;
  21803. protected _buildBlock(state: NodeMaterialBuildState): this;
  21804. protected _dumpPropertiesCode(): string;
  21805. serialize(): any;
  21806. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21807. }
  21808. }
  21809. declare module BABYLON {
  21810. /**
  21811. * Block used to multiply 2 values
  21812. */
  21813. export class MultiplyBlock extends NodeMaterialBlock {
  21814. /**
  21815. * Creates a new MultiplyBlock
  21816. * @param name defines the block name
  21817. */
  21818. constructor(name: string);
  21819. /**
  21820. * Gets the current class name
  21821. * @returns the class name
  21822. */
  21823. getClassName(): string;
  21824. /**
  21825. * Gets the left operand input component
  21826. */
  21827. get left(): NodeMaterialConnectionPoint;
  21828. /**
  21829. * Gets the right operand input component
  21830. */
  21831. get right(): NodeMaterialConnectionPoint;
  21832. /**
  21833. * Gets the output component
  21834. */
  21835. get output(): NodeMaterialConnectionPoint;
  21836. protected _buildBlock(state: NodeMaterialBuildState): this;
  21837. }
  21838. }
  21839. declare module BABYLON {
  21840. /**
  21841. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21842. */
  21843. export class ColorSplitterBlock extends NodeMaterialBlock {
  21844. /**
  21845. * Create a new ColorSplitterBlock
  21846. * @param name defines the block name
  21847. */
  21848. constructor(name: string);
  21849. /**
  21850. * Gets the current class name
  21851. * @returns the class name
  21852. */
  21853. getClassName(): string;
  21854. /**
  21855. * Gets the rgba component (input)
  21856. */
  21857. get rgba(): NodeMaterialConnectionPoint;
  21858. /**
  21859. * Gets the rgb component (input)
  21860. */
  21861. get rgbIn(): NodeMaterialConnectionPoint;
  21862. /**
  21863. * Gets the rgb component (output)
  21864. */
  21865. get rgbOut(): NodeMaterialConnectionPoint;
  21866. /**
  21867. * Gets the r component (output)
  21868. */
  21869. get r(): NodeMaterialConnectionPoint;
  21870. /**
  21871. * Gets the g component (output)
  21872. */
  21873. get g(): NodeMaterialConnectionPoint;
  21874. /**
  21875. * Gets the b component (output)
  21876. */
  21877. get b(): NodeMaterialConnectionPoint;
  21878. /**
  21879. * Gets the a component (output)
  21880. */
  21881. get a(): NodeMaterialConnectionPoint;
  21882. protected _inputRename(name: string): string;
  21883. protected _outputRename(name: string): string;
  21884. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21885. }
  21886. }
  21887. declare module BABYLON {
  21888. /**
  21889. * Interface used to configure the node material editor
  21890. */
  21891. export interface INodeMaterialEditorOptions {
  21892. /** Define the URl to load node editor script */
  21893. editorURL?: string;
  21894. }
  21895. /** @hidden */
  21896. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21897. NORMAL: boolean;
  21898. TANGENT: boolean;
  21899. UV1: boolean;
  21900. /** BONES */
  21901. NUM_BONE_INFLUENCERS: number;
  21902. BonesPerMesh: number;
  21903. BONETEXTURE: boolean;
  21904. /** MORPH TARGETS */
  21905. MORPHTARGETS: boolean;
  21906. MORPHTARGETS_NORMAL: boolean;
  21907. MORPHTARGETS_TANGENT: boolean;
  21908. MORPHTARGETS_UV: boolean;
  21909. NUM_MORPH_INFLUENCERS: number;
  21910. /** IMAGE PROCESSING */
  21911. IMAGEPROCESSING: boolean;
  21912. VIGNETTE: boolean;
  21913. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21914. VIGNETTEBLENDMODEOPAQUE: boolean;
  21915. TONEMAPPING: boolean;
  21916. TONEMAPPING_ACES: boolean;
  21917. CONTRAST: boolean;
  21918. EXPOSURE: boolean;
  21919. COLORCURVES: boolean;
  21920. COLORGRADING: boolean;
  21921. COLORGRADING3D: boolean;
  21922. SAMPLER3DGREENDEPTH: boolean;
  21923. SAMPLER3DBGRMAP: boolean;
  21924. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21925. /** MISC. */
  21926. BUMPDIRECTUV: number;
  21927. constructor();
  21928. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  21929. }
  21930. /**
  21931. * Class used to configure NodeMaterial
  21932. */
  21933. export interface INodeMaterialOptions {
  21934. /**
  21935. * Defines if blocks should emit comments
  21936. */
  21937. emitComments: boolean;
  21938. }
  21939. /**
  21940. * Class used to create a node based material built by assembling shader blocks
  21941. */
  21942. export class NodeMaterial extends PushMaterial {
  21943. private static _BuildIdGenerator;
  21944. private _options;
  21945. private _vertexCompilationState;
  21946. private _fragmentCompilationState;
  21947. private _sharedData;
  21948. private _buildId;
  21949. private _buildWasSuccessful;
  21950. private _cachedWorldViewMatrix;
  21951. private _cachedWorldViewProjectionMatrix;
  21952. private _optimizers;
  21953. private _animationFrame;
  21954. /** Define the Url to load node editor script */
  21955. static EditorURL: string;
  21956. /** Define the Url to load snippets */
  21957. static SnippetUrl: string;
  21958. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  21959. static IgnoreTexturesAtLoadTime: boolean;
  21960. private BJSNODEMATERIALEDITOR;
  21961. /** Get the inspector from bundle or global */
  21962. private _getGlobalNodeMaterialEditor;
  21963. /**
  21964. * Snippet ID if the material was created from the snippet server
  21965. */
  21966. snippetId: string;
  21967. /**
  21968. * Gets or sets data used by visual editor
  21969. * @see https://nme.babylonjs.com
  21970. */
  21971. editorData: any;
  21972. /**
  21973. * 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)
  21974. */
  21975. ignoreAlpha: boolean;
  21976. /**
  21977. * Defines the maximum number of lights that can be used in the material
  21978. */
  21979. maxSimultaneousLights: number;
  21980. /**
  21981. * Observable raised when the material is built
  21982. */
  21983. onBuildObservable: Observable<NodeMaterial>;
  21984. /**
  21985. * Gets or sets the root nodes of the material vertex shader
  21986. */
  21987. _vertexOutputNodes: NodeMaterialBlock[];
  21988. /**
  21989. * Gets or sets the root nodes of the material fragment (pixel) shader
  21990. */
  21991. _fragmentOutputNodes: NodeMaterialBlock[];
  21992. /** Gets or sets options to control the node material overall behavior */
  21993. get options(): INodeMaterialOptions;
  21994. set options(options: INodeMaterialOptions);
  21995. /**
  21996. * Default configuration related to image processing available in the standard Material.
  21997. */
  21998. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  21999. /**
  22000. * Gets the image processing configuration used either in this material.
  22001. */
  22002. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22003. /**
  22004. * Sets the Default image processing configuration used either in the this material.
  22005. *
  22006. * If sets to null, the scene one is in use.
  22007. */
  22008. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22009. /**
  22010. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22011. */
  22012. attachedBlocks: NodeMaterialBlock[];
  22013. /**
  22014. * Specifies the mode of the node material
  22015. * @hidden
  22016. */
  22017. _mode: NodeMaterialModes;
  22018. /**
  22019. * Gets the mode property
  22020. */
  22021. get mode(): NodeMaterialModes;
  22022. /**
  22023. * Create a new node based material
  22024. * @param name defines the material name
  22025. * @param scene defines the hosting scene
  22026. * @param options defines creation option
  22027. */
  22028. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22029. /**
  22030. * Gets the current class name of the material e.g. "NodeMaterial"
  22031. * @returns the class name
  22032. */
  22033. getClassName(): string;
  22034. /**
  22035. * Keep track of the image processing observer to allow dispose and replace.
  22036. */
  22037. private _imageProcessingObserver;
  22038. /**
  22039. * Attaches a new image processing configuration to the Standard Material.
  22040. * @param configuration
  22041. */
  22042. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22043. /**
  22044. * Get a block by its name
  22045. * @param name defines the name of the block to retrieve
  22046. * @returns the required block or null if not found
  22047. */
  22048. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22049. /**
  22050. * Get a block by its name
  22051. * @param predicate defines the predicate used to find the good candidate
  22052. * @returns the required block or null if not found
  22053. */
  22054. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22055. /**
  22056. * Get an input block by its name
  22057. * @param predicate defines the predicate used to find the good candidate
  22058. * @returns the required input block or null if not found
  22059. */
  22060. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22061. /**
  22062. * Gets the list of input blocks attached to this material
  22063. * @returns an array of InputBlocks
  22064. */
  22065. getInputBlocks(): InputBlock[];
  22066. /**
  22067. * Adds a new optimizer to the list of optimizers
  22068. * @param optimizer defines the optimizers to add
  22069. * @returns the current material
  22070. */
  22071. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22072. /**
  22073. * Remove an optimizer from the list of optimizers
  22074. * @param optimizer defines the optimizers to remove
  22075. * @returns the current material
  22076. */
  22077. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22078. /**
  22079. * Add a new block to the list of output nodes
  22080. * @param node defines the node to add
  22081. * @returns the current material
  22082. */
  22083. addOutputNode(node: NodeMaterialBlock): this;
  22084. /**
  22085. * Remove a block from the list of root nodes
  22086. * @param node defines the node to remove
  22087. * @returns the current material
  22088. */
  22089. removeOutputNode(node: NodeMaterialBlock): this;
  22090. private _addVertexOutputNode;
  22091. private _removeVertexOutputNode;
  22092. private _addFragmentOutputNode;
  22093. private _removeFragmentOutputNode;
  22094. /**
  22095. * Specifies if the material will require alpha blending
  22096. * @returns a boolean specifying if alpha blending is needed
  22097. */
  22098. needAlphaBlending(): boolean;
  22099. /**
  22100. * Specifies if this material should be rendered in alpha test mode
  22101. * @returns a boolean specifying if an alpha test is needed.
  22102. */
  22103. needAlphaTesting(): boolean;
  22104. private _initializeBlock;
  22105. private _resetDualBlocks;
  22106. /**
  22107. * Remove a block from the current node material
  22108. * @param block defines the block to remove
  22109. */
  22110. removeBlock(block: NodeMaterialBlock): void;
  22111. /**
  22112. * Build the material and generates the inner effect
  22113. * @param verbose defines if the build should log activity
  22114. */
  22115. build(verbose?: boolean): void;
  22116. /**
  22117. * Runs an otpimization phase to try to improve the shader code
  22118. */
  22119. optimize(): void;
  22120. private _prepareDefinesForAttributes;
  22121. /**
  22122. * Create a post process from the material
  22123. * @param camera The camera to apply the render pass to.
  22124. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22125. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22126. * @param engine The engine which the post process will be applied. (default: current engine)
  22127. * @param reusable If the post process can be reused on the same frame. (default: false)
  22128. * @param textureType Type of textures used when performing the post process. (default: 0)
  22129. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22130. * @returns the post process created
  22131. */
  22132. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22133. private _createEffectForParticles;
  22134. /**
  22135. * Create the effect to be used as the custom effect for a particle system
  22136. * @param particleSystem Particle system to create the effect for
  22137. * @param onCompiled defines a function to call when the effect creation is successful
  22138. * @param onError defines a function to call when the effect creation has failed
  22139. */
  22140. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22141. private _processDefines;
  22142. /**
  22143. * Get if the submesh is ready to be used and all its information available.
  22144. * Child classes can use it to update shaders
  22145. * @param mesh defines the mesh to check
  22146. * @param subMesh defines which submesh to check
  22147. * @param useInstances specifies that instances should be used
  22148. * @returns a boolean indicating that the submesh is ready or not
  22149. */
  22150. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22151. /**
  22152. * Get a string representing the shaders built by the current node graph
  22153. */
  22154. get compiledShaders(): string;
  22155. /**
  22156. * Binds the world matrix to the material
  22157. * @param world defines the world transformation matrix
  22158. */
  22159. bindOnlyWorldMatrix(world: Matrix): void;
  22160. /**
  22161. * Binds the submesh to this material by preparing the effect and shader to draw
  22162. * @param world defines the world transformation matrix
  22163. * @param mesh defines the mesh containing the submesh
  22164. * @param subMesh defines the submesh to bind the material to
  22165. */
  22166. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22167. /**
  22168. * Gets the active textures from the material
  22169. * @returns an array of textures
  22170. */
  22171. getActiveTextures(): BaseTexture[];
  22172. /**
  22173. * Gets the list of texture blocks
  22174. * @returns an array of texture blocks
  22175. */
  22176. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22177. /**
  22178. * Specifies if the material uses a texture
  22179. * @param texture defines the texture to check against the material
  22180. * @returns a boolean specifying if the material uses the texture
  22181. */
  22182. hasTexture(texture: BaseTexture): boolean;
  22183. /**
  22184. * Disposes the material
  22185. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22186. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22187. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22188. */
  22189. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22190. /** Creates the node editor window. */
  22191. private _createNodeEditor;
  22192. /**
  22193. * Launch the node material editor
  22194. * @param config Define the configuration of the editor
  22195. * @return a promise fulfilled when the node editor is visible
  22196. */
  22197. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22198. /**
  22199. * Clear the current material
  22200. */
  22201. clear(): void;
  22202. /**
  22203. * Clear the current material and set it to a default state
  22204. */
  22205. setToDefault(): void;
  22206. /**
  22207. * Clear the current material and set it to a default state for post process
  22208. */
  22209. setToDefaultPostProcess(): void;
  22210. /**
  22211. * Clear the current material and set it to a default state for particle
  22212. */
  22213. setToDefaultParticle(): void;
  22214. /**
  22215. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22216. * @param url defines the url to load from
  22217. * @returns a promise that will fullfil when the material is fully loaded
  22218. */
  22219. loadAsync(url: string): Promise<void>;
  22220. private _gatherBlocks;
  22221. /**
  22222. * Generate a string containing the code declaration required to create an equivalent of this material
  22223. * @returns a string
  22224. */
  22225. generateCode(): string;
  22226. /**
  22227. * Serializes this material in a JSON representation
  22228. * @returns the serialized material object
  22229. */
  22230. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22231. private _restoreConnections;
  22232. /**
  22233. * Clear the current graph and load a new one from a serialization object
  22234. * @param source defines the JSON representation of the material
  22235. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22236. */
  22237. loadFromSerialization(source: any, rootUrl?: string): void;
  22238. /**
  22239. * Makes a duplicate of the current material.
  22240. * @param name - name to use for the new material.
  22241. */
  22242. clone(name: string): NodeMaterial;
  22243. /**
  22244. * Creates a node material from parsed material data
  22245. * @param source defines the JSON representation of the material
  22246. * @param scene defines the hosting scene
  22247. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22248. * @returns a new node material
  22249. */
  22250. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22251. /**
  22252. * Creates a node material from a snippet saved in a remote file
  22253. * @param name defines the name of the material to create
  22254. * @param url defines the url to load from
  22255. * @param scene defines the hosting scene
  22256. * @returns a promise that will resolve to the new node material
  22257. */
  22258. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22259. /**
  22260. * Creates a node material from a snippet saved by the node material editor
  22261. * @param snippetId defines the snippet to load
  22262. * @param scene defines the hosting scene
  22263. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22264. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22265. * @returns a promise that will resolve to the new node material
  22266. */
  22267. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22268. /**
  22269. * Creates a new node material set to default basic configuration
  22270. * @param name defines the name of the material
  22271. * @param scene defines the hosting scene
  22272. * @returns a new NodeMaterial
  22273. */
  22274. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22275. }
  22276. }
  22277. declare module BABYLON {
  22278. /**
  22279. * Size options for a post process
  22280. */
  22281. export type PostProcessOptions = {
  22282. width: number;
  22283. height: number;
  22284. };
  22285. /**
  22286. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22287. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22288. */
  22289. export class PostProcess {
  22290. /** Name of the PostProcess. */
  22291. name: string;
  22292. /**
  22293. * Gets or sets the unique id of the post process
  22294. */
  22295. uniqueId: number;
  22296. /**
  22297. * Width of the texture to apply the post process on
  22298. */
  22299. width: number;
  22300. /**
  22301. * Height of the texture to apply the post process on
  22302. */
  22303. height: number;
  22304. /**
  22305. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22306. */
  22307. nodeMaterialSource: Nullable<NodeMaterial>;
  22308. /**
  22309. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22310. * @hidden
  22311. */
  22312. _outputTexture: Nullable<InternalTexture>;
  22313. /**
  22314. * Sampling mode used by the shader
  22315. * See https://doc.babylonjs.com/classes/3.1/texture
  22316. */
  22317. renderTargetSamplingMode: number;
  22318. /**
  22319. * Clear color to use when screen clearing
  22320. */
  22321. clearColor: Color4;
  22322. /**
  22323. * If the buffer needs to be cleared before applying the post process. (default: true)
  22324. * Should be set to false if shader will overwrite all previous pixels.
  22325. */
  22326. autoClear: boolean;
  22327. /**
  22328. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22329. */
  22330. alphaMode: number;
  22331. /**
  22332. * Sets the setAlphaBlendConstants of the babylon engine
  22333. */
  22334. alphaConstants: Color4;
  22335. /**
  22336. * Animations to be used for the post processing
  22337. */
  22338. animations: Animation[];
  22339. /**
  22340. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22341. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22342. */
  22343. enablePixelPerfectMode: boolean;
  22344. /**
  22345. * Force the postprocess to be applied without taking in account viewport
  22346. */
  22347. forceFullscreenViewport: boolean;
  22348. /**
  22349. * List of inspectable custom properties (used by the Inspector)
  22350. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22351. */
  22352. inspectableCustomProperties: IInspectable[];
  22353. /**
  22354. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22355. *
  22356. * | Value | Type | Description |
  22357. * | ----- | ----------------------------------- | ----------- |
  22358. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22359. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22360. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22361. *
  22362. */
  22363. scaleMode: number;
  22364. /**
  22365. * Force textures to be a power of two (default: false)
  22366. */
  22367. alwaysForcePOT: boolean;
  22368. private _samples;
  22369. /**
  22370. * Number of sample textures (default: 1)
  22371. */
  22372. get samples(): number;
  22373. set samples(n: number);
  22374. /**
  22375. * Modify the scale of the post process to be the same as the viewport (default: false)
  22376. */
  22377. adaptScaleToCurrentViewport: boolean;
  22378. private _camera;
  22379. private _scene;
  22380. private _engine;
  22381. private _options;
  22382. private _reusable;
  22383. private _textureType;
  22384. private _textureFormat;
  22385. /**
  22386. * Smart array of input and output textures for the post process.
  22387. * @hidden
  22388. */
  22389. _textures: SmartArray<InternalTexture>;
  22390. /**
  22391. * The index in _textures that corresponds to the output texture.
  22392. * @hidden
  22393. */
  22394. _currentRenderTextureInd: number;
  22395. private _effect;
  22396. private _samplers;
  22397. private _fragmentUrl;
  22398. private _vertexUrl;
  22399. private _parameters;
  22400. private _scaleRatio;
  22401. protected _indexParameters: any;
  22402. private _shareOutputWithPostProcess;
  22403. private _texelSize;
  22404. private _forcedOutputTexture;
  22405. /**
  22406. * Returns the fragment url or shader name used in the post process.
  22407. * @returns the fragment url or name in the shader store.
  22408. */
  22409. getEffectName(): string;
  22410. /**
  22411. * An event triggered when the postprocess is activated.
  22412. */
  22413. onActivateObservable: Observable<Camera>;
  22414. private _onActivateObserver;
  22415. /**
  22416. * A function that is added to the onActivateObservable
  22417. */
  22418. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22419. /**
  22420. * An event triggered when the postprocess changes its size.
  22421. */
  22422. onSizeChangedObservable: Observable<PostProcess>;
  22423. private _onSizeChangedObserver;
  22424. /**
  22425. * A function that is added to the onSizeChangedObservable
  22426. */
  22427. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22428. /**
  22429. * An event triggered when the postprocess applies its effect.
  22430. */
  22431. onApplyObservable: Observable<Effect>;
  22432. private _onApplyObserver;
  22433. /**
  22434. * A function that is added to the onApplyObservable
  22435. */
  22436. set onApply(callback: (effect: Effect) => void);
  22437. /**
  22438. * An event triggered before rendering the postprocess
  22439. */
  22440. onBeforeRenderObservable: Observable<Effect>;
  22441. private _onBeforeRenderObserver;
  22442. /**
  22443. * A function that is added to the onBeforeRenderObservable
  22444. */
  22445. set onBeforeRender(callback: (effect: Effect) => void);
  22446. /**
  22447. * An event triggered after rendering the postprocess
  22448. */
  22449. onAfterRenderObservable: Observable<Effect>;
  22450. private _onAfterRenderObserver;
  22451. /**
  22452. * A function that is added to the onAfterRenderObservable
  22453. */
  22454. set onAfterRender(callback: (efect: Effect) => void);
  22455. /**
  22456. * 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
  22457. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22458. */
  22459. get inputTexture(): InternalTexture;
  22460. set inputTexture(value: InternalTexture);
  22461. /**
  22462. * Gets the camera which post process is applied to.
  22463. * @returns The camera the post process is applied to.
  22464. */
  22465. getCamera(): Camera;
  22466. /**
  22467. * Gets the texel size of the postprocess.
  22468. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22469. */
  22470. get texelSize(): Vector2;
  22471. /**
  22472. * Creates a new instance PostProcess
  22473. * @param name The name of the PostProcess.
  22474. * @param fragmentUrl The url of the fragment shader to be used.
  22475. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22476. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22477. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22478. * @param camera The camera to apply the render pass to.
  22479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22480. * @param engine The engine which the post process will be applied. (default: current engine)
  22481. * @param reusable If the post process can be reused on the same frame. (default: false)
  22482. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22483. * @param textureType Type of textures used when performing the post process. (default: 0)
  22484. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22485. * @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
  22486. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22487. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22488. */
  22489. constructor(
  22490. /** Name of the PostProcess. */
  22491. 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);
  22492. /**
  22493. * Gets a string idenfifying the name of the class
  22494. * @returns "PostProcess" string
  22495. */
  22496. getClassName(): string;
  22497. /**
  22498. * Gets the engine which this post process belongs to.
  22499. * @returns The engine the post process was enabled with.
  22500. */
  22501. getEngine(): Engine;
  22502. /**
  22503. * The effect that is created when initializing the post process.
  22504. * @returns The created effect corresponding the the postprocess.
  22505. */
  22506. getEffect(): Effect;
  22507. /**
  22508. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22509. * @param postProcess The post process to share the output with.
  22510. * @returns This post process.
  22511. */
  22512. shareOutputWith(postProcess: PostProcess): PostProcess;
  22513. /**
  22514. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22515. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22516. */
  22517. useOwnOutput(): void;
  22518. /**
  22519. * Updates the effect with the current post process compile time values and recompiles the shader.
  22520. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22521. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22522. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22523. * @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
  22524. * @param onCompiled Called when the shader has been compiled.
  22525. * @param onError Called if there is an error when compiling a shader.
  22526. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22527. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22528. */
  22529. 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;
  22530. /**
  22531. * The post process is reusable if it can be used multiple times within one frame.
  22532. * @returns If the post process is reusable
  22533. */
  22534. isReusable(): boolean;
  22535. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22536. markTextureDirty(): void;
  22537. /**
  22538. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22539. * 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.
  22540. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22541. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22542. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22543. * @returns The target texture that was bound to be written to.
  22544. */
  22545. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22546. /**
  22547. * If the post process is supported.
  22548. */
  22549. get isSupported(): boolean;
  22550. /**
  22551. * The aspect ratio of the output texture.
  22552. */
  22553. get aspectRatio(): number;
  22554. /**
  22555. * Get a value indicating if the post-process is ready to be used
  22556. * @returns true if the post-process is ready (shader is compiled)
  22557. */
  22558. isReady(): boolean;
  22559. /**
  22560. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22561. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22562. */
  22563. apply(): Nullable<Effect>;
  22564. private _disposeTextures;
  22565. /**
  22566. * Disposes the post process.
  22567. * @param camera The camera to dispose the post process on.
  22568. */
  22569. dispose(camera?: Camera): void;
  22570. }
  22571. }
  22572. declare module BABYLON {
  22573. /** @hidden */
  22574. export var kernelBlurVaryingDeclaration: {
  22575. name: string;
  22576. shader: string;
  22577. };
  22578. }
  22579. declare module BABYLON {
  22580. /** @hidden */
  22581. export var kernelBlurFragment: {
  22582. name: string;
  22583. shader: string;
  22584. };
  22585. }
  22586. declare module BABYLON {
  22587. /** @hidden */
  22588. export var kernelBlurFragment2: {
  22589. name: string;
  22590. shader: string;
  22591. };
  22592. }
  22593. declare module BABYLON {
  22594. /** @hidden */
  22595. export var kernelBlurPixelShader: {
  22596. name: string;
  22597. shader: string;
  22598. };
  22599. }
  22600. declare module BABYLON {
  22601. /** @hidden */
  22602. export var kernelBlurVertex: {
  22603. name: string;
  22604. shader: string;
  22605. };
  22606. }
  22607. declare module BABYLON {
  22608. /** @hidden */
  22609. export var kernelBlurVertexShader: {
  22610. name: string;
  22611. shader: string;
  22612. };
  22613. }
  22614. declare module BABYLON {
  22615. /**
  22616. * The Blur Post Process which blurs an image based on a kernel and direction.
  22617. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22618. */
  22619. export class BlurPostProcess extends PostProcess {
  22620. /** The direction in which to blur the image. */
  22621. direction: Vector2;
  22622. private blockCompilation;
  22623. protected _kernel: number;
  22624. protected _idealKernel: number;
  22625. protected _packedFloat: boolean;
  22626. private _staticDefines;
  22627. /**
  22628. * Sets the length in pixels of the blur sample region
  22629. */
  22630. set kernel(v: number);
  22631. /**
  22632. * Gets the length in pixels of the blur sample region
  22633. */
  22634. get kernel(): number;
  22635. /**
  22636. * Sets wether or not the blur needs to unpack/repack floats
  22637. */
  22638. set packedFloat(v: boolean);
  22639. /**
  22640. * Gets wether or not the blur is unpacking/repacking floats
  22641. */
  22642. get packedFloat(): boolean;
  22643. /**
  22644. * Creates a new instance BlurPostProcess
  22645. * @param name The name of the effect.
  22646. * @param direction The direction in which to blur the image.
  22647. * @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.
  22648. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22649. * @param camera The camera to apply the render pass to.
  22650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22651. * @param engine The engine which the post process will be applied. (default: current engine)
  22652. * @param reusable If the post process can be reused on the same frame. (default: false)
  22653. * @param textureType Type of textures used when performing the post process. (default: 0)
  22654. * @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)
  22655. */
  22656. constructor(name: string,
  22657. /** The direction in which to blur the image. */
  22658. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22659. /**
  22660. * Updates the effect with the current post process compile time values and recompiles the shader.
  22661. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22662. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22663. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22664. * @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
  22665. * @param onCompiled Called when the shader has been compiled.
  22666. * @param onError Called if there is an error when compiling a shader.
  22667. */
  22668. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22669. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22670. /**
  22671. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22672. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22673. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22674. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22675. * The gaps between physical kernels are compensated for in the weighting of the samples
  22676. * @param idealKernel Ideal blur kernel.
  22677. * @return Nearest best kernel.
  22678. */
  22679. protected _nearestBestKernel(idealKernel: number): number;
  22680. /**
  22681. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22682. * @param x The point on the Gaussian distribution to sample.
  22683. * @return the value of the Gaussian function at x.
  22684. */
  22685. protected _gaussianWeight(x: number): number;
  22686. /**
  22687. * Generates a string that can be used as a floating point number in GLSL.
  22688. * @param x Value to print.
  22689. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22690. * @return GLSL float string.
  22691. */
  22692. protected _glslFloat(x: number, decimalFigures?: number): string;
  22693. }
  22694. }
  22695. declare module BABYLON {
  22696. /**
  22697. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22698. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22699. * You can then easily use it as a reflectionTexture on a flat surface.
  22700. * In case the surface is not a plane, please consider relying on reflection probes.
  22701. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22702. */
  22703. export class MirrorTexture extends RenderTargetTexture {
  22704. private scene;
  22705. /**
  22706. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22707. * 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.
  22708. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22709. */
  22710. mirrorPlane: Plane;
  22711. /**
  22712. * Define the blur ratio used to blur the reflection if needed.
  22713. */
  22714. set blurRatio(value: number);
  22715. get blurRatio(): number;
  22716. /**
  22717. * Define the adaptive blur kernel used to blur the reflection if needed.
  22718. * This will autocompute the closest best match for the `blurKernel`
  22719. */
  22720. set adaptiveBlurKernel(value: number);
  22721. /**
  22722. * Define the blur kernel used to blur the reflection if needed.
  22723. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22724. */
  22725. set blurKernel(value: number);
  22726. /**
  22727. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22728. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22729. */
  22730. set blurKernelX(value: number);
  22731. get blurKernelX(): number;
  22732. /**
  22733. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22734. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22735. */
  22736. set blurKernelY(value: number);
  22737. get blurKernelY(): number;
  22738. private _autoComputeBlurKernel;
  22739. protected _onRatioRescale(): void;
  22740. private _updateGammaSpace;
  22741. private _imageProcessingConfigChangeObserver;
  22742. private _transformMatrix;
  22743. private _mirrorMatrix;
  22744. private _savedViewMatrix;
  22745. private _blurX;
  22746. private _blurY;
  22747. private _adaptiveBlurKernel;
  22748. private _blurKernelX;
  22749. private _blurKernelY;
  22750. private _blurRatio;
  22751. /**
  22752. * Instantiates a Mirror Texture.
  22753. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22754. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22755. * You can then easily use it as a reflectionTexture on a flat surface.
  22756. * In case the surface is not a plane, please consider relying on reflection probes.
  22757. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22758. * @param name
  22759. * @param size
  22760. * @param scene
  22761. * @param generateMipMaps
  22762. * @param type
  22763. * @param samplingMode
  22764. * @param generateDepthBuffer
  22765. */
  22766. constructor(name: string, size: number | {
  22767. width: number;
  22768. height: number;
  22769. } | {
  22770. ratio: number;
  22771. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22772. private _preparePostProcesses;
  22773. /**
  22774. * Clone the mirror texture.
  22775. * @returns the cloned texture
  22776. */
  22777. clone(): MirrorTexture;
  22778. /**
  22779. * Serialize the texture to a JSON representation you could use in Parse later on
  22780. * @returns the serialized JSON representation
  22781. */
  22782. serialize(): any;
  22783. /**
  22784. * Dispose the texture and release its associated resources.
  22785. */
  22786. dispose(): void;
  22787. }
  22788. }
  22789. declare module BABYLON {
  22790. /**
  22791. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22792. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22793. */
  22794. export class Texture extends BaseTexture {
  22795. /**
  22796. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22797. */
  22798. static SerializeBuffers: boolean;
  22799. /** @hidden */
  22800. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22801. /** @hidden */
  22802. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22803. /** @hidden */
  22804. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22805. /** nearest is mag = nearest and min = nearest and mip = linear */
  22806. static readonly NEAREST_SAMPLINGMODE: number;
  22807. /** nearest is mag = nearest and min = nearest and mip = linear */
  22808. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22809. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22810. static readonly BILINEAR_SAMPLINGMODE: number;
  22811. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22812. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22813. /** Trilinear is mag = linear and min = linear and mip = linear */
  22814. static readonly TRILINEAR_SAMPLINGMODE: number;
  22815. /** Trilinear is mag = linear and min = linear and mip = linear */
  22816. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22817. /** mag = nearest and min = nearest and mip = nearest */
  22818. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22819. /** mag = nearest and min = linear and mip = nearest */
  22820. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22821. /** mag = nearest and min = linear and mip = linear */
  22822. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22823. /** mag = nearest and min = linear and mip = none */
  22824. static readonly NEAREST_LINEAR: number;
  22825. /** mag = nearest and min = nearest and mip = none */
  22826. static readonly NEAREST_NEAREST: number;
  22827. /** mag = linear and min = nearest and mip = nearest */
  22828. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22829. /** mag = linear and min = nearest and mip = linear */
  22830. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22831. /** mag = linear and min = linear and mip = none */
  22832. static readonly LINEAR_LINEAR: number;
  22833. /** mag = linear and min = nearest and mip = none */
  22834. static readonly LINEAR_NEAREST: number;
  22835. /** Explicit coordinates mode */
  22836. static readonly EXPLICIT_MODE: number;
  22837. /** Spherical coordinates mode */
  22838. static readonly SPHERICAL_MODE: number;
  22839. /** Planar coordinates mode */
  22840. static readonly PLANAR_MODE: number;
  22841. /** Cubic coordinates mode */
  22842. static readonly CUBIC_MODE: number;
  22843. /** Projection coordinates mode */
  22844. static readonly PROJECTION_MODE: number;
  22845. /** Inverse Cubic coordinates mode */
  22846. static readonly SKYBOX_MODE: number;
  22847. /** Inverse Cubic coordinates mode */
  22848. static readonly INVCUBIC_MODE: number;
  22849. /** Equirectangular coordinates mode */
  22850. static readonly EQUIRECTANGULAR_MODE: number;
  22851. /** Equirectangular Fixed coordinates mode */
  22852. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22853. /** Equirectangular Fixed Mirrored coordinates mode */
  22854. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22855. /** Texture is not repeating outside of 0..1 UVs */
  22856. static readonly CLAMP_ADDRESSMODE: number;
  22857. /** Texture is repeating outside of 0..1 UVs */
  22858. static readonly WRAP_ADDRESSMODE: number;
  22859. /** Texture is repeating and mirrored */
  22860. static readonly MIRROR_ADDRESSMODE: number;
  22861. /**
  22862. * 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
  22863. */
  22864. static UseSerializedUrlIfAny: boolean;
  22865. /**
  22866. * Define the url of the texture.
  22867. */
  22868. url: Nullable<string>;
  22869. /**
  22870. * Define an offset on the texture to offset the u coordinates of the UVs
  22871. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22872. */
  22873. uOffset: number;
  22874. /**
  22875. * Define an offset on the texture to offset the v coordinates of the UVs
  22876. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22877. */
  22878. vOffset: number;
  22879. /**
  22880. * Define an offset on the texture to scale the u coordinates of the UVs
  22881. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22882. */
  22883. uScale: number;
  22884. /**
  22885. * Define an offset on the texture to scale the v coordinates of the UVs
  22886. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22887. */
  22888. vScale: number;
  22889. /**
  22890. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22891. * @see http://doc.babylonjs.com/how_to/more_materials
  22892. */
  22893. uAng: number;
  22894. /**
  22895. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22896. * @see http://doc.babylonjs.com/how_to/more_materials
  22897. */
  22898. vAng: number;
  22899. /**
  22900. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22901. * @see http://doc.babylonjs.com/how_to/more_materials
  22902. */
  22903. wAng: number;
  22904. /**
  22905. * Defines the center of rotation (U)
  22906. */
  22907. uRotationCenter: number;
  22908. /**
  22909. * Defines the center of rotation (V)
  22910. */
  22911. vRotationCenter: number;
  22912. /**
  22913. * Defines the center of rotation (W)
  22914. */
  22915. wRotationCenter: number;
  22916. /**
  22917. * Are mip maps generated for this texture or not.
  22918. */
  22919. get noMipmap(): boolean;
  22920. /**
  22921. * List of inspectable custom properties (used by the Inspector)
  22922. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22923. */
  22924. inspectableCustomProperties: Nullable<IInspectable[]>;
  22925. private _noMipmap;
  22926. /** @hidden */
  22927. _invertY: boolean;
  22928. private _rowGenerationMatrix;
  22929. private _cachedTextureMatrix;
  22930. private _projectionModeMatrix;
  22931. private _t0;
  22932. private _t1;
  22933. private _t2;
  22934. private _cachedUOffset;
  22935. private _cachedVOffset;
  22936. private _cachedUScale;
  22937. private _cachedVScale;
  22938. private _cachedUAng;
  22939. private _cachedVAng;
  22940. private _cachedWAng;
  22941. private _cachedProjectionMatrixId;
  22942. private _cachedCoordinatesMode;
  22943. /** @hidden */
  22944. protected _initialSamplingMode: number;
  22945. /** @hidden */
  22946. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  22947. private _deleteBuffer;
  22948. protected _format: Nullable<number>;
  22949. private _delayedOnLoad;
  22950. private _delayedOnError;
  22951. private _mimeType?;
  22952. /**
  22953. * Observable triggered once the texture has been loaded.
  22954. */
  22955. onLoadObservable: Observable<Texture>;
  22956. protected _isBlocking: boolean;
  22957. /**
  22958. * Is the texture preventing material to render while loading.
  22959. * If false, a default texture will be used instead of the loading one during the preparation step.
  22960. */
  22961. set isBlocking(value: boolean);
  22962. get isBlocking(): boolean;
  22963. /**
  22964. * Get the current sampling mode associated with the texture.
  22965. */
  22966. get samplingMode(): number;
  22967. /**
  22968. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  22969. */
  22970. get invertY(): boolean;
  22971. /**
  22972. * Instantiates a new texture.
  22973. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22974. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22975. * @param url defines the url of the picture to load as a texture
  22976. * @param sceneOrEngine defines the scene or engine the texture will belong to
  22977. * @param noMipmap defines if the texture will require mip maps or not
  22978. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  22979. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  22980. * @param onLoad defines a callback triggered when the texture has been loaded
  22981. * @param onError defines a callback triggered when an error occurred during the loading session
  22982. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  22983. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  22984. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  22985. * @param mimeType defines an optional mime type information
  22986. */
  22987. 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);
  22988. /**
  22989. * Update the url (and optional buffer) of this texture if url was null during construction.
  22990. * @param url the url of the texture
  22991. * @param buffer the buffer of the texture (defaults to null)
  22992. * @param onLoad callback called when the texture is loaded (defaults to null)
  22993. */
  22994. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  22995. /**
  22996. * Finish the loading sequence of a texture flagged as delayed load.
  22997. * @hidden
  22998. */
  22999. delayLoad(): void;
  23000. private _prepareRowForTextureGeneration;
  23001. /**
  23002. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23003. * @returns the transform matrix of the texture.
  23004. */
  23005. getTextureMatrix(uBase?: number): Matrix;
  23006. /**
  23007. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23008. * @returns The reflection texture transform
  23009. */
  23010. getReflectionTextureMatrix(): Matrix;
  23011. /**
  23012. * Clones the texture.
  23013. * @returns the cloned texture
  23014. */
  23015. clone(): Texture;
  23016. /**
  23017. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23018. * @returns The JSON representation of the texture
  23019. */
  23020. serialize(): any;
  23021. /**
  23022. * Get the current class name of the texture useful for serialization or dynamic coding.
  23023. * @returns "Texture"
  23024. */
  23025. getClassName(): string;
  23026. /**
  23027. * Dispose the texture and release its associated resources.
  23028. */
  23029. dispose(): void;
  23030. /**
  23031. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23032. * @param parsedTexture Define the JSON representation of the texture
  23033. * @param scene Define the scene the parsed texture should be instantiated in
  23034. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23035. * @returns The parsed texture if successful
  23036. */
  23037. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23038. /**
  23039. * Creates a texture from its base 64 representation.
  23040. * @param data Define the base64 payload without the data: prefix
  23041. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23042. * @param scene Define the scene the texture should belong to
  23043. * @param noMipmap Forces the texture to not create mip map information if true
  23044. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23045. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23046. * @param onLoad define a callback triggered when the texture has been loaded
  23047. * @param onError define a callback triggered when an error occurred during the loading session
  23048. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23049. * @returns the created texture
  23050. */
  23051. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23052. /**
  23053. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23054. * @param data Define the base64 payload without the data: prefix
  23055. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23056. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23057. * @param scene Define the scene the texture should belong to
  23058. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23059. * @param noMipmap Forces the texture to not create mip map information if true
  23060. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23061. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23062. * @param onLoad define a callback triggered when the texture has been loaded
  23063. * @param onError define a callback triggered when an error occurred during the loading session
  23064. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23065. * @returns the created texture
  23066. */
  23067. 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;
  23068. }
  23069. }
  23070. declare module BABYLON {
  23071. /**
  23072. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23073. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23074. */
  23075. export class PostProcessManager {
  23076. private _scene;
  23077. private _indexBuffer;
  23078. private _vertexBuffers;
  23079. /**
  23080. * Creates a new instance PostProcess
  23081. * @param scene The scene that the post process is associated with.
  23082. */
  23083. constructor(scene: Scene);
  23084. private _prepareBuffers;
  23085. private _buildIndexBuffer;
  23086. /**
  23087. * Rebuilds the vertex buffers of the manager.
  23088. * @hidden
  23089. */
  23090. _rebuild(): void;
  23091. /**
  23092. * Prepares a frame to be run through a post process.
  23093. * @param sourceTexture The input texture to the post procesess. (default: null)
  23094. * @param postProcesses An array of post processes to be run. (default: null)
  23095. * @returns True if the post processes were able to be run.
  23096. * @hidden
  23097. */
  23098. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23099. /**
  23100. * Manually render a set of post processes to a texture.
  23101. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23102. * @param postProcesses An array of post processes to be run.
  23103. * @param targetTexture The target texture to render to.
  23104. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23105. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23106. * @param lodLevel defines which lod of the texture to render to
  23107. */
  23108. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23109. /**
  23110. * Finalize the result of the output of the postprocesses.
  23111. * @param doNotPresent If true the result will not be displayed to the screen.
  23112. * @param targetTexture The target texture to render to.
  23113. * @param faceIndex The index of the face to bind the target texture to.
  23114. * @param postProcesses The array of post processes to render.
  23115. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23116. * @hidden
  23117. */
  23118. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23119. /**
  23120. * Disposes of the post process manager.
  23121. */
  23122. dispose(): void;
  23123. }
  23124. }
  23125. declare module BABYLON {
  23126. /**
  23127. * This Helps creating a texture that will be created from a camera in your scene.
  23128. * It is basically a dynamic texture that could be used to create special effects for instance.
  23129. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23130. */
  23131. export class RenderTargetTexture extends Texture {
  23132. isCube: boolean;
  23133. /**
  23134. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23135. */
  23136. static readonly REFRESHRATE_RENDER_ONCE: number;
  23137. /**
  23138. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23139. */
  23140. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23141. /**
  23142. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23143. * the central point of your effect and can save a lot of performances.
  23144. */
  23145. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23146. /**
  23147. * Use this predicate to dynamically define the list of mesh you want to render.
  23148. * If set, the renderList property will be overwritten.
  23149. */
  23150. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23151. private _renderList;
  23152. /**
  23153. * Use this list to define the list of mesh you want to render.
  23154. */
  23155. get renderList(): Nullable<Array<AbstractMesh>>;
  23156. set renderList(value: Nullable<Array<AbstractMesh>>);
  23157. /**
  23158. * Use this function to overload the renderList array at rendering time.
  23159. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23160. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23161. * the cube (if the RTT is a cube, else layerOrFace=0).
  23162. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23163. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23164. * hold dummy elements!
  23165. */
  23166. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23167. private _hookArray;
  23168. /**
  23169. * Define if particles should be rendered in your texture.
  23170. */
  23171. renderParticles: boolean;
  23172. /**
  23173. * Define if sprites should be rendered in your texture.
  23174. */
  23175. renderSprites: boolean;
  23176. /**
  23177. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23178. */
  23179. coordinatesMode: number;
  23180. /**
  23181. * Define the camera used to render the texture.
  23182. */
  23183. activeCamera: Nullable<Camera>;
  23184. /**
  23185. * Override the mesh isReady function with your own one.
  23186. */
  23187. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23188. /**
  23189. * Override the render function of the texture with your own one.
  23190. */
  23191. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23192. /**
  23193. * Define if camera post processes should be use while rendering the texture.
  23194. */
  23195. useCameraPostProcesses: boolean;
  23196. /**
  23197. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23198. */
  23199. ignoreCameraViewport: boolean;
  23200. private _postProcessManager;
  23201. private _postProcesses;
  23202. private _resizeObserver;
  23203. /**
  23204. * An event triggered when the texture is unbind.
  23205. */
  23206. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23207. /**
  23208. * An event triggered when the texture is unbind.
  23209. */
  23210. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23211. private _onAfterUnbindObserver;
  23212. /**
  23213. * Set a after unbind callback in the texture.
  23214. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23215. */
  23216. set onAfterUnbind(callback: () => void);
  23217. /**
  23218. * An event triggered before rendering the texture
  23219. */
  23220. onBeforeRenderObservable: Observable<number>;
  23221. private _onBeforeRenderObserver;
  23222. /**
  23223. * Set a before render callback in the texture.
  23224. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23225. */
  23226. set onBeforeRender(callback: (faceIndex: number) => void);
  23227. /**
  23228. * An event triggered after rendering the texture
  23229. */
  23230. onAfterRenderObservable: Observable<number>;
  23231. private _onAfterRenderObserver;
  23232. /**
  23233. * Set a after render callback in the texture.
  23234. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23235. */
  23236. set onAfterRender(callback: (faceIndex: number) => void);
  23237. /**
  23238. * An event triggered after the texture clear
  23239. */
  23240. onClearObservable: Observable<Engine>;
  23241. private _onClearObserver;
  23242. /**
  23243. * Set a clear callback in the texture.
  23244. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23245. */
  23246. set onClear(callback: (Engine: Engine) => void);
  23247. /**
  23248. * An event triggered when the texture is resized.
  23249. */
  23250. onResizeObservable: Observable<RenderTargetTexture>;
  23251. /**
  23252. * Define the clear color of the Render Target if it should be different from the scene.
  23253. */
  23254. clearColor: Color4;
  23255. protected _size: number | {
  23256. width: number;
  23257. height: number;
  23258. layers?: number;
  23259. };
  23260. protected _initialSizeParameter: number | {
  23261. width: number;
  23262. height: number;
  23263. } | {
  23264. ratio: number;
  23265. };
  23266. protected _sizeRatio: Nullable<number>;
  23267. /** @hidden */
  23268. _generateMipMaps: boolean;
  23269. protected _renderingManager: RenderingManager;
  23270. /** @hidden */
  23271. _waitingRenderList: string[];
  23272. protected _doNotChangeAspectRatio: boolean;
  23273. protected _currentRefreshId: number;
  23274. protected _refreshRate: number;
  23275. protected _textureMatrix: Matrix;
  23276. protected _samples: number;
  23277. protected _renderTargetOptions: RenderTargetCreationOptions;
  23278. /**
  23279. * Gets render target creation options that were used.
  23280. */
  23281. get renderTargetOptions(): RenderTargetCreationOptions;
  23282. protected _onRatioRescale(): void;
  23283. /**
  23284. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23285. * It must define where the camera used to render the texture is set
  23286. */
  23287. boundingBoxPosition: Vector3;
  23288. private _boundingBoxSize;
  23289. /**
  23290. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23291. * When defined, the cubemap will switch to local mode
  23292. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23293. * @example https://www.babylonjs-playground.com/#RNASML
  23294. */
  23295. set boundingBoxSize(value: Vector3);
  23296. get boundingBoxSize(): Vector3;
  23297. /**
  23298. * In case the RTT has been created with a depth texture, get the associated
  23299. * depth texture.
  23300. * Otherwise, return null.
  23301. */
  23302. get depthStencilTexture(): Nullable<InternalTexture>;
  23303. /**
  23304. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23305. * or used a shadow, depth texture...
  23306. * @param name The friendly name of the texture
  23307. * @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)
  23308. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23309. * @param generateMipMaps True if mip maps need to be generated after render.
  23310. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23311. * @param type The type of the buffer in the RTT (int, half float, float...)
  23312. * @param isCube True if a cube texture needs to be created
  23313. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23314. * @param generateDepthBuffer True to generate a depth buffer
  23315. * @param generateStencilBuffer True to generate a stencil buffer
  23316. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23317. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23318. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23319. */
  23320. constructor(name: string, size: number | {
  23321. width: number;
  23322. height: number;
  23323. layers?: number;
  23324. } | {
  23325. ratio: number;
  23326. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23327. /**
  23328. * Creates a depth stencil texture.
  23329. * This is only available in WebGL 2 or with the depth texture extension available.
  23330. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23331. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23332. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23333. */
  23334. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23335. private _processSizeParameter;
  23336. /**
  23337. * Define the number of samples to use in case of MSAA.
  23338. * It defaults to one meaning no MSAA has been enabled.
  23339. */
  23340. get samples(): number;
  23341. set samples(value: number);
  23342. /**
  23343. * Resets the refresh counter of the texture and start bak from scratch.
  23344. * Could be useful to regenerate the texture if it is setup to render only once.
  23345. */
  23346. resetRefreshCounter(): void;
  23347. /**
  23348. * Define the refresh rate of the texture or the rendering frequency.
  23349. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23350. */
  23351. get refreshRate(): number;
  23352. set refreshRate(value: number);
  23353. /**
  23354. * Adds a post process to the render target rendering passes.
  23355. * @param postProcess define the post process to add
  23356. */
  23357. addPostProcess(postProcess: PostProcess): void;
  23358. /**
  23359. * Clear all the post processes attached to the render target
  23360. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23361. */
  23362. clearPostProcesses(dispose?: boolean): void;
  23363. /**
  23364. * Remove one of the post process from the list of attached post processes to the texture
  23365. * @param postProcess define the post process to remove from the list
  23366. */
  23367. removePostProcess(postProcess: PostProcess): void;
  23368. /** @hidden */
  23369. _shouldRender(): boolean;
  23370. /**
  23371. * Gets the actual render size of the texture.
  23372. * @returns the width of the render size
  23373. */
  23374. getRenderSize(): number;
  23375. /**
  23376. * Gets the actual render width of the texture.
  23377. * @returns the width of the render size
  23378. */
  23379. getRenderWidth(): number;
  23380. /**
  23381. * Gets the actual render height of the texture.
  23382. * @returns the height of the render size
  23383. */
  23384. getRenderHeight(): number;
  23385. /**
  23386. * Gets the actual number of layers of the texture.
  23387. * @returns the number of layers
  23388. */
  23389. getRenderLayers(): number;
  23390. /**
  23391. * Get if the texture can be rescaled or not.
  23392. */
  23393. get canRescale(): boolean;
  23394. /**
  23395. * Resize the texture using a ratio.
  23396. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23397. */
  23398. scale(ratio: number): void;
  23399. /**
  23400. * Get the texture reflection matrix used to rotate/transform the reflection.
  23401. * @returns the reflection matrix
  23402. */
  23403. getReflectionTextureMatrix(): Matrix;
  23404. /**
  23405. * Resize the texture to a new desired size.
  23406. * Be carrefull as it will recreate all the data in the new texture.
  23407. * @param size Define the new size. It can be:
  23408. * - a number for squared texture,
  23409. * - an object containing { width: number, height: number }
  23410. * - or an object containing a ratio { ratio: number }
  23411. */
  23412. resize(size: number | {
  23413. width: number;
  23414. height: number;
  23415. } | {
  23416. ratio: number;
  23417. }): void;
  23418. private _defaultRenderListPrepared;
  23419. /**
  23420. * Renders all the objects from the render list into the texture.
  23421. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23422. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23423. */
  23424. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23425. private _bestReflectionRenderTargetDimension;
  23426. private _prepareRenderingManager;
  23427. /**
  23428. * @hidden
  23429. * @param faceIndex face index to bind to if this is a cubetexture
  23430. * @param layer defines the index of the texture to bind in the array
  23431. */
  23432. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23433. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23434. private renderToTarget;
  23435. /**
  23436. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23437. * This allowed control for front to back rendering or reversly depending of the special needs.
  23438. *
  23439. * @param renderingGroupId The rendering group id corresponding to its index
  23440. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23441. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23442. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23443. */
  23444. 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;
  23445. /**
  23446. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23447. *
  23448. * @param renderingGroupId The rendering group id corresponding to its index
  23449. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23450. */
  23451. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23452. /**
  23453. * Clones the texture.
  23454. * @returns the cloned texture
  23455. */
  23456. clone(): RenderTargetTexture;
  23457. /**
  23458. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23459. * @returns The JSON representation of the texture
  23460. */
  23461. serialize(): any;
  23462. /**
  23463. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23464. */
  23465. disposeFramebufferObjects(): void;
  23466. /**
  23467. * Dispose the texture and release its associated resources.
  23468. */
  23469. dispose(): void;
  23470. /** @hidden */
  23471. _rebuild(): void;
  23472. /**
  23473. * Clear the info related to rendering groups preventing retention point in material dispose.
  23474. */
  23475. freeRenderingGroups(): void;
  23476. /**
  23477. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23478. * @returns the view count
  23479. */
  23480. getViewCount(): number;
  23481. }
  23482. }
  23483. declare module BABYLON {
  23484. /**
  23485. * Class used to manipulate GUIDs
  23486. */
  23487. export class GUID {
  23488. /**
  23489. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23490. * Be aware Math.random() could cause collisions, but:
  23491. * "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"
  23492. * @returns a pseudo random id
  23493. */
  23494. static RandomId(): string;
  23495. }
  23496. }
  23497. declare module BABYLON {
  23498. /**
  23499. * Options to be used when creating a shadow depth material
  23500. */
  23501. export interface IIOptionShadowDepthMaterial {
  23502. /** Variables in the vertex shader code that need to have their names remapped.
  23503. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23504. * "var_name" should be either: worldPos or vNormalW
  23505. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23506. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23507. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23508. */
  23509. remappedVariables?: string[];
  23510. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23511. standalone?: boolean;
  23512. }
  23513. /**
  23514. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23515. */
  23516. export class ShadowDepthWrapper {
  23517. private _scene;
  23518. private _options?;
  23519. private _baseMaterial;
  23520. private _onEffectCreatedObserver;
  23521. private _subMeshToEffect;
  23522. private _subMeshToDepthEffect;
  23523. private _meshes;
  23524. /** @hidden */
  23525. _matriceNames: any;
  23526. /** Gets the standalone status of the wrapper */
  23527. get standalone(): boolean;
  23528. /** Gets the base material the wrapper is built upon */
  23529. get baseMaterial(): Material;
  23530. /**
  23531. * Instantiate a new shadow depth wrapper.
  23532. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23533. * generate the shadow depth map. For more information, please refer to the documentation:
  23534. * https://doc.babylonjs.com/babylon101/shadows
  23535. * @param baseMaterial Material to wrap
  23536. * @param scene Define the scene the material belongs to
  23537. * @param options Options used to create the wrapper
  23538. */
  23539. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23540. /**
  23541. * Gets the effect to use to generate the depth map
  23542. * @param subMesh subMesh to get the effect for
  23543. * @param shadowGenerator shadow generator to get the effect for
  23544. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23545. */
  23546. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23547. /**
  23548. * Specifies that the submesh is ready to be used for depth rendering
  23549. * @param subMesh submesh to check
  23550. * @param defines the list of defines to take into account when checking the effect
  23551. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23552. * @param useInstances specifies that instances should be used
  23553. * @returns a boolean indicating that the submesh is ready or not
  23554. */
  23555. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23556. /**
  23557. * Disposes the resources
  23558. */
  23559. dispose(): void;
  23560. private _makeEffect;
  23561. }
  23562. }
  23563. declare module BABYLON {
  23564. /**
  23565. * Options for compiling materials.
  23566. */
  23567. export interface IMaterialCompilationOptions {
  23568. /**
  23569. * Defines whether clip planes are enabled.
  23570. */
  23571. clipPlane: boolean;
  23572. /**
  23573. * Defines whether instances are enabled.
  23574. */
  23575. useInstances: boolean;
  23576. }
  23577. /**
  23578. * Base class for the main features of a material in Babylon.js
  23579. */
  23580. export class Material implements IAnimatable {
  23581. /**
  23582. * Returns the triangle fill mode
  23583. */
  23584. static readonly TriangleFillMode: number;
  23585. /**
  23586. * Returns the wireframe mode
  23587. */
  23588. static readonly WireFrameFillMode: number;
  23589. /**
  23590. * Returns the point fill mode
  23591. */
  23592. static readonly PointFillMode: number;
  23593. /**
  23594. * Returns the point list draw mode
  23595. */
  23596. static readonly PointListDrawMode: number;
  23597. /**
  23598. * Returns the line list draw mode
  23599. */
  23600. static readonly LineListDrawMode: number;
  23601. /**
  23602. * Returns the line loop draw mode
  23603. */
  23604. static readonly LineLoopDrawMode: number;
  23605. /**
  23606. * Returns the line strip draw mode
  23607. */
  23608. static readonly LineStripDrawMode: number;
  23609. /**
  23610. * Returns the triangle strip draw mode
  23611. */
  23612. static readonly TriangleStripDrawMode: number;
  23613. /**
  23614. * Returns the triangle fan draw mode
  23615. */
  23616. static readonly TriangleFanDrawMode: number;
  23617. /**
  23618. * Stores the clock-wise side orientation
  23619. */
  23620. static readonly ClockWiseSideOrientation: number;
  23621. /**
  23622. * Stores the counter clock-wise side orientation
  23623. */
  23624. static readonly CounterClockWiseSideOrientation: number;
  23625. /**
  23626. * The dirty texture flag value
  23627. */
  23628. static readonly TextureDirtyFlag: number;
  23629. /**
  23630. * The dirty light flag value
  23631. */
  23632. static readonly LightDirtyFlag: number;
  23633. /**
  23634. * The dirty fresnel flag value
  23635. */
  23636. static readonly FresnelDirtyFlag: number;
  23637. /**
  23638. * The dirty attribute flag value
  23639. */
  23640. static readonly AttributesDirtyFlag: number;
  23641. /**
  23642. * The dirty misc flag value
  23643. */
  23644. static readonly MiscDirtyFlag: number;
  23645. /**
  23646. * The all dirty flag value
  23647. */
  23648. static readonly AllDirtyFlag: number;
  23649. /**
  23650. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23651. */
  23652. static readonly MATERIAL_OPAQUE: number;
  23653. /**
  23654. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23655. */
  23656. static readonly MATERIAL_ALPHATEST: number;
  23657. /**
  23658. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23659. */
  23660. static readonly MATERIAL_ALPHABLEND: number;
  23661. /**
  23662. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23663. * They are also discarded below the alpha cutoff threshold to improve performances.
  23664. */
  23665. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23666. /**
  23667. * Custom callback helping to override the default shader used in the material.
  23668. */
  23669. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  23670. /**
  23671. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23672. */
  23673. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23674. /**
  23675. * The ID of the material
  23676. */
  23677. id: string;
  23678. /**
  23679. * Gets or sets the unique id of the material
  23680. */
  23681. uniqueId: number;
  23682. /**
  23683. * The name of the material
  23684. */
  23685. name: string;
  23686. /**
  23687. * Gets or sets user defined metadata
  23688. */
  23689. metadata: any;
  23690. /**
  23691. * For internal use only. Please do not use.
  23692. */
  23693. reservedDataStore: any;
  23694. /**
  23695. * Specifies if the ready state should be checked on each call
  23696. */
  23697. checkReadyOnEveryCall: boolean;
  23698. /**
  23699. * Specifies if the ready state should be checked once
  23700. */
  23701. checkReadyOnlyOnce: boolean;
  23702. /**
  23703. * The state of the material
  23704. */
  23705. state: string;
  23706. /**
  23707. * The alpha value of the material
  23708. */
  23709. protected _alpha: number;
  23710. /**
  23711. * List of inspectable custom properties (used by the Inspector)
  23712. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23713. */
  23714. inspectableCustomProperties: IInspectable[];
  23715. /**
  23716. * Sets the alpha value of the material
  23717. */
  23718. set alpha(value: number);
  23719. /**
  23720. * Gets the alpha value of the material
  23721. */
  23722. get alpha(): number;
  23723. /**
  23724. * Specifies if back face culling is enabled
  23725. */
  23726. protected _backFaceCulling: boolean;
  23727. /**
  23728. * Sets the back-face culling state
  23729. */
  23730. set backFaceCulling(value: boolean);
  23731. /**
  23732. * Gets the back-face culling state
  23733. */
  23734. get backFaceCulling(): boolean;
  23735. /**
  23736. * Stores the value for side orientation
  23737. */
  23738. sideOrientation: number;
  23739. /**
  23740. * Callback triggered when the material is compiled
  23741. */
  23742. onCompiled: Nullable<(effect: Effect) => void>;
  23743. /**
  23744. * Callback triggered when an error occurs
  23745. */
  23746. onError: Nullable<(effect: Effect, errors: string) => void>;
  23747. /**
  23748. * Callback triggered to get the render target textures
  23749. */
  23750. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23751. /**
  23752. * Gets a boolean indicating that current material needs to register RTT
  23753. */
  23754. get hasRenderTargetTextures(): boolean;
  23755. /**
  23756. * Specifies if the material should be serialized
  23757. */
  23758. doNotSerialize: boolean;
  23759. /**
  23760. * @hidden
  23761. */
  23762. _storeEffectOnSubMeshes: boolean;
  23763. /**
  23764. * Stores the animations for the material
  23765. */
  23766. animations: Nullable<Array<Animation>>;
  23767. /**
  23768. * An event triggered when the material is disposed
  23769. */
  23770. onDisposeObservable: Observable<Material>;
  23771. /**
  23772. * An observer which watches for dispose events
  23773. */
  23774. private _onDisposeObserver;
  23775. private _onUnBindObservable;
  23776. /**
  23777. * Called during a dispose event
  23778. */
  23779. set onDispose(callback: () => void);
  23780. private _onBindObservable;
  23781. /**
  23782. * An event triggered when the material is bound
  23783. */
  23784. get onBindObservable(): Observable<AbstractMesh>;
  23785. /**
  23786. * An observer which watches for bind events
  23787. */
  23788. private _onBindObserver;
  23789. /**
  23790. * Called during a bind event
  23791. */
  23792. set onBind(callback: (Mesh: AbstractMesh) => void);
  23793. /**
  23794. * An event triggered when the material is unbound
  23795. */
  23796. get onUnBindObservable(): Observable<Material>;
  23797. protected _onEffectCreatedObservable: Nullable<Observable<{
  23798. effect: Effect;
  23799. subMesh: Nullable<SubMesh>;
  23800. }>>;
  23801. /**
  23802. * An event triggered when the effect is (re)created
  23803. */
  23804. get onEffectCreatedObservable(): Observable<{
  23805. effect: Effect;
  23806. subMesh: Nullable<SubMesh>;
  23807. }>;
  23808. /**
  23809. * Stores the value of the alpha mode
  23810. */
  23811. private _alphaMode;
  23812. /**
  23813. * Sets the value of the alpha mode.
  23814. *
  23815. * | Value | Type | Description |
  23816. * | --- | --- | --- |
  23817. * | 0 | ALPHA_DISABLE | |
  23818. * | 1 | ALPHA_ADD | |
  23819. * | 2 | ALPHA_COMBINE | |
  23820. * | 3 | ALPHA_SUBTRACT | |
  23821. * | 4 | ALPHA_MULTIPLY | |
  23822. * | 5 | ALPHA_MAXIMIZED | |
  23823. * | 6 | ALPHA_ONEONE | |
  23824. * | 7 | ALPHA_PREMULTIPLIED | |
  23825. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23826. * | 9 | ALPHA_INTERPOLATE | |
  23827. * | 10 | ALPHA_SCREENMODE | |
  23828. *
  23829. */
  23830. set alphaMode(value: number);
  23831. /**
  23832. * Gets the value of the alpha mode
  23833. */
  23834. get alphaMode(): number;
  23835. /**
  23836. * Stores the state of the need depth pre-pass value
  23837. */
  23838. private _needDepthPrePass;
  23839. /**
  23840. * Sets the need depth pre-pass value
  23841. */
  23842. set needDepthPrePass(value: boolean);
  23843. /**
  23844. * Gets the depth pre-pass value
  23845. */
  23846. get needDepthPrePass(): boolean;
  23847. /**
  23848. * Specifies if depth writing should be disabled
  23849. */
  23850. disableDepthWrite: boolean;
  23851. /**
  23852. * Specifies if color writing should be disabled
  23853. */
  23854. disableColorWrite: boolean;
  23855. /**
  23856. * Specifies if depth writing should be forced
  23857. */
  23858. forceDepthWrite: boolean;
  23859. /**
  23860. * Specifies the depth function that should be used. 0 means the default engine function
  23861. */
  23862. depthFunction: number;
  23863. /**
  23864. * Specifies if there should be a separate pass for culling
  23865. */
  23866. separateCullingPass: boolean;
  23867. /**
  23868. * Stores the state specifing if fog should be enabled
  23869. */
  23870. private _fogEnabled;
  23871. /**
  23872. * Sets the state for enabling fog
  23873. */
  23874. set fogEnabled(value: boolean);
  23875. /**
  23876. * Gets the value of the fog enabled state
  23877. */
  23878. get fogEnabled(): boolean;
  23879. /**
  23880. * Stores the size of points
  23881. */
  23882. pointSize: number;
  23883. /**
  23884. * Stores the z offset value
  23885. */
  23886. zOffset: number;
  23887. get wireframe(): boolean;
  23888. /**
  23889. * Sets the state of wireframe mode
  23890. */
  23891. set wireframe(value: boolean);
  23892. /**
  23893. * Gets the value specifying if point clouds are enabled
  23894. */
  23895. get pointsCloud(): boolean;
  23896. /**
  23897. * Sets the state of point cloud mode
  23898. */
  23899. set pointsCloud(value: boolean);
  23900. /**
  23901. * Gets the material fill mode
  23902. */
  23903. get fillMode(): number;
  23904. /**
  23905. * Sets the material fill mode
  23906. */
  23907. set fillMode(value: number);
  23908. /**
  23909. * @hidden
  23910. * Stores the effects for the material
  23911. */
  23912. _effect: Nullable<Effect>;
  23913. /**
  23914. * Specifies if uniform buffers should be used
  23915. */
  23916. private _useUBO;
  23917. /**
  23918. * Stores a reference to the scene
  23919. */
  23920. private _scene;
  23921. /**
  23922. * Stores the fill mode state
  23923. */
  23924. private _fillMode;
  23925. /**
  23926. * Specifies if the depth write state should be cached
  23927. */
  23928. private _cachedDepthWriteState;
  23929. /**
  23930. * Specifies if the color write state should be cached
  23931. */
  23932. private _cachedColorWriteState;
  23933. /**
  23934. * Specifies if the depth function state should be cached
  23935. */
  23936. private _cachedDepthFunctionState;
  23937. /**
  23938. * Stores the uniform buffer
  23939. */
  23940. protected _uniformBuffer: UniformBuffer;
  23941. /** @hidden */
  23942. _indexInSceneMaterialArray: number;
  23943. /** @hidden */
  23944. meshMap: Nullable<{
  23945. [id: string]: AbstractMesh | undefined;
  23946. }>;
  23947. /**
  23948. * Creates a material instance
  23949. * @param name defines the name of the material
  23950. * @param scene defines the scene to reference
  23951. * @param doNotAdd specifies if the material should be added to the scene
  23952. */
  23953. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  23954. /**
  23955. * Returns a string representation of the current material
  23956. * @param fullDetails defines a boolean indicating which levels of logging is desired
  23957. * @returns a string with material information
  23958. */
  23959. toString(fullDetails?: boolean): string;
  23960. /**
  23961. * Gets the class name of the material
  23962. * @returns a string with the class name of the material
  23963. */
  23964. getClassName(): string;
  23965. /**
  23966. * Specifies if updates for the material been locked
  23967. */
  23968. get isFrozen(): boolean;
  23969. /**
  23970. * Locks updates for the material
  23971. */
  23972. freeze(): void;
  23973. /**
  23974. * Unlocks updates for the material
  23975. */
  23976. unfreeze(): void;
  23977. /**
  23978. * Specifies if the material is ready to be used
  23979. * @param mesh defines the mesh to check
  23980. * @param useInstances specifies if instances should be used
  23981. * @returns a boolean indicating if the material is ready to be used
  23982. */
  23983. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23984. /**
  23985. * Specifies that the submesh is ready to be used
  23986. * @param mesh defines the mesh to check
  23987. * @param subMesh defines which submesh to check
  23988. * @param useInstances specifies that instances should be used
  23989. * @returns a boolean indicating that the submesh is ready or not
  23990. */
  23991. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  23992. /**
  23993. * Returns the material effect
  23994. * @returns the effect associated with the material
  23995. */
  23996. getEffect(): Nullable<Effect>;
  23997. /**
  23998. * Returns the current scene
  23999. * @returns a Scene
  24000. */
  24001. getScene(): Scene;
  24002. /**
  24003. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24004. */
  24005. protected _forceAlphaTest: boolean;
  24006. /**
  24007. * The transparency mode of the material.
  24008. */
  24009. protected _transparencyMode: Nullable<number>;
  24010. /**
  24011. * Gets the current transparency mode.
  24012. */
  24013. get transparencyMode(): Nullable<number>;
  24014. /**
  24015. * Sets the transparency mode of the material.
  24016. *
  24017. * | Value | Type | Description |
  24018. * | ----- | ----------------------------------- | ----------- |
  24019. * | 0 | OPAQUE | |
  24020. * | 1 | ALPHATEST | |
  24021. * | 2 | ALPHABLEND | |
  24022. * | 3 | ALPHATESTANDBLEND | |
  24023. *
  24024. */
  24025. set transparencyMode(value: Nullable<number>);
  24026. /**
  24027. * Returns true if alpha blending should be disabled.
  24028. */
  24029. protected get _disableAlphaBlending(): boolean;
  24030. /**
  24031. * Specifies whether or not this material should be rendered in alpha blend mode.
  24032. * @returns a boolean specifying if alpha blending is needed
  24033. */
  24034. needAlphaBlending(): boolean;
  24035. /**
  24036. * Specifies if the mesh will require alpha blending
  24037. * @param mesh defines the mesh to check
  24038. * @returns a boolean specifying if alpha blending is needed for the mesh
  24039. */
  24040. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24041. /**
  24042. * Specifies whether or not this material should be rendered in alpha test mode.
  24043. * @returns a boolean specifying if an alpha test is needed.
  24044. */
  24045. needAlphaTesting(): boolean;
  24046. /**
  24047. * Specifies if material alpha testing should be turned on for the mesh
  24048. * @param mesh defines the mesh to check
  24049. */
  24050. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24051. /**
  24052. * Gets the texture used for the alpha test
  24053. * @returns the texture to use for alpha testing
  24054. */
  24055. getAlphaTestTexture(): Nullable<BaseTexture>;
  24056. /**
  24057. * Marks the material to indicate that it needs to be re-calculated
  24058. */
  24059. markDirty(): void;
  24060. /** @hidden */
  24061. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24062. /**
  24063. * Binds the material to the mesh
  24064. * @param world defines the world transformation matrix
  24065. * @param mesh defines the mesh to bind the material to
  24066. */
  24067. bind(world: Matrix, mesh?: Mesh): void;
  24068. /**
  24069. * Binds the submesh to the material
  24070. * @param world defines the world transformation matrix
  24071. * @param mesh defines the mesh containing the submesh
  24072. * @param subMesh defines the submesh to bind the material to
  24073. */
  24074. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24075. /**
  24076. * Binds the world matrix to the material
  24077. * @param world defines the world transformation matrix
  24078. */
  24079. bindOnlyWorldMatrix(world: Matrix): void;
  24080. /**
  24081. * Binds the scene's uniform buffer to the effect.
  24082. * @param effect defines the effect to bind to the scene uniform buffer
  24083. * @param sceneUbo defines the uniform buffer storing scene data
  24084. */
  24085. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24086. /**
  24087. * Binds the view matrix to the effect
  24088. * @param effect defines the effect to bind the view matrix to
  24089. */
  24090. bindView(effect: Effect): void;
  24091. /**
  24092. * Binds the view projection matrix to the effect
  24093. * @param effect defines the effect to bind the view projection matrix to
  24094. */
  24095. bindViewProjection(effect: Effect): void;
  24096. /**
  24097. * Processes to execute after binding the material to a mesh
  24098. * @param mesh defines the rendered mesh
  24099. */
  24100. protected _afterBind(mesh?: Mesh): void;
  24101. /**
  24102. * Unbinds the material from the mesh
  24103. */
  24104. unbind(): void;
  24105. /**
  24106. * Gets the active textures from the material
  24107. * @returns an array of textures
  24108. */
  24109. getActiveTextures(): BaseTexture[];
  24110. /**
  24111. * Specifies if the material uses a texture
  24112. * @param texture defines the texture to check against the material
  24113. * @returns a boolean specifying if the material uses the texture
  24114. */
  24115. hasTexture(texture: BaseTexture): boolean;
  24116. /**
  24117. * Makes a duplicate of the material, and gives it a new name
  24118. * @param name defines the new name for the duplicated material
  24119. * @returns the cloned material
  24120. */
  24121. clone(name: string): Nullable<Material>;
  24122. /**
  24123. * Gets the meshes bound to the material
  24124. * @returns an array of meshes bound to the material
  24125. */
  24126. getBindedMeshes(): AbstractMesh[];
  24127. /**
  24128. * Force shader compilation
  24129. * @param mesh defines the mesh associated with this material
  24130. * @param onCompiled defines a function to execute once the material is compiled
  24131. * @param options defines the options to configure the compilation
  24132. * @param onError defines a function to execute if the material fails compiling
  24133. */
  24134. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24135. /**
  24136. * Force shader compilation
  24137. * @param mesh defines the mesh that will use this material
  24138. * @param options defines additional options for compiling the shaders
  24139. * @returns a promise that resolves when the compilation completes
  24140. */
  24141. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24142. private static readonly _AllDirtyCallBack;
  24143. private static readonly _ImageProcessingDirtyCallBack;
  24144. private static readonly _TextureDirtyCallBack;
  24145. private static readonly _FresnelDirtyCallBack;
  24146. private static readonly _MiscDirtyCallBack;
  24147. private static readonly _LightsDirtyCallBack;
  24148. private static readonly _AttributeDirtyCallBack;
  24149. private static _FresnelAndMiscDirtyCallBack;
  24150. private static _TextureAndMiscDirtyCallBack;
  24151. private static readonly _DirtyCallbackArray;
  24152. private static readonly _RunDirtyCallBacks;
  24153. /**
  24154. * Marks a define in the material to indicate that it needs to be re-computed
  24155. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24156. */
  24157. markAsDirty(flag: number): void;
  24158. /**
  24159. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24160. * @param func defines a function which checks material defines against the submeshes
  24161. */
  24162. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24163. /**
  24164. * Indicates that we need to re-calculated for all submeshes
  24165. */
  24166. protected _markAllSubMeshesAsAllDirty(): void;
  24167. /**
  24168. * Indicates that image processing needs to be re-calculated for all submeshes
  24169. */
  24170. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24171. /**
  24172. * Indicates that textures need to be re-calculated for all submeshes
  24173. */
  24174. protected _markAllSubMeshesAsTexturesDirty(): void;
  24175. /**
  24176. * Indicates that fresnel needs to be re-calculated for all submeshes
  24177. */
  24178. protected _markAllSubMeshesAsFresnelDirty(): void;
  24179. /**
  24180. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24181. */
  24182. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24183. /**
  24184. * Indicates that lights need to be re-calculated for all submeshes
  24185. */
  24186. protected _markAllSubMeshesAsLightsDirty(): void;
  24187. /**
  24188. * Indicates that attributes need to be re-calculated for all submeshes
  24189. */
  24190. protected _markAllSubMeshesAsAttributesDirty(): void;
  24191. /**
  24192. * Indicates that misc needs to be re-calculated for all submeshes
  24193. */
  24194. protected _markAllSubMeshesAsMiscDirty(): void;
  24195. /**
  24196. * Indicates that textures and misc need to be re-calculated for all submeshes
  24197. */
  24198. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24199. /**
  24200. * Disposes the material
  24201. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24202. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24203. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24204. */
  24205. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24206. /** @hidden */
  24207. private releaseVertexArrayObject;
  24208. /**
  24209. * Serializes this material
  24210. * @returns the serialized material object
  24211. */
  24212. serialize(): any;
  24213. /**
  24214. * Creates a material from parsed material data
  24215. * @param parsedMaterial defines parsed material data
  24216. * @param scene defines the hosting scene
  24217. * @param rootUrl defines the root URL to use to load textures
  24218. * @returns a new material
  24219. */
  24220. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24221. }
  24222. }
  24223. declare module BABYLON {
  24224. /**
  24225. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24226. * separate meshes. This can be use to improve performances.
  24227. * @see http://doc.babylonjs.com/how_to/multi_materials
  24228. */
  24229. export class MultiMaterial extends Material {
  24230. private _subMaterials;
  24231. /**
  24232. * Gets or Sets the list of Materials used within the multi material.
  24233. * They need to be ordered according to the submeshes order in the associated mesh
  24234. */
  24235. get subMaterials(): Nullable<Material>[];
  24236. set subMaterials(value: Nullable<Material>[]);
  24237. /**
  24238. * Function used to align with Node.getChildren()
  24239. * @returns the list of Materials used within the multi material
  24240. */
  24241. getChildren(): Nullable<Material>[];
  24242. /**
  24243. * Instantiates a new Multi Material
  24244. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24245. * separate meshes. This can be use to improve performances.
  24246. * @see http://doc.babylonjs.com/how_to/multi_materials
  24247. * @param name Define the name in the scene
  24248. * @param scene Define the scene the material belongs to
  24249. */
  24250. constructor(name: string, scene: Scene);
  24251. private _hookArray;
  24252. /**
  24253. * Get one of the submaterial by its index in the submaterials array
  24254. * @param index The index to look the sub material at
  24255. * @returns The Material if the index has been defined
  24256. */
  24257. getSubMaterial(index: number): Nullable<Material>;
  24258. /**
  24259. * Get the list of active textures for the whole sub materials list.
  24260. * @returns All the textures that will be used during the rendering
  24261. */
  24262. getActiveTextures(): BaseTexture[];
  24263. /**
  24264. * Gets the current class name of the material e.g. "MultiMaterial"
  24265. * Mainly use in serialization.
  24266. * @returns the class name
  24267. */
  24268. getClassName(): string;
  24269. /**
  24270. * Checks if the material is ready to render the requested sub mesh
  24271. * @param mesh Define the mesh the submesh belongs to
  24272. * @param subMesh Define the sub mesh to look readyness for
  24273. * @param useInstances Define whether or not the material is used with instances
  24274. * @returns true if ready, otherwise false
  24275. */
  24276. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  24277. /**
  24278. * Clones the current material and its related sub materials
  24279. * @param name Define the name of the newly cloned material
  24280. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24281. * @returns the cloned material
  24282. */
  24283. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24284. /**
  24285. * Serializes the materials into a JSON representation.
  24286. * @returns the JSON representation
  24287. */
  24288. serialize(): any;
  24289. /**
  24290. * Dispose the material and release its associated resources
  24291. * @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)
  24292. * @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)
  24293. * @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)
  24294. */
  24295. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24296. /**
  24297. * Creates a MultiMaterial from parsed MultiMaterial data.
  24298. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24299. * @param scene defines the hosting scene
  24300. * @returns a new MultiMaterial
  24301. */
  24302. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24303. }
  24304. }
  24305. declare module BABYLON {
  24306. /**
  24307. * Base class for submeshes
  24308. */
  24309. export class BaseSubMesh {
  24310. /** @hidden */
  24311. _materialDefines: Nullable<MaterialDefines>;
  24312. /** @hidden */
  24313. _materialEffect: Nullable<Effect>;
  24314. /** @hidden */
  24315. _effectOverride: Nullable<Effect>;
  24316. /**
  24317. * Gets material defines used by the effect associated to the sub mesh
  24318. */
  24319. get materialDefines(): Nullable<MaterialDefines>;
  24320. /**
  24321. * Sets material defines used by the effect associated to the sub mesh
  24322. */
  24323. set materialDefines(defines: Nullable<MaterialDefines>);
  24324. /**
  24325. * Gets associated effect
  24326. */
  24327. get effect(): Nullable<Effect>;
  24328. /**
  24329. * Sets associated effect (effect used to render this submesh)
  24330. * @param effect defines the effect to associate with
  24331. * @param defines defines the set of defines used to compile this effect
  24332. */
  24333. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24334. }
  24335. /**
  24336. * Defines a subdivision inside a mesh
  24337. */
  24338. export class SubMesh extends BaseSubMesh implements ICullable {
  24339. /** the material index to use */
  24340. materialIndex: number;
  24341. /** vertex index start */
  24342. verticesStart: number;
  24343. /** vertices count */
  24344. verticesCount: number;
  24345. /** index start */
  24346. indexStart: number;
  24347. /** indices count */
  24348. indexCount: number;
  24349. /** @hidden */
  24350. _linesIndexCount: number;
  24351. private _mesh;
  24352. private _renderingMesh;
  24353. private _boundingInfo;
  24354. private _linesIndexBuffer;
  24355. /** @hidden */
  24356. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24357. /** @hidden */
  24358. _trianglePlanes: Plane[];
  24359. /** @hidden */
  24360. _lastColliderTransformMatrix: Nullable<Matrix>;
  24361. /** @hidden */
  24362. _renderId: number;
  24363. /** @hidden */
  24364. _alphaIndex: number;
  24365. /** @hidden */
  24366. _distanceToCamera: number;
  24367. /** @hidden */
  24368. _id: number;
  24369. private _currentMaterial;
  24370. /**
  24371. * Add a new submesh to a mesh
  24372. * @param materialIndex defines the material index to use
  24373. * @param verticesStart defines vertex index start
  24374. * @param verticesCount defines vertices count
  24375. * @param indexStart defines index start
  24376. * @param indexCount defines indices count
  24377. * @param mesh defines the parent mesh
  24378. * @param renderingMesh defines an optional rendering mesh
  24379. * @param createBoundingBox defines if bounding box should be created for this submesh
  24380. * @returns the new submesh
  24381. */
  24382. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24383. /**
  24384. * Creates a new submesh
  24385. * @param materialIndex defines the material index to use
  24386. * @param verticesStart defines vertex index start
  24387. * @param verticesCount defines vertices count
  24388. * @param indexStart defines index start
  24389. * @param indexCount defines indices count
  24390. * @param mesh defines the parent mesh
  24391. * @param renderingMesh defines an optional rendering mesh
  24392. * @param createBoundingBox defines if bounding box should be created for this submesh
  24393. */
  24394. constructor(
  24395. /** the material index to use */
  24396. materialIndex: number,
  24397. /** vertex index start */
  24398. verticesStart: number,
  24399. /** vertices count */
  24400. verticesCount: number,
  24401. /** index start */
  24402. indexStart: number,
  24403. /** indices count */
  24404. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  24405. /**
  24406. * Returns true if this submesh covers the entire parent mesh
  24407. * @ignorenaming
  24408. */
  24409. get IsGlobal(): boolean;
  24410. /**
  24411. * Returns the submesh BoudingInfo object
  24412. * @returns current bounding info (or mesh's one if the submesh is global)
  24413. */
  24414. getBoundingInfo(): BoundingInfo;
  24415. /**
  24416. * Sets the submesh BoundingInfo
  24417. * @param boundingInfo defines the new bounding info to use
  24418. * @returns the SubMesh
  24419. */
  24420. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24421. /**
  24422. * Returns the mesh of the current submesh
  24423. * @return the parent mesh
  24424. */
  24425. getMesh(): AbstractMesh;
  24426. /**
  24427. * Returns the rendering mesh of the submesh
  24428. * @returns the rendering mesh (could be different from parent mesh)
  24429. */
  24430. getRenderingMesh(): Mesh;
  24431. /**
  24432. * Returns the submesh material
  24433. * @returns null or the current material
  24434. */
  24435. getMaterial(): Nullable<Material>;
  24436. /**
  24437. * Sets a new updated BoundingInfo object to the submesh
  24438. * @param data defines an optional position array to use to determine the bounding info
  24439. * @returns the SubMesh
  24440. */
  24441. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24442. /** @hidden */
  24443. _checkCollision(collider: Collider): boolean;
  24444. /**
  24445. * Updates the submesh BoundingInfo
  24446. * @param world defines the world matrix to use to update the bounding info
  24447. * @returns the submesh
  24448. */
  24449. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24450. /**
  24451. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24452. * @param frustumPlanes defines the frustum planes
  24453. * @returns true if the submesh is intersecting with the frustum
  24454. */
  24455. isInFrustum(frustumPlanes: Plane[]): boolean;
  24456. /**
  24457. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24458. * @param frustumPlanes defines the frustum planes
  24459. * @returns true if the submesh is inside the frustum
  24460. */
  24461. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24462. /**
  24463. * Renders the submesh
  24464. * @param enableAlphaMode defines if alpha needs to be used
  24465. * @returns the submesh
  24466. */
  24467. render(enableAlphaMode: boolean): SubMesh;
  24468. /**
  24469. * @hidden
  24470. */
  24471. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24472. /**
  24473. * Checks if the submesh intersects with a ray
  24474. * @param ray defines the ray to test
  24475. * @returns true is the passed ray intersects the submesh bounding box
  24476. */
  24477. canIntersects(ray: Ray): boolean;
  24478. /**
  24479. * Intersects current submesh with a ray
  24480. * @param ray defines the ray to test
  24481. * @param positions defines mesh's positions array
  24482. * @param indices defines mesh's indices array
  24483. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24484. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24485. * @returns intersection info or null if no intersection
  24486. */
  24487. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24488. /** @hidden */
  24489. private _intersectLines;
  24490. /** @hidden */
  24491. private _intersectUnIndexedLines;
  24492. /** @hidden */
  24493. private _intersectTriangles;
  24494. /** @hidden */
  24495. private _intersectUnIndexedTriangles;
  24496. /** @hidden */
  24497. _rebuild(): void;
  24498. /**
  24499. * Creates a new submesh from the passed mesh
  24500. * @param newMesh defines the new hosting mesh
  24501. * @param newRenderingMesh defines an optional rendering mesh
  24502. * @returns the new submesh
  24503. */
  24504. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24505. /**
  24506. * Release associated resources
  24507. */
  24508. dispose(): void;
  24509. /**
  24510. * Gets the class name
  24511. * @returns the string "SubMesh".
  24512. */
  24513. getClassName(): string;
  24514. /**
  24515. * Creates a new submesh from indices data
  24516. * @param materialIndex the index of the main mesh material
  24517. * @param startIndex the index where to start the copy in the mesh indices array
  24518. * @param indexCount the number of indices to copy then from the startIndex
  24519. * @param mesh the main mesh to create the submesh from
  24520. * @param renderingMesh the optional rendering mesh
  24521. * @returns a new submesh
  24522. */
  24523. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24524. }
  24525. }
  24526. declare module BABYLON {
  24527. /**
  24528. * Class used to represent data loading progression
  24529. */
  24530. export class SceneLoaderFlags {
  24531. private static _ForceFullSceneLoadingForIncremental;
  24532. private static _ShowLoadingScreen;
  24533. private static _CleanBoneMatrixWeights;
  24534. private static _loggingLevel;
  24535. /**
  24536. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24537. */
  24538. static get ForceFullSceneLoadingForIncremental(): boolean;
  24539. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24540. /**
  24541. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24542. */
  24543. static get ShowLoadingScreen(): boolean;
  24544. static set ShowLoadingScreen(value: boolean);
  24545. /**
  24546. * Defines the current logging level (while loading the scene)
  24547. * @ignorenaming
  24548. */
  24549. static get loggingLevel(): number;
  24550. static set loggingLevel(value: number);
  24551. /**
  24552. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24553. */
  24554. static get CleanBoneMatrixWeights(): boolean;
  24555. static set CleanBoneMatrixWeights(value: boolean);
  24556. }
  24557. }
  24558. declare module BABYLON {
  24559. /**
  24560. * Class used to store geometry data (vertex buffers + index buffer)
  24561. */
  24562. export class Geometry implements IGetSetVerticesData {
  24563. /**
  24564. * Gets or sets the ID of the geometry
  24565. */
  24566. id: string;
  24567. /**
  24568. * Gets or sets the unique ID of the geometry
  24569. */
  24570. uniqueId: number;
  24571. /**
  24572. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24573. */
  24574. delayLoadState: number;
  24575. /**
  24576. * Gets the file containing the data to load when running in delay load state
  24577. */
  24578. delayLoadingFile: Nullable<string>;
  24579. /**
  24580. * Callback called when the geometry is updated
  24581. */
  24582. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24583. private _scene;
  24584. private _engine;
  24585. private _meshes;
  24586. private _totalVertices;
  24587. /** @hidden */
  24588. _indices: IndicesArray;
  24589. /** @hidden */
  24590. _vertexBuffers: {
  24591. [key: string]: VertexBuffer;
  24592. };
  24593. private _isDisposed;
  24594. private _extend;
  24595. private _boundingBias;
  24596. /** @hidden */
  24597. _delayInfo: Array<string>;
  24598. private _indexBuffer;
  24599. private _indexBufferIsUpdatable;
  24600. /** @hidden */
  24601. _boundingInfo: Nullable<BoundingInfo>;
  24602. /** @hidden */
  24603. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24604. /** @hidden */
  24605. _softwareSkinningFrameId: number;
  24606. private _vertexArrayObjects;
  24607. private _updatable;
  24608. /** @hidden */
  24609. _positions: Nullable<Vector3[]>;
  24610. /**
  24611. * 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
  24612. */
  24613. get boundingBias(): Vector2;
  24614. /**
  24615. * 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
  24616. */
  24617. set boundingBias(value: Vector2);
  24618. /**
  24619. * Static function used to attach a new empty geometry to a mesh
  24620. * @param mesh defines the mesh to attach the geometry to
  24621. * @returns the new Geometry
  24622. */
  24623. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24624. /** Get the list of meshes using this geometry */
  24625. get meshes(): Mesh[];
  24626. /**
  24627. * Creates a new geometry
  24628. * @param id defines the unique ID
  24629. * @param scene defines the hosting scene
  24630. * @param vertexData defines the VertexData used to get geometry data
  24631. * @param updatable defines if geometry must be updatable (false by default)
  24632. * @param mesh defines the mesh that will be associated with the geometry
  24633. */
  24634. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24635. /**
  24636. * Gets the current extend of the geometry
  24637. */
  24638. get extend(): {
  24639. minimum: Vector3;
  24640. maximum: Vector3;
  24641. };
  24642. /**
  24643. * Gets the hosting scene
  24644. * @returns the hosting Scene
  24645. */
  24646. getScene(): Scene;
  24647. /**
  24648. * Gets the hosting engine
  24649. * @returns the hosting Engine
  24650. */
  24651. getEngine(): Engine;
  24652. /**
  24653. * Defines if the geometry is ready to use
  24654. * @returns true if the geometry is ready to be used
  24655. */
  24656. isReady(): boolean;
  24657. /**
  24658. * Gets a value indicating that the geometry should not be serialized
  24659. */
  24660. get doNotSerialize(): boolean;
  24661. /** @hidden */
  24662. _rebuild(): void;
  24663. /**
  24664. * Affects all geometry data in one call
  24665. * @param vertexData defines the geometry data
  24666. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24667. */
  24668. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24669. /**
  24670. * Set specific vertex data
  24671. * @param kind defines the data kind (Position, normal, etc...)
  24672. * @param data defines the vertex data to use
  24673. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24674. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24675. */
  24676. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24677. /**
  24678. * Removes a specific vertex data
  24679. * @param kind defines the data kind (Position, normal, etc...)
  24680. */
  24681. removeVerticesData(kind: string): void;
  24682. /**
  24683. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24684. * @param buffer defines the vertex buffer to use
  24685. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24686. */
  24687. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24688. /**
  24689. * Update a specific vertex buffer
  24690. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24691. * It will do nothing if the buffer is not updatable
  24692. * @param kind defines the data kind (Position, normal, etc...)
  24693. * @param data defines the data to use
  24694. * @param offset defines the offset in the target buffer where to store the data
  24695. * @param useBytes set to true if the offset is in bytes
  24696. */
  24697. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24698. /**
  24699. * Update a specific vertex buffer
  24700. * This function will create a new buffer if the current one is not updatable
  24701. * @param kind defines the data kind (Position, normal, etc...)
  24702. * @param data defines the data to use
  24703. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24704. */
  24705. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24706. private _updateBoundingInfo;
  24707. /** @hidden */
  24708. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24709. /**
  24710. * Gets total number of vertices
  24711. * @returns the total number of vertices
  24712. */
  24713. getTotalVertices(): number;
  24714. /**
  24715. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24716. * @param kind defines the data kind (Position, normal, etc...)
  24717. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24718. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24719. * @returns a float array containing vertex data
  24720. */
  24721. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24722. /**
  24723. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24724. * @param kind defines the data kind (Position, normal, etc...)
  24725. * @returns true if the vertex buffer with the specified kind is updatable
  24726. */
  24727. isVertexBufferUpdatable(kind: string): boolean;
  24728. /**
  24729. * Gets a specific vertex buffer
  24730. * @param kind defines the data kind (Position, normal, etc...)
  24731. * @returns a VertexBuffer
  24732. */
  24733. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24734. /**
  24735. * Returns all vertex buffers
  24736. * @return an object holding all vertex buffers indexed by kind
  24737. */
  24738. getVertexBuffers(): Nullable<{
  24739. [key: string]: VertexBuffer;
  24740. }>;
  24741. /**
  24742. * Gets a boolean indicating if specific vertex buffer is present
  24743. * @param kind defines the data kind (Position, normal, etc...)
  24744. * @returns true if data is present
  24745. */
  24746. isVerticesDataPresent(kind: string): boolean;
  24747. /**
  24748. * Gets a list of all attached data kinds (Position, normal, etc...)
  24749. * @returns a list of string containing all kinds
  24750. */
  24751. getVerticesDataKinds(): string[];
  24752. /**
  24753. * Update index buffer
  24754. * @param indices defines the indices to store in the index buffer
  24755. * @param offset defines the offset in the target buffer where to store the data
  24756. * @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)
  24757. */
  24758. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24759. /**
  24760. * Creates a new index buffer
  24761. * @param indices defines the indices to store in the index buffer
  24762. * @param totalVertices defines the total number of vertices (could be null)
  24763. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24764. */
  24765. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24766. /**
  24767. * Return the total number of indices
  24768. * @returns the total number of indices
  24769. */
  24770. getTotalIndices(): number;
  24771. /**
  24772. * Gets the index buffer array
  24773. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24774. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24775. * @returns the index buffer array
  24776. */
  24777. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24778. /**
  24779. * Gets the index buffer
  24780. * @return the index buffer
  24781. */
  24782. getIndexBuffer(): Nullable<DataBuffer>;
  24783. /** @hidden */
  24784. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24785. /**
  24786. * Release the associated resources for a specific mesh
  24787. * @param mesh defines the source mesh
  24788. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24789. */
  24790. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24791. /**
  24792. * Apply current geometry to a given mesh
  24793. * @param mesh defines the mesh to apply geometry to
  24794. */
  24795. applyToMesh(mesh: Mesh): void;
  24796. private _updateExtend;
  24797. private _applyToMesh;
  24798. private notifyUpdate;
  24799. /**
  24800. * Load the geometry if it was flagged as delay loaded
  24801. * @param scene defines the hosting scene
  24802. * @param onLoaded defines a callback called when the geometry is loaded
  24803. */
  24804. load(scene: Scene, onLoaded?: () => void): void;
  24805. private _queueLoad;
  24806. /**
  24807. * Invert the geometry to move from a right handed system to a left handed one.
  24808. */
  24809. toLeftHanded(): void;
  24810. /** @hidden */
  24811. _resetPointsArrayCache(): void;
  24812. /** @hidden */
  24813. _generatePointsArray(): boolean;
  24814. /**
  24815. * Gets a value indicating if the geometry is disposed
  24816. * @returns true if the geometry was disposed
  24817. */
  24818. isDisposed(): boolean;
  24819. private _disposeVertexArrayObjects;
  24820. /**
  24821. * Free all associated resources
  24822. */
  24823. dispose(): void;
  24824. /**
  24825. * Clone the current geometry into a new geometry
  24826. * @param id defines the unique ID of the new geometry
  24827. * @returns a new geometry object
  24828. */
  24829. copy(id: string): Geometry;
  24830. /**
  24831. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24832. * @return a JSON representation of the current geometry data (without the vertices data)
  24833. */
  24834. serialize(): any;
  24835. private toNumberArray;
  24836. /**
  24837. * Serialize all vertices data into a JSON oject
  24838. * @returns a JSON representation of the current geometry data
  24839. */
  24840. serializeVerticeData(): any;
  24841. /**
  24842. * Extracts a clone of a mesh geometry
  24843. * @param mesh defines the source mesh
  24844. * @param id defines the unique ID of the new geometry object
  24845. * @returns the new geometry object
  24846. */
  24847. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24848. /**
  24849. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24850. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24851. * Be aware Math.random() could cause collisions, but:
  24852. * "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"
  24853. * @returns a string containing a new GUID
  24854. */
  24855. static RandomId(): string;
  24856. /** @hidden */
  24857. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24858. private static _CleanMatricesWeights;
  24859. /**
  24860. * Create a new geometry from persisted data (Using .babylon file format)
  24861. * @param parsedVertexData defines the persisted data
  24862. * @param scene defines the hosting scene
  24863. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24864. * @returns the new geometry object
  24865. */
  24866. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24867. }
  24868. }
  24869. declare module BABYLON {
  24870. /**
  24871. * Define an interface for all classes that will get and set the data on vertices
  24872. */
  24873. export interface IGetSetVerticesData {
  24874. /**
  24875. * Gets a boolean indicating if specific vertex data is present
  24876. * @param kind defines the vertex data kind to use
  24877. * @returns true is data kind is present
  24878. */
  24879. isVerticesDataPresent(kind: string): boolean;
  24880. /**
  24881. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24882. * @param kind defines the data kind (Position, normal, etc...)
  24883. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24884. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24885. * @returns a float array containing vertex data
  24886. */
  24887. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24888. /**
  24889. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24890. * @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.
  24891. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24892. * @returns the indices array or an empty array if the mesh has no geometry
  24893. */
  24894. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24895. /**
  24896. * Set specific vertex data
  24897. * @param kind defines the data kind (Position, normal, etc...)
  24898. * @param data defines the vertex data to use
  24899. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24900. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24901. */
  24902. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  24903. /**
  24904. * Update a specific associated vertex buffer
  24905. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24906. * - VertexBuffer.PositionKind
  24907. * - VertexBuffer.UVKind
  24908. * - VertexBuffer.UV2Kind
  24909. * - VertexBuffer.UV3Kind
  24910. * - VertexBuffer.UV4Kind
  24911. * - VertexBuffer.UV5Kind
  24912. * - VertexBuffer.UV6Kind
  24913. * - VertexBuffer.ColorKind
  24914. * - VertexBuffer.MatricesIndicesKind
  24915. * - VertexBuffer.MatricesIndicesExtraKind
  24916. * - VertexBuffer.MatricesWeightsKind
  24917. * - VertexBuffer.MatricesWeightsExtraKind
  24918. * @param data defines the data source
  24919. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24920. * @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)
  24921. */
  24922. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  24923. /**
  24924. * Creates a new index buffer
  24925. * @param indices defines the indices to store in the index buffer
  24926. * @param totalVertices defines the total number of vertices (could be null)
  24927. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24928. */
  24929. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  24930. }
  24931. /**
  24932. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  24933. */
  24934. export class VertexData {
  24935. /**
  24936. * Mesh side orientation : usually the external or front surface
  24937. */
  24938. static readonly FRONTSIDE: number;
  24939. /**
  24940. * Mesh side orientation : usually the internal or back surface
  24941. */
  24942. static readonly BACKSIDE: number;
  24943. /**
  24944. * Mesh side orientation : both internal and external or front and back surfaces
  24945. */
  24946. static readonly DOUBLESIDE: number;
  24947. /**
  24948. * Mesh side orientation : by default, `FRONTSIDE`
  24949. */
  24950. static readonly DEFAULTSIDE: number;
  24951. /**
  24952. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  24953. */
  24954. positions: Nullable<FloatArray>;
  24955. /**
  24956. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  24957. */
  24958. normals: Nullable<FloatArray>;
  24959. /**
  24960. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  24961. */
  24962. tangents: Nullable<FloatArray>;
  24963. /**
  24964. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24965. */
  24966. uvs: Nullable<FloatArray>;
  24967. /**
  24968. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24969. */
  24970. uvs2: Nullable<FloatArray>;
  24971. /**
  24972. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24973. */
  24974. uvs3: Nullable<FloatArray>;
  24975. /**
  24976. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24977. */
  24978. uvs4: Nullable<FloatArray>;
  24979. /**
  24980. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24981. */
  24982. uvs5: Nullable<FloatArray>;
  24983. /**
  24984. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24985. */
  24986. uvs6: Nullable<FloatArray>;
  24987. /**
  24988. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  24989. */
  24990. colors: Nullable<FloatArray>;
  24991. /**
  24992. * 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).
  24993. */
  24994. matricesIndices: Nullable<FloatArray>;
  24995. /**
  24996. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  24997. */
  24998. matricesWeights: Nullable<FloatArray>;
  24999. /**
  25000. * An array extending the number of possible indices
  25001. */
  25002. matricesIndicesExtra: Nullable<FloatArray>;
  25003. /**
  25004. * An array extending the number of possible weights when the number of indices is extended
  25005. */
  25006. matricesWeightsExtra: Nullable<FloatArray>;
  25007. /**
  25008. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25009. */
  25010. indices: Nullable<IndicesArray>;
  25011. /**
  25012. * Uses the passed data array to set the set the values for the specified kind of data
  25013. * @param data a linear array of floating numbers
  25014. * @param kind the type of data that is being set, eg positions, colors etc
  25015. */
  25016. set(data: FloatArray, kind: string): void;
  25017. /**
  25018. * Associates the vertexData to the passed Mesh.
  25019. * Sets it as updatable or not (default `false`)
  25020. * @param mesh the mesh the vertexData is applied to
  25021. * @param updatable when used and having the value true allows new data to update the vertexData
  25022. * @returns the VertexData
  25023. */
  25024. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25025. /**
  25026. * Associates the vertexData to the passed Geometry.
  25027. * Sets it as updatable or not (default `false`)
  25028. * @param geometry the geometry the vertexData is applied to
  25029. * @param updatable when used and having the value true allows new data to update the vertexData
  25030. * @returns VertexData
  25031. */
  25032. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25033. /**
  25034. * Updates the associated mesh
  25035. * @param mesh the mesh to be updated
  25036. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25037. * @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
  25038. * @returns VertexData
  25039. */
  25040. updateMesh(mesh: Mesh): VertexData;
  25041. /**
  25042. * Updates the associated geometry
  25043. * @param geometry the geometry to be updated
  25044. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25045. * @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
  25046. * @returns VertexData.
  25047. */
  25048. updateGeometry(geometry: Geometry): VertexData;
  25049. private _applyTo;
  25050. private _update;
  25051. /**
  25052. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25053. * @param matrix the transforming matrix
  25054. * @returns the VertexData
  25055. */
  25056. transform(matrix: Matrix): VertexData;
  25057. /**
  25058. * Merges the passed VertexData into the current one
  25059. * @param other the VertexData to be merged into the current one
  25060. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25061. * @returns the modified VertexData
  25062. */
  25063. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25064. private _mergeElement;
  25065. private _validate;
  25066. /**
  25067. * Serializes the VertexData
  25068. * @returns a serialized object
  25069. */
  25070. serialize(): any;
  25071. /**
  25072. * Extracts the vertexData from a mesh
  25073. * @param mesh the mesh from which to extract the VertexData
  25074. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25075. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25076. * @returns the object VertexData associated to the passed mesh
  25077. */
  25078. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25079. /**
  25080. * Extracts the vertexData from the geometry
  25081. * @param geometry the geometry from which to extract the VertexData
  25082. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25083. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25084. * @returns the object VertexData associated to the passed mesh
  25085. */
  25086. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25087. private static _ExtractFrom;
  25088. /**
  25089. * Creates the VertexData for a Ribbon
  25090. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25091. * * pathArray array of paths, each of which an array of successive Vector3
  25092. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25093. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25094. * * 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
  25095. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25096. * * 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)
  25097. * * 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)
  25098. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25099. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25100. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25101. * @returns the VertexData of the ribbon
  25102. */
  25103. static CreateRibbon(options: {
  25104. pathArray: Vector3[][];
  25105. closeArray?: boolean;
  25106. closePath?: boolean;
  25107. offset?: number;
  25108. sideOrientation?: number;
  25109. frontUVs?: Vector4;
  25110. backUVs?: Vector4;
  25111. invertUV?: boolean;
  25112. uvs?: Vector2[];
  25113. colors?: Color4[];
  25114. }): VertexData;
  25115. /**
  25116. * Creates the VertexData for a box
  25117. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25118. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25119. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25120. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25121. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25122. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25123. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25124. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25125. * * 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)
  25126. * * 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)
  25127. * @returns the VertexData of the box
  25128. */
  25129. static CreateBox(options: {
  25130. size?: number;
  25131. width?: number;
  25132. height?: number;
  25133. depth?: number;
  25134. faceUV?: Vector4[];
  25135. faceColors?: Color4[];
  25136. sideOrientation?: number;
  25137. frontUVs?: Vector4;
  25138. backUVs?: Vector4;
  25139. }): VertexData;
  25140. /**
  25141. * Creates the VertexData for a tiled box
  25142. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25143. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25144. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25145. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25146. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25147. * @returns the VertexData of the box
  25148. */
  25149. static CreateTiledBox(options: {
  25150. pattern?: number;
  25151. width?: number;
  25152. height?: number;
  25153. depth?: number;
  25154. tileSize?: number;
  25155. tileWidth?: number;
  25156. tileHeight?: number;
  25157. alignHorizontal?: number;
  25158. alignVertical?: number;
  25159. faceUV?: Vector4[];
  25160. faceColors?: Color4[];
  25161. sideOrientation?: number;
  25162. }): VertexData;
  25163. /**
  25164. * Creates the VertexData for a tiled plane
  25165. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25166. * * pattern a limited pattern arrangement depending on the number
  25167. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25168. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25169. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25170. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25171. * * 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)
  25172. * * 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)
  25173. * @returns the VertexData of the tiled plane
  25174. */
  25175. static CreateTiledPlane(options: {
  25176. pattern?: number;
  25177. tileSize?: number;
  25178. tileWidth?: number;
  25179. tileHeight?: number;
  25180. size?: number;
  25181. width?: number;
  25182. height?: number;
  25183. alignHorizontal?: number;
  25184. alignVertical?: number;
  25185. sideOrientation?: number;
  25186. frontUVs?: Vector4;
  25187. backUVs?: Vector4;
  25188. }): VertexData;
  25189. /**
  25190. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25191. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25192. * * segments sets the number of horizontal strips optional, default 32
  25193. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25194. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25195. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25196. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25197. * * 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
  25198. * * 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
  25199. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25200. * * 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)
  25201. * * 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)
  25202. * @returns the VertexData of the ellipsoid
  25203. */
  25204. static CreateSphere(options: {
  25205. segments?: number;
  25206. diameter?: number;
  25207. diameterX?: number;
  25208. diameterY?: number;
  25209. diameterZ?: number;
  25210. arc?: number;
  25211. slice?: number;
  25212. sideOrientation?: number;
  25213. frontUVs?: Vector4;
  25214. backUVs?: Vector4;
  25215. }): VertexData;
  25216. /**
  25217. * Creates the VertexData for a cylinder, cone or prism
  25218. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25219. * * height sets the height (y direction) of the cylinder, optional, default 2
  25220. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25221. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25222. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25223. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25224. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25225. * * 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
  25226. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25227. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25228. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25229. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25230. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25231. * * 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)
  25232. * * 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)
  25233. * @returns the VertexData of the cylinder, cone or prism
  25234. */
  25235. static CreateCylinder(options: {
  25236. height?: number;
  25237. diameterTop?: number;
  25238. diameterBottom?: number;
  25239. diameter?: number;
  25240. tessellation?: number;
  25241. subdivisions?: number;
  25242. arc?: number;
  25243. faceColors?: Color4[];
  25244. faceUV?: Vector4[];
  25245. hasRings?: boolean;
  25246. enclose?: boolean;
  25247. sideOrientation?: number;
  25248. frontUVs?: Vector4;
  25249. backUVs?: Vector4;
  25250. }): VertexData;
  25251. /**
  25252. * Creates the VertexData for a torus
  25253. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25254. * * diameter the diameter of the torus, optional default 1
  25255. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25256. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25257. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25258. * * 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)
  25259. * * 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)
  25260. * @returns the VertexData of the torus
  25261. */
  25262. static CreateTorus(options: {
  25263. diameter?: number;
  25264. thickness?: number;
  25265. tessellation?: number;
  25266. sideOrientation?: number;
  25267. frontUVs?: Vector4;
  25268. backUVs?: Vector4;
  25269. }): VertexData;
  25270. /**
  25271. * Creates the VertexData of the LineSystem
  25272. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25273. * - lines an array of lines, each line being an array of successive Vector3
  25274. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25275. * @returns the VertexData of the LineSystem
  25276. */
  25277. static CreateLineSystem(options: {
  25278. lines: Vector3[][];
  25279. colors?: Nullable<Color4[][]>;
  25280. }): VertexData;
  25281. /**
  25282. * Create the VertexData for a DashedLines
  25283. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25284. * - points an array successive Vector3
  25285. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25286. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25287. * - dashNb the intended total number of dashes, optional, default 200
  25288. * @returns the VertexData for the DashedLines
  25289. */
  25290. static CreateDashedLines(options: {
  25291. points: Vector3[];
  25292. dashSize?: number;
  25293. gapSize?: number;
  25294. dashNb?: number;
  25295. }): VertexData;
  25296. /**
  25297. * Creates the VertexData for a Ground
  25298. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25299. * - width the width (x direction) of the ground, optional, default 1
  25300. * - height the height (z direction) of the ground, optional, default 1
  25301. * - subdivisions the number of subdivisions per side, optional, default 1
  25302. * @returns the VertexData of the Ground
  25303. */
  25304. static CreateGround(options: {
  25305. width?: number;
  25306. height?: number;
  25307. subdivisions?: number;
  25308. subdivisionsX?: number;
  25309. subdivisionsY?: number;
  25310. }): VertexData;
  25311. /**
  25312. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25313. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25314. * * xmin the ground minimum X coordinate, optional, default -1
  25315. * * zmin the ground minimum Z coordinate, optional, default -1
  25316. * * xmax the ground maximum X coordinate, optional, default 1
  25317. * * zmax the ground maximum Z coordinate, optional, default 1
  25318. * * 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}
  25319. * * 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}
  25320. * @returns the VertexData of the TiledGround
  25321. */
  25322. static CreateTiledGround(options: {
  25323. xmin: number;
  25324. zmin: number;
  25325. xmax: number;
  25326. zmax: number;
  25327. subdivisions?: {
  25328. w: number;
  25329. h: number;
  25330. };
  25331. precision?: {
  25332. w: number;
  25333. h: number;
  25334. };
  25335. }): VertexData;
  25336. /**
  25337. * Creates the VertexData of the Ground designed from a heightmap
  25338. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25339. * * width the width (x direction) of the ground
  25340. * * height the height (z direction) of the ground
  25341. * * subdivisions the number of subdivisions per side
  25342. * * minHeight the minimum altitude on the ground, optional, default 0
  25343. * * maxHeight the maximum altitude on the ground, optional default 1
  25344. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25345. * * buffer the array holding the image color data
  25346. * * bufferWidth the width of image
  25347. * * bufferHeight the height of image
  25348. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25349. * @returns the VertexData of the Ground designed from a heightmap
  25350. */
  25351. static CreateGroundFromHeightMap(options: {
  25352. width: number;
  25353. height: number;
  25354. subdivisions: number;
  25355. minHeight: number;
  25356. maxHeight: number;
  25357. colorFilter: Color3;
  25358. buffer: Uint8Array;
  25359. bufferWidth: number;
  25360. bufferHeight: number;
  25361. alphaFilter: number;
  25362. }): VertexData;
  25363. /**
  25364. * Creates the VertexData for a Plane
  25365. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25366. * * size sets the width and height of the plane to the value of size, optional default 1
  25367. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25368. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25369. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25370. * * 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)
  25371. * * 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)
  25372. * @returns the VertexData of the box
  25373. */
  25374. static CreatePlane(options: {
  25375. size?: number;
  25376. width?: number;
  25377. height?: number;
  25378. sideOrientation?: number;
  25379. frontUVs?: Vector4;
  25380. backUVs?: Vector4;
  25381. }): VertexData;
  25382. /**
  25383. * Creates the VertexData of the Disc or regular Polygon
  25384. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25385. * * radius the radius of the disc, optional default 0.5
  25386. * * tessellation the number of polygon sides, optional, default 64
  25387. * * 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
  25388. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25389. * * 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)
  25390. * * 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)
  25391. * @returns the VertexData of the box
  25392. */
  25393. static CreateDisc(options: {
  25394. radius?: number;
  25395. tessellation?: number;
  25396. arc?: number;
  25397. sideOrientation?: number;
  25398. frontUVs?: Vector4;
  25399. backUVs?: Vector4;
  25400. }): VertexData;
  25401. /**
  25402. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25403. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25404. * @param polygon a mesh built from polygonTriangulation.build()
  25405. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25406. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25407. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25408. * @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)
  25409. * @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)
  25410. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25411. * @returns the VertexData of the Polygon
  25412. */
  25413. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25414. /**
  25415. * Creates the VertexData of the IcoSphere
  25416. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25417. * * radius the radius of the IcoSphere, optional default 1
  25418. * * radiusX allows stretching in the x direction, optional, default radius
  25419. * * radiusY allows stretching in the y direction, optional, default radius
  25420. * * radiusZ allows stretching in the z direction, optional, default radius
  25421. * * flat when true creates a flat shaded mesh, optional, default true
  25422. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25423. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25424. * * 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)
  25425. * * 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)
  25426. * @returns the VertexData of the IcoSphere
  25427. */
  25428. static CreateIcoSphere(options: {
  25429. radius?: number;
  25430. radiusX?: number;
  25431. radiusY?: number;
  25432. radiusZ?: number;
  25433. flat?: boolean;
  25434. subdivisions?: number;
  25435. sideOrientation?: number;
  25436. frontUVs?: Vector4;
  25437. backUVs?: Vector4;
  25438. }): VertexData;
  25439. /**
  25440. * Creates the VertexData for a Polyhedron
  25441. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25442. * * type provided types are:
  25443. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25444. * * 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)
  25445. * * size the size of the IcoSphere, optional default 1
  25446. * * sizeX allows stretching in the x direction, optional, default size
  25447. * * sizeY allows stretching in the y direction, optional, default size
  25448. * * sizeZ allows stretching in the z direction, optional, default size
  25449. * * 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
  25450. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25451. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25452. * * flat when true creates a flat shaded mesh, optional, default true
  25453. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25454. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25455. * * 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)
  25456. * * 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)
  25457. * @returns the VertexData of the Polyhedron
  25458. */
  25459. static CreatePolyhedron(options: {
  25460. type?: number;
  25461. size?: number;
  25462. sizeX?: number;
  25463. sizeY?: number;
  25464. sizeZ?: number;
  25465. custom?: any;
  25466. faceUV?: Vector4[];
  25467. faceColors?: Color4[];
  25468. flat?: boolean;
  25469. sideOrientation?: number;
  25470. frontUVs?: Vector4;
  25471. backUVs?: Vector4;
  25472. }): VertexData;
  25473. /**
  25474. * Creates the VertexData for a TorusKnot
  25475. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25476. * * radius the radius of the torus knot, optional, default 2
  25477. * * tube the thickness of the tube, optional, default 0.5
  25478. * * radialSegments the number of sides on each tube segments, optional, default 32
  25479. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25480. * * p the number of windings around the z axis, optional, default 2
  25481. * * q the number of windings around the x axis, optional, default 3
  25482. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25483. * * 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)
  25484. * * 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)
  25485. * @returns the VertexData of the Torus Knot
  25486. */
  25487. static CreateTorusKnot(options: {
  25488. radius?: number;
  25489. tube?: number;
  25490. radialSegments?: number;
  25491. tubularSegments?: number;
  25492. p?: number;
  25493. q?: number;
  25494. sideOrientation?: number;
  25495. frontUVs?: Vector4;
  25496. backUVs?: Vector4;
  25497. }): VertexData;
  25498. /**
  25499. * Compute normals for given positions and indices
  25500. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25501. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25502. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25503. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25504. * * facetNormals : optional array of facet normals (vector3)
  25505. * * facetPositions : optional array of facet positions (vector3)
  25506. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25507. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25508. * * bInfo : optional bounding info, required for facetPartitioning computation
  25509. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25510. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25511. * * useRightHandedSystem: optional boolean to for right handed system computation
  25512. * * depthSort : optional boolean to enable the facet depth sort computation
  25513. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25514. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25515. */
  25516. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25517. facetNormals?: any;
  25518. facetPositions?: any;
  25519. facetPartitioning?: any;
  25520. ratio?: number;
  25521. bInfo?: any;
  25522. bbSize?: Vector3;
  25523. subDiv?: any;
  25524. useRightHandedSystem?: boolean;
  25525. depthSort?: boolean;
  25526. distanceTo?: Vector3;
  25527. depthSortedFacets?: any;
  25528. }): void;
  25529. /** @hidden */
  25530. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25531. /**
  25532. * Applies VertexData created from the imported parameters to the geometry
  25533. * @param parsedVertexData the parsed data from an imported file
  25534. * @param geometry the geometry to apply the VertexData to
  25535. */
  25536. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25537. }
  25538. }
  25539. declare module BABYLON {
  25540. /**
  25541. * Defines a target to use with MorphTargetManager
  25542. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25543. */
  25544. export class MorphTarget implements IAnimatable {
  25545. /** defines the name of the target */
  25546. name: string;
  25547. /**
  25548. * Gets or sets the list of animations
  25549. */
  25550. animations: Animation[];
  25551. private _scene;
  25552. private _positions;
  25553. private _normals;
  25554. private _tangents;
  25555. private _uvs;
  25556. private _influence;
  25557. private _uniqueId;
  25558. /**
  25559. * Observable raised when the influence changes
  25560. */
  25561. onInfluenceChanged: Observable<boolean>;
  25562. /** @hidden */
  25563. _onDataLayoutChanged: Observable<void>;
  25564. /**
  25565. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25566. */
  25567. get influence(): number;
  25568. set influence(influence: number);
  25569. /**
  25570. * Gets or sets the id of the morph Target
  25571. */
  25572. id: string;
  25573. private _animationPropertiesOverride;
  25574. /**
  25575. * Gets or sets the animation properties override
  25576. */
  25577. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25578. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25579. /**
  25580. * Creates a new MorphTarget
  25581. * @param name defines the name of the target
  25582. * @param influence defines the influence to use
  25583. * @param scene defines the scene the morphtarget belongs to
  25584. */
  25585. constructor(
  25586. /** defines the name of the target */
  25587. name: string, influence?: number, scene?: Nullable<Scene>);
  25588. /**
  25589. * Gets the unique ID of this manager
  25590. */
  25591. get uniqueId(): number;
  25592. /**
  25593. * Gets a boolean defining if the target contains position data
  25594. */
  25595. get hasPositions(): boolean;
  25596. /**
  25597. * Gets a boolean defining if the target contains normal data
  25598. */
  25599. get hasNormals(): boolean;
  25600. /**
  25601. * Gets a boolean defining if the target contains tangent data
  25602. */
  25603. get hasTangents(): boolean;
  25604. /**
  25605. * Gets a boolean defining if the target contains texture coordinates data
  25606. */
  25607. get hasUVs(): boolean;
  25608. /**
  25609. * Affects position data to this target
  25610. * @param data defines the position data to use
  25611. */
  25612. setPositions(data: Nullable<FloatArray>): void;
  25613. /**
  25614. * Gets the position data stored in this target
  25615. * @returns a FloatArray containing the position data (or null if not present)
  25616. */
  25617. getPositions(): Nullable<FloatArray>;
  25618. /**
  25619. * Affects normal data to this target
  25620. * @param data defines the normal data to use
  25621. */
  25622. setNormals(data: Nullable<FloatArray>): void;
  25623. /**
  25624. * Gets the normal data stored in this target
  25625. * @returns a FloatArray containing the normal data (or null if not present)
  25626. */
  25627. getNormals(): Nullable<FloatArray>;
  25628. /**
  25629. * Affects tangent data to this target
  25630. * @param data defines the tangent data to use
  25631. */
  25632. setTangents(data: Nullable<FloatArray>): void;
  25633. /**
  25634. * Gets the tangent data stored in this target
  25635. * @returns a FloatArray containing the tangent data (or null if not present)
  25636. */
  25637. getTangents(): Nullable<FloatArray>;
  25638. /**
  25639. * Affects texture coordinates data to this target
  25640. * @param data defines the texture coordinates data to use
  25641. */
  25642. setUVs(data: Nullable<FloatArray>): void;
  25643. /**
  25644. * Gets the texture coordinates data stored in this target
  25645. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25646. */
  25647. getUVs(): Nullable<FloatArray>;
  25648. /**
  25649. * Clone the current target
  25650. * @returns a new MorphTarget
  25651. */
  25652. clone(): MorphTarget;
  25653. /**
  25654. * Serializes the current target into a Serialization object
  25655. * @returns the serialized object
  25656. */
  25657. serialize(): any;
  25658. /**
  25659. * Returns the string "MorphTarget"
  25660. * @returns "MorphTarget"
  25661. */
  25662. getClassName(): string;
  25663. /**
  25664. * Creates a new target from serialized data
  25665. * @param serializationObject defines the serialized data to use
  25666. * @returns a new MorphTarget
  25667. */
  25668. static Parse(serializationObject: any): MorphTarget;
  25669. /**
  25670. * Creates a MorphTarget from mesh data
  25671. * @param mesh defines the source mesh
  25672. * @param name defines the name to use for the new target
  25673. * @param influence defines the influence to attach to the target
  25674. * @returns a new MorphTarget
  25675. */
  25676. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25677. }
  25678. }
  25679. declare module BABYLON {
  25680. /**
  25681. * This class is used to deform meshes using morphing between different targets
  25682. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25683. */
  25684. export class MorphTargetManager {
  25685. private _targets;
  25686. private _targetInfluenceChangedObservers;
  25687. private _targetDataLayoutChangedObservers;
  25688. private _activeTargets;
  25689. private _scene;
  25690. private _influences;
  25691. private _supportsNormals;
  25692. private _supportsTangents;
  25693. private _supportsUVs;
  25694. private _vertexCount;
  25695. private _uniqueId;
  25696. private _tempInfluences;
  25697. /**
  25698. * Gets or sets a boolean indicating if normals must be morphed
  25699. */
  25700. enableNormalMorphing: boolean;
  25701. /**
  25702. * Gets or sets a boolean indicating if tangents must be morphed
  25703. */
  25704. enableTangentMorphing: boolean;
  25705. /**
  25706. * Gets or sets a boolean indicating if UV must be morphed
  25707. */
  25708. enableUVMorphing: boolean;
  25709. /**
  25710. * Creates a new MorphTargetManager
  25711. * @param scene defines the current scene
  25712. */
  25713. constructor(scene?: Nullable<Scene>);
  25714. /**
  25715. * Gets the unique ID of this manager
  25716. */
  25717. get uniqueId(): number;
  25718. /**
  25719. * Gets the number of vertices handled by this manager
  25720. */
  25721. get vertexCount(): number;
  25722. /**
  25723. * Gets a boolean indicating if this manager supports morphing of normals
  25724. */
  25725. get supportsNormals(): boolean;
  25726. /**
  25727. * Gets a boolean indicating if this manager supports morphing of tangents
  25728. */
  25729. get supportsTangents(): boolean;
  25730. /**
  25731. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25732. */
  25733. get supportsUVs(): boolean;
  25734. /**
  25735. * Gets the number of targets stored in this manager
  25736. */
  25737. get numTargets(): number;
  25738. /**
  25739. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25740. */
  25741. get numInfluencers(): number;
  25742. /**
  25743. * Gets the list of influences (one per target)
  25744. */
  25745. get influences(): Float32Array;
  25746. /**
  25747. * Gets the active target at specified index. An active target is a target with an influence > 0
  25748. * @param index defines the index to check
  25749. * @returns the requested target
  25750. */
  25751. getActiveTarget(index: number): MorphTarget;
  25752. /**
  25753. * Gets the target at specified index
  25754. * @param index defines the index to check
  25755. * @returns the requested target
  25756. */
  25757. getTarget(index: number): MorphTarget;
  25758. /**
  25759. * Add a new target to this manager
  25760. * @param target defines the target to add
  25761. */
  25762. addTarget(target: MorphTarget): void;
  25763. /**
  25764. * Removes a target from the manager
  25765. * @param target defines the target to remove
  25766. */
  25767. removeTarget(target: MorphTarget): void;
  25768. /**
  25769. * Clone the current manager
  25770. * @returns a new MorphTargetManager
  25771. */
  25772. clone(): MorphTargetManager;
  25773. /**
  25774. * Serializes the current manager into a Serialization object
  25775. * @returns the serialized object
  25776. */
  25777. serialize(): any;
  25778. private _syncActiveTargets;
  25779. /**
  25780. * Syncrhonize the targets with all the meshes using this morph target manager
  25781. */
  25782. synchronize(): void;
  25783. /**
  25784. * Creates a new MorphTargetManager from serialized data
  25785. * @param serializationObject defines the serialized data
  25786. * @param scene defines the hosting scene
  25787. * @returns the new MorphTargetManager
  25788. */
  25789. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25790. }
  25791. }
  25792. declare module BABYLON {
  25793. /**
  25794. * Class used to represent a specific level of detail of a mesh
  25795. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25796. */
  25797. export class MeshLODLevel {
  25798. /** Defines the distance where this level should start being displayed */
  25799. distance: number;
  25800. /** Defines the mesh to use to render this level */
  25801. mesh: Nullable<Mesh>;
  25802. /**
  25803. * Creates a new LOD level
  25804. * @param distance defines the distance where this level should star being displayed
  25805. * @param mesh defines the mesh to use to render this level
  25806. */
  25807. constructor(
  25808. /** Defines the distance where this level should start being displayed */
  25809. distance: number,
  25810. /** Defines the mesh to use to render this level */
  25811. mesh: Nullable<Mesh>);
  25812. }
  25813. }
  25814. declare module BABYLON {
  25815. /**
  25816. * Mesh representing the gorund
  25817. */
  25818. export class GroundMesh extends Mesh {
  25819. /** If octree should be generated */
  25820. generateOctree: boolean;
  25821. private _heightQuads;
  25822. /** @hidden */
  25823. _subdivisionsX: number;
  25824. /** @hidden */
  25825. _subdivisionsY: number;
  25826. /** @hidden */
  25827. _width: number;
  25828. /** @hidden */
  25829. _height: number;
  25830. /** @hidden */
  25831. _minX: number;
  25832. /** @hidden */
  25833. _maxX: number;
  25834. /** @hidden */
  25835. _minZ: number;
  25836. /** @hidden */
  25837. _maxZ: number;
  25838. constructor(name: string, scene: Scene);
  25839. /**
  25840. * "GroundMesh"
  25841. * @returns "GroundMesh"
  25842. */
  25843. getClassName(): string;
  25844. /**
  25845. * The minimum of x and y subdivisions
  25846. */
  25847. get subdivisions(): number;
  25848. /**
  25849. * X subdivisions
  25850. */
  25851. get subdivisionsX(): number;
  25852. /**
  25853. * Y subdivisions
  25854. */
  25855. get subdivisionsY(): number;
  25856. /**
  25857. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25858. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25859. * @param chunksCount the number of subdivisions for x and y
  25860. * @param octreeBlocksSize (Default: 32)
  25861. */
  25862. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25863. /**
  25864. * Returns a height (y) value in the Worl system :
  25865. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25866. * @param x x coordinate
  25867. * @param z z coordinate
  25868. * @returns the ground y position if (x, z) are outside the ground surface.
  25869. */
  25870. getHeightAtCoordinates(x: number, z: number): number;
  25871. /**
  25872. * Returns a normalized vector (Vector3) orthogonal to the ground
  25873. * at the ground coordinates (x, z) expressed in the World system.
  25874. * @param x x coordinate
  25875. * @param z z coordinate
  25876. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25877. */
  25878. getNormalAtCoordinates(x: number, z: number): Vector3;
  25879. /**
  25880. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25881. * at the ground coordinates (x, z) expressed in the World system.
  25882. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25883. * @param x x coordinate
  25884. * @param z z coordinate
  25885. * @param ref vector to store the result
  25886. * @returns the GroundMesh.
  25887. */
  25888. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25889. /**
  25890. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25891. * if the ground has been updated.
  25892. * This can be used in the render loop.
  25893. * @returns the GroundMesh.
  25894. */
  25895. updateCoordinateHeights(): GroundMesh;
  25896. private _getFacetAt;
  25897. private _initHeightQuads;
  25898. private _computeHeightQuads;
  25899. /**
  25900. * Serializes this ground mesh
  25901. * @param serializationObject object to write serialization to
  25902. */
  25903. serialize(serializationObject: any): void;
  25904. /**
  25905. * Parses a serialized ground mesh
  25906. * @param parsedMesh the serialized mesh
  25907. * @param scene the scene to create the ground mesh in
  25908. * @returns the created ground mesh
  25909. */
  25910. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25911. }
  25912. }
  25913. declare module BABYLON {
  25914. /**
  25915. * Interface for Physics-Joint data
  25916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25917. */
  25918. export interface PhysicsJointData {
  25919. /**
  25920. * The main pivot of the joint
  25921. */
  25922. mainPivot?: Vector3;
  25923. /**
  25924. * The connected pivot of the joint
  25925. */
  25926. connectedPivot?: Vector3;
  25927. /**
  25928. * The main axis of the joint
  25929. */
  25930. mainAxis?: Vector3;
  25931. /**
  25932. * The connected axis of the joint
  25933. */
  25934. connectedAxis?: Vector3;
  25935. /**
  25936. * The collision of the joint
  25937. */
  25938. collision?: boolean;
  25939. /**
  25940. * Native Oimo/Cannon/Energy data
  25941. */
  25942. nativeParams?: any;
  25943. }
  25944. /**
  25945. * This is a holder class for the physics joint created by the physics plugin
  25946. * It holds a set of functions to control the underlying joint
  25947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25948. */
  25949. export class PhysicsJoint {
  25950. /**
  25951. * The type of the physics joint
  25952. */
  25953. type: number;
  25954. /**
  25955. * The data for the physics joint
  25956. */
  25957. jointData: PhysicsJointData;
  25958. private _physicsJoint;
  25959. protected _physicsPlugin: IPhysicsEnginePlugin;
  25960. /**
  25961. * Initializes the physics joint
  25962. * @param type The type of the physics joint
  25963. * @param jointData The data for the physics joint
  25964. */
  25965. constructor(
  25966. /**
  25967. * The type of the physics joint
  25968. */
  25969. type: number,
  25970. /**
  25971. * The data for the physics joint
  25972. */
  25973. jointData: PhysicsJointData);
  25974. /**
  25975. * Gets the physics joint
  25976. */
  25977. get physicsJoint(): any;
  25978. /**
  25979. * Sets the physics joint
  25980. */
  25981. set physicsJoint(newJoint: any);
  25982. /**
  25983. * Sets the physics plugin
  25984. */
  25985. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  25986. /**
  25987. * Execute a function that is physics-plugin specific.
  25988. * @param {Function} func the function that will be executed.
  25989. * It accepts two parameters: the physics world and the physics joint
  25990. */
  25991. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  25992. /**
  25993. * Distance-Joint type
  25994. */
  25995. static DistanceJoint: number;
  25996. /**
  25997. * Hinge-Joint type
  25998. */
  25999. static HingeJoint: number;
  26000. /**
  26001. * Ball-and-Socket joint type
  26002. */
  26003. static BallAndSocketJoint: number;
  26004. /**
  26005. * Wheel-Joint type
  26006. */
  26007. static WheelJoint: number;
  26008. /**
  26009. * Slider-Joint type
  26010. */
  26011. static SliderJoint: number;
  26012. /**
  26013. * Prismatic-Joint type
  26014. */
  26015. static PrismaticJoint: number;
  26016. /**
  26017. * Universal-Joint type
  26018. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26019. */
  26020. static UniversalJoint: number;
  26021. /**
  26022. * Hinge-Joint 2 type
  26023. */
  26024. static Hinge2Joint: number;
  26025. /**
  26026. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26027. */
  26028. static PointToPointJoint: number;
  26029. /**
  26030. * Spring-Joint type
  26031. */
  26032. static SpringJoint: number;
  26033. /**
  26034. * Lock-Joint type
  26035. */
  26036. static LockJoint: number;
  26037. }
  26038. /**
  26039. * A class representing a physics distance joint
  26040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26041. */
  26042. export class DistanceJoint extends PhysicsJoint {
  26043. /**
  26044. *
  26045. * @param jointData The data for the Distance-Joint
  26046. */
  26047. constructor(jointData: DistanceJointData);
  26048. /**
  26049. * Update the predefined distance.
  26050. * @param maxDistance The maximum preferred distance
  26051. * @param minDistance The minimum preferred distance
  26052. */
  26053. updateDistance(maxDistance: number, minDistance?: number): void;
  26054. }
  26055. /**
  26056. * Represents a Motor-Enabled Joint
  26057. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26058. */
  26059. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26060. /**
  26061. * Initializes the Motor-Enabled Joint
  26062. * @param type The type of the joint
  26063. * @param jointData The physica joint data for the joint
  26064. */
  26065. constructor(type: number, jointData: PhysicsJointData);
  26066. /**
  26067. * Set the motor values.
  26068. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26069. * @param force the force to apply
  26070. * @param maxForce max force for this motor.
  26071. */
  26072. setMotor(force?: number, maxForce?: number): void;
  26073. /**
  26074. * Set the motor's limits.
  26075. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26076. * @param upperLimit The upper limit of the motor
  26077. * @param lowerLimit The lower limit of the motor
  26078. */
  26079. setLimit(upperLimit: number, lowerLimit?: number): void;
  26080. }
  26081. /**
  26082. * This class represents a single physics Hinge-Joint
  26083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26084. */
  26085. export class HingeJoint extends MotorEnabledJoint {
  26086. /**
  26087. * Initializes the Hinge-Joint
  26088. * @param jointData The joint data for the Hinge-Joint
  26089. */
  26090. constructor(jointData: PhysicsJointData);
  26091. /**
  26092. * Set the motor values.
  26093. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26094. * @param {number} force the force to apply
  26095. * @param {number} maxForce max force for this motor.
  26096. */
  26097. setMotor(force?: number, maxForce?: number): void;
  26098. /**
  26099. * Set the motor's limits.
  26100. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26101. * @param upperLimit The upper limit of the motor
  26102. * @param lowerLimit The lower limit of the motor
  26103. */
  26104. setLimit(upperLimit: number, lowerLimit?: number): void;
  26105. }
  26106. /**
  26107. * This class represents a dual hinge physics joint (same as wheel joint)
  26108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26109. */
  26110. export class Hinge2Joint extends MotorEnabledJoint {
  26111. /**
  26112. * Initializes the Hinge2-Joint
  26113. * @param jointData The joint data for the Hinge2-Joint
  26114. */
  26115. constructor(jointData: PhysicsJointData);
  26116. /**
  26117. * Set the motor values.
  26118. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26119. * @param {number} targetSpeed the speed the motor is to reach
  26120. * @param {number} maxForce max force for this motor.
  26121. * @param {motorIndex} the motor's index, 0 or 1.
  26122. */
  26123. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26124. /**
  26125. * Set the motor limits.
  26126. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26127. * @param {number} upperLimit the upper limit
  26128. * @param {number} lowerLimit lower limit
  26129. * @param {motorIndex} the motor's index, 0 or 1.
  26130. */
  26131. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26132. }
  26133. /**
  26134. * Interface for a motor enabled joint
  26135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26136. */
  26137. export interface IMotorEnabledJoint {
  26138. /**
  26139. * Physics joint
  26140. */
  26141. physicsJoint: any;
  26142. /**
  26143. * Sets the motor of the motor-enabled joint
  26144. * @param force The force of the motor
  26145. * @param maxForce The maximum force of the motor
  26146. * @param motorIndex The index of the motor
  26147. */
  26148. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26149. /**
  26150. * Sets the limit of the motor
  26151. * @param upperLimit The upper limit of the motor
  26152. * @param lowerLimit The lower limit of the motor
  26153. * @param motorIndex The index of the motor
  26154. */
  26155. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26156. }
  26157. /**
  26158. * Joint data for a Distance-Joint
  26159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26160. */
  26161. export interface DistanceJointData extends PhysicsJointData {
  26162. /**
  26163. * Max distance the 2 joint objects can be apart
  26164. */
  26165. maxDistance: number;
  26166. }
  26167. /**
  26168. * Joint data from a spring joint
  26169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26170. */
  26171. export interface SpringJointData extends PhysicsJointData {
  26172. /**
  26173. * Length of the spring
  26174. */
  26175. length: number;
  26176. /**
  26177. * Stiffness of the spring
  26178. */
  26179. stiffness: number;
  26180. /**
  26181. * Damping of the spring
  26182. */
  26183. damping: number;
  26184. /** this callback will be called when applying the force to the impostors. */
  26185. forceApplicationCallback: () => void;
  26186. }
  26187. }
  26188. declare module BABYLON {
  26189. /**
  26190. * Holds the data for the raycast result
  26191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26192. */
  26193. export class PhysicsRaycastResult {
  26194. private _hasHit;
  26195. private _hitDistance;
  26196. private _hitNormalWorld;
  26197. private _hitPointWorld;
  26198. private _rayFromWorld;
  26199. private _rayToWorld;
  26200. /**
  26201. * Gets if there was a hit
  26202. */
  26203. get hasHit(): boolean;
  26204. /**
  26205. * Gets the distance from the hit
  26206. */
  26207. get hitDistance(): number;
  26208. /**
  26209. * Gets the hit normal/direction in the world
  26210. */
  26211. get hitNormalWorld(): Vector3;
  26212. /**
  26213. * Gets the hit point in the world
  26214. */
  26215. get hitPointWorld(): Vector3;
  26216. /**
  26217. * Gets the ray "start point" of the ray in the world
  26218. */
  26219. get rayFromWorld(): Vector3;
  26220. /**
  26221. * Gets the ray "end point" of the ray in the world
  26222. */
  26223. get rayToWorld(): Vector3;
  26224. /**
  26225. * Sets the hit data (normal & point in world space)
  26226. * @param hitNormalWorld defines the normal in world space
  26227. * @param hitPointWorld defines the point in world space
  26228. */
  26229. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26230. /**
  26231. * Sets the distance from the start point to the hit point
  26232. * @param distance
  26233. */
  26234. setHitDistance(distance: number): void;
  26235. /**
  26236. * Calculates the distance manually
  26237. */
  26238. calculateHitDistance(): void;
  26239. /**
  26240. * Resets all the values to default
  26241. * @param from The from point on world space
  26242. * @param to The to point on world space
  26243. */
  26244. reset(from?: Vector3, to?: Vector3): void;
  26245. }
  26246. /**
  26247. * Interface for the size containing width and height
  26248. */
  26249. interface IXYZ {
  26250. /**
  26251. * X
  26252. */
  26253. x: number;
  26254. /**
  26255. * Y
  26256. */
  26257. y: number;
  26258. /**
  26259. * Z
  26260. */
  26261. z: number;
  26262. }
  26263. }
  26264. declare module BABYLON {
  26265. /**
  26266. * Interface used to describe a physics joint
  26267. */
  26268. export interface PhysicsImpostorJoint {
  26269. /** Defines the main impostor to which the joint is linked */
  26270. mainImpostor: PhysicsImpostor;
  26271. /** Defines the impostor that is connected to the main impostor using this joint */
  26272. connectedImpostor: PhysicsImpostor;
  26273. /** Defines the joint itself */
  26274. joint: PhysicsJoint;
  26275. }
  26276. /** @hidden */
  26277. export interface IPhysicsEnginePlugin {
  26278. world: any;
  26279. name: string;
  26280. setGravity(gravity: Vector3): void;
  26281. setTimeStep(timeStep: number): void;
  26282. getTimeStep(): number;
  26283. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26284. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26285. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26286. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26287. removePhysicsBody(impostor: PhysicsImpostor): void;
  26288. generateJoint(joint: PhysicsImpostorJoint): void;
  26289. removeJoint(joint: PhysicsImpostorJoint): void;
  26290. isSupported(): boolean;
  26291. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26292. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26293. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26294. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26295. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26296. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26297. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26298. getBodyMass(impostor: PhysicsImpostor): number;
  26299. getBodyFriction(impostor: PhysicsImpostor): number;
  26300. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26301. getBodyRestitution(impostor: PhysicsImpostor): number;
  26302. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26303. getBodyPressure?(impostor: PhysicsImpostor): number;
  26304. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26305. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26306. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26307. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26308. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26309. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26310. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26311. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26312. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26313. sleepBody(impostor: PhysicsImpostor): void;
  26314. wakeUpBody(impostor: PhysicsImpostor): void;
  26315. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26316. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26317. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26318. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26319. getRadius(impostor: PhysicsImpostor): number;
  26320. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26321. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26322. dispose(): void;
  26323. }
  26324. /**
  26325. * Interface used to define a physics engine
  26326. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26327. */
  26328. export interface IPhysicsEngine {
  26329. /**
  26330. * Gets the gravity vector used by the simulation
  26331. */
  26332. gravity: Vector3;
  26333. /**
  26334. * Sets the gravity vector used by the simulation
  26335. * @param gravity defines the gravity vector to use
  26336. */
  26337. setGravity(gravity: Vector3): void;
  26338. /**
  26339. * Set the time step of the physics engine.
  26340. * Default is 1/60.
  26341. * To slow it down, enter 1/600 for example.
  26342. * To speed it up, 1/30
  26343. * @param newTimeStep the new timestep to apply to this world.
  26344. */
  26345. setTimeStep(newTimeStep: number): void;
  26346. /**
  26347. * Get the time step of the physics engine.
  26348. * @returns the current time step
  26349. */
  26350. getTimeStep(): number;
  26351. /**
  26352. * Set the sub time step of the physics engine.
  26353. * Default is 0 meaning there is no sub steps
  26354. * To increase physics resolution precision, set a small value (like 1 ms)
  26355. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26356. */
  26357. setSubTimeStep(subTimeStep: number): void;
  26358. /**
  26359. * Get the sub time step of the physics engine.
  26360. * @returns the current sub time step
  26361. */
  26362. getSubTimeStep(): number;
  26363. /**
  26364. * Release all resources
  26365. */
  26366. dispose(): void;
  26367. /**
  26368. * Gets the name of the current physics plugin
  26369. * @returns the name of the plugin
  26370. */
  26371. getPhysicsPluginName(): string;
  26372. /**
  26373. * Adding a new impostor for the impostor tracking.
  26374. * This will be done by the impostor itself.
  26375. * @param impostor the impostor to add
  26376. */
  26377. addImpostor(impostor: PhysicsImpostor): void;
  26378. /**
  26379. * Remove an impostor from the engine.
  26380. * This impostor and its mesh will not longer be updated by the physics engine.
  26381. * @param impostor the impostor to remove
  26382. */
  26383. removeImpostor(impostor: PhysicsImpostor): void;
  26384. /**
  26385. * Add a joint to the physics engine
  26386. * @param mainImpostor defines the main impostor to which the joint is added.
  26387. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26388. * @param joint defines the joint that will connect both impostors.
  26389. */
  26390. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26391. /**
  26392. * Removes a joint from the simulation
  26393. * @param mainImpostor defines the impostor used with the joint
  26394. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26395. * @param joint defines the joint to remove
  26396. */
  26397. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26398. /**
  26399. * Gets the current plugin used to run the simulation
  26400. * @returns current plugin
  26401. */
  26402. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26403. /**
  26404. * Gets the list of physic impostors
  26405. * @returns an array of PhysicsImpostor
  26406. */
  26407. getImpostors(): Array<PhysicsImpostor>;
  26408. /**
  26409. * Gets the impostor for a physics enabled object
  26410. * @param object defines the object impersonated by the impostor
  26411. * @returns the PhysicsImpostor or null if not found
  26412. */
  26413. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26414. /**
  26415. * Gets the impostor for a physics body object
  26416. * @param body defines physics body used by the impostor
  26417. * @returns the PhysicsImpostor or null if not found
  26418. */
  26419. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26420. /**
  26421. * Does a raycast in the physics world
  26422. * @param from when should the ray start?
  26423. * @param to when should the ray end?
  26424. * @returns PhysicsRaycastResult
  26425. */
  26426. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26427. /**
  26428. * Called by the scene. No need to call it.
  26429. * @param delta defines the timespam between frames
  26430. */
  26431. _step(delta: number): void;
  26432. }
  26433. }
  26434. declare module BABYLON {
  26435. /**
  26436. * The interface for the physics imposter parameters
  26437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26438. */
  26439. export interface PhysicsImpostorParameters {
  26440. /**
  26441. * The mass of the physics imposter
  26442. */
  26443. mass: number;
  26444. /**
  26445. * The friction of the physics imposter
  26446. */
  26447. friction?: number;
  26448. /**
  26449. * The coefficient of restitution of the physics imposter
  26450. */
  26451. restitution?: number;
  26452. /**
  26453. * The native options of the physics imposter
  26454. */
  26455. nativeOptions?: any;
  26456. /**
  26457. * Specifies if the parent should be ignored
  26458. */
  26459. ignoreParent?: boolean;
  26460. /**
  26461. * Specifies if bi-directional transformations should be disabled
  26462. */
  26463. disableBidirectionalTransformation?: boolean;
  26464. /**
  26465. * The pressure inside the physics imposter, soft object only
  26466. */
  26467. pressure?: number;
  26468. /**
  26469. * The stiffness the physics imposter, soft object only
  26470. */
  26471. stiffness?: number;
  26472. /**
  26473. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26474. */
  26475. velocityIterations?: number;
  26476. /**
  26477. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26478. */
  26479. positionIterations?: number;
  26480. /**
  26481. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26482. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26483. * Add to fix multiple points
  26484. */
  26485. fixedPoints?: number;
  26486. /**
  26487. * The collision margin around a soft object
  26488. */
  26489. margin?: number;
  26490. /**
  26491. * The collision margin around a soft object
  26492. */
  26493. damping?: number;
  26494. /**
  26495. * The path for a rope based on an extrusion
  26496. */
  26497. path?: any;
  26498. /**
  26499. * The shape of an extrusion used for a rope based on an extrusion
  26500. */
  26501. shape?: any;
  26502. }
  26503. /**
  26504. * Interface for a physics-enabled object
  26505. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26506. */
  26507. export interface IPhysicsEnabledObject {
  26508. /**
  26509. * The position of the physics-enabled object
  26510. */
  26511. position: Vector3;
  26512. /**
  26513. * The rotation of the physics-enabled object
  26514. */
  26515. rotationQuaternion: Nullable<Quaternion>;
  26516. /**
  26517. * The scale of the physics-enabled object
  26518. */
  26519. scaling: Vector3;
  26520. /**
  26521. * The rotation of the physics-enabled object
  26522. */
  26523. rotation?: Vector3;
  26524. /**
  26525. * The parent of the physics-enabled object
  26526. */
  26527. parent?: any;
  26528. /**
  26529. * The bounding info of the physics-enabled object
  26530. * @returns The bounding info of the physics-enabled object
  26531. */
  26532. getBoundingInfo(): BoundingInfo;
  26533. /**
  26534. * Computes the world matrix
  26535. * @param force Specifies if the world matrix should be computed by force
  26536. * @returns A world matrix
  26537. */
  26538. computeWorldMatrix(force: boolean): Matrix;
  26539. /**
  26540. * Gets the world matrix
  26541. * @returns A world matrix
  26542. */
  26543. getWorldMatrix?(): Matrix;
  26544. /**
  26545. * Gets the child meshes
  26546. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26547. * @returns An array of abstract meshes
  26548. */
  26549. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26550. /**
  26551. * Gets the vertex data
  26552. * @param kind The type of vertex data
  26553. * @returns A nullable array of numbers, or a float32 array
  26554. */
  26555. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26556. /**
  26557. * Gets the indices from the mesh
  26558. * @returns A nullable array of index arrays
  26559. */
  26560. getIndices?(): Nullable<IndicesArray>;
  26561. /**
  26562. * Gets the scene from the mesh
  26563. * @returns the indices array or null
  26564. */
  26565. getScene?(): Scene;
  26566. /**
  26567. * Gets the absolute position from the mesh
  26568. * @returns the absolute position
  26569. */
  26570. getAbsolutePosition(): Vector3;
  26571. /**
  26572. * Gets the absolute pivot point from the mesh
  26573. * @returns the absolute pivot point
  26574. */
  26575. getAbsolutePivotPoint(): Vector3;
  26576. /**
  26577. * Rotates the mesh
  26578. * @param axis The axis of rotation
  26579. * @param amount The amount of rotation
  26580. * @param space The space of the rotation
  26581. * @returns The rotation transform node
  26582. */
  26583. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26584. /**
  26585. * Translates the mesh
  26586. * @param axis The axis of translation
  26587. * @param distance The distance of translation
  26588. * @param space The space of the translation
  26589. * @returns The transform node
  26590. */
  26591. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26592. /**
  26593. * Sets the absolute position of the mesh
  26594. * @param absolutePosition The absolute position of the mesh
  26595. * @returns The transform node
  26596. */
  26597. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26598. /**
  26599. * Gets the class name of the mesh
  26600. * @returns The class name
  26601. */
  26602. getClassName(): string;
  26603. }
  26604. /**
  26605. * Represents a physics imposter
  26606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26607. */
  26608. export class PhysicsImpostor {
  26609. /**
  26610. * The physics-enabled object used as the physics imposter
  26611. */
  26612. object: IPhysicsEnabledObject;
  26613. /**
  26614. * The type of the physics imposter
  26615. */
  26616. type: number;
  26617. private _options;
  26618. private _scene?;
  26619. /**
  26620. * The default object size of the imposter
  26621. */
  26622. static DEFAULT_OBJECT_SIZE: Vector3;
  26623. /**
  26624. * The identity quaternion of the imposter
  26625. */
  26626. static IDENTITY_QUATERNION: Quaternion;
  26627. /** @hidden */
  26628. _pluginData: any;
  26629. private _physicsEngine;
  26630. private _physicsBody;
  26631. private _bodyUpdateRequired;
  26632. private _onBeforePhysicsStepCallbacks;
  26633. private _onAfterPhysicsStepCallbacks;
  26634. /** @hidden */
  26635. _onPhysicsCollideCallbacks: Array<{
  26636. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26637. otherImpostors: Array<PhysicsImpostor>;
  26638. }>;
  26639. private _deltaPosition;
  26640. private _deltaRotation;
  26641. private _deltaRotationConjugated;
  26642. /** @hidden */
  26643. _isFromLine: boolean;
  26644. private _parent;
  26645. private _isDisposed;
  26646. private static _tmpVecs;
  26647. private static _tmpQuat;
  26648. /**
  26649. * Specifies if the physics imposter is disposed
  26650. */
  26651. get isDisposed(): boolean;
  26652. /**
  26653. * Gets the mass of the physics imposter
  26654. */
  26655. get mass(): number;
  26656. set mass(value: number);
  26657. /**
  26658. * Gets the coefficient of friction
  26659. */
  26660. get friction(): number;
  26661. /**
  26662. * Sets the coefficient of friction
  26663. */
  26664. set friction(value: number);
  26665. /**
  26666. * Gets the coefficient of restitution
  26667. */
  26668. get restitution(): number;
  26669. /**
  26670. * Sets the coefficient of restitution
  26671. */
  26672. set restitution(value: number);
  26673. /**
  26674. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26675. */
  26676. get pressure(): number;
  26677. /**
  26678. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26679. */
  26680. set pressure(value: number);
  26681. /**
  26682. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26683. */
  26684. get stiffness(): number;
  26685. /**
  26686. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26687. */
  26688. set stiffness(value: number);
  26689. /**
  26690. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26691. */
  26692. get velocityIterations(): number;
  26693. /**
  26694. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26695. */
  26696. set velocityIterations(value: number);
  26697. /**
  26698. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26699. */
  26700. get positionIterations(): number;
  26701. /**
  26702. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26703. */
  26704. set positionIterations(value: number);
  26705. /**
  26706. * The unique id of the physics imposter
  26707. * set by the physics engine when adding this impostor to the array
  26708. */
  26709. uniqueId: number;
  26710. /**
  26711. * @hidden
  26712. */
  26713. soft: boolean;
  26714. /**
  26715. * @hidden
  26716. */
  26717. segments: number;
  26718. private _joints;
  26719. /**
  26720. * Initializes the physics imposter
  26721. * @param object The physics-enabled object used as the physics imposter
  26722. * @param type The type of the physics imposter
  26723. * @param _options The options for the physics imposter
  26724. * @param _scene The Babylon scene
  26725. */
  26726. constructor(
  26727. /**
  26728. * The physics-enabled object used as the physics imposter
  26729. */
  26730. object: IPhysicsEnabledObject,
  26731. /**
  26732. * The type of the physics imposter
  26733. */
  26734. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26735. /**
  26736. * This function will completly initialize this impostor.
  26737. * It will create a new body - but only if this mesh has no parent.
  26738. * If it has, this impostor will not be used other than to define the impostor
  26739. * of the child mesh.
  26740. * @hidden
  26741. */
  26742. _init(): void;
  26743. private _getPhysicsParent;
  26744. /**
  26745. * Should a new body be generated.
  26746. * @returns boolean specifying if body initialization is required
  26747. */
  26748. isBodyInitRequired(): boolean;
  26749. /**
  26750. * Sets the updated scaling
  26751. * @param updated Specifies if the scaling is updated
  26752. */
  26753. setScalingUpdated(): void;
  26754. /**
  26755. * Force a regeneration of this or the parent's impostor's body.
  26756. * Use under cautious - This will remove all joints already implemented.
  26757. */
  26758. forceUpdate(): void;
  26759. /**
  26760. * Gets the body that holds this impostor. Either its own, or its parent.
  26761. */
  26762. get physicsBody(): any;
  26763. /**
  26764. * Get the parent of the physics imposter
  26765. * @returns Physics imposter or null
  26766. */
  26767. get parent(): Nullable<PhysicsImpostor>;
  26768. /**
  26769. * Sets the parent of the physics imposter
  26770. */
  26771. set parent(value: Nullable<PhysicsImpostor>);
  26772. /**
  26773. * Set the physics body. Used mainly by the physics engine/plugin
  26774. */
  26775. set physicsBody(physicsBody: any);
  26776. /**
  26777. * Resets the update flags
  26778. */
  26779. resetUpdateFlags(): void;
  26780. /**
  26781. * Gets the object extend size
  26782. * @returns the object extend size
  26783. */
  26784. getObjectExtendSize(): Vector3;
  26785. /**
  26786. * Gets the object center
  26787. * @returns The object center
  26788. */
  26789. getObjectCenter(): Vector3;
  26790. /**
  26791. * Get a specific parameter from the options parameters
  26792. * @param paramName The object parameter name
  26793. * @returns The object parameter
  26794. */
  26795. getParam(paramName: string): any;
  26796. /**
  26797. * Sets a specific parameter in the options given to the physics plugin
  26798. * @param paramName The parameter name
  26799. * @param value The value of the parameter
  26800. */
  26801. setParam(paramName: string, value: number): void;
  26802. /**
  26803. * Specifically change the body's mass option. Won't recreate the physics body object
  26804. * @param mass The mass of the physics imposter
  26805. */
  26806. setMass(mass: number): void;
  26807. /**
  26808. * Gets the linear velocity
  26809. * @returns linear velocity or null
  26810. */
  26811. getLinearVelocity(): Nullable<Vector3>;
  26812. /**
  26813. * Sets the linear velocity
  26814. * @param velocity linear velocity or null
  26815. */
  26816. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26817. /**
  26818. * Gets the angular velocity
  26819. * @returns angular velocity or null
  26820. */
  26821. getAngularVelocity(): Nullable<Vector3>;
  26822. /**
  26823. * Sets the angular velocity
  26824. * @param velocity The velocity or null
  26825. */
  26826. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26827. /**
  26828. * Execute a function with the physics plugin native code
  26829. * Provide a function the will have two variables - the world object and the physics body object
  26830. * @param func The function to execute with the physics plugin native code
  26831. */
  26832. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26833. /**
  26834. * Register a function that will be executed before the physics world is stepping forward
  26835. * @param func The function to execute before the physics world is stepped forward
  26836. */
  26837. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26838. /**
  26839. * Unregister a function that will be executed before the physics world is stepping forward
  26840. * @param func The function to execute before the physics world is stepped forward
  26841. */
  26842. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26843. /**
  26844. * Register a function that will be executed after the physics step
  26845. * @param func The function to execute after physics step
  26846. */
  26847. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26848. /**
  26849. * Unregisters a function that will be executed after the physics step
  26850. * @param func The function to execute after physics step
  26851. */
  26852. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26853. /**
  26854. * register a function that will be executed when this impostor collides against a different body
  26855. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26856. * @param func Callback that is executed on collision
  26857. */
  26858. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26859. /**
  26860. * Unregisters the physics imposter on contact
  26861. * @param collideAgainst The physics object to collide against
  26862. * @param func Callback to execute on collision
  26863. */
  26864. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26865. private _tmpQuat;
  26866. private _tmpQuat2;
  26867. /**
  26868. * Get the parent rotation
  26869. * @returns The parent rotation
  26870. */
  26871. getParentsRotation(): Quaternion;
  26872. /**
  26873. * this function is executed by the physics engine.
  26874. */
  26875. beforeStep: () => void;
  26876. /**
  26877. * this function is executed by the physics engine
  26878. */
  26879. afterStep: () => void;
  26880. /**
  26881. * Legacy collision detection event support
  26882. */
  26883. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26884. /**
  26885. * event and body object due to cannon's event-based architecture.
  26886. */
  26887. onCollide: (e: {
  26888. body: any;
  26889. }) => void;
  26890. /**
  26891. * Apply a force
  26892. * @param force The force to apply
  26893. * @param contactPoint The contact point for the force
  26894. * @returns The physics imposter
  26895. */
  26896. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26897. /**
  26898. * Apply an impulse
  26899. * @param force The impulse force
  26900. * @param contactPoint The contact point for the impulse force
  26901. * @returns The physics imposter
  26902. */
  26903. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26904. /**
  26905. * A help function to create a joint
  26906. * @param otherImpostor A physics imposter used to create a joint
  26907. * @param jointType The type of joint
  26908. * @param jointData The data for the joint
  26909. * @returns The physics imposter
  26910. */
  26911. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26912. /**
  26913. * Add a joint to this impostor with a different impostor
  26914. * @param otherImpostor A physics imposter used to add a joint
  26915. * @param joint The joint to add
  26916. * @returns The physics imposter
  26917. */
  26918. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26919. /**
  26920. * Add an anchor to a cloth impostor
  26921. * @param otherImpostor rigid impostor to anchor to
  26922. * @param width ratio across width from 0 to 1
  26923. * @param height ratio up height from 0 to 1
  26924. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  26925. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  26926. * @returns impostor the soft imposter
  26927. */
  26928. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  26929. /**
  26930. * Add a hook to a rope impostor
  26931. * @param otherImpostor rigid impostor to anchor to
  26932. * @param length ratio across rope from 0 to 1
  26933. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  26934. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  26935. * @returns impostor the rope imposter
  26936. */
  26937. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  26938. /**
  26939. * Will keep this body still, in a sleep mode.
  26940. * @returns the physics imposter
  26941. */
  26942. sleep(): PhysicsImpostor;
  26943. /**
  26944. * Wake the body up.
  26945. * @returns The physics imposter
  26946. */
  26947. wakeUp(): PhysicsImpostor;
  26948. /**
  26949. * Clones the physics imposter
  26950. * @param newObject The physics imposter clones to this physics-enabled object
  26951. * @returns A nullable physics imposter
  26952. */
  26953. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26954. /**
  26955. * Disposes the physics imposter
  26956. */
  26957. dispose(): void;
  26958. /**
  26959. * Sets the delta position
  26960. * @param position The delta position amount
  26961. */
  26962. setDeltaPosition(position: Vector3): void;
  26963. /**
  26964. * Sets the delta rotation
  26965. * @param rotation The delta rotation amount
  26966. */
  26967. setDeltaRotation(rotation: Quaternion): void;
  26968. /**
  26969. * Gets the box size of the physics imposter and stores the result in the input parameter
  26970. * @param result Stores the box size
  26971. * @returns The physics imposter
  26972. */
  26973. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  26974. /**
  26975. * Gets the radius of the physics imposter
  26976. * @returns Radius of the physics imposter
  26977. */
  26978. getRadius(): number;
  26979. /**
  26980. * Sync a bone with this impostor
  26981. * @param bone The bone to sync to the impostor.
  26982. * @param boneMesh The mesh that the bone is influencing.
  26983. * @param jointPivot The pivot of the joint / bone in local space.
  26984. * @param distToJoint Optional distance from the impostor to the joint.
  26985. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  26986. */
  26987. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  26988. /**
  26989. * Sync impostor to a bone
  26990. * @param bone The bone that the impostor will be synced to.
  26991. * @param boneMesh The mesh that the bone is influencing.
  26992. * @param jointPivot The pivot of the joint / bone in local space.
  26993. * @param distToJoint Optional distance from the impostor to the joint.
  26994. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  26995. * @param boneAxis Optional vector3 axis the bone is aligned with
  26996. */
  26997. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  26998. /**
  26999. * No-Imposter type
  27000. */
  27001. static NoImpostor: number;
  27002. /**
  27003. * Sphere-Imposter type
  27004. */
  27005. static SphereImpostor: number;
  27006. /**
  27007. * Box-Imposter type
  27008. */
  27009. static BoxImpostor: number;
  27010. /**
  27011. * Plane-Imposter type
  27012. */
  27013. static PlaneImpostor: number;
  27014. /**
  27015. * Mesh-imposter type
  27016. */
  27017. static MeshImpostor: number;
  27018. /**
  27019. * Capsule-Impostor type (Ammo.js plugin only)
  27020. */
  27021. static CapsuleImpostor: number;
  27022. /**
  27023. * Cylinder-Imposter type
  27024. */
  27025. static CylinderImpostor: number;
  27026. /**
  27027. * Particle-Imposter type
  27028. */
  27029. static ParticleImpostor: number;
  27030. /**
  27031. * Heightmap-Imposter type
  27032. */
  27033. static HeightmapImpostor: number;
  27034. /**
  27035. * ConvexHull-Impostor type (Ammo.js plugin only)
  27036. */
  27037. static ConvexHullImpostor: number;
  27038. /**
  27039. * Custom-Imposter type (Ammo.js plugin only)
  27040. */
  27041. static CustomImpostor: number;
  27042. /**
  27043. * Rope-Imposter type
  27044. */
  27045. static RopeImpostor: number;
  27046. /**
  27047. * Cloth-Imposter type
  27048. */
  27049. static ClothImpostor: number;
  27050. /**
  27051. * Softbody-Imposter type
  27052. */
  27053. static SoftbodyImpostor: number;
  27054. }
  27055. }
  27056. declare module BABYLON {
  27057. /**
  27058. * @hidden
  27059. **/
  27060. export class _CreationDataStorage {
  27061. closePath?: boolean;
  27062. closeArray?: boolean;
  27063. idx: number[];
  27064. dashSize: number;
  27065. gapSize: number;
  27066. path3D: Path3D;
  27067. pathArray: Vector3[][];
  27068. arc: number;
  27069. radius: number;
  27070. cap: number;
  27071. tessellation: number;
  27072. }
  27073. /**
  27074. * @hidden
  27075. **/
  27076. class _InstanceDataStorage {
  27077. visibleInstances: any;
  27078. batchCache: _InstancesBatch;
  27079. instancesBufferSize: number;
  27080. instancesBuffer: Nullable<Buffer>;
  27081. instancesData: Float32Array;
  27082. overridenInstanceCount: number;
  27083. isFrozen: boolean;
  27084. previousBatch: Nullable<_InstancesBatch>;
  27085. hardwareInstancedRendering: boolean;
  27086. sideOrientation: number;
  27087. manualUpdate: boolean;
  27088. }
  27089. /**
  27090. * @hidden
  27091. **/
  27092. export class _InstancesBatch {
  27093. mustReturn: boolean;
  27094. visibleInstances: Nullable<InstancedMesh[]>[];
  27095. renderSelf: boolean[];
  27096. hardwareInstancedRendering: boolean[];
  27097. }
  27098. /**
  27099. * Class used to represent renderable models
  27100. */
  27101. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27102. /**
  27103. * Mesh side orientation : usually the external or front surface
  27104. */
  27105. static readonly FRONTSIDE: number;
  27106. /**
  27107. * Mesh side orientation : usually the internal or back surface
  27108. */
  27109. static readonly BACKSIDE: number;
  27110. /**
  27111. * Mesh side orientation : both internal and external or front and back surfaces
  27112. */
  27113. static readonly DOUBLESIDE: number;
  27114. /**
  27115. * Mesh side orientation : by default, `FRONTSIDE`
  27116. */
  27117. static readonly DEFAULTSIDE: number;
  27118. /**
  27119. * Mesh cap setting : no cap
  27120. */
  27121. static readonly NO_CAP: number;
  27122. /**
  27123. * Mesh cap setting : one cap at the beginning of the mesh
  27124. */
  27125. static readonly CAP_START: number;
  27126. /**
  27127. * Mesh cap setting : one cap at the end of the mesh
  27128. */
  27129. static readonly CAP_END: number;
  27130. /**
  27131. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27132. */
  27133. static readonly CAP_ALL: number;
  27134. /**
  27135. * Mesh pattern setting : no flip or rotate
  27136. */
  27137. static readonly NO_FLIP: number;
  27138. /**
  27139. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27140. */
  27141. static readonly FLIP_TILE: number;
  27142. /**
  27143. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27144. */
  27145. static readonly ROTATE_TILE: number;
  27146. /**
  27147. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27148. */
  27149. static readonly FLIP_ROW: number;
  27150. /**
  27151. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27152. */
  27153. static readonly ROTATE_ROW: number;
  27154. /**
  27155. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27156. */
  27157. static readonly FLIP_N_ROTATE_TILE: number;
  27158. /**
  27159. * Mesh pattern setting : rotate pattern and rotate
  27160. */
  27161. static readonly FLIP_N_ROTATE_ROW: number;
  27162. /**
  27163. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27164. */
  27165. static readonly CENTER: number;
  27166. /**
  27167. * Mesh tile positioning : part tiles on left
  27168. */
  27169. static readonly LEFT: number;
  27170. /**
  27171. * Mesh tile positioning : part tiles on right
  27172. */
  27173. static readonly RIGHT: number;
  27174. /**
  27175. * Mesh tile positioning : part tiles on top
  27176. */
  27177. static readonly TOP: number;
  27178. /**
  27179. * Mesh tile positioning : part tiles on bottom
  27180. */
  27181. static readonly BOTTOM: number;
  27182. /**
  27183. * Gets the default side orientation.
  27184. * @param orientation the orientation to value to attempt to get
  27185. * @returns the default orientation
  27186. * @hidden
  27187. */
  27188. static _GetDefaultSideOrientation(orientation?: number): number;
  27189. private _internalMeshDataInfo;
  27190. /**
  27191. * An event triggered before rendering the mesh
  27192. */
  27193. get onBeforeRenderObservable(): Observable<Mesh>;
  27194. /**
  27195. * An event triggered before binding the mesh
  27196. */
  27197. get onBeforeBindObservable(): Observable<Mesh>;
  27198. /**
  27199. * An event triggered after rendering the mesh
  27200. */
  27201. get onAfterRenderObservable(): Observable<Mesh>;
  27202. /**
  27203. * An event triggered before drawing the mesh
  27204. */
  27205. get onBeforeDrawObservable(): Observable<Mesh>;
  27206. private _onBeforeDrawObserver;
  27207. /**
  27208. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27209. */
  27210. set onBeforeDraw(callback: () => void);
  27211. get hasInstances(): boolean;
  27212. /**
  27213. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27214. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27215. */
  27216. delayLoadState: number;
  27217. /**
  27218. * Gets the list of instances created from this mesh
  27219. * it is not supposed to be modified manually.
  27220. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27221. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27222. */
  27223. instances: InstancedMesh[];
  27224. /**
  27225. * Gets the file containing delay loading data for this mesh
  27226. */
  27227. delayLoadingFile: string;
  27228. /** @hidden */
  27229. _binaryInfo: any;
  27230. /**
  27231. * User defined function used to change how LOD level selection is done
  27232. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27233. */
  27234. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27235. /**
  27236. * Gets or sets the morph target manager
  27237. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27238. */
  27239. get morphTargetManager(): Nullable<MorphTargetManager>;
  27240. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27241. /** @hidden */
  27242. _creationDataStorage: Nullable<_CreationDataStorage>;
  27243. /** @hidden */
  27244. _geometry: Nullable<Geometry>;
  27245. /** @hidden */
  27246. _delayInfo: Array<string>;
  27247. /** @hidden */
  27248. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27249. /** @hidden */
  27250. _instanceDataStorage: _InstanceDataStorage;
  27251. private _effectiveMaterial;
  27252. /** @hidden */
  27253. _shouldGenerateFlatShading: boolean;
  27254. /** @hidden */
  27255. _originalBuilderSideOrientation: number;
  27256. /**
  27257. * Use this property to change the original side orientation defined at construction time
  27258. */
  27259. overrideMaterialSideOrientation: Nullable<number>;
  27260. /**
  27261. * Gets the source mesh (the one used to clone this one from)
  27262. */
  27263. get source(): Nullable<Mesh>;
  27264. /**
  27265. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27266. */
  27267. get isUnIndexed(): boolean;
  27268. set isUnIndexed(value: boolean);
  27269. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27270. get worldMatrixInstancedBuffer(): Float32Array;
  27271. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27272. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27273. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27274. /**
  27275. * @constructor
  27276. * @param name The value used by scene.getMeshByName() to do a lookup.
  27277. * @param scene The scene to add this mesh to.
  27278. * @param parent The parent of this mesh, if it has one
  27279. * @param source An optional Mesh from which geometry is shared, cloned.
  27280. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27281. * When false, achieved by calling a clone(), also passing False.
  27282. * This will make creation of children, recursive.
  27283. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27284. */
  27285. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27286. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27287. doNotInstantiate: boolean;
  27288. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27289. /**
  27290. * Gets the class name
  27291. * @returns the string "Mesh".
  27292. */
  27293. getClassName(): string;
  27294. /** @hidden */
  27295. get _isMesh(): boolean;
  27296. /**
  27297. * Returns a description of this mesh
  27298. * @param fullDetails define if full details about this mesh must be used
  27299. * @returns a descriptive string representing this mesh
  27300. */
  27301. toString(fullDetails?: boolean): string;
  27302. /** @hidden */
  27303. _unBindEffect(): void;
  27304. /**
  27305. * Gets a boolean indicating if this mesh has LOD
  27306. */
  27307. get hasLODLevels(): boolean;
  27308. /**
  27309. * Gets the list of MeshLODLevel associated with the current mesh
  27310. * @returns an array of MeshLODLevel
  27311. */
  27312. getLODLevels(): MeshLODLevel[];
  27313. private _sortLODLevels;
  27314. /**
  27315. * Add a mesh as LOD level triggered at the given distance.
  27316. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27317. * @param distance The distance from the center of the object to show this level
  27318. * @param mesh The mesh to be added as LOD level (can be null)
  27319. * @return This mesh (for chaining)
  27320. */
  27321. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27322. /**
  27323. * Returns the LOD level mesh at the passed distance or null if not found.
  27324. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27325. * @param distance The distance from the center of the object to show this level
  27326. * @returns a Mesh or `null`
  27327. */
  27328. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27329. /**
  27330. * Remove a mesh from the LOD array
  27331. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27332. * @param mesh defines the mesh to be removed
  27333. * @return This mesh (for chaining)
  27334. */
  27335. removeLODLevel(mesh: Mesh): Mesh;
  27336. /**
  27337. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27338. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27339. * @param camera defines the camera to use to compute distance
  27340. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27341. * @return This mesh (for chaining)
  27342. */
  27343. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27344. /**
  27345. * Gets the mesh internal Geometry object
  27346. */
  27347. get geometry(): Nullable<Geometry>;
  27348. /**
  27349. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27350. * @returns the total number of vertices
  27351. */
  27352. getTotalVertices(): number;
  27353. /**
  27354. * Returns the content of an associated vertex buffer
  27355. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27356. * - VertexBuffer.PositionKind
  27357. * - VertexBuffer.UVKind
  27358. * - VertexBuffer.UV2Kind
  27359. * - VertexBuffer.UV3Kind
  27360. * - VertexBuffer.UV4Kind
  27361. * - VertexBuffer.UV5Kind
  27362. * - VertexBuffer.UV6Kind
  27363. * - VertexBuffer.ColorKind
  27364. * - VertexBuffer.MatricesIndicesKind
  27365. * - VertexBuffer.MatricesIndicesExtraKind
  27366. * - VertexBuffer.MatricesWeightsKind
  27367. * - VertexBuffer.MatricesWeightsExtraKind
  27368. * @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
  27369. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27370. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27371. */
  27372. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27373. /**
  27374. * Returns the mesh VertexBuffer object from the requested `kind`
  27375. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27376. * - VertexBuffer.PositionKind
  27377. * - VertexBuffer.NormalKind
  27378. * - VertexBuffer.UVKind
  27379. * - VertexBuffer.UV2Kind
  27380. * - VertexBuffer.UV3Kind
  27381. * - VertexBuffer.UV4Kind
  27382. * - VertexBuffer.UV5Kind
  27383. * - VertexBuffer.UV6Kind
  27384. * - VertexBuffer.ColorKind
  27385. * - VertexBuffer.MatricesIndicesKind
  27386. * - VertexBuffer.MatricesIndicesExtraKind
  27387. * - VertexBuffer.MatricesWeightsKind
  27388. * - VertexBuffer.MatricesWeightsExtraKind
  27389. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27390. */
  27391. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27392. /**
  27393. * Tests if a specific vertex buffer is associated with this mesh
  27394. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27395. * - VertexBuffer.PositionKind
  27396. * - VertexBuffer.NormalKind
  27397. * - VertexBuffer.UVKind
  27398. * - VertexBuffer.UV2Kind
  27399. * - VertexBuffer.UV3Kind
  27400. * - VertexBuffer.UV4Kind
  27401. * - VertexBuffer.UV5Kind
  27402. * - VertexBuffer.UV6Kind
  27403. * - VertexBuffer.ColorKind
  27404. * - VertexBuffer.MatricesIndicesKind
  27405. * - VertexBuffer.MatricesIndicesExtraKind
  27406. * - VertexBuffer.MatricesWeightsKind
  27407. * - VertexBuffer.MatricesWeightsExtraKind
  27408. * @returns a boolean
  27409. */
  27410. isVerticesDataPresent(kind: string): boolean;
  27411. /**
  27412. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27413. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27414. * - VertexBuffer.PositionKind
  27415. * - VertexBuffer.UVKind
  27416. * - VertexBuffer.UV2Kind
  27417. * - VertexBuffer.UV3Kind
  27418. * - VertexBuffer.UV4Kind
  27419. * - VertexBuffer.UV5Kind
  27420. * - VertexBuffer.UV6Kind
  27421. * - VertexBuffer.ColorKind
  27422. * - VertexBuffer.MatricesIndicesKind
  27423. * - VertexBuffer.MatricesIndicesExtraKind
  27424. * - VertexBuffer.MatricesWeightsKind
  27425. * - VertexBuffer.MatricesWeightsExtraKind
  27426. * @returns a boolean
  27427. */
  27428. isVertexBufferUpdatable(kind: string): boolean;
  27429. /**
  27430. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27431. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27432. * - VertexBuffer.PositionKind
  27433. * - VertexBuffer.NormalKind
  27434. * - VertexBuffer.UVKind
  27435. * - VertexBuffer.UV2Kind
  27436. * - VertexBuffer.UV3Kind
  27437. * - VertexBuffer.UV4Kind
  27438. * - VertexBuffer.UV5Kind
  27439. * - VertexBuffer.UV6Kind
  27440. * - VertexBuffer.ColorKind
  27441. * - VertexBuffer.MatricesIndicesKind
  27442. * - VertexBuffer.MatricesIndicesExtraKind
  27443. * - VertexBuffer.MatricesWeightsKind
  27444. * - VertexBuffer.MatricesWeightsExtraKind
  27445. * @returns an array of strings
  27446. */
  27447. getVerticesDataKinds(): string[];
  27448. /**
  27449. * Returns a positive integer : the total number of indices in this mesh geometry.
  27450. * @returns the numner of indices or zero if the mesh has no geometry.
  27451. */
  27452. getTotalIndices(): number;
  27453. /**
  27454. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27455. * @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.
  27456. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27457. * @returns the indices array or an empty array if the mesh has no geometry
  27458. */
  27459. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27460. get isBlocked(): boolean;
  27461. /**
  27462. * Determine if the current mesh is ready to be rendered
  27463. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27464. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27465. * @returns true if all associated assets are ready (material, textures, shaders)
  27466. */
  27467. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27468. /**
  27469. * 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.
  27470. */
  27471. get areNormalsFrozen(): boolean;
  27472. /**
  27473. * 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.
  27474. * @returns the current mesh
  27475. */
  27476. freezeNormals(): Mesh;
  27477. /**
  27478. * 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
  27479. * @returns the current mesh
  27480. */
  27481. unfreezeNormals(): Mesh;
  27482. /**
  27483. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27484. */
  27485. set overridenInstanceCount(count: number);
  27486. /** @hidden */
  27487. _preActivate(): Mesh;
  27488. /** @hidden */
  27489. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27490. /** @hidden */
  27491. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27492. /**
  27493. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27494. * This means the mesh underlying bounding box and sphere are recomputed.
  27495. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27496. * @returns the current mesh
  27497. */
  27498. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27499. /** @hidden */
  27500. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27501. /**
  27502. * This function will subdivide the mesh into multiple submeshes
  27503. * @param count defines the expected number of submeshes
  27504. */
  27505. subdivide(count: number): void;
  27506. /**
  27507. * Copy a FloatArray into a specific associated vertex buffer
  27508. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27509. * - VertexBuffer.PositionKind
  27510. * - VertexBuffer.UVKind
  27511. * - VertexBuffer.UV2Kind
  27512. * - VertexBuffer.UV3Kind
  27513. * - VertexBuffer.UV4Kind
  27514. * - VertexBuffer.UV5Kind
  27515. * - VertexBuffer.UV6Kind
  27516. * - VertexBuffer.ColorKind
  27517. * - VertexBuffer.MatricesIndicesKind
  27518. * - VertexBuffer.MatricesIndicesExtraKind
  27519. * - VertexBuffer.MatricesWeightsKind
  27520. * - VertexBuffer.MatricesWeightsExtraKind
  27521. * @param data defines the data source
  27522. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27523. * @param stride defines the data stride size (can be null)
  27524. * @returns the current mesh
  27525. */
  27526. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27527. /**
  27528. * Delete a vertex buffer associated with this mesh
  27529. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27530. * - VertexBuffer.PositionKind
  27531. * - VertexBuffer.UVKind
  27532. * - VertexBuffer.UV2Kind
  27533. * - VertexBuffer.UV3Kind
  27534. * - VertexBuffer.UV4Kind
  27535. * - VertexBuffer.UV5Kind
  27536. * - VertexBuffer.UV6Kind
  27537. * - VertexBuffer.ColorKind
  27538. * - VertexBuffer.MatricesIndicesKind
  27539. * - VertexBuffer.MatricesIndicesExtraKind
  27540. * - VertexBuffer.MatricesWeightsKind
  27541. * - VertexBuffer.MatricesWeightsExtraKind
  27542. */
  27543. removeVerticesData(kind: string): void;
  27544. /**
  27545. * Flags an associated vertex buffer as updatable
  27546. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27547. * - VertexBuffer.PositionKind
  27548. * - VertexBuffer.UVKind
  27549. * - VertexBuffer.UV2Kind
  27550. * - VertexBuffer.UV3Kind
  27551. * - VertexBuffer.UV4Kind
  27552. * - VertexBuffer.UV5Kind
  27553. * - VertexBuffer.UV6Kind
  27554. * - VertexBuffer.ColorKind
  27555. * - VertexBuffer.MatricesIndicesKind
  27556. * - VertexBuffer.MatricesIndicesExtraKind
  27557. * - VertexBuffer.MatricesWeightsKind
  27558. * - VertexBuffer.MatricesWeightsExtraKind
  27559. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27560. */
  27561. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27562. /**
  27563. * Sets the mesh global Vertex Buffer
  27564. * @param buffer defines the buffer to use
  27565. * @returns the current mesh
  27566. */
  27567. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27568. /**
  27569. * Update a specific associated vertex buffer
  27570. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27571. * - VertexBuffer.PositionKind
  27572. * - VertexBuffer.UVKind
  27573. * - VertexBuffer.UV2Kind
  27574. * - VertexBuffer.UV3Kind
  27575. * - VertexBuffer.UV4Kind
  27576. * - VertexBuffer.UV5Kind
  27577. * - VertexBuffer.UV6Kind
  27578. * - VertexBuffer.ColorKind
  27579. * - VertexBuffer.MatricesIndicesKind
  27580. * - VertexBuffer.MatricesIndicesExtraKind
  27581. * - VertexBuffer.MatricesWeightsKind
  27582. * - VertexBuffer.MatricesWeightsExtraKind
  27583. * @param data defines the data source
  27584. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27585. * @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)
  27586. * @returns the current mesh
  27587. */
  27588. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27589. /**
  27590. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27591. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27592. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27593. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27594. * @returns the current mesh
  27595. */
  27596. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27597. /**
  27598. * Creates a un-shared specific occurence of the geometry for the mesh.
  27599. * @returns the current mesh
  27600. */
  27601. makeGeometryUnique(): Mesh;
  27602. /**
  27603. * Set the index buffer of this mesh
  27604. * @param indices defines the source data
  27605. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27606. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27607. * @returns the current mesh
  27608. */
  27609. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27610. /**
  27611. * Update the current index buffer
  27612. * @param indices defines the source data
  27613. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27614. * @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)
  27615. * @returns the current mesh
  27616. */
  27617. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27618. /**
  27619. * Invert the geometry to move from a right handed system to a left handed one.
  27620. * @returns the current mesh
  27621. */
  27622. toLeftHanded(): Mesh;
  27623. /** @hidden */
  27624. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27625. /** @hidden */
  27626. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27627. /**
  27628. * Registers for this mesh a javascript function called just before the rendering process
  27629. * @param func defines the function to call before rendering this mesh
  27630. * @returns the current mesh
  27631. */
  27632. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27633. /**
  27634. * Disposes a previously registered javascript function called before the rendering
  27635. * @param func defines the function to remove
  27636. * @returns the current mesh
  27637. */
  27638. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27639. /**
  27640. * Registers for this mesh a javascript function called just after the rendering is complete
  27641. * @param func defines the function to call after rendering this mesh
  27642. * @returns the current mesh
  27643. */
  27644. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27645. /**
  27646. * Disposes a previously registered javascript function called after the rendering.
  27647. * @param func defines the function to remove
  27648. * @returns the current mesh
  27649. */
  27650. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27651. /** @hidden */
  27652. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27653. /** @hidden */
  27654. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27655. /** @hidden */
  27656. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27657. /** @hidden */
  27658. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27659. /** @hidden */
  27660. _rebuild(): void;
  27661. /** @hidden */
  27662. _freeze(): void;
  27663. /** @hidden */
  27664. _unFreeze(): void;
  27665. /**
  27666. * 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
  27667. * @param subMesh defines the subMesh to render
  27668. * @param enableAlphaMode defines if alpha mode can be changed
  27669. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27670. * @returns the current mesh
  27671. */
  27672. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27673. private _onBeforeDraw;
  27674. /**
  27675. * Renormalize the mesh and patch it up if there are no weights
  27676. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27677. * However in the case of zero weights then we set just a single influence to 1.
  27678. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27679. */
  27680. cleanMatrixWeights(): void;
  27681. private normalizeSkinFourWeights;
  27682. private normalizeSkinWeightsAndExtra;
  27683. /**
  27684. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27685. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27686. * the user know there was an issue with importing the mesh
  27687. * @returns a validation object with skinned, valid and report string
  27688. */
  27689. validateSkinning(): {
  27690. skinned: boolean;
  27691. valid: boolean;
  27692. report: string;
  27693. };
  27694. /** @hidden */
  27695. _checkDelayState(): Mesh;
  27696. private _queueLoad;
  27697. /**
  27698. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27699. * A mesh is in the frustum if its bounding box intersects the frustum
  27700. * @param frustumPlanes defines the frustum to test
  27701. * @returns true if the mesh is in the frustum planes
  27702. */
  27703. isInFrustum(frustumPlanes: Plane[]): boolean;
  27704. /**
  27705. * Sets the mesh material by the material or multiMaterial `id` property
  27706. * @param id is a string identifying the material or the multiMaterial
  27707. * @returns the current mesh
  27708. */
  27709. setMaterialByID(id: string): Mesh;
  27710. /**
  27711. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27712. * @returns an array of IAnimatable
  27713. */
  27714. getAnimatables(): IAnimatable[];
  27715. /**
  27716. * Modifies the mesh geometry according to the passed transformation matrix.
  27717. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27718. * The mesh normals are modified using the same transformation.
  27719. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27720. * @param transform defines the transform matrix to use
  27721. * @see http://doc.babylonjs.com/resources/baking_transformations
  27722. * @returns the current mesh
  27723. */
  27724. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27725. /**
  27726. * Modifies the mesh geometry according to its own current World Matrix.
  27727. * The mesh World Matrix is then reset.
  27728. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27729. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27730. * @see http://doc.babylonjs.com/resources/baking_transformations
  27731. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27732. * @returns the current mesh
  27733. */
  27734. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27735. /** @hidden */
  27736. get _positions(): Nullable<Vector3[]>;
  27737. /** @hidden */
  27738. _resetPointsArrayCache(): Mesh;
  27739. /** @hidden */
  27740. _generatePointsArray(): boolean;
  27741. /**
  27742. * Returns a new Mesh object generated from the current mesh properties.
  27743. * This method must not get confused with createInstance()
  27744. * @param name is a string, the name given to the new mesh
  27745. * @param newParent can be any Node object (default `null`)
  27746. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27747. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27748. * @returns a new mesh
  27749. */
  27750. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27751. /**
  27752. * Releases resources associated with this mesh.
  27753. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27754. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27755. */
  27756. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27757. /** @hidden */
  27758. _disposeInstanceSpecificData(): void;
  27759. /**
  27760. * Modifies the mesh geometry according to a displacement map.
  27761. * 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.
  27762. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27763. * @param url is a string, the URL from the image file is to be downloaded.
  27764. * @param minHeight is the lower limit of the displacement.
  27765. * @param maxHeight is the upper limit of the displacement.
  27766. * @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.
  27767. * @param uvOffset is an optional vector2 used to offset UV.
  27768. * @param uvScale is an optional vector2 used to scale UV.
  27769. * @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.
  27770. * @returns the Mesh.
  27771. */
  27772. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27773. /**
  27774. * Modifies the mesh geometry according to a displacementMap buffer.
  27775. * 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.
  27776. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27777. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27778. * @param heightMapWidth is the width of the buffer image.
  27779. * @param heightMapHeight is the height of the buffer image.
  27780. * @param minHeight is the lower limit of the displacement.
  27781. * @param maxHeight is the upper limit of the displacement.
  27782. * @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.
  27783. * @param uvOffset is an optional vector2 used to offset UV.
  27784. * @param uvScale is an optional vector2 used to scale UV.
  27785. * @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.
  27786. * @returns the Mesh.
  27787. */
  27788. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27789. /**
  27790. * Modify the mesh to get a flat shading rendering.
  27791. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27792. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27793. * @returns current mesh
  27794. */
  27795. convertToFlatShadedMesh(): Mesh;
  27796. /**
  27797. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27798. * In other words, more vertices, no more indices and a single bigger VBO.
  27799. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27800. * @returns current mesh
  27801. */
  27802. convertToUnIndexedMesh(): Mesh;
  27803. /**
  27804. * Inverses facet orientations.
  27805. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27806. * @param flipNormals will also inverts the normals
  27807. * @returns current mesh
  27808. */
  27809. flipFaces(flipNormals?: boolean): Mesh;
  27810. /**
  27811. * Increase the number of facets and hence vertices in a mesh
  27812. * Vertex normals are interpolated from existing vertex normals
  27813. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27814. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27815. */
  27816. increaseVertices(numberPerEdge: number): void;
  27817. /**
  27818. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27819. * This will undo any application of covertToFlatShadedMesh
  27820. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27821. */
  27822. forceSharedVertices(): void;
  27823. /** @hidden */
  27824. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27825. /** @hidden */
  27826. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27827. /**
  27828. * Creates a new InstancedMesh object from the mesh model.
  27829. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27830. * @param name defines the name of the new instance
  27831. * @returns a new InstancedMesh
  27832. */
  27833. createInstance(name: string): InstancedMesh;
  27834. /**
  27835. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27836. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27837. * @returns the current mesh
  27838. */
  27839. synchronizeInstances(): Mesh;
  27840. /**
  27841. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27842. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27843. * This should be used together with the simplification to avoid disappearing triangles.
  27844. * @param successCallback an optional success callback to be called after the optimization finished.
  27845. * @returns the current mesh
  27846. */
  27847. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27848. /**
  27849. * Serialize current mesh
  27850. * @param serializationObject defines the object which will receive the serialization data
  27851. */
  27852. serialize(serializationObject: any): void;
  27853. /** @hidden */
  27854. _syncGeometryWithMorphTargetManager(): void;
  27855. /** @hidden */
  27856. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  27857. /**
  27858. * Returns a new Mesh object parsed from the source provided.
  27859. * @param parsedMesh is the source
  27860. * @param scene defines the hosting scene
  27861. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27862. * @returns a new Mesh
  27863. */
  27864. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27865. /**
  27866. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27867. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27868. * @param name defines the name of the mesh to create
  27869. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27870. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27871. * @param closePath creates a seam between the first and the last points of each path of the path array
  27872. * @param offset is taken in account only if the `pathArray` is containing a single path
  27873. * @param scene defines the hosting scene
  27874. * @param updatable defines if the mesh must be flagged as updatable
  27875. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27876. * @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)
  27877. * @returns a new Mesh
  27878. */
  27879. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27880. /**
  27881. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27882. * @param name defines the name of the mesh to create
  27883. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27884. * @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
  27885. * @param scene defines the hosting scene
  27886. * @param updatable defines if the mesh must be flagged as updatable
  27887. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27888. * @returns a new Mesh
  27889. */
  27890. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27891. /**
  27892. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27893. * @param name defines the name of the mesh to create
  27894. * @param size sets the size (float) of each box side (default 1)
  27895. * @param scene defines the hosting scene
  27896. * @param updatable defines if the mesh must be flagged as updatable
  27897. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27898. * @returns a new Mesh
  27899. */
  27900. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27901. /**
  27902. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27903. * @param name defines the name of the mesh to create
  27904. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27905. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27906. * @param scene defines the hosting scene
  27907. * @param updatable defines if the mesh must be flagged as updatable
  27908. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27909. * @returns a new Mesh
  27910. */
  27911. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27912. /**
  27913. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  27914. * @param name defines the name of the mesh to create
  27915. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27916. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27917. * @param scene defines the hosting scene
  27918. * @returns a new Mesh
  27919. */
  27920. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  27921. /**
  27922. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27923. * @param name defines the name of the mesh to create
  27924. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27925. * @param diameterTop set the top cap diameter (floats, default 1)
  27926. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27927. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27928. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27929. * @param scene defines the hosting scene
  27930. * @param updatable defines if the mesh must be flagged as updatable
  27931. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27932. * @returns a new Mesh
  27933. */
  27934. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27935. /**
  27936. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27937. * @param name defines the name of the mesh to create
  27938. * @param diameter sets the diameter size (float) of the torus (default 1)
  27939. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27940. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27941. * @param scene defines the hosting scene
  27942. * @param updatable defines if the mesh must be flagged as updatable
  27943. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27944. * @returns a new Mesh
  27945. */
  27946. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27947. /**
  27948. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27949. * @param name defines the name of the mesh to create
  27950. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27951. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27952. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27953. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27954. * @param p the number of windings on X axis (positive integers, default 2)
  27955. * @param q the number of windings on Y axis (positive integers, default 3)
  27956. * @param scene defines the hosting scene
  27957. * @param updatable defines if the mesh must be flagged as updatable
  27958. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27959. * @returns a new Mesh
  27960. */
  27961. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27962. /**
  27963. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27964. * @param name defines the name of the mesh to create
  27965. * @param points is an array successive Vector3
  27966. * @param scene defines the hosting scene
  27967. * @param updatable defines if the mesh must be flagged as updatable
  27968. * @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).
  27969. * @returns a new Mesh
  27970. */
  27971. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27972. /**
  27973. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27974. * @param name defines the name of the mesh to create
  27975. * @param points is an array successive Vector3
  27976. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27977. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27978. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27979. * @param scene defines the hosting scene
  27980. * @param updatable defines if the mesh must be flagged as updatable
  27981. * @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)
  27982. * @returns a new Mesh
  27983. */
  27984. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27985. /**
  27986. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27987. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27988. * 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.
  27989. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27990. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27991. * Remember you can only change the shape positions, not their number when updating a polygon.
  27992. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27993. * @param name defines the name of the mesh to create
  27994. * @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
  27995. * @param scene defines the hosting scene
  27996. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  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. * @param earcutInjection can be used to inject your own earcut reference
  28000. * @returns a new Mesh
  28001. */
  28002. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28003. /**
  28004. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28005. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28006. * @param name defines the name of the mesh to create
  28007. * @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
  28008. * @param depth defines the height of extrusion
  28009. * @param scene defines the hosting scene
  28010. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28011. * @param updatable defines if the mesh must be flagged as updatable
  28012. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28013. * @param earcutInjection can be used to inject your own earcut reference
  28014. * @returns a new Mesh
  28015. */
  28016. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28017. /**
  28018. * Creates an extruded shape mesh.
  28019. * 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
  28020. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28021. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28022. * @param name defines the name of the mesh to create
  28023. * @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
  28024. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28025. * @param scale is the value to scale the shape
  28026. * @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
  28027. * @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
  28028. * @param scene defines the hosting scene
  28029. * @param updatable defines if the mesh must be flagged as updatable
  28030. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28031. * @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)
  28032. * @returns a new Mesh
  28033. */
  28034. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28035. /**
  28036. * Creates an custom extruded shape mesh.
  28037. * The custom extrusion is a parametric shape.
  28038. * It has no predefined shape. Its final shape will depend on the input parameters.
  28039. * Please consider using the same method from the MeshBuilder class instead
  28040. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28041. * @param name defines the name of the mesh to create
  28042. * @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
  28043. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28044. * @param scaleFunction is a custom Javascript function called on each path point
  28045. * @param rotationFunction is a custom Javascript function called on each path point
  28046. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28047. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28048. * @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
  28049. * @param scene defines the hosting scene
  28050. * @param updatable defines if the mesh must be flagged as updatable
  28051. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28052. * @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)
  28053. * @returns a new Mesh
  28054. */
  28055. 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;
  28056. /**
  28057. * Creates lathe mesh.
  28058. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28059. * Please consider using the same method from the MeshBuilder class instead
  28060. * @param name defines the name of the mesh to create
  28061. * @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
  28062. * @param radius is the radius value of the lathe
  28063. * @param tessellation is the side number of the lathe.
  28064. * @param scene defines the hosting scene
  28065. * @param updatable defines if the mesh must be flagged as updatable
  28066. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28067. * @returns a new Mesh
  28068. */
  28069. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28070. /**
  28071. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28072. * @param name defines the name of the mesh to create
  28073. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28074. * @param scene defines the hosting scene
  28075. * @param updatable defines if the mesh must be flagged as updatable
  28076. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28077. * @returns a new Mesh
  28078. */
  28079. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28080. /**
  28081. * Creates a ground mesh.
  28082. * Please consider using the same method from the MeshBuilder class instead
  28083. * @param name defines the name of the mesh to create
  28084. * @param width set the width of the ground
  28085. * @param height set the height of the ground
  28086. * @param subdivisions sets the number of subdivisions per side
  28087. * @param scene defines the hosting scene
  28088. * @param updatable defines if the mesh must be flagged as updatable
  28089. * @returns a new Mesh
  28090. */
  28091. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28092. /**
  28093. * Creates a tiled ground mesh.
  28094. * Please consider using the same method from the MeshBuilder class instead
  28095. * @param name defines the name of the mesh to create
  28096. * @param xmin set the ground minimum X coordinate
  28097. * @param zmin set the ground minimum Y coordinate
  28098. * @param xmax set the ground maximum X coordinate
  28099. * @param zmax set the ground maximum Z coordinate
  28100. * @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
  28101. * @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
  28102. * @param scene defines the hosting scene
  28103. * @param updatable defines if the mesh must be flagged as updatable
  28104. * @returns a new Mesh
  28105. */
  28106. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28107. w: number;
  28108. h: number;
  28109. }, precision: {
  28110. w: number;
  28111. h: number;
  28112. }, scene: Scene, updatable?: boolean): Mesh;
  28113. /**
  28114. * Creates a ground mesh from a height map.
  28115. * Please consider using the same method from the MeshBuilder class instead
  28116. * @see http://doc.babylonjs.com/babylon101/height_map
  28117. * @param name defines the name of the mesh to create
  28118. * @param url sets the URL of the height map image resource
  28119. * @param width set the ground width size
  28120. * @param height set the ground height size
  28121. * @param subdivisions sets the number of subdivision per side
  28122. * @param minHeight is the minimum altitude on the ground
  28123. * @param maxHeight is the maximum altitude on the ground
  28124. * @param scene defines the hosting scene
  28125. * @param updatable defines if the mesh must be flagged as updatable
  28126. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28127. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28128. * @returns a new Mesh
  28129. */
  28130. 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;
  28131. /**
  28132. * Creates a tube mesh.
  28133. * The tube is a parametric shape.
  28134. * It has no predefined shape. Its final shape will depend on the input parameters.
  28135. * Please consider using the same method from the MeshBuilder class instead
  28136. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28137. * @param name defines the name of the mesh to create
  28138. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28139. * @param radius sets the tube radius size
  28140. * @param tessellation is the number of sides on the tubular surface
  28141. * @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
  28142. * @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
  28143. * @param scene defines the hosting scene
  28144. * @param updatable defines if the mesh must be flagged as updatable
  28145. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28146. * @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)
  28147. * @returns a new Mesh
  28148. */
  28149. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28150. (i: number, distance: number): number;
  28151. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28152. /**
  28153. * Creates a polyhedron mesh.
  28154. * Please consider using the same method from the MeshBuilder class instead.
  28155. * * 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
  28156. * * The parameter `size` (positive float, default 1) sets the polygon size
  28157. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28158. * * 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`
  28159. * * 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
  28160. * * 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)`)
  28161. * * 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
  28162. * * 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
  28163. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28164. * * 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
  28165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28166. * @param name defines the name of the mesh to create
  28167. * @param options defines the options used to create the mesh
  28168. * @param scene defines the hosting scene
  28169. * @returns a new Mesh
  28170. */
  28171. static CreatePolyhedron(name: string, options: {
  28172. type?: number;
  28173. size?: number;
  28174. sizeX?: number;
  28175. sizeY?: number;
  28176. sizeZ?: number;
  28177. custom?: any;
  28178. faceUV?: Vector4[];
  28179. faceColors?: Color4[];
  28180. updatable?: boolean;
  28181. sideOrientation?: number;
  28182. }, scene: Scene): Mesh;
  28183. /**
  28184. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28185. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28186. * * 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`)
  28187. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28188. * * 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
  28189. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28190. * * 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
  28191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28192. * @param name defines the name of the mesh
  28193. * @param options defines the options used to create the mesh
  28194. * @param scene defines the hosting scene
  28195. * @returns a new Mesh
  28196. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28197. */
  28198. static CreateIcoSphere(name: string, options: {
  28199. radius?: number;
  28200. flat?: boolean;
  28201. subdivisions?: number;
  28202. sideOrientation?: number;
  28203. updatable?: boolean;
  28204. }, scene: Scene): Mesh;
  28205. /**
  28206. * Creates a decal mesh.
  28207. * Please consider using the same method from the MeshBuilder class instead.
  28208. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28209. * @param name defines the name of the mesh
  28210. * @param sourceMesh defines the mesh receiving the decal
  28211. * @param position sets the position of the decal in world coordinates
  28212. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28213. * @param size sets the decal scaling
  28214. * @param angle sets the angle to rotate the decal
  28215. * @returns a new Mesh
  28216. */
  28217. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28218. /**
  28219. * Prepare internal position array for software CPU skinning
  28220. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28221. */
  28222. setPositionsForCPUSkinning(): Float32Array;
  28223. /**
  28224. * Prepare internal normal array for software CPU skinning
  28225. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28226. */
  28227. setNormalsForCPUSkinning(): Float32Array;
  28228. /**
  28229. * Updates the vertex buffer by applying transformation from the bones
  28230. * @param skeleton defines the skeleton to apply to current mesh
  28231. * @returns the current mesh
  28232. */
  28233. applySkeleton(skeleton: Skeleton): Mesh;
  28234. /**
  28235. * 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
  28236. * @param meshes defines the list of meshes to scan
  28237. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28238. */
  28239. static MinMax(meshes: AbstractMesh[]): {
  28240. min: Vector3;
  28241. max: Vector3;
  28242. };
  28243. /**
  28244. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28245. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28246. * @returns a vector3
  28247. */
  28248. static Center(meshesOrMinMaxVector: {
  28249. min: Vector3;
  28250. max: Vector3;
  28251. } | AbstractMesh[]): Vector3;
  28252. /**
  28253. * Merge the array of meshes into a single mesh for performance reasons.
  28254. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28255. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28256. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28257. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28258. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28259. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28260. * @returns a new mesh
  28261. */
  28262. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28263. /** @hidden */
  28264. addInstance(instance: InstancedMesh): void;
  28265. /** @hidden */
  28266. removeInstance(instance: InstancedMesh): void;
  28267. }
  28268. }
  28269. declare module BABYLON {
  28270. /**
  28271. * This is the base class of all the camera used in the application.
  28272. * @see http://doc.babylonjs.com/features/cameras
  28273. */
  28274. export class Camera extends Node {
  28275. /** @hidden */
  28276. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28277. /**
  28278. * This is the default projection mode used by the cameras.
  28279. * It helps recreating a feeling of perspective and better appreciate depth.
  28280. * This is the best way to simulate real life cameras.
  28281. */
  28282. static readonly PERSPECTIVE_CAMERA: number;
  28283. /**
  28284. * This helps creating camera with an orthographic mode.
  28285. * 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.
  28286. */
  28287. static readonly ORTHOGRAPHIC_CAMERA: number;
  28288. /**
  28289. * This is the default FOV mode for perspective cameras.
  28290. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28291. */
  28292. static readonly FOVMODE_VERTICAL_FIXED: number;
  28293. /**
  28294. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28295. */
  28296. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28297. /**
  28298. * This specifies ther is no need for a camera rig.
  28299. * Basically only one eye is rendered corresponding to the camera.
  28300. */
  28301. static readonly RIG_MODE_NONE: number;
  28302. /**
  28303. * Simulates a camera Rig with one blue eye and one red eye.
  28304. * This can be use with 3d blue and red glasses.
  28305. */
  28306. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28307. /**
  28308. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28309. */
  28310. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28311. /**
  28312. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28313. */
  28314. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28315. /**
  28316. * Defines that both eyes of the camera will be rendered over under each other.
  28317. */
  28318. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28319. /**
  28320. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28321. */
  28322. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28323. /**
  28324. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28325. */
  28326. static readonly RIG_MODE_VR: number;
  28327. /**
  28328. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28329. */
  28330. static readonly RIG_MODE_WEBVR: number;
  28331. /**
  28332. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28333. */
  28334. static readonly RIG_MODE_CUSTOM: number;
  28335. /**
  28336. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28337. */
  28338. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28339. /**
  28340. * Define the input manager associated with the camera.
  28341. */
  28342. inputs: CameraInputsManager<Camera>;
  28343. /** @hidden */
  28344. _position: Vector3;
  28345. /**
  28346. * Define the current local position of the camera in the scene
  28347. */
  28348. get position(): Vector3;
  28349. set position(newPosition: Vector3);
  28350. /**
  28351. * The vector the camera should consider as up.
  28352. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28353. */
  28354. upVector: Vector3;
  28355. /**
  28356. * Define the current limit on the left side for an orthographic camera
  28357. * In scene unit
  28358. */
  28359. orthoLeft: Nullable<number>;
  28360. /**
  28361. * Define the current limit on the right side for an orthographic camera
  28362. * In scene unit
  28363. */
  28364. orthoRight: Nullable<number>;
  28365. /**
  28366. * Define the current limit on the bottom side for an orthographic camera
  28367. * In scene unit
  28368. */
  28369. orthoBottom: Nullable<number>;
  28370. /**
  28371. * Define the current limit on the top side for an orthographic camera
  28372. * In scene unit
  28373. */
  28374. orthoTop: Nullable<number>;
  28375. /**
  28376. * Field Of View is set in Radians. (default is 0.8)
  28377. */
  28378. fov: number;
  28379. /**
  28380. * Define the minimum distance the camera can see from.
  28381. * This is important to note that the depth buffer are not infinite and the closer it starts
  28382. * the more your scene might encounter depth fighting issue.
  28383. */
  28384. minZ: number;
  28385. /**
  28386. * Define the maximum distance the camera can see to.
  28387. * This is important to note that the depth buffer are not infinite and the further it end
  28388. * the more your scene might encounter depth fighting issue.
  28389. */
  28390. maxZ: number;
  28391. /**
  28392. * Define the default inertia of the camera.
  28393. * This helps giving a smooth feeling to the camera movement.
  28394. */
  28395. inertia: number;
  28396. /**
  28397. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28398. */
  28399. mode: number;
  28400. /**
  28401. * Define whether the camera is intermediate.
  28402. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28403. */
  28404. isIntermediate: boolean;
  28405. /**
  28406. * Define the viewport of the camera.
  28407. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28408. */
  28409. viewport: Viewport;
  28410. /**
  28411. * Restricts the camera to viewing objects with the same layerMask.
  28412. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28413. */
  28414. layerMask: number;
  28415. /**
  28416. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28417. */
  28418. fovMode: number;
  28419. /**
  28420. * Rig mode of the camera.
  28421. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28422. * This is normally controlled byt the camera themselves as internal use.
  28423. */
  28424. cameraRigMode: number;
  28425. /**
  28426. * Defines the distance between both "eyes" in case of a RIG
  28427. */
  28428. interaxialDistance: number;
  28429. /**
  28430. * Defines if stereoscopic rendering is done side by side or over under.
  28431. */
  28432. isStereoscopicSideBySide: boolean;
  28433. /**
  28434. * 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
  28435. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28436. * else in the scene. (Eg. security camera)
  28437. *
  28438. * 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)
  28439. */
  28440. customRenderTargets: RenderTargetTexture[];
  28441. /**
  28442. * When set, the camera will render to this render target instead of the default canvas
  28443. *
  28444. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28445. */
  28446. outputRenderTarget: Nullable<RenderTargetTexture>;
  28447. /**
  28448. * Observable triggered when the camera view matrix has changed.
  28449. */
  28450. onViewMatrixChangedObservable: Observable<Camera>;
  28451. /**
  28452. * Observable triggered when the camera Projection matrix has changed.
  28453. */
  28454. onProjectionMatrixChangedObservable: Observable<Camera>;
  28455. /**
  28456. * Observable triggered when the inputs have been processed.
  28457. */
  28458. onAfterCheckInputsObservable: Observable<Camera>;
  28459. /**
  28460. * Observable triggered when reset has been called and applied to the camera.
  28461. */
  28462. onRestoreStateObservable: Observable<Camera>;
  28463. /**
  28464. * Is this camera a part of a rig system?
  28465. */
  28466. isRigCamera: boolean;
  28467. /**
  28468. * If isRigCamera set to true this will be set with the parent camera.
  28469. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28470. */
  28471. rigParent?: Camera;
  28472. /** @hidden */
  28473. _cameraRigParams: any;
  28474. /** @hidden */
  28475. _rigCameras: Camera[];
  28476. /** @hidden */
  28477. _rigPostProcess: Nullable<PostProcess>;
  28478. protected _webvrViewMatrix: Matrix;
  28479. /** @hidden */
  28480. _skipRendering: boolean;
  28481. /** @hidden */
  28482. _projectionMatrix: Matrix;
  28483. /** @hidden */
  28484. _postProcesses: Nullable<PostProcess>[];
  28485. /** @hidden */
  28486. _activeMeshes: SmartArray<AbstractMesh>;
  28487. protected _globalPosition: Vector3;
  28488. /** @hidden */
  28489. _computedViewMatrix: Matrix;
  28490. private _doNotComputeProjectionMatrix;
  28491. private _transformMatrix;
  28492. private _frustumPlanes;
  28493. private _refreshFrustumPlanes;
  28494. private _storedFov;
  28495. private _stateStored;
  28496. /**
  28497. * Instantiates a new camera object.
  28498. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28499. * @see http://doc.babylonjs.com/features/cameras
  28500. * @param name Defines the name of the camera in the scene
  28501. * @param position Defines the position of the camera
  28502. * @param scene Defines the scene the camera belongs too
  28503. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28504. */
  28505. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28506. /**
  28507. * Store current camera state (fov, position, etc..)
  28508. * @returns the camera
  28509. */
  28510. storeState(): Camera;
  28511. /**
  28512. * Restores the camera state values if it has been stored. You must call storeState() first
  28513. */
  28514. protected _restoreStateValues(): boolean;
  28515. /**
  28516. * Restored camera state. You must call storeState() first.
  28517. * @returns true if restored and false otherwise
  28518. */
  28519. restoreState(): boolean;
  28520. /**
  28521. * Gets the class name of the camera.
  28522. * @returns the class name
  28523. */
  28524. getClassName(): string;
  28525. /** @hidden */
  28526. readonly _isCamera: boolean;
  28527. /**
  28528. * Gets a string representation of the camera useful for debug purpose.
  28529. * @param fullDetails Defines that a more verboe level of logging is required
  28530. * @returns the string representation
  28531. */
  28532. toString(fullDetails?: boolean): string;
  28533. /**
  28534. * Gets the current world space position of the camera.
  28535. */
  28536. get globalPosition(): Vector3;
  28537. /**
  28538. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28539. * @returns the active meshe list
  28540. */
  28541. getActiveMeshes(): SmartArray<AbstractMesh>;
  28542. /**
  28543. * Check whether a mesh is part of the current active mesh list of the camera
  28544. * @param mesh Defines the mesh to check
  28545. * @returns true if active, false otherwise
  28546. */
  28547. isActiveMesh(mesh: Mesh): boolean;
  28548. /**
  28549. * Is this camera ready to be used/rendered
  28550. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28551. * @return true if the camera is ready
  28552. */
  28553. isReady(completeCheck?: boolean): boolean;
  28554. /** @hidden */
  28555. _initCache(): void;
  28556. /** @hidden */
  28557. _updateCache(ignoreParentClass?: boolean): void;
  28558. /** @hidden */
  28559. _isSynchronized(): boolean;
  28560. /** @hidden */
  28561. _isSynchronizedViewMatrix(): boolean;
  28562. /** @hidden */
  28563. _isSynchronizedProjectionMatrix(): boolean;
  28564. /**
  28565. * Attach the input controls to a specific dom element to get the input from.
  28566. * @param element Defines the element the controls should be listened from
  28567. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28568. */
  28569. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28570. /**
  28571. * Detach the current controls from the specified dom element.
  28572. * @param element Defines the element to stop listening the inputs from
  28573. */
  28574. detachControl(element: HTMLElement): void;
  28575. /**
  28576. * Update the camera state according to the different inputs gathered during the frame.
  28577. */
  28578. update(): void;
  28579. /** @hidden */
  28580. _checkInputs(): void;
  28581. /** @hidden */
  28582. get rigCameras(): Camera[];
  28583. /**
  28584. * Gets the post process used by the rig cameras
  28585. */
  28586. get rigPostProcess(): Nullable<PostProcess>;
  28587. /**
  28588. * Internal, gets the first post proces.
  28589. * @returns the first post process to be run on this camera.
  28590. */
  28591. _getFirstPostProcess(): Nullable<PostProcess>;
  28592. private _cascadePostProcessesToRigCams;
  28593. /**
  28594. * Attach a post process to the camera.
  28595. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28596. * @param postProcess The post process to attach to the camera
  28597. * @param insertAt The position of the post process in case several of them are in use in the scene
  28598. * @returns the position the post process has been inserted at
  28599. */
  28600. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28601. /**
  28602. * Detach a post process to the camera.
  28603. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28604. * @param postProcess The post process to detach from the camera
  28605. */
  28606. detachPostProcess(postProcess: PostProcess): void;
  28607. /**
  28608. * Gets the current world matrix of the camera
  28609. */
  28610. getWorldMatrix(): Matrix;
  28611. /** @hidden */
  28612. _getViewMatrix(): Matrix;
  28613. /**
  28614. * Gets the current view matrix of the camera.
  28615. * @param force forces the camera to recompute the matrix without looking at the cached state
  28616. * @returns the view matrix
  28617. */
  28618. getViewMatrix(force?: boolean): Matrix;
  28619. /**
  28620. * Freeze the projection matrix.
  28621. * It will prevent the cache check of the camera projection compute and can speed up perf
  28622. * if no parameter of the camera are meant to change
  28623. * @param projection Defines manually a projection if necessary
  28624. */
  28625. freezeProjectionMatrix(projection?: Matrix): void;
  28626. /**
  28627. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28628. */
  28629. unfreezeProjectionMatrix(): void;
  28630. /**
  28631. * Gets the current projection matrix of the camera.
  28632. * @param force forces the camera to recompute the matrix without looking at the cached state
  28633. * @returns the projection matrix
  28634. */
  28635. getProjectionMatrix(force?: boolean): Matrix;
  28636. /**
  28637. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28638. * @returns a Matrix
  28639. */
  28640. getTransformationMatrix(): Matrix;
  28641. private _updateFrustumPlanes;
  28642. /**
  28643. * Checks if a cullable object (mesh...) is in the camera frustum
  28644. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28645. * @param target The object to check
  28646. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28647. * @returns true if the object is in frustum otherwise false
  28648. */
  28649. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28650. /**
  28651. * Checks if a cullable object (mesh...) is in the camera frustum
  28652. * Unlike isInFrustum this cheks the full bounding box
  28653. * @param target The object to check
  28654. * @returns true if the object is in frustum otherwise false
  28655. */
  28656. isCompletelyInFrustum(target: ICullable): boolean;
  28657. /**
  28658. * Gets a ray in the forward direction from the camera.
  28659. * @param length Defines the length of the ray to create
  28660. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28661. * @param origin Defines the start point of the ray which defaults to the camera position
  28662. * @returns the forward ray
  28663. */
  28664. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28665. /**
  28666. * Releases resources associated with this node.
  28667. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28668. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28669. */
  28670. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28671. /** @hidden */
  28672. _isLeftCamera: boolean;
  28673. /**
  28674. * Gets the left camera of a rig setup in case of Rigged Camera
  28675. */
  28676. get isLeftCamera(): boolean;
  28677. /** @hidden */
  28678. _isRightCamera: boolean;
  28679. /**
  28680. * Gets the right camera of a rig setup in case of Rigged Camera
  28681. */
  28682. get isRightCamera(): boolean;
  28683. /**
  28684. * Gets the left camera of a rig setup in case of Rigged Camera
  28685. */
  28686. get leftCamera(): Nullable<FreeCamera>;
  28687. /**
  28688. * Gets the right camera of a rig setup in case of Rigged Camera
  28689. */
  28690. get rightCamera(): Nullable<FreeCamera>;
  28691. /**
  28692. * Gets the left camera target of a rig setup in case of Rigged Camera
  28693. * @returns the target position
  28694. */
  28695. getLeftTarget(): Nullable<Vector3>;
  28696. /**
  28697. * Gets the right camera target of a rig setup in case of Rigged Camera
  28698. * @returns the target position
  28699. */
  28700. getRightTarget(): Nullable<Vector3>;
  28701. /**
  28702. * @hidden
  28703. */
  28704. setCameraRigMode(mode: number, rigParams: any): void;
  28705. /** @hidden */
  28706. static _setStereoscopicRigMode(camera: Camera): void;
  28707. /** @hidden */
  28708. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28709. /** @hidden */
  28710. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28711. /** @hidden */
  28712. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28713. /** @hidden */
  28714. _getVRProjectionMatrix(): Matrix;
  28715. protected _updateCameraRotationMatrix(): void;
  28716. protected _updateWebVRCameraRotationMatrix(): void;
  28717. /**
  28718. * This function MUST be overwritten by the different WebVR cameras available.
  28719. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28720. * @hidden
  28721. */
  28722. _getWebVRProjectionMatrix(): Matrix;
  28723. /**
  28724. * This function MUST be overwritten by the different WebVR cameras available.
  28725. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28726. * @hidden
  28727. */
  28728. _getWebVRViewMatrix(): Matrix;
  28729. /** @hidden */
  28730. setCameraRigParameter(name: string, value: any): void;
  28731. /**
  28732. * needs to be overridden by children so sub has required properties to be copied
  28733. * @hidden
  28734. */
  28735. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28736. /**
  28737. * May need to be overridden by children
  28738. * @hidden
  28739. */
  28740. _updateRigCameras(): void;
  28741. /** @hidden */
  28742. _setupInputs(): void;
  28743. /**
  28744. * Serialiaze the camera setup to a json represention
  28745. * @returns the JSON representation
  28746. */
  28747. serialize(): any;
  28748. /**
  28749. * Clones the current camera.
  28750. * @param name The cloned camera name
  28751. * @returns the cloned camera
  28752. */
  28753. clone(name: string): Camera;
  28754. /**
  28755. * Gets the direction of the camera relative to a given local axis.
  28756. * @param localAxis Defines the reference axis to provide a relative direction.
  28757. * @return the direction
  28758. */
  28759. getDirection(localAxis: Vector3): Vector3;
  28760. /**
  28761. * Returns the current camera absolute rotation
  28762. */
  28763. get absoluteRotation(): Quaternion;
  28764. /**
  28765. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28766. * @param localAxis Defines the reference axis to provide a relative direction.
  28767. * @param result Defines the vector to store the result in
  28768. */
  28769. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28770. /**
  28771. * Gets a camera constructor for a given camera type
  28772. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28773. * @param name The name of the camera the result will be able to instantiate
  28774. * @param scene The scene the result will construct the camera in
  28775. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28776. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28777. * @returns a factory method to construc the camera
  28778. */
  28779. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28780. /**
  28781. * Compute the world matrix of the camera.
  28782. * @returns the camera world matrix
  28783. */
  28784. computeWorldMatrix(): Matrix;
  28785. /**
  28786. * Parse a JSON and creates the camera from the parsed information
  28787. * @param parsedCamera The JSON to parse
  28788. * @param scene The scene to instantiate the camera in
  28789. * @returns the newly constructed camera
  28790. */
  28791. static Parse(parsedCamera: any, scene: Scene): Camera;
  28792. }
  28793. }
  28794. declare module BABYLON {
  28795. /**
  28796. * Class containing static functions to help procedurally build meshes
  28797. */
  28798. export class DiscBuilder {
  28799. /**
  28800. * Creates a plane polygonal mesh. By default, this is a disc
  28801. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28802. * * 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
  28803. * * 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
  28804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28805. * * 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
  28806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28807. * @param name defines the name of the mesh
  28808. * @param options defines the options used to create the mesh
  28809. * @param scene defines the hosting scene
  28810. * @returns the plane polygonal mesh
  28811. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28812. */
  28813. static CreateDisc(name: string, options: {
  28814. radius?: number;
  28815. tessellation?: number;
  28816. arc?: number;
  28817. updatable?: boolean;
  28818. sideOrientation?: number;
  28819. frontUVs?: Vector4;
  28820. backUVs?: Vector4;
  28821. }, scene?: Nullable<Scene>): Mesh;
  28822. }
  28823. }
  28824. declare module BABYLON {
  28825. /**
  28826. * Options to be used when creating a FresnelParameters.
  28827. */
  28828. export type IFresnelParametersCreationOptions = {
  28829. /**
  28830. * Define the color used on edges (grazing angle)
  28831. */
  28832. leftColor?: Color3;
  28833. /**
  28834. * Define the color used on center
  28835. */
  28836. rightColor?: Color3;
  28837. /**
  28838. * Define bias applied to computed fresnel term
  28839. */
  28840. bias?: number;
  28841. /**
  28842. * Defined the power exponent applied to fresnel term
  28843. */
  28844. power?: number;
  28845. /**
  28846. * Define if the fresnel effect is enable or not.
  28847. */
  28848. isEnabled?: boolean;
  28849. };
  28850. /**
  28851. * Serialized format for FresnelParameters.
  28852. */
  28853. export type IFresnelParametersSerialized = {
  28854. /**
  28855. * Define the color used on edges (grazing angle) [as an array]
  28856. */
  28857. leftColor: number[];
  28858. /**
  28859. * Define the color used on center [as an array]
  28860. */
  28861. rightColor: number[];
  28862. /**
  28863. * Define bias applied to computed fresnel term
  28864. */
  28865. bias: number;
  28866. /**
  28867. * Defined the power exponent applied to fresnel term
  28868. */
  28869. power?: number;
  28870. /**
  28871. * Define if the fresnel effect is enable or not.
  28872. */
  28873. isEnabled: boolean;
  28874. };
  28875. /**
  28876. * This represents all the required information to add a fresnel effect on a material:
  28877. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28878. */
  28879. export class FresnelParameters {
  28880. private _isEnabled;
  28881. /**
  28882. * Define if the fresnel effect is enable or not.
  28883. */
  28884. get isEnabled(): boolean;
  28885. set isEnabled(value: boolean);
  28886. /**
  28887. * Define the color used on edges (grazing angle)
  28888. */
  28889. leftColor: Color3;
  28890. /**
  28891. * Define the color used on center
  28892. */
  28893. rightColor: Color3;
  28894. /**
  28895. * Define bias applied to computed fresnel term
  28896. */
  28897. bias: number;
  28898. /**
  28899. * Defined the power exponent applied to fresnel term
  28900. */
  28901. power: number;
  28902. /**
  28903. * Creates a new FresnelParameters object.
  28904. *
  28905. * @param options provide your own settings to optionally to override defaults
  28906. */
  28907. constructor(options?: IFresnelParametersCreationOptions);
  28908. /**
  28909. * Clones the current fresnel and its valuues
  28910. * @returns a clone fresnel configuration
  28911. */
  28912. clone(): FresnelParameters;
  28913. /**
  28914. * Determines equality between FresnelParameters objects
  28915. * @param otherFresnelParameters defines the second operand
  28916. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  28917. */
  28918. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  28919. /**
  28920. * Serializes the current fresnel parameters to a JSON representation.
  28921. * @return the JSON serialization
  28922. */
  28923. serialize(): IFresnelParametersSerialized;
  28924. /**
  28925. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28926. * @param parsedFresnelParameters Define the JSON representation
  28927. * @returns the parsed parameters
  28928. */
  28929. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  28930. }
  28931. }
  28932. declare module BABYLON {
  28933. /**
  28934. * This groups all the flags used to control the materials channel.
  28935. */
  28936. export class MaterialFlags {
  28937. private static _DiffuseTextureEnabled;
  28938. /**
  28939. * Are diffuse textures enabled in the application.
  28940. */
  28941. static get DiffuseTextureEnabled(): boolean;
  28942. static set DiffuseTextureEnabled(value: boolean);
  28943. private static _AmbientTextureEnabled;
  28944. /**
  28945. * Are ambient textures enabled in the application.
  28946. */
  28947. static get AmbientTextureEnabled(): boolean;
  28948. static set AmbientTextureEnabled(value: boolean);
  28949. private static _OpacityTextureEnabled;
  28950. /**
  28951. * Are opacity textures enabled in the application.
  28952. */
  28953. static get OpacityTextureEnabled(): boolean;
  28954. static set OpacityTextureEnabled(value: boolean);
  28955. private static _ReflectionTextureEnabled;
  28956. /**
  28957. * Are reflection textures enabled in the application.
  28958. */
  28959. static get ReflectionTextureEnabled(): boolean;
  28960. static set ReflectionTextureEnabled(value: boolean);
  28961. private static _EmissiveTextureEnabled;
  28962. /**
  28963. * Are emissive textures enabled in the application.
  28964. */
  28965. static get EmissiveTextureEnabled(): boolean;
  28966. static set EmissiveTextureEnabled(value: boolean);
  28967. private static _SpecularTextureEnabled;
  28968. /**
  28969. * Are specular textures enabled in the application.
  28970. */
  28971. static get SpecularTextureEnabled(): boolean;
  28972. static set SpecularTextureEnabled(value: boolean);
  28973. private static _BumpTextureEnabled;
  28974. /**
  28975. * Are bump textures enabled in the application.
  28976. */
  28977. static get BumpTextureEnabled(): boolean;
  28978. static set BumpTextureEnabled(value: boolean);
  28979. private static _LightmapTextureEnabled;
  28980. /**
  28981. * Are lightmap textures enabled in the application.
  28982. */
  28983. static get LightmapTextureEnabled(): boolean;
  28984. static set LightmapTextureEnabled(value: boolean);
  28985. private static _RefractionTextureEnabled;
  28986. /**
  28987. * Are refraction textures enabled in the application.
  28988. */
  28989. static get RefractionTextureEnabled(): boolean;
  28990. static set RefractionTextureEnabled(value: boolean);
  28991. private static _ColorGradingTextureEnabled;
  28992. /**
  28993. * Are color grading textures enabled in the application.
  28994. */
  28995. static get ColorGradingTextureEnabled(): boolean;
  28996. static set ColorGradingTextureEnabled(value: boolean);
  28997. private static _FresnelEnabled;
  28998. /**
  28999. * Are fresnels enabled in the application.
  29000. */
  29001. static get FresnelEnabled(): boolean;
  29002. static set FresnelEnabled(value: boolean);
  29003. private static _ClearCoatTextureEnabled;
  29004. /**
  29005. * Are clear coat textures enabled in the application.
  29006. */
  29007. static get ClearCoatTextureEnabled(): boolean;
  29008. static set ClearCoatTextureEnabled(value: boolean);
  29009. private static _ClearCoatBumpTextureEnabled;
  29010. /**
  29011. * Are clear coat bump textures enabled in the application.
  29012. */
  29013. static get ClearCoatBumpTextureEnabled(): boolean;
  29014. static set ClearCoatBumpTextureEnabled(value: boolean);
  29015. private static _ClearCoatTintTextureEnabled;
  29016. /**
  29017. * Are clear coat tint textures enabled in the application.
  29018. */
  29019. static get ClearCoatTintTextureEnabled(): boolean;
  29020. static set ClearCoatTintTextureEnabled(value: boolean);
  29021. private static _SheenTextureEnabled;
  29022. /**
  29023. * Are sheen textures enabled in the application.
  29024. */
  29025. static get SheenTextureEnabled(): boolean;
  29026. static set SheenTextureEnabled(value: boolean);
  29027. private static _AnisotropicTextureEnabled;
  29028. /**
  29029. * Are anisotropic textures enabled in the application.
  29030. */
  29031. static get AnisotropicTextureEnabled(): boolean;
  29032. static set AnisotropicTextureEnabled(value: boolean);
  29033. private static _ThicknessTextureEnabled;
  29034. /**
  29035. * Are thickness textures enabled in the application.
  29036. */
  29037. static get ThicknessTextureEnabled(): boolean;
  29038. static set ThicknessTextureEnabled(value: boolean);
  29039. }
  29040. }
  29041. declare module BABYLON {
  29042. /** @hidden */
  29043. export var defaultFragmentDeclaration: {
  29044. name: string;
  29045. shader: string;
  29046. };
  29047. }
  29048. declare module BABYLON {
  29049. /** @hidden */
  29050. export var defaultUboDeclaration: {
  29051. name: string;
  29052. shader: string;
  29053. };
  29054. }
  29055. declare module BABYLON {
  29056. /** @hidden */
  29057. export var lightFragmentDeclaration: {
  29058. name: string;
  29059. shader: string;
  29060. };
  29061. }
  29062. declare module BABYLON {
  29063. /** @hidden */
  29064. export var lightUboDeclaration: {
  29065. name: string;
  29066. shader: string;
  29067. };
  29068. }
  29069. declare module BABYLON {
  29070. /** @hidden */
  29071. export var lightsFragmentFunctions: {
  29072. name: string;
  29073. shader: string;
  29074. };
  29075. }
  29076. declare module BABYLON {
  29077. /** @hidden */
  29078. export var shadowsFragmentFunctions: {
  29079. name: string;
  29080. shader: string;
  29081. };
  29082. }
  29083. declare module BABYLON {
  29084. /** @hidden */
  29085. export var fresnelFunction: {
  29086. name: string;
  29087. shader: string;
  29088. };
  29089. }
  29090. declare module BABYLON {
  29091. /** @hidden */
  29092. export var bumpFragmentMainFunctions: {
  29093. name: string;
  29094. shader: string;
  29095. };
  29096. }
  29097. declare module BABYLON {
  29098. /** @hidden */
  29099. export var bumpFragmentFunctions: {
  29100. name: string;
  29101. shader: string;
  29102. };
  29103. }
  29104. declare module BABYLON {
  29105. /** @hidden */
  29106. export var logDepthDeclaration: {
  29107. name: string;
  29108. shader: string;
  29109. };
  29110. }
  29111. declare module BABYLON {
  29112. /** @hidden */
  29113. export var bumpFragment: {
  29114. name: string;
  29115. shader: string;
  29116. };
  29117. }
  29118. declare module BABYLON {
  29119. /** @hidden */
  29120. export var depthPrePass: {
  29121. name: string;
  29122. shader: string;
  29123. };
  29124. }
  29125. declare module BABYLON {
  29126. /** @hidden */
  29127. export var lightFragment: {
  29128. name: string;
  29129. shader: string;
  29130. };
  29131. }
  29132. declare module BABYLON {
  29133. /** @hidden */
  29134. export var logDepthFragment: {
  29135. name: string;
  29136. shader: string;
  29137. };
  29138. }
  29139. declare module BABYLON {
  29140. /** @hidden */
  29141. export var defaultPixelShader: {
  29142. name: string;
  29143. shader: string;
  29144. };
  29145. }
  29146. declare module BABYLON {
  29147. /** @hidden */
  29148. export var defaultVertexDeclaration: {
  29149. name: string;
  29150. shader: string;
  29151. };
  29152. }
  29153. declare module BABYLON {
  29154. /** @hidden */
  29155. export var bumpVertexDeclaration: {
  29156. name: string;
  29157. shader: string;
  29158. };
  29159. }
  29160. declare module BABYLON {
  29161. /** @hidden */
  29162. export var bumpVertex: {
  29163. name: string;
  29164. shader: string;
  29165. };
  29166. }
  29167. declare module BABYLON {
  29168. /** @hidden */
  29169. export var fogVertex: {
  29170. name: string;
  29171. shader: string;
  29172. };
  29173. }
  29174. declare module BABYLON {
  29175. /** @hidden */
  29176. export var shadowsVertex: {
  29177. name: string;
  29178. shader: string;
  29179. };
  29180. }
  29181. declare module BABYLON {
  29182. /** @hidden */
  29183. export var pointCloudVertex: {
  29184. name: string;
  29185. shader: string;
  29186. };
  29187. }
  29188. declare module BABYLON {
  29189. /** @hidden */
  29190. export var logDepthVertex: {
  29191. name: string;
  29192. shader: string;
  29193. };
  29194. }
  29195. declare module BABYLON {
  29196. /** @hidden */
  29197. export var defaultVertexShader: {
  29198. name: string;
  29199. shader: string;
  29200. };
  29201. }
  29202. declare module BABYLON {
  29203. /** @hidden */
  29204. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29205. MAINUV1: boolean;
  29206. MAINUV2: boolean;
  29207. DIFFUSE: boolean;
  29208. DIFFUSEDIRECTUV: number;
  29209. AMBIENT: boolean;
  29210. AMBIENTDIRECTUV: number;
  29211. OPACITY: boolean;
  29212. OPACITYDIRECTUV: number;
  29213. OPACITYRGB: boolean;
  29214. REFLECTION: boolean;
  29215. EMISSIVE: boolean;
  29216. EMISSIVEDIRECTUV: number;
  29217. SPECULAR: boolean;
  29218. SPECULARDIRECTUV: number;
  29219. BUMP: boolean;
  29220. BUMPDIRECTUV: number;
  29221. PARALLAX: boolean;
  29222. PARALLAXOCCLUSION: boolean;
  29223. SPECULAROVERALPHA: boolean;
  29224. CLIPPLANE: boolean;
  29225. CLIPPLANE2: boolean;
  29226. CLIPPLANE3: boolean;
  29227. CLIPPLANE4: boolean;
  29228. CLIPPLANE5: boolean;
  29229. CLIPPLANE6: boolean;
  29230. ALPHATEST: boolean;
  29231. DEPTHPREPASS: boolean;
  29232. ALPHAFROMDIFFUSE: boolean;
  29233. POINTSIZE: boolean;
  29234. FOG: boolean;
  29235. SPECULARTERM: boolean;
  29236. DIFFUSEFRESNEL: boolean;
  29237. OPACITYFRESNEL: boolean;
  29238. REFLECTIONFRESNEL: boolean;
  29239. REFRACTIONFRESNEL: boolean;
  29240. EMISSIVEFRESNEL: boolean;
  29241. FRESNEL: boolean;
  29242. NORMAL: boolean;
  29243. UV1: boolean;
  29244. UV2: boolean;
  29245. VERTEXCOLOR: boolean;
  29246. VERTEXALPHA: boolean;
  29247. NUM_BONE_INFLUENCERS: number;
  29248. BonesPerMesh: number;
  29249. BONETEXTURE: boolean;
  29250. INSTANCES: boolean;
  29251. GLOSSINESS: boolean;
  29252. ROUGHNESS: boolean;
  29253. EMISSIVEASILLUMINATION: boolean;
  29254. LINKEMISSIVEWITHDIFFUSE: boolean;
  29255. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29256. LIGHTMAP: boolean;
  29257. LIGHTMAPDIRECTUV: number;
  29258. OBJECTSPACE_NORMALMAP: boolean;
  29259. USELIGHTMAPASSHADOWMAP: boolean;
  29260. REFLECTIONMAP_3D: boolean;
  29261. REFLECTIONMAP_SPHERICAL: boolean;
  29262. REFLECTIONMAP_PLANAR: boolean;
  29263. REFLECTIONMAP_CUBIC: boolean;
  29264. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29265. REFLECTIONMAP_PROJECTION: boolean;
  29266. REFLECTIONMAP_SKYBOX: boolean;
  29267. REFLECTIONMAP_EXPLICIT: boolean;
  29268. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29269. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29270. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29271. INVERTCUBICMAP: boolean;
  29272. LOGARITHMICDEPTH: boolean;
  29273. REFRACTION: boolean;
  29274. REFRACTIONMAP_3D: boolean;
  29275. REFLECTIONOVERALPHA: boolean;
  29276. TWOSIDEDLIGHTING: boolean;
  29277. SHADOWFLOAT: boolean;
  29278. MORPHTARGETS: boolean;
  29279. MORPHTARGETS_NORMAL: boolean;
  29280. MORPHTARGETS_TANGENT: boolean;
  29281. MORPHTARGETS_UV: boolean;
  29282. NUM_MORPH_INFLUENCERS: number;
  29283. NONUNIFORMSCALING: boolean;
  29284. PREMULTIPLYALPHA: boolean;
  29285. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29286. ALPHABLEND: boolean;
  29287. RGBDLIGHTMAP: boolean;
  29288. RGBDREFLECTION: boolean;
  29289. RGBDREFRACTION: boolean;
  29290. IMAGEPROCESSING: boolean;
  29291. VIGNETTE: boolean;
  29292. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29293. VIGNETTEBLENDMODEOPAQUE: boolean;
  29294. TONEMAPPING: boolean;
  29295. TONEMAPPING_ACES: boolean;
  29296. CONTRAST: boolean;
  29297. COLORCURVES: boolean;
  29298. COLORGRADING: boolean;
  29299. COLORGRADING3D: boolean;
  29300. SAMPLER3DGREENDEPTH: boolean;
  29301. SAMPLER3DBGRMAP: boolean;
  29302. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29303. MULTIVIEW: boolean;
  29304. /**
  29305. * If the reflection texture on this material is in linear color space
  29306. * @hidden
  29307. */
  29308. IS_REFLECTION_LINEAR: boolean;
  29309. /**
  29310. * If the refraction texture on this material is in linear color space
  29311. * @hidden
  29312. */
  29313. IS_REFRACTION_LINEAR: boolean;
  29314. EXPOSURE: boolean;
  29315. constructor();
  29316. setReflectionMode(modeToEnable: string): void;
  29317. }
  29318. /**
  29319. * This is the default material used in Babylon. It is the best trade off between quality
  29320. * and performances.
  29321. * @see http://doc.babylonjs.com/babylon101/materials
  29322. */
  29323. export class StandardMaterial extends PushMaterial {
  29324. private _diffuseTexture;
  29325. /**
  29326. * The basic texture of the material as viewed under a light.
  29327. */
  29328. diffuseTexture: Nullable<BaseTexture>;
  29329. private _ambientTexture;
  29330. /**
  29331. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29332. */
  29333. ambientTexture: Nullable<BaseTexture>;
  29334. private _opacityTexture;
  29335. /**
  29336. * Define the transparency of the material from a texture.
  29337. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29338. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29339. */
  29340. opacityTexture: Nullable<BaseTexture>;
  29341. private _reflectionTexture;
  29342. /**
  29343. * Define the texture used to display the reflection.
  29344. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29345. */
  29346. reflectionTexture: Nullable<BaseTexture>;
  29347. private _emissiveTexture;
  29348. /**
  29349. * Define texture of the material as if self lit.
  29350. * This will be mixed in the final result even in the absence of light.
  29351. */
  29352. emissiveTexture: Nullable<BaseTexture>;
  29353. private _specularTexture;
  29354. /**
  29355. * Define how the color and intensity of the highlight given by the light in the material.
  29356. */
  29357. specularTexture: Nullable<BaseTexture>;
  29358. private _bumpTexture;
  29359. /**
  29360. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29361. * 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.
  29362. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29363. */
  29364. bumpTexture: Nullable<BaseTexture>;
  29365. private _lightmapTexture;
  29366. /**
  29367. * Complex lighting can be computationally expensive to compute at runtime.
  29368. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29369. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29370. */
  29371. lightmapTexture: Nullable<BaseTexture>;
  29372. private _refractionTexture;
  29373. /**
  29374. * Define the texture used to display the refraction.
  29375. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29376. */
  29377. refractionTexture: Nullable<BaseTexture>;
  29378. /**
  29379. * The color of the material lit by the environmental background lighting.
  29380. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29381. */
  29382. ambientColor: Color3;
  29383. /**
  29384. * The basic color of the material as viewed under a light.
  29385. */
  29386. diffuseColor: Color3;
  29387. /**
  29388. * Define how the color and intensity of the highlight given by the light in the material.
  29389. */
  29390. specularColor: Color3;
  29391. /**
  29392. * Define the color of the material as if self lit.
  29393. * This will be mixed in the final result even in the absence of light.
  29394. */
  29395. emissiveColor: Color3;
  29396. /**
  29397. * Defines how sharp are the highlights in the material.
  29398. * The bigger the value the sharper giving a more glossy feeling to the result.
  29399. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29400. */
  29401. specularPower: number;
  29402. private _useAlphaFromDiffuseTexture;
  29403. /**
  29404. * Does the transparency come from the diffuse texture alpha channel.
  29405. */
  29406. useAlphaFromDiffuseTexture: boolean;
  29407. private _useEmissiveAsIllumination;
  29408. /**
  29409. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29410. */
  29411. useEmissiveAsIllumination: boolean;
  29412. private _linkEmissiveWithDiffuse;
  29413. /**
  29414. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29415. * the emissive level when the final color is close to one.
  29416. */
  29417. linkEmissiveWithDiffuse: boolean;
  29418. private _useSpecularOverAlpha;
  29419. /**
  29420. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29421. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29422. */
  29423. useSpecularOverAlpha: boolean;
  29424. private _useReflectionOverAlpha;
  29425. /**
  29426. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29427. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29428. */
  29429. useReflectionOverAlpha: boolean;
  29430. private _disableLighting;
  29431. /**
  29432. * Does lights from the scene impacts this material.
  29433. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29434. */
  29435. disableLighting: boolean;
  29436. private _useObjectSpaceNormalMap;
  29437. /**
  29438. * Allows using an object space normal map (instead of tangent space).
  29439. */
  29440. useObjectSpaceNormalMap: boolean;
  29441. private _useParallax;
  29442. /**
  29443. * Is parallax enabled or not.
  29444. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29445. */
  29446. useParallax: boolean;
  29447. private _useParallaxOcclusion;
  29448. /**
  29449. * Is parallax occlusion enabled or not.
  29450. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29451. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29452. */
  29453. useParallaxOcclusion: boolean;
  29454. /**
  29455. * 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.
  29456. */
  29457. parallaxScaleBias: number;
  29458. private _roughness;
  29459. /**
  29460. * Helps to define how blurry the reflections should appears in the material.
  29461. */
  29462. roughness: number;
  29463. /**
  29464. * In case of refraction, define the value of the index of refraction.
  29465. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29466. */
  29467. indexOfRefraction: number;
  29468. /**
  29469. * Invert the refraction texture alongside the y axis.
  29470. * It can be useful with procedural textures or probe for instance.
  29471. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29472. */
  29473. invertRefractionY: boolean;
  29474. /**
  29475. * Defines the alpha limits in alpha test mode.
  29476. */
  29477. alphaCutOff: number;
  29478. private _useLightmapAsShadowmap;
  29479. /**
  29480. * In case of light mapping, define whether the map contains light or shadow informations.
  29481. */
  29482. useLightmapAsShadowmap: boolean;
  29483. private _diffuseFresnelParameters;
  29484. /**
  29485. * Define the diffuse fresnel parameters of the material.
  29486. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29487. */
  29488. diffuseFresnelParameters: FresnelParameters;
  29489. private _opacityFresnelParameters;
  29490. /**
  29491. * Define the opacity fresnel parameters of the material.
  29492. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29493. */
  29494. opacityFresnelParameters: FresnelParameters;
  29495. private _reflectionFresnelParameters;
  29496. /**
  29497. * Define the reflection fresnel parameters of the material.
  29498. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29499. */
  29500. reflectionFresnelParameters: FresnelParameters;
  29501. private _refractionFresnelParameters;
  29502. /**
  29503. * Define the refraction fresnel parameters of the material.
  29504. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29505. */
  29506. refractionFresnelParameters: FresnelParameters;
  29507. private _emissiveFresnelParameters;
  29508. /**
  29509. * Define the emissive fresnel parameters of the material.
  29510. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29511. */
  29512. emissiveFresnelParameters: FresnelParameters;
  29513. private _useReflectionFresnelFromSpecular;
  29514. /**
  29515. * If true automatically deducts the fresnels values from the material specularity.
  29516. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29517. */
  29518. useReflectionFresnelFromSpecular: boolean;
  29519. private _useGlossinessFromSpecularMapAlpha;
  29520. /**
  29521. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29522. */
  29523. useGlossinessFromSpecularMapAlpha: boolean;
  29524. private _maxSimultaneousLights;
  29525. /**
  29526. * Defines the maximum number of lights that can be used in the material
  29527. */
  29528. maxSimultaneousLights: number;
  29529. private _invertNormalMapX;
  29530. /**
  29531. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29532. */
  29533. invertNormalMapX: boolean;
  29534. private _invertNormalMapY;
  29535. /**
  29536. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29537. */
  29538. invertNormalMapY: boolean;
  29539. private _twoSidedLighting;
  29540. /**
  29541. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29542. */
  29543. twoSidedLighting: boolean;
  29544. /**
  29545. * Default configuration related to image processing available in the standard Material.
  29546. */
  29547. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29548. /**
  29549. * Gets the image processing configuration used either in this material.
  29550. */
  29551. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29552. /**
  29553. * Sets the Default image processing configuration used either in the this material.
  29554. *
  29555. * If sets to null, the scene one is in use.
  29556. */
  29557. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29558. /**
  29559. * Keep track of the image processing observer to allow dispose and replace.
  29560. */
  29561. private _imageProcessingObserver;
  29562. /**
  29563. * Attaches a new image processing configuration to the Standard Material.
  29564. * @param configuration
  29565. */
  29566. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29567. /**
  29568. * Gets wether the color curves effect is enabled.
  29569. */
  29570. get cameraColorCurvesEnabled(): boolean;
  29571. /**
  29572. * Sets wether the color curves effect is enabled.
  29573. */
  29574. set cameraColorCurvesEnabled(value: boolean);
  29575. /**
  29576. * Gets wether the color grading effect is enabled.
  29577. */
  29578. get cameraColorGradingEnabled(): boolean;
  29579. /**
  29580. * Gets wether the color grading effect is enabled.
  29581. */
  29582. set cameraColorGradingEnabled(value: boolean);
  29583. /**
  29584. * Gets wether tonemapping is enabled or not.
  29585. */
  29586. get cameraToneMappingEnabled(): boolean;
  29587. /**
  29588. * Sets wether tonemapping is enabled or not
  29589. */
  29590. set cameraToneMappingEnabled(value: boolean);
  29591. /**
  29592. * The camera exposure used on this material.
  29593. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29594. * This corresponds to a photographic exposure.
  29595. */
  29596. get cameraExposure(): number;
  29597. /**
  29598. * The camera exposure used on this material.
  29599. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29600. * This corresponds to a photographic exposure.
  29601. */
  29602. set cameraExposure(value: number);
  29603. /**
  29604. * Gets The camera contrast used on this material.
  29605. */
  29606. get cameraContrast(): number;
  29607. /**
  29608. * Sets The camera contrast used on this material.
  29609. */
  29610. set cameraContrast(value: number);
  29611. /**
  29612. * Gets the Color Grading 2D Lookup Texture.
  29613. */
  29614. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29615. /**
  29616. * Sets the Color Grading 2D Lookup Texture.
  29617. */
  29618. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29619. /**
  29620. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29621. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29622. * 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;
  29623. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29624. */
  29625. get cameraColorCurves(): Nullable<ColorCurves>;
  29626. /**
  29627. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29628. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29629. * 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;
  29630. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29631. */
  29632. set cameraColorCurves(value: Nullable<ColorCurves>);
  29633. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29634. protected _worldViewProjectionMatrix: Matrix;
  29635. protected _globalAmbientColor: Color3;
  29636. protected _useLogarithmicDepth: boolean;
  29637. protected _rebuildInParallel: boolean;
  29638. /**
  29639. * Instantiates a new standard material.
  29640. * This is the default material used in Babylon. It is the best trade off between quality
  29641. * and performances.
  29642. * @see http://doc.babylonjs.com/babylon101/materials
  29643. * @param name Define the name of the material in the scene
  29644. * @param scene Define the scene the material belong to
  29645. */
  29646. constructor(name: string, scene: Scene);
  29647. /**
  29648. * Gets a boolean indicating that current material needs to register RTT
  29649. */
  29650. get hasRenderTargetTextures(): boolean;
  29651. /**
  29652. * Gets the current class name of the material e.g. "StandardMaterial"
  29653. * Mainly use in serialization.
  29654. * @returns the class name
  29655. */
  29656. getClassName(): string;
  29657. /**
  29658. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29659. * You can try switching to logarithmic depth.
  29660. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29661. */
  29662. get useLogarithmicDepth(): boolean;
  29663. set useLogarithmicDepth(value: boolean);
  29664. /**
  29665. * Specifies if the material will require alpha blending
  29666. * @returns a boolean specifying if alpha blending is needed
  29667. */
  29668. needAlphaBlending(): boolean;
  29669. /**
  29670. * Specifies if this material should be rendered in alpha test mode
  29671. * @returns a boolean specifying if an alpha test is needed.
  29672. */
  29673. needAlphaTesting(): boolean;
  29674. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29675. /**
  29676. * Get the texture used for alpha test purpose.
  29677. * @returns the diffuse texture in case of the standard material.
  29678. */
  29679. getAlphaTestTexture(): Nullable<BaseTexture>;
  29680. /**
  29681. * Get if the submesh is ready to be used and all its information available.
  29682. * Child classes can use it to update shaders
  29683. * @param mesh defines the mesh to check
  29684. * @param subMesh defines which submesh to check
  29685. * @param useInstances specifies that instances should be used
  29686. * @returns a boolean indicating that the submesh is ready or not
  29687. */
  29688. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29689. /**
  29690. * Builds the material UBO layouts.
  29691. * Used internally during the effect preparation.
  29692. */
  29693. buildUniformLayout(): void;
  29694. /**
  29695. * Unbinds the material from the mesh
  29696. */
  29697. unbind(): void;
  29698. /**
  29699. * Binds the submesh to this material by preparing the effect and shader to draw
  29700. * @param world defines the world transformation matrix
  29701. * @param mesh defines the mesh containing the submesh
  29702. * @param subMesh defines the submesh to bind the material to
  29703. */
  29704. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29705. /**
  29706. * Get the list of animatables in the material.
  29707. * @returns the list of animatables object used in the material
  29708. */
  29709. getAnimatables(): IAnimatable[];
  29710. /**
  29711. * Gets the active textures from the material
  29712. * @returns an array of textures
  29713. */
  29714. getActiveTextures(): BaseTexture[];
  29715. /**
  29716. * Specifies if the material uses a texture
  29717. * @param texture defines the texture to check against the material
  29718. * @returns a boolean specifying if the material uses the texture
  29719. */
  29720. hasTexture(texture: BaseTexture): boolean;
  29721. /**
  29722. * Disposes the material
  29723. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29724. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29725. */
  29726. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  29727. /**
  29728. * Makes a duplicate of the material, and gives it a new name
  29729. * @param name defines the new name for the duplicated material
  29730. * @returns the cloned material
  29731. */
  29732. clone(name: string): StandardMaterial;
  29733. /**
  29734. * Serializes this material in a JSON representation
  29735. * @returns the serialized material object
  29736. */
  29737. serialize(): any;
  29738. /**
  29739. * Creates a standard material from parsed material data
  29740. * @param source defines the JSON representation of the material
  29741. * @param scene defines the hosting scene
  29742. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29743. * @returns a new standard material
  29744. */
  29745. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  29746. /**
  29747. * Are diffuse textures enabled in the application.
  29748. */
  29749. static get DiffuseTextureEnabled(): boolean;
  29750. static set DiffuseTextureEnabled(value: boolean);
  29751. /**
  29752. * Are ambient textures enabled in the application.
  29753. */
  29754. static get AmbientTextureEnabled(): boolean;
  29755. static set AmbientTextureEnabled(value: boolean);
  29756. /**
  29757. * Are opacity textures enabled in the application.
  29758. */
  29759. static get OpacityTextureEnabled(): boolean;
  29760. static set OpacityTextureEnabled(value: boolean);
  29761. /**
  29762. * Are reflection textures enabled in the application.
  29763. */
  29764. static get ReflectionTextureEnabled(): boolean;
  29765. static set ReflectionTextureEnabled(value: boolean);
  29766. /**
  29767. * Are emissive textures enabled in the application.
  29768. */
  29769. static get EmissiveTextureEnabled(): boolean;
  29770. static set EmissiveTextureEnabled(value: boolean);
  29771. /**
  29772. * Are specular textures enabled in the application.
  29773. */
  29774. static get SpecularTextureEnabled(): boolean;
  29775. static set SpecularTextureEnabled(value: boolean);
  29776. /**
  29777. * Are bump textures enabled in the application.
  29778. */
  29779. static get BumpTextureEnabled(): boolean;
  29780. static set BumpTextureEnabled(value: boolean);
  29781. /**
  29782. * Are lightmap textures enabled in the application.
  29783. */
  29784. static get LightmapTextureEnabled(): boolean;
  29785. static set LightmapTextureEnabled(value: boolean);
  29786. /**
  29787. * Are refraction textures enabled in the application.
  29788. */
  29789. static get RefractionTextureEnabled(): boolean;
  29790. static set RefractionTextureEnabled(value: boolean);
  29791. /**
  29792. * Are color grading textures enabled in the application.
  29793. */
  29794. static get ColorGradingTextureEnabled(): boolean;
  29795. static set ColorGradingTextureEnabled(value: boolean);
  29796. /**
  29797. * Are fresnels enabled in the application.
  29798. */
  29799. static get FresnelEnabled(): boolean;
  29800. static set FresnelEnabled(value: boolean);
  29801. }
  29802. }
  29803. declare module BABYLON {
  29804. /**
  29805. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  29806. *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.
  29807. * The SPS is also a particle system. It provides some methods to manage the particles.
  29808. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  29809. *
  29810. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  29811. */
  29812. export class SolidParticleSystem implements IDisposable {
  29813. /**
  29814. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  29815. * Example : var p = SPS.particles[i];
  29816. */
  29817. particles: SolidParticle[];
  29818. /**
  29819. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  29820. */
  29821. nbParticles: number;
  29822. /**
  29823. * If the particles must ever face the camera (default false). Useful for planar particles.
  29824. */
  29825. billboard: boolean;
  29826. /**
  29827. * Recompute normals when adding a shape
  29828. */
  29829. recomputeNormals: boolean;
  29830. /**
  29831. * This a counter ofr your own usage. It's not set by any SPS functions.
  29832. */
  29833. counter: number;
  29834. /**
  29835. * The SPS name. This name is also given to the underlying mesh.
  29836. */
  29837. name: string;
  29838. /**
  29839. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  29840. */
  29841. mesh: Mesh;
  29842. /**
  29843. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  29844. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  29845. */
  29846. vars: any;
  29847. /**
  29848. * This array is populated when the SPS is set as 'pickable'.
  29849. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  29850. * Each element of this array is an object `{idx: int, faceId: int}`.
  29851. * `idx` is the picked particle index in the `SPS.particles` array
  29852. * `faceId` is the picked face index counted within this particle.
  29853. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  29854. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  29855. * Use the method SPS.pickedParticle(pickingInfo) instead.
  29856. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29857. */
  29858. pickedParticles: {
  29859. idx: number;
  29860. faceId: number;
  29861. }[];
  29862. /**
  29863. * This array is populated when the SPS is set as 'pickable'
  29864. * Each key of this array is a submesh index.
  29865. * Each element of this array is a second array defined like this :
  29866. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  29867. * Each element of this second array is an object `{idx: int, faceId: int}`.
  29868. * `idx` is the picked particle index in the `SPS.particles` array
  29869. * `faceId` is the picked face index counted within this particle.
  29870. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  29871. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29872. */
  29873. pickedBySubMesh: {
  29874. idx: number;
  29875. faceId: number;
  29876. }[][];
  29877. /**
  29878. * This array is populated when `enableDepthSort` is set to true.
  29879. * Each element of this array is an instance of the class DepthSortedParticle.
  29880. */
  29881. depthSortedParticles: DepthSortedParticle[];
  29882. /**
  29883. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  29884. * @hidden
  29885. */
  29886. _bSphereOnly: boolean;
  29887. /**
  29888. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  29889. * @hidden
  29890. */
  29891. _bSphereRadiusFactor: number;
  29892. private _scene;
  29893. private _positions;
  29894. private _indices;
  29895. private _normals;
  29896. private _colors;
  29897. private _uvs;
  29898. private _indices32;
  29899. private _positions32;
  29900. private _normals32;
  29901. private _fixedNormal32;
  29902. private _colors32;
  29903. private _uvs32;
  29904. private _index;
  29905. private _updatable;
  29906. private _pickable;
  29907. private _isVisibilityBoxLocked;
  29908. private _alwaysVisible;
  29909. private _depthSort;
  29910. private _expandable;
  29911. private _shapeCounter;
  29912. private _copy;
  29913. private _color;
  29914. private _computeParticleColor;
  29915. private _computeParticleTexture;
  29916. private _computeParticleRotation;
  29917. private _computeParticleVertex;
  29918. private _computeBoundingBox;
  29919. private _depthSortParticles;
  29920. private _camera;
  29921. private _mustUnrotateFixedNormals;
  29922. private _particlesIntersect;
  29923. private _needs32Bits;
  29924. private _isNotBuilt;
  29925. private _lastParticleId;
  29926. private _idxOfId;
  29927. private _multimaterialEnabled;
  29928. private _useModelMaterial;
  29929. private _indicesByMaterial;
  29930. private _materialIndexes;
  29931. private _depthSortFunction;
  29932. private _materialSortFunction;
  29933. private _materials;
  29934. private _multimaterial;
  29935. private _materialIndexesById;
  29936. private _defaultMaterial;
  29937. private _autoUpdateSubMeshes;
  29938. private _tmpVertex;
  29939. /**
  29940. * Creates a SPS (Solid Particle System) object.
  29941. * @param name (String) is the SPS name, this will be the underlying mesh name.
  29942. * @param scene (Scene) is the scene in which the SPS is added.
  29943. * @param options defines the options of the sps e.g.
  29944. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  29945. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  29946. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  29947. * * 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.
  29948. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  29949. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  29950. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  29951. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  29952. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  29953. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  29954. */
  29955. constructor(name: string, scene: Scene, options?: {
  29956. updatable?: boolean;
  29957. isPickable?: boolean;
  29958. enableDepthSort?: boolean;
  29959. particleIntersection?: boolean;
  29960. boundingSphereOnly?: boolean;
  29961. bSphereRadiusFactor?: number;
  29962. expandable?: boolean;
  29963. useModelMaterial?: boolean;
  29964. enableMultiMaterial?: boolean;
  29965. });
  29966. /**
  29967. * Builds the SPS underlying mesh. Returns a standard Mesh.
  29968. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  29969. * @returns the created mesh
  29970. */
  29971. buildMesh(): Mesh;
  29972. /**
  29973. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  29974. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  29975. * Thus the particles generated from `digest()` have their property `position` set yet.
  29976. * @param mesh ( Mesh ) is the mesh to be digested
  29977. * @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
  29978. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  29979. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  29980. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  29981. * @returns the current SPS
  29982. */
  29983. digest(mesh: Mesh, options?: {
  29984. facetNb?: number;
  29985. number?: number;
  29986. delta?: number;
  29987. storage?: [];
  29988. }): SolidParticleSystem;
  29989. /**
  29990. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  29991. * @hidden
  29992. */
  29993. private _unrotateFixedNormals;
  29994. /**
  29995. * Resets the temporary working copy particle
  29996. * @hidden
  29997. */
  29998. private _resetCopy;
  29999. /**
  30000. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30001. * @param p the current index in the positions array to be updated
  30002. * @param ind the current index in the indices array
  30003. * @param shape a Vector3 array, the shape geometry
  30004. * @param positions the positions array to be updated
  30005. * @param meshInd the shape indices array
  30006. * @param indices the indices array to be updated
  30007. * @param meshUV the shape uv array
  30008. * @param uvs the uv array to be updated
  30009. * @param meshCol the shape color array
  30010. * @param colors the color array to be updated
  30011. * @param meshNor the shape normals array
  30012. * @param normals the normals array to be updated
  30013. * @param idx the particle index
  30014. * @param idxInShape the particle index in its shape
  30015. * @param options the addShape() method passed options
  30016. * @model the particle model
  30017. * @hidden
  30018. */
  30019. private _meshBuilder;
  30020. /**
  30021. * Returns a shape Vector3 array from positions float array
  30022. * @param positions float array
  30023. * @returns a vector3 array
  30024. * @hidden
  30025. */
  30026. private _posToShape;
  30027. /**
  30028. * Returns a shapeUV array from a float uvs (array deep copy)
  30029. * @param uvs as a float array
  30030. * @returns a shapeUV array
  30031. * @hidden
  30032. */
  30033. private _uvsToShapeUV;
  30034. /**
  30035. * Adds a new particle object in the particles array
  30036. * @param idx particle index in particles array
  30037. * @param id particle id
  30038. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30039. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30040. * @param model particle ModelShape object
  30041. * @param shapeId model shape identifier
  30042. * @param idxInShape index of the particle in the current model
  30043. * @param bInfo model bounding info object
  30044. * @param storage target storage array, if any
  30045. * @hidden
  30046. */
  30047. private _addParticle;
  30048. /**
  30049. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30050. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30051. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30052. * @param nb (positive integer) the number of particles to be created from this model
  30053. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30054. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30055. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30056. * @returns the number of shapes in the system
  30057. */
  30058. addShape(mesh: Mesh, nb: number, options?: {
  30059. positionFunction?: any;
  30060. vertexFunction?: any;
  30061. storage?: [];
  30062. }): number;
  30063. /**
  30064. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30065. * @hidden
  30066. */
  30067. private _rebuildParticle;
  30068. /**
  30069. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30070. * @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.
  30071. * @returns the SPS.
  30072. */
  30073. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30074. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30075. * Returns an array with the removed particles.
  30076. * 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.
  30077. * The SPS can't be empty so at least one particle needs to remain in place.
  30078. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30079. * @param start index of the first particle to remove
  30080. * @param end index of the last particle to remove (included)
  30081. * @returns an array populated with the removed particles
  30082. */
  30083. removeParticles(start: number, end: number): SolidParticle[];
  30084. /**
  30085. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30086. * @param solidParticleArray an array populated with Solid Particles objects
  30087. * @returns the SPS
  30088. */
  30089. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30090. /**
  30091. * Creates a new particle and modifies the SPS mesh geometry :
  30092. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30093. * - calls _addParticle() to populate the particle array
  30094. * factorized code from addShape() and insertParticlesFromArray()
  30095. * @param idx particle index in the particles array
  30096. * @param i particle index in its shape
  30097. * @param modelShape particle ModelShape object
  30098. * @param shape shape vertex array
  30099. * @param meshInd shape indices array
  30100. * @param meshUV shape uv array
  30101. * @param meshCol shape color array
  30102. * @param meshNor shape normals array
  30103. * @param bbInfo shape bounding info
  30104. * @param storage target particle storage
  30105. * @options addShape() passed options
  30106. * @hidden
  30107. */
  30108. private _insertNewParticle;
  30109. /**
  30110. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30111. * This method calls `updateParticle()` for each particle of the SPS.
  30112. * For an animated SPS, it is usually called within the render loop.
  30113. * 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.
  30114. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30115. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30116. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30117. * @returns the SPS.
  30118. */
  30119. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30120. /**
  30121. * Disposes the SPS.
  30122. */
  30123. dispose(): void;
  30124. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30125. * idx is the particle index in the SPS
  30126. * faceId is the picked face index counted within this particle.
  30127. * Returns null if the pickInfo can't identify a picked particle.
  30128. * @param pickingInfo (PickingInfo object)
  30129. * @returns {idx: number, faceId: number} or null
  30130. */
  30131. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30132. idx: number;
  30133. faceId: number;
  30134. }>;
  30135. /**
  30136. * Returns a SolidParticle object from its identifier : particle.id
  30137. * @param id (integer) the particle Id
  30138. * @returns the searched particle or null if not found in the SPS.
  30139. */
  30140. getParticleById(id: number): Nullable<SolidParticle>;
  30141. /**
  30142. * Returns a new array populated with the particles having the passed shapeId.
  30143. * @param shapeId (integer) the shape identifier
  30144. * @returns a new solid particle array
  30145. */
  30146. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30147. /**
  30148. * Populates the passed array "ref" with the particles having the passed shapeId.
  30149. * @param shapeId the shape identifier
  30150. * @returns the SPS
  30151. * @param ref
  30152. */
  30153. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30154. /**
  30155. * Computes the required SubMeshes according the materials assigned to the particles.
  30156. * @returns the solid particle system.
  30157. * Does nothing if called before the SPS mesh is built.
  30158. */
  30159. computeSubMeshes(): SolidParticleSystem;
  30160. /**
  30161. * Sorts the solid particles by material when MultiMaterial is enabled.
  30162. * Updates the indices32 array.
  30163. * Updates the indicesByMaterial array.
  30164. * Updates the mesh indices array.
  30165. * @returns the SPS
  30166. * @hidden
  30167. */
  30168. private _sortParticlesByMaterial;
  30169. /**
  30170. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30171. * @hidden
  30172. */
  30173. private _setMaterialIndexesById;
  30174. /**
  30175. * Returns an array with unique values of Materials from the passed array
  30176. * @param array the material array to be checked and filtered
  30177. * @hidden
  30178. */
  30179. private _filterUniqueMaterialId;
  30180. /**
  30181. * Sets a new Standard Material as _defaultMaterial if not already set.
  30182. * @hidden
  30183. */
  30184. private _setDefaultMaterial;
  30185. /**
  30186. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30187. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30188. * @returns the SPS.
  30189. */
  30190. refreshVisibleSize(): SolidParticleSystem;
  30191. /**
  30192. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30193. * @param size the size (float) of the visibility box
  30194. * note : this doesn't lock the SPS mesh bounding box.
  30195. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30196. */
  30197. setVisibilityBox(size: number): void;
  30198. /**
  30199. * Gets whether the SPS as always visible or not
  30200. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30201. */
  30202. get isAlwaysVisible(): boolean;
  30203. /**
  30204. * Sets the SPS as always visible or not
  30205. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30206. */
  30207. set isAlwaysVisible(val: boolean);
  30208. /**
  30209. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30210. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30211. */
  30212. set isVisibilityBoxLocked(val: boolean);
  30213. /**
  30214. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30215. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30216. */
  30217. get isVisibilityBoxLocked(): boolean;
  30218. /**
  30219. * Tells to `setParticles()` to compute the particle rotations or not.
  30220. * Default value : true. The SPS is faster when it's set to false.
  30221. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30222. */
  30223. set computeParticleRotation(val: boolean);
  30224. /**
  30225. * Tells to `setParticles()` to compute the particle colors or not.
  30226. * Default value : true. The SPS is faster when it's set to false.
  30227. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30228. */
  30229. set computeParticleColor(val: boolean);
  30230. set computeParticleTexture(val: boolean);
  30231. /**
  30232. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30233. * Default value : false. The SPS is faster when it's set to false.
  30234. * Note : the particle custom vertex positions aren't stored values.
  30235. */
  30236. set computeParticleVertex(val: boolean);
  30237. /**
  30238. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30239. */
  30240. set computeBoundingBox(val: boolean);
  30241. /**
  30242. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30243. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30244. * Default : `true`
  30245. */
  30246. set depthSortParticles(val: boolean);
  30247. /**
  30248. * Gets if `setParticles()` computes the particle rotations or not.
  30249. * Default value : true. The SPS is faster when it's set to false.
  30250. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30251. */
  30252. get computeParticleRotation(): boolean;
  30253. /**
  30254. * Gets if `setParticles()` computes the particle colors or not.
  30255. * Default value : true. The SPS is faster when it's set to false.
  30256. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30257. */
  30258. get computeParticleColor(): boolean;
  30259. /**
  30260. * Gets if `setParticles()` computes the particle textures or not.
  30261. * Default value : true. The SPS is faster when it's set to false.
  30262. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30263. */
  30264. get computeParticleTexture(): boolean;
  30265. /**
  30266. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30267. * Default value : false. The SPS is faster when it's set to false.
  30268. * Note : the particle custom vertex positions aren't stored values.
  30269. */
  30270. get computeParticleVertex(): boolean;
  30271. /**
  30272. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30273. */
  30274. get computeBoundingBox(): boolean;
  30275. /**
  30276. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30277. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30278. * Default : `true`
  30279. */
  30280. get depthSortParticles(): boolean;
  30281. /**
  30282. * Gets if the SPS is created as expandable at construction time.
  30283. * Default : `false`
  30284. */
  30285. get expandable(): boolean;
  30286. /**
  30287. * Gets if the SPS supports the Multi Materials
  30288. */
  30289. get multimaterialEnabled(): boolean;
  30290. /**
  30291. * Gets if the SPS uses the model materials for its own multimaterial.
  30292. */
  30293. get useModelMaterial(): boolean;
  30294. /**
  30295. * The SPS used material array.
  30296. */
  30297. get materials(): Material[];
  30298. /**
  30299. * Sets the SPS MultiMaterial from the passed materials.
  30300. * Note : the passed array is internally copied and not used then by reference.
  30301. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30302. */
  30303. setMultiMaterial(materials: Material[]): void;
  30304. /**
  30305. * The SPS computed multimaterial object
  30306. */
  30307. get multimaterial(): MultiMaterial;
  30308. set multimaterial(mm: MultiMaterial);
  30309. /**
  30310. * If the subMeshes must be updated on the next call to setParticles()
  30311. */
  30312. get autoUpdateSubMeshes(): boolean;
  30313. set autoUpdateSubMeshes(val: boolean);
  30314. /**
  30315. * This function does nothing. It may be overwritten to set all the particle first values.
  30316. * The SPS doesn't call this function, you may have to call it by your own.
  30317. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30318. */
  30319. initParticles(): void;
  30320. /**
  30321. * This function does nothing. It may be overwritten to recycle a particle.
  30322. * The SPS doesn't call this function, you may have to call it by your own.
  30323. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30324. * @param particle The particle to recycle
  30325. * @returns the recycled particle
  30326. */
  30327. recycleParticle(particle: SolidParticle): SolidParticle;
  30328. /**
  30329. * Updates a particle : this function should be overwritten by the user.
  30330. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30331. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30332. * @example : just set a particle position or velocity and recycle conditions
  30333. * @param particle The particle to update
  30334. * @returns the updated particle
  30335. */
  30336. updateParticle(particle: SolidParticle): SolidParticle;
  30337. /**
  30338. * Updates a vertex of a particle : it can be overwritten by the user.
  30339. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30340. * @param particle the current particle
  30341. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30342. * @param pt the index of the current vertex in the particle shape
  30343. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30344. * @example : just set a vertex particle position or color
  30345. * @returns the sps
  30346. */
  30347. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30348. /**
  30349. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30350. * This does nothing and may be overwritten by the user.
  30351. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30352. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30353. * @param update the boolean update value actually passed to setParticles()
  30354. */
  30355. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30356. /**
  30357. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30358. * This will be passed three parameters.
  30359. * This does nothing and may be overwritten by the user.
  30360. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30361. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30362. * @param update the boolean update value actually passed to setParticles()
  30363. */
  30364. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30365. }
  30366. }
  30367. declare module BABYLON {
  30368. /**
  30369. * Represents one particle of a solid particle system.
  30370. */
  30371. export class SolidParticle {
  30372. /**
  30373. * particle global index
  30374. */
  30375. idx: number;
  30376. /**
  30377. * particle identifier
  30378. */
  30379. id: number;
  30380. /**
  30381. * The color of the particle
  30382. */
  30383. color: Nullable<Color4>;
  30384. /**
  30385. * The world space position of the particle.
  30386. */
  30387. position: Vector3;
  30388. /**
  30389. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30390. */
  30391. rotation: Vector3;
  30392. /**
  30393. * The world space rotation quaternion of the particle.
  30394. */
  30395. rotationQuaternion: Nullable<Quaternion>;
  30396. /**
  30397. * The scaling of the particle.
  30398. */
  30399. scaling: Vector3;
  30400. /**
  30401. * The uvs of the particle.
  30402. */
  30403. uvs: Vector4;
  30404. /**
  30405. * The current speed of the particle.
  30406. */
  30407. velocity: Vector3;
  30408. /**
  30409. * The pivot point in the particle local space.
  30410. */
  30411. pivot: Vector3;
  30412. /**
  30413. * Must the particle be translated from its pivot point in its local space ?
  30414. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30415. * Default : false
  30416. */
  30417. translateFromPivot: boolean;
  30418. /**
  30419. * Is the particle active or not ?
  30420. */
  30421. alive: boolean;
  30422. /**
  30423. * Is the particle visible or not ?
  30424. */
  30425. isVisible: boolean;
  30426. /**
  30427. * Index of this particle in the global "positions" array (Internal use)
  30428. * @hidden
  30429. */
  30430. _pos: number;
  30431. /**
  30432. * @hidden Index of this particle in the global "indices" array (Internal use)
  30433. */
  30434. _ind: number;
  30435. /**
  30436. * @hidden ModelShape of this particle (Internal use)
  30437. */
  30438. _model: ModelShape;
  30439. /**
  30440. * ModelShape id of this particle
  30441. */
  30442. shapeId: number;
  30443. /**
  30444. * Index of the particle in its shape id
  30445. */
  30446. idxInShape: number;
  30447. /**
  30448. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30449. */
  30450. _modelBoundingInfo: BoundingInfo;
  30451. /**
  30452. * @hidden Particle BoundingInfo object (Internal use)
  30453. */
  30454. _boundingInfo: BoundingInfo;
  30455. /**
  30456. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30457. */
  30458. _sps: SolidParticleSystem;
  30459. /**
  30460. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30461. */
  30462. _stillInvisible: boolean;
  30463. /**
  30464. * @hidden Last computed particle rotation matrix
  30465. */
  30466. _rotationMatrix: number[];
  30467. /**
  30468. * Parent particle Id, if any.
  30469. * Default null.
  30470. */
  30471. parentId: Nullable<number>;
  30472. /**
  30473. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30474. */
  30475. materialIndex: Nullable<number>;
  30476. /**
  30477. * Custom object or properties.
  30478. */
  30479. props: Nullable<any>;
  30480. /**
  30481. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30482. * The possible values are :
  30483. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30484. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30485. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30486. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30487. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30488. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30489. * */
  30490. cullingStrategy: number;
  30491. /**
  30492. * @hidden Internal global position in the SPS.
  30493. */
  30494. _globalPosition: Vector3;
  30495. /**
  30496. * Creates a Solid Particle object.
  30497. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30498. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30499. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30500. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30501. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30502. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30503. * @param shapeId (integer) is the model shape identifier in the SPS.
  30504. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30505. * @param sps defines the sps it is associated to
  30506. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30507. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30508. */
  30509. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30510. /**
  30511. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30512. * @param target the particle target
  30513. * @returns the current particle
  30514. */
  30515. copyToRef(target: SolidParticle): SolidParticle;
  30516. /**
  30517. * Legacy support, changed scale to scaling
  30518. */
  30519. get scale(): Vector3;
  30520. /**
  30521. * Legacy support, changed scale to scaling
  30522. */
  30523. set scale(scale: Vector3);
  30524. /**
  30525. * Legacy support, changed quaternion to rotationQuaternion
  30526. */
  30527. get quaternion(): Nullable<Quaternion>;
  30528. /**
  30529. * Legacy support, changed quaternion to rotationQuaternion
  30530. */
  30531. set quaternion(q: Nullable<Quaternion>);
  30532. /**
  30533. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30534. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30535. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30536. * @returns true if it intersects
  30537. */
  30538. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30539. /**
  30540. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30541. * A particle is in the frustum if its bounding box intersects the frustum
  30542. * @param frustumPlanes defines the frustum to test
  30543. * @returns true if the particle is in the frustum planes
  30544. */
  30545. isInFrustum(frustumPlanes: Plane[]): boolean;
  30546. /**
  30547. * get the rotation matrix of the particle
  30548. * @hidden
  30549. */
  30550. getRotationMatrix(m: Matrix): void;
  30551. }
  30552. /**
  30553. * Represents the shape of the model used by one particle of a solid particle system.
  30554. * SPS internal tool, don't use it manually.
  30555. */
  30556. export class ModelShape {
  30557. /**
  30558. * The shape id
  30559. * @hidden
  30560. */
  30561. shapeID: number;
  30562. /**
  30563. * flat array of model positions (internal use)
  30564. * @hidden
  30565. */
  30566. _shape: Vector3[];
  30567. /**
  30568. * flat array of model UVs (internal use)
  30569. * @hidden
  30570. */
  30571. _shapeUV: number[];
  30572. /**
  30573. * color array of the model
  30574. * @hidden
  30575. */
  30576. _shapeColors: number[];
  30577. /**
  30578. * indices array of the model
  30579. * @hidden
  30580. */
  30581. _indices: number[];
  30582. /**
  30583. * normals array of the model
  30584. * @hidden
  30585. */
  30586. _normals: number[];
  30587. /**
  30588. * length of the shape in the model indices array (internal use)
  30589. * @hidden
  30590. */
  30591. _indicesLength: number;
  30592. /**
  30593. * Custom position function (internal use)
  30594. * @hidden
  30595. */
  30596. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30597. /**
  30598. * Custom vertex function (internal use)
  30599. * @hidden
  30600. */
  30601. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30602. /**
  30603. * Model material (internal use)
  30604. * @hidden
  30605. */
  30606. _material: Nullable<Material>;
  30607. /**
  30608. * 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.
  30609. * SPS internal tool, don't use it manually.
  30610. * @hidden
  30611. */
  30612. 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>);
  30613. }
  30614. /**
  30615. * Represents a Depth Sorted Particle in the solid particle system.
  30616. * @hidden
  30617. */
  30618. export class DepthSortedParticle {
  30619. /**
  30620. * Particle index
  30621. */
  30622. idx: number;
  30623. /**
  30624. * Index of the particle in the "indices" array
  30625. */
  30626. ind: number;
  30627. /**
  30628. * Length of the particle shape in the "indices" array
  30629. */
  30630. indicesLength: number;
  30631. /**
  30632. * Squared distance from the particle to the camera
  30633. */
  30634. sqDistance: number;
  30635. /**
  30636. * Material index when used with MultiMaterials
  30637. */
  30638. materialIndex: number;
  30639. /**
  30640. * Creates a new sorted particle
  30641. * @param materialIndex
  30642. */
  30643. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30644. }
  30645. /**
  30646. * Represents a solid particle vertex
  30647. */
  30648. export class SolidParticleVertex {
  30649. /**
  30650. * Vertex position
  30651. */
  30652. position: Vector3;
  30653. /**
  30654. * Vertex color
  30655. */
  30656. color: Color4;
  30657. /**
  30658. * Vertex UV
  30659. */
  30660. uv: Vector2;
  30661. /**
  30662. * Creates a new solid particle vertex
  30663. */
  30664. constructor();
  30665. /** Vertex x coordinate */
  30666. get x(): number;
  30667. set x(val: number);
  30668. /** Vertex y coordinate */
  30669. get y(): number;
  30670. set y(val: number);
  30671. /** Vertex z coordinate */
  30672. get z(): number;
  30673. set z(val: number);
  30674. }
  30675. }
  30676. declare module BABYLON {
  30677. /**
  30678. * @hidden
  30679. */
  30680. export class _MeshCollisionData {
  30681. _checkCollisions: boolean;
  30682. _collisionMask: number;
  30683. _collisionGroup: number;
  30684. _surroundingMeshes: Nullable<AbstractMesh[]>;
  30685. _collider: Nullable<Collider>;
  30686. _oldPositionForCollisions: Vector3;
  30687. _diffPositionForCollisions: Vector3;
  30688. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  30689. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  30690. }
  30691. }
  30692. declare module BABYLON {
  30693. /** @hidden */
  30694. class _FacetDataStorage {
  30695. facetPositions: Vector3[];
  30696. facetNormals: Vector3[];
  30697. facetPartitioning: number[][];
  30698. facetNb: number;
  30699. partitioningSubdivisions: number;
  30700. partitioningBBoxRatio: number;
  30701. facetDataEnabled: boolean;
  30702. facetParameters: any;
  30703. bbSize: Vector3;
  30704. subDiv: {
  30705. max: number;
  30706. X: number;
  30707. Y: number;
  30708. Z: number;
  30709. };
  30710. facetDepthSort: boolean;
  30711. facetDepthSortEnabled: boolean;
  30712. depthSortedIndices: IndicesArray;
  30713. depthSortedFacets: {
  30714. ind: number;
  30715. sqDistance: number;
  30716. }[];
  30717. facetDepthSortFunction: (f1: {
  30718. ind: number;
  30719. sqDistance: number;
  30720. }, f2: {
  30721. ind: number;
  30722. sqDistance: number;
  30723. }) => number;
  30724. facetDepthSortFrom: Vector3;
  30725. facetDepthSortOrigin: Vector3;
  30726. invertedMatrix: Matrix;
  30727. }
  30728. /**
  30729. * @hidden
  30730. **/
  30731. class _InternalAbstractMeshDataInfo {
  30732. _hasVertexAlpha: boolean;
  30733. _useVertexColors: boolean;
  30734. _numBoneInfluencers: number;
  30735. _applyFog: boolean;
  30736. _receiveShadows: boolean;
  30737. _facetData: _FacetDataStorage;
  30738. _visibility: number;
  30739. _skeleton: Nullable<Skeleton>;
  30740. _layerMask: number;
  30741. _computeBonesUsingShaders: boolean;
  30742. _isActive: boolean;
  30743. _onlyForInstances: boolean;
  30744. _isActiveIntermediate: boolean;
  30745. _onlyForInstancesIntermediate: boolean;
  30746. _actAsRegularMesh: boolean;
  30747. }
  30748. /**
  30749. * Class used to store all common mesh properties
  30750. */
  30751. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  30752. /** No occlusion */
  30753. static OCCLUSION_TYPE_NONE: number;
  30754. /** Occlusion set to optimisitic */
  30755. static OCCLUSION_TYPE_OPTIMISTIC: number;
  30756. /** Occlusion set to strict */
  30757. static OCCLUSION_TYPE_STRICT: number;
  30758. /** Use an accurante occlusion algorithm */
  30759. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  30760. /** Use a conservative occlusion algorithm */
  30761. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  30762. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  30763. * Test order :
  30764. * Is the bounding sphere outside the frustum ?
  30765. * If not, are the bounding box vertices outside the frustum ?
  30766. * It not, then the cullable object is in the frustum.
  30767. */
  30768. static readonly CULLINGSTRATEGY_STANDARD: number;
  30769. /** Culling strategy : Bounding Sphere Only.
  30770. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  30771. * It's also less accurate than the standard because some not visible objects can still be selected.
  30772. * Test : is the bounding sphere outside the frustum ?
  30773. * If not, then the cullable object is in the frustum.
  30774. */
  30775. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  30776. /** Culling strategy : Optimistic Inclusion.
  30777. * This in an inclusion test first, then the standard exclusion test.
  30778. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  30779. * 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.
  30780. * Anyway, it's as accurate as the standard strategy.
  30781. * Test :
  30782. * Is the cullable object bounding sphere center in the frustum ?
  30783. * If not, apply the default culling strategy.
  30784. */
  30785. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  30786. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  30787. * This in an inclusion test first, then the bounding sphere only exclusion test.
  30788. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  30789. * 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.
  30790. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  30791. * Test :
  30792. * Is the cullable object bounding sphere center in the frustum ?
  30793. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  30794. */
  30795. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  30796. /**
  30797. * No billboard
  30798. */
  30799. static get BILLBOARDMODE_NONE(): number;
  30800. /** Billboard on X axis */
  30801. static get BILLBOARDMODE_X(): number;
  30802. /** Billboard on Y axis */
  30803. static get BILLBOARDMODE_Y(): number;
  30804. /** Billboard on Z axis */
  30805. static get BILLBOARDMODE_Z(): number;
  30806. /** Billboard on all axes */
  30807. static get BILLBOARDMODE_ALL(): number;
  30808. /** Billboard on using position instead of orientation */
  30809. static get BILLBOARDMODE_USE_POSITION(): number;
  30810. /** @hidden */
  30811. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  30812. /**
  30813. * The culling strategy to use to check whether the mesh must be rendered or not.
  30814. * This value can be changed at any time and will be used on the next render mesh selection.
  30815. * The possible values are :
  30816. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30817. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30818. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30819. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30820. * Please read each static variable documentation to get details about the culling process.
  30821. * */
  30822. cullingStrategy: number;
  30823. /**
  30824. * Gets the number of facets in the mesh
  30825. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30826. */
  30827. get facetNb(): number;
  30828. /**
  30829. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  30830. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30831. */
  30832. get partitioningSubdivisions(): number;
  30833. set partitioningSubdivisions(nb: number);
  30834. /**
  30835. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  30836. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  30837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30838. */
  30839. get partitioningBBoxRatio(): number;
  30840. set partitioningBBoxRatio(ratio: number);
  30841. /**
  30842. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  30843. * Works only for updatable meshes.
  30844. * Doesn't work with multi-materials
  30845. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30846. */
  30847. get mustDepthSortFacets(): boolean;
  30848. set mustDepthSortFacets(sort: boolean);
  30849. /**
  30850. * The location (Vector3) where the facet depth sort must be computed from.
  30851. * By default, the active camera position.
  30852. * Used only when facet depth sort is enabled
  30853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30854. */
  30855. get facetDepthSortFrom(): Vector3;
  30856. set facetDepthSortFrom(location: Vector3);
  30857. /**
  30858. * gets a boolean indicating if facetData is enabled
  30859. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30860. */
  30861. get isFacetDataEnabled(): boolean;
  30862. /** @hidden */
  30863. _updateNonUniformScalingState(value: boolean): boolean;
  30864. /**
  30865. * An event triggered when this mesh collides with another one
  30866. */
  30867. onCollideObservable: Observable<AbstractMesh>;
  30868. /** Set a function to call when this mesh collides with another one */
  30869. set onCollide(callback: () => void);
  30870. /**
  30871. * An event triggered when the collision's position changes
  30872. */
  30873. onCollisionPositionChangeObservable: Observable<Vector3>;
  30874. /** Set a function to call when the collision's position changes */
  30875. set onCollisionPositionChange(callback: () => void);
  30876. /**
  30877. * An event triggered when material is changed
  30878. */
  30879. onMaterialChangedObservable: Observable<AbstractMesh>;
  30880. /**
  30881. * Gets or sets the orientation for POV movement & rotation
  30882. */
  30883. definedFacingForward: boolean;
  30884. /** @hidden */
  30885. _occlusionQuery: Nullable<WebGLQuery>;
  30886. /** @hidden */
  30887. _renderingGroup: Nullable<RenderingGroup>;
  30888. /**
  30889. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30890. */
  30891. get visibility(): number;
  30892. /**
  30893. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30894. */
  30895. set visibility(value: number);
  30896. /** Gets or sets the alpha index used to sort transparent meshes
  30897. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  30898. */
  30899. alphaIndex: number;
  30900. /**
  30901. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  30902. */
  30903. isVisible: boolean;
  30904. /**
  30905. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  30906. */
  30907. isPickable: boolean;
  30908. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  30909. showSubMeshesBoundingBox: boolean;
  30910. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  30911. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  30912. */
  30913. isBlocker: boolean;
  30914. /**
  30915. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  30916. */
  30917. enablePointerMoveEvents: boolean;
  30918. /**
  30919. * Specifies the rendering group id for this mesh (0 by default)
  30920. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  30921. */
  30922. renderingGroupId: number;
  30923. private _material;
  30924. /** Gets or sets current material */
  30925. get material(): Nullable<Material>;
  30926. set material(value: Nullable<Material>);
  30927. /**
  30928. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  30929. * @see http://doc.babylonjs.com/babylon101/shadows
  30930. */
  30931. get receiveShadows(): boolean;
  30932. set receiveShadows(value: boolean);
  30933. /** Defines color to use when rendering outline */
  30934. outlineColor: Color3;
  30935. /** Define width to use when rendering outline */
  30936. outlineWidth: number;
  30937. /** Defines color to use when rendering overlay */
  30938. overlayColor: Color3;
  30939. /** Defines alpha to use when rendering overlay */
  30940. overlayAlpha: number;
  30941. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  30942. get hasVertexAlpha(): boolean;
  30943. set hasVertexAlpha(value: boolean);
  30944. /** 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) */
  30945. get useVertexColors(): boolean;
  30946. set useVertexColors(value: boolean);
  30947. /**
  30948. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  30949. */
  30950. get computeBonesUsingShaders(): boolean;
  30951. set computeBonesUsingShaders(value: boolean);
  30952. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  30953. get numBoneInfluencers(): number;
  30954. set numBoneInfluencers(value: number);
  30955. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  30956. get applyFog(): boolean;
  30957. set applyFog(value: boolean);
  30958. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  30959. useOctreeForRenderingSelection: boolean;
  30960. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  30961. useOctreeForPicking: boolean;
  30962. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  30963. useOctreeForCollisions: boolean;
  30964. /**
  30965. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  30966. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  30967. */
  30968. get layerMask(): number;
  30969. set layerMask(value: number);
  30970. /**
  30971. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  30972. */
  30973. alwaysSelectAsActiveMesh: boolean;
  30974. /**
  30975. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  30976. */
  30977. doNotSyncBoundingInfo: boolean;
  30978. /**
  30979. * Gets or sets the current action manager
  30980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  30981. */
  30982. actionManager: Nullable<AbstractActionManager>;
  30983. private _meshCollisionData;
  30984. /**
  30985. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  30986. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  30987. */
  30988. ellipsoid: Vector3;
  30989. /**
  30990. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  30991. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  30992. */
  30993. ellipsoidOffset: Vector3;
  30994. /**
  30995. * Gets or sets a collision mask used to mask collisions (default is -1).
  30996. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  30997. */
  30998. get collisionMask(): number;
  30999. set collisionMask(mask: number);
  31000. /**
  31001. * Gets or sets the current collision group mask (-1 by default).
  31002. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31003. */
  31004. get collisionGroup(): number;
  31005. set collisionGroup(mask: number);
  31006. /**
  31007. * Gets or sets current surrounding meshes (null by default).
  31008. *
  31009. * By default collision detection is tested against every mesh in the scene.
  31010. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31011. * meshes will be tested for the collision.
  31012. *
  31013. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31014. */
  31015. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31016. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31017. /**
  31018. * Defines edge width used when edgesRenderer is enabled
  31019. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31020. */
  31021. edgesWidth: number;
  31022. /**
  31023. * Defines edge color used when edgesRenderer is enabled
  31024. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31025. */
  31026. edgesColor: Color4;
  31027. /** @hidden */
  31028. _edgesRenderer: Nullable<IEdgesRenderer>;
  31029. /** @hidden */
  31030. _masterMesh: Nullable<AbstractMesh>;
  31031. /** @hidden */
  31032. _boundingInfo: Nullable<BoundingInfo>;
  31033. /** @hidden */
  31034. _renderId: number;
  31035. /**
  31036. * Gets or sets the list of subMeshes
  31037. * @see http://doc.babylonjs.com/how_to/multi_materials
  31038. */
  31039. subMeshes: SubMesh[];
  31040. /** @hidden */
  31041. _intersectionsInProgress: AbstractMesh[];
  31042. /** @hidden */
  31043. _unIndexed: boolean;
  31044. /** @hidden */
  31045. _lightSources: Light[];
  31046. /** Gets the list of lights affecting that mesh */
  31047. get lightSources(): Light[];
  31048. /** @hidden */
  31049. get _positions(): Nullable<Vector3[]>;
  31050. /** @hidden */
  31051. _waitingData: {
  31052. lods: Nullable<any>;
  31053. actions: Nullable<any>;
  31054. freezeWorldMatrix: Nullable<boolean>;
  31055. };
  31056. /** @hidden */
  31057. _bonesTransformMatrices: Nullable<Float32Array>;
  31058. /** @hidden */
  31059. _transformMatrixTexture: Nullable<RawTexture>;
  31060. /**
  31061. * Gets or sets a skeleton to apply skining transformations
  31062. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31063. */
  31064. set skeleton(value: Nullable<Skeleton>);
  31065. get skeleton(): Nullable<Skeleton>;
  31066. /**
  31067. * An event triggered when the mesh is rebuilt.
  31068. */
  31069. onRebuildObservable: Observable<AbstractMesh>;
  31070. /**
  31071. * Creates a new AbstractMesh
  31072. * @param name defines the name of the mesh
  31073. * @param scene defines the hosting scene
  31074. */
  31075. constructor(name: string, scene?: Nullable<Scene>);
  31076. /**
  31077. * Returns the string "AbstractMesh"
  31078. * @returns "AbstractMesh"
  31079. */
  31080. getClassName(): string;
  31081. /**
  31082. * Gets a string representation of the current mesh
  31083. * @param fullDetails defines a boolean indicating if full details must be included
  31084. * @returns a string representation of the current mesh
  31085. */
  31086. toString(fullDetails?: boolean): string;
  31087. /**
  31088. * @hidden
  31089. */
  31090. protected _getEffectiveParent(): Nullable<Node>;
  31091. /** @hidden */
  31092. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31093. /** @hidden */
  31094. _rebuild(): void;
  31095. /** @hidden */
  31096. _resyncLightSources(): void;
  31097. /** @hidden */
  31098. _resyncLightSource(light: Light): void;
  31099. /** @hidden */
  31100. _unBindEffect(): void;
  31101. /** @hidden */
  31102. _removeLightSource(light: Light, dispose: boolean): void;
  31103. private _markSubMeshesAsDirty;
  31104. /** @hidden */
  31105. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31106. /** @hidden */
  31107. _markSubMeshesAsAttributesDirty(): void;
  31108. /** @hidden */
  31109. _markSubMeshesAsMiscDirty(): void;
  31110. /**
  31111. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31112. */
  31113. get scaling(): Vector3;
  31114. set scaling(newScaling: Vector3);
  31115. /**
  31116. * Returns true if the mesh is blocked. Implemented by child classes
  31117. */
  31118. get isBlocked(): boolean;
  31119. /**
  31120. * Returns the mesh itself by default. Implemented by child classes
  31121. * @param camera defines the camera to use to pick the right LOD level
  31122. * @returns the currentAbstractMesh
  31123. */
  31124. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31125. /**
  31126. * Returns 0 by default. Implemented by child classes
  31127. * @returns an integer
  31128. */
  31129. getTotalVertices(): number;
  31130. /**
  31131. * Returns a positive integer : the total number of indices in this mesh geometry.
  31132. * @returns the numner of indices or zero if the mesh has no geometry.
  31133. */
  31134. getTotalIndices(): number;
  31135. /**
  31136. * Returns null by default. Implemented by child classes
  31137. * @returns null
  31138. */
  31139. getIndices(): Nullable<IndicesArray>;
  31140. /**
  31141. * Returns the array of the requested vertex data kind. Implemented by child classes
  31142. * @param kind defines the vertex data kind to use
  31143. * @returns null
  31144. */
  31145. getVerticesData(kind: string): Nullable<FloatArray>;
  31146. /**
  31147. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31148. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31149. * Note that a new underlying VertexBuffer object is created each call.
  31150. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31151. * @param kind defines vertex data kind:
  31152. * * VertexBuffer.PositionKind
  31153. * * VertexBuffer.UVKind
  31154. * * VertexBuffer.UV2Kind
  31155. * * VertexBuffer.UV3Kind
  31156. * * VertexBuffer.UV4Kind
  31157. * * VertexBuffer.UV5Kind
  31158. * * VertexBuffer.UV6Kind
  31159. * * VertexBuffer.ColorKind
  31160. * * VertexBuffer.MatricesIndicesKind
  31161. * * VertexBuffer.MatricesIndicesExtraKind
  31162. * * VertexBuffer.MatricesWeightsKind
  31163. * * VertexBuffer.MatricesWeightsExtraKind
  31164. * @param data defines the data source
  31165. * @param updatable defines if the data must be flagged as updatable (or static)
  31166. * @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
  31167. * @returns the current mesh
  31168. */
  31169. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31170. /**
  31171. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31172. * If the mesh has no geometry, it is simply returned as it is.
  31173. * @param kind defines vertex data kind:
  31174. * * VertexBuffer.PositionKind
  31175. * * VertexBuffer.UVKind
  31176. * * VertexBuffer.UV2Kind
  31177. * * VertexBuffer.UV3Kind
  31178. * * VertexBuffer.UV4Kind
  31179. * * VertexBuffer.UV5Kind
  31180. * * VertexBuffer.UV6Kind
  31181. * * VertexBuffer.ColorKind
  31182. * * VertexBuffer.MatricesIndicesKind
  31183. * * VertexBuffer.MatricesIndicesExtraKind
  31184. * * VertexBuffer.MatricesWeightsKind
  31185. * * VertexBuffer.MatricesWeightsExtraKind
  31186. * @param data defines the data source
  31187. * @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
  31188. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31189. * @returns the current mesh
  31190. */
  31191. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31192. /**
  31193. * Sets the mesh indices,
  31194. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31195. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31196. * @param totalVertices Defines the total number of vertices
  31197. * @returns the current mesh
  31198. */
  31199. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31200. /**
  31201. * Gets a boolean indicating if specific vertex data is present
  31202. * @param kind defines the vertex data kind to use
  31203. * @returns true is data kind is present
  31204. */
  31205. isVerticesDataPresent(kind: string): boolean;
  31206. /**
  31207. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31208. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31209. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31210. * @returns a BoundingInfo
  31211. */
  31212. getBoundingInfo(): BoundingInfo;
  31213. /**
  31214. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31215. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31216. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31217. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31218. * @returns the current mesh
  31219. */
  31220. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31221. /**
  31222. * Overwrite the current bounding info
  31223. * @param boundingInfo defines the new bounding info
  31224. * @returns the current mesh
  31225. */
  31226. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31227. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31228. get useBones(): boolean;
  31229. /** @hidden */
  31230. _preActivate(): void;
  31231. /** @hidden */
  31232. _preActivateForIntermediateRendering(renderId: number): void;
  31233. /** @hidden */
  31234. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31235. /** @hidden */
  31236. _postActivate(): void;
  31237. /** @hidden */
  31238. _freeze(): void;
  31239. /** @hidden */
  31240. _unFreeze(): void;
  31241. /**
  31242. * Gets the current world matrix
  31243. * @returns a Matrix
  31244. */
  31245. getWorldMatrix(): Matrix;
  31246. /** @hidden */
  31247. _getWorldMatrixDeterminant(): number;
  31248. /**
  31249. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31250. */
  31251. get isAnInstance(): boolean;
  31252. /**
  31253. * Gets a boolean indicating if this mesh has instances
  31254. */
  31255. get hasInstances(): boolean;
  31256. /**
  31257. * Perform relative position change from the point of view of behind the front of the mesh.
  31258. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31259. * Supports definition of mesh facing forward or backward
  31260. * @param amountRight defines the distance on the right axis
  31261. * @param amountUp defines the distance on the up axis
  31262. * @param amountForward defines the distance on the forward axis
  31263. * @returns the current mesh
  31264. */
  31265. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31266. /**
  31267. * Calculate relative position change from the point of view of behind the front of the mesh.
  31268. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31269. * Supports definition of mesh facing forward or backward
  31270. * @param amountRight defines the distance on the right axis
  31271. * @param amountUp defines the distance on the up axis
  31272. * @param amountForward defines the distance on the forward axis
  31273. * @returns the new displacement vector
  31274. */
  31275. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31276. /**
  31277. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31278. * Supports definition of mesh facing forward or backward
  31279. * @param flipBack defines the flip
  31280. * @param twirlClockwise defines the twirl
  31281. * @param tiltRight defines the tilt
  31282. * @returns the current mesh
  31283. */
  31284. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31285. /**
  31286. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31287. * Supports definition of mesh facing forward or backward.
  31288. * @param flipBack defines the flip
  31289. * @param twirlClockwise defines the twirl
  31290. * @param tiltRight defines the tilt
  31291. * @returns the new rotation vector
  31292. */
  31293. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31294. /**
  31295. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31296. * This means the mesh underlying bounding box and sphere are recomputed.
  31297. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31298. * @returns the current mesh
  31299. */
  31300. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31301. /** @hidden */
  31302. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31303. /** @hidden */
  31304. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31305. /** @hidden */
  31306. _updateBoundingInfo(): AbstractMesh;
  31307. /** @hidden */
  31308. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31309. /** @hidden */
  31310. protected _afterComputeWorldMatrix(): void;
  31311. /** @hidden */
  31312. get _effectiveMesh(): AbstractMesh;
  31313. /**
  31314. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31315. * A mesh is in the frustum if its bounding box intersects the frustum
  31316. * @param frustumPlanes defines the frustum to test
  31317. * @returns true if the mesh is in the frustum planes
  31318. */
  31319. isInFrustum(frustumPlanes: Plane[]): boolean;
  31320. /**
  31321. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31322. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31323. * @param frustumPlanes defines the frustum to test
  31324. * @returns true if the mesh is completely in the frustum planes
  31325. */
  31326. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31327. /**
  31328. * True if the mesh intersects another mesh or a SolidParticle object
  31329. * @param mesh defines a target mesh or SolidParticle to test
  31330. * @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)
  31331. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31332. * @returns true if there is an intersection
  31333. */
  31334. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31335. /**
  31336. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31337. * @param point defines the point to test
  31338. * @returns true if there is an intersection
  31339. */
  31340. intersectsPoint(point: Vector3): boolean;
  31341. /**
  31342. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31343. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31344. */
  31345. get checkCollisions(): boolean;
  31346. set checkCollisions(collisionEnabled: boolean);
  31347. /**
  31348. * Gets Collider object used to compute collisions (not physics)
  31349. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31350. */
  31351. get collider(): Nullable<Collider>;
  31352. /**
  31353. * Move the mesh using collision engine
  31354. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31355. * @param displacement defines the requested displacement vector
  31356. * @returns the current mesh
  31357. */
  31358. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31359. private _onCollisionPositionChange;
  31360. /** @hidden */
  31361. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31362. /** @hidden */
  31363. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31364. /** @hidden */
  31365. _checkCollision(collider: Collider): AbstractMesh;
  31366. /** @hidden */
  31367. _generatePointsArray(): boolean;
  31368. /**
  31369. * Checks if the passed Ray intersects with the mesh
  31370. * @param ray defines the ray to use
  31371. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31372. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31373. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31374. * @returns the picking info
  31375. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31376. */
  31377. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31378. /**
  31379. * Clones the current mesh
  31380. * @param name defines the mesh name
  31381. * @param newParent defines the new mesh parent
  31382. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31383. * @returns the new mesh
  31384. */
  31385. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31386. /**
  31387. * Disposes all the submeshes of the current meshnp
  31388. * @returns the current mesh
  31389. */
  31390. releaseSubMeshes(): AbstractMesh;
  31391. /**
  31392. * Releases resources associated with this abstract mesh.
  31393. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31394. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31395. */
  31396. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31397. /**
  31398. * Adds the passed mesh as a child to the current mesh
  31399. * @param mesh defines the child mesh
  31400. * @returns the current mesh
  31401. */
  31402. addChild(mesh: AbstractMesh): AbstractMesh;
  31403. /**
  31404. * Removes the passed mesh from the current mesh children list
  31405. * @param mesh defines the child mesh
  31406. * @returns the current mesh
  31407. */
  31408. removeChild(mesh: AbstractMesh): AbstractMesh;
  31409. /** @hidden */
  31410. private _initFacetData;
  31411. /**
  31412. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31413. * This method can be called within the render loop.
  31414. * 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
  31415. * @returns the current mesh
  31416. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31417. */
  31418. updateFacetData(): AbstractMesh;
  31419. /**
  31420. * Returns the facetLocalNormals array.
  31421. * The normals are expressed in the mesh local spac
  31422. * @returns an array of Vector3
  31423. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31424. */
  31425. getFacetLocalNormals(): Vector3[];
  31426. /**
  31427. * Returns the facetLocalPositions array.
  31428. * The facet positions are expressed in the mesh local space
  31429. * @returns an array of Vector3
  31430. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31431. */
  31432. getFacetLocalPositions(): Vector3[];
  31433. /**
  31434. * Returns the facetLocalPartioning array
  31435. * @returns an array of array of numbers
  31436. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31437. */
  31438. getFacetLocalPartitioning(): number[][];
  31439. /**
  31440. * Returns the i-th facet position in the world system.
  31441. * This method allocates a new Vector3 per call
  31442. * @param i defines the facet index
  31443. * @returns a new Vector3
  31444. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31445. */
  31446. getFacetPosition(i: number): Vector3;
  31447. /**
  31448. * Sets the reference Vector3 with the i-th facet position in the world system
  31449. * @param i defines the facet index
  31450. * @param ref defines the target vector
  31451. * @returns the current mesh
  31452. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31453. */
  31454. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31455. /**
  31456. * Returns the i-th facet normal in the world system.
  31457. * This method allocates a new Vector3 per call
  31458. * @param i defines the facet index
  31459. * @returns a new Vector3
  31460. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31461. */
  31462. getFacetNormal(i: number): Vector3;
  31463. /**
  31464. * Sets the reference Vector3 with the i-th facet normal in the world system
  31465. * @param i defines the facet index
  31466. * @param ref defines the target vector
  31467. * @returns the current mesh
  31468. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31469. */
  31470. getFacetNormalToRef(i: number, ref: Vector3): this;
  31471. /**
  31472. * 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)
  31473. * @param x defines x coordinate
  31474. * @param y defines y coordinate
  31475. * @param z defines z coordinate
  31476. * @returns the array of facet indexes
  31477. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31478. */
  31479. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31480. /**
  31481. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31482. * @param projected sets as the (x,y,z) world projection on the facet
  31483. * @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
  31484. * @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
  31485. * @param x defines x coordinate
  31486. * @param y defines y coordinate
  31487. * @param z defines z coordinate
  31488. * @returns the face index if found (or null instead)
  31489. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31490. */
  31491. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31492. /**
  31493. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31494. * @param projected sets as the (x,y,z) local projection on the facet
  31495. * @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
  31496. * @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
  31497. * @param x defines x coordinate
  31498. * @param y defines y coordinate
  31499. * @param z defines z coordinate
  31500. * @returns the face index if found (or null instead)
  31501. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31502. */
  31503. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31504. /**
  31505. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31506. * @returns the parameters
  31507. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31508. */
  31509. getFacetDataParameters(): any;
  31510. /**
  31511. * Disables the feature FacetData and frees the related memory
  31512. * @returns the current mesh
  31513. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31514. */
  31515. disableFacetData(): AbstractMesh;
  31516. /**
  31517. * Updates the AbstractMesh indices array
  31518. * @param indices defines the data source
  31519. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31520. * @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)
  31521. * @returns the current mesh
  31522. */
  31523. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31524. /**
  31525. * Creates new normals data for the mesh
  31526. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31527. * @returns the current mesh
  31528. */
  31529. createNormals(updatable: boolean): AbstractMesh;
  31530. /**
  31531. * Align the mesh with a normal
  31532. * @param normal defines the normal to use
  31533. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31534. * @returns the current mesh
  31535. */
  31536. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31537. /** @hidden */
  31538. _checkOcclusionQuery(): boolean;
  31539. /**
  31540. * Disables the mesh edge rendering mode
  31541. * @returns the currentAbstractMesh
  31542. */
  31543. disableEdgesRendering(): AbstractMesh;
  31544. /**
  31545. * Enables the edge rendering mode on the mesh.
  31546. * This mode makes the mesh edges visible
  31547. * @param epsilon defines the maximal distance between two angles to detect a face
  31548. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31549. * @returns the currentAbstractMesh
  31550. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31551. */
  31552. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31553. }
  31554. }
  31555. declare module BABYLON {
  31556. /**
  31557. * Interface used to define ActionEvent
  31558. */
  31559. export interface IActionEvent {
  31560. /** The mesh or sprite that triggered the action */
  31561. source: any;
  31562. /** The X mouse cursor position at the time of the event */
  31563. pointerX: number;
  31564. /** The Y mouse cursor position at the time of the event */
  31565. pointerY: number;
  31566. /** The mesh that is currently pointed at (can be null) */
  31567. meshUnderPointer: Nullable<AbstractMesh>;
  31568. /** the original (browser) event that triggered the ActionEvent */
  31569. sourceEvent?: any;
  31570. /** additional data for the event */
  31571. additionalData?: any;
  31572. }
  31573. /**
  31574. * ActionEvent is the event being sent when an action is triggered.
  31575. */
  31576. export class ActionEvent implements IActionEvent {
  31577. /** The mesh or sprite that triggered the action */
  31578. source: any;
  31579. /** The X mouse cursor position at the time of the event */
  31580. pointerX: number;
  31581. /** The Y mouse cursor position at the time of the event */
  31582. pointerY: number;
  31583. /** The mesh that is currently pointed at (can be null) */
  31584. meshUnderPointer: Nullable<AbstractMesh>;
  31585. /** the original (browser) event that triggered the ActionEvent */
  31586. sourceEvent?: any;
  31587. /** additional data for the event */
  31588. additionalData?: any;
  31589. /**
  31590. * Creates a new ActionEvent
  31591. * @param source The mesh or sprite that triggered the action
  31592. * @param pointerX The X mouse cursor position at the time of the event
  31593. * @param pointerY The Y mouse cursor position at the time of the event
  31594. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31595. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31596. * @param additionalData additional data for the event
  31597. */
  31598. constructor(
  31599. /** The mesh or sprite that triggered the action */
  31600. source: any,
  31601. /** The X mouse cursor position at the time of the event */
  31602. pointerX: number,
  31603. /** The Y mouse cursor position at the time of the event */
  31604. pointerY: number,
  31605. /** The mesh that is currently pointed at (can be null) */
  31606. meshUnderPointer: Nullable<AbstractMesh>,
  31607. /** the original (browser) event that triggered the ActionEvent */
  31608. sourceEvent?: any,
  31609. /** additional data for the event */
  31610. additionalData?: any);
  31611. /**
  31612. * Helper function to auto-create an ActionEvent from a source mesh.
  31613. * @param source The source mesh that triggered the event
  31614. * @param evt The original (browser) event
  31615. * @param additionalData additional data for the event
  31616. * @returns the new ActionEvent
  31617. */
  31618. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31619. /**
  31620. * Helper function to auto-create an ActionEvent from a source sprite
  31621. * @param source The source sprite that triggered the event
  31622. * @param scene Scene associated with the sprite
  31623. * @param evt The original (browser) event
  31624. * @param additionalData additional data for the event
  31625. * @returns the new ActionEvent
  31626. */
  31627. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31628. /**
  31629. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31630. * @param scene the scene where the event occurred
  31631. * @param evt The original (browser) event
  31632. * @returns the new ActionEvent
  31633. */
  31634. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31635. /**
  31636. * Helper function to auto-create an ActionEvent from a primitive
  31637. * @param prim defines the target primitive
  31638. * @param pointerPos defines the pointer position
  31639. * @param evt The original (browser) event
  31640. * @param additionalData additional data for the event
  31641. * @returns the new ActionEvent
  31642. */
  31643. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31644. }
  31645. }
  31646. declare module BABYLON {
  31647. /**
  31648. * Abstract class used to decouple action Manager from scene and meshes.
  31649. * Do not instantiate.
  31650. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31651. */
  31652. export abstract class AbstractActionManager implements IDisposable {
  31653. /** Gets the list of active triggers */
  31654. static Triggers: {
  31655. [key: string]: number;
  31656. };
  31657. /** Gets the cursor to use when hovering items */
  31658. hoverCursor: string;
  31659. /** Gets the list of actions */
  31660. actions: IAction[];
  31661. /**
  31662. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31663. */
  31664. isRecursive: boolean;
  31665. /**
  31666. * Releases all associated resources
  31667. */
  31668. abstract dispose(): void;
  31669. /**
  31670. * Does this action manager has pointer triggers
  31671. */
  31672. abstract get hasPointerTriggers(): boolean;
  31673. /**
  31674. * Does this action manager has pick triggers
  31675. */
  31676. abstract get hasPickTriggers(): boolean;
  31677. /**
  31678. * Process a specific trigger
  31679. * @param trigger defines the trigger to process
  31680. * @param evt defines the event details to be processed
  31681. */
  31682. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31683. /**
  31684. * Does this action manager handles actions of any of the given triggers
  31685. * @param triggers defines the triggers to be tested
  31686. * @return a boolean indicating whether one (or more) of the triggers is handled
  31687. */
  31688. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31689. /**
  31690. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31691. * speed.
  31692. * @param triggerA defines the trigger to be tested
  31693. * @param triggerB defines the trigger to be tested
  31694. * @return a boolean indicating whether one (or more) of the triggers is handled
  31695. */
  31696. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31697. /**
  31698. * Does this action manager handles actions of a given trigger
  31699. * @param trigger defines the trigger to be tested
  31700. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31701. * @return whether the trigger is handled
  31702. */
  31703. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31704. /**
  31705. * Serialize this manager to a JSON object
  31706. * @param name defines the property name to store this manager
  31707. * @returns a JSON representation of this manager
  31708. */
  31709. abstract serialize(name: string): any;
  31710. /**
  31711. * Registers an action to this action manager
  31712. * @param action defines the action to be registered
  31713. * @return the action amended (prepared) after registration
  31714. */
  31715. abstract registerAction(action: IAction): Nullable<IAction>;
  31716. /**
  31717. * Unregisters an action to this action manager
  31718. * @param action defines the action to be unregistered
  31719. * @return a boolean indicating whether the action has been unregistered
  31720. */
  31721. abstract unregisterAction(action: IAction): Boolean;
  31722. /**
  31723. * Does exist one action manager with at least one trigger
  31724. **/
  31725. static get HasTriggers(): boolean;
  31726. /**
  31727. * Does exist one action manager with at least one pick trigger
  31728. **/
  31729. static get HasPickTriggers(): boolean;
  31730. /**
  31731. * Does exist one action manager that handles actions of a given trigger
  31732. * @param trigger defines the trigger to be tested
  31733. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  31734. **/
  31735. static HasSpecificTrigger(trigger: number): boolean;
  31736. }
  31737. }
  31738. declare module BABYLON {
  31739. /**
  31740. * Defines how a node can be built from a string name.
  31741. */
  31742. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  31743. /**
  31744. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  31745. */
  31746. export class Node implements IBehaviorAware<Node> {
  31747. /** @hidden */
  31748. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  31749. private static _NodeConstructors;
  31750. /**
  31751. * Add a new node constructor
  31752. * @param type defines the type name of the node to construct
  31753. * @param constructorFunc defines the constructor function
  31754. */
  31755. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  31756. /**
  31757. * Returns a node constructor based on type name
  31758. * @param type defines the type name
  31759. * @param name defines the new node name
  31760. * @param scene defines the hosting scene
  31761. * @param options defines optional options to transmit to constructors
  31762. * @returns the new constructor or null
  31763. */
  31764. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  31765. /**
  31766. * Gets or sets the name of the node
  31767. */
  31768. name: string;
  31769. /**
  31770. * Gets or sets the id of the node
  31771. */
  31772. id: string;
  31773. /**
  31774. * Gets or sets the unique id of the node
  31775. */
  31776. uniqueId: number;
  31777. /**
  31778. * Gets or sets a string used to store user defined state for the node
  31779. */
  31780. state: string;
  31781. /**
  31782. * Gets or sets an object used to store user defined information for the node
  31783. */
  31784. metadata: any;
  31785. /**
  31786. * For internal use only. Please do not use.
  31787. */
  31788. reservedDataStore: any;
  31789. /**
  31790. * List of inspectable custom properties (used by the Inspector)
  31791. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  31792. */
  31793. inspectableCustomProperties: IInspectable[];
  31794. private _doNotSerialize;
  31795. /**
  31796. * Gets or sets a boolean used to define if the node must be serialized
  31797. */
  31798. get doNotSerialize(): boolean;
  31799. set doNotSerialize(value: boolean);
  31800. /** @hidden */
  31801. _isDisposed: boolean;
  31802. /**
  31803. * Gets a list of Animations associated with the node
  31804. */
  31805. animations: Animation[];
  31806. protected _ranges: {
  31807. [name: string]: Nullable<AnimationRange>;
  31808. };
  31809. /**
  31810. * Callback raised when the node is ready to be used
  31811. */
  31812. onReady: Nullable<(node: Node) => void>;
  31813. private _isEnabled;
  31814. private _isParentEnabled;
  31815. private _isReady;
  31816. /** @hidden */
  31817. _currentRenderId: number;
  31818. private _parentUpdateId;
  31819. /** @hidden */
  31820. _childUpdateId: number;
  31821. /** @hidden */
  31822. _waitingParentId: Nullable<string>;
  31823. /** @hidden */
  31824. _scene: Scene;
  31825. /** @hidden */
  31826. _cache: any;
  31827. private _parentNode;
  31828. private _children;
  31829. /** @hidden */
  31830. _worldMatrix: Matrix;
  31831. /** @hidden */
  31832. _worldMatrixDeterminant: number;
  31833. /** @hidden */
  31834. _worldMatrixDeterminantIsDirty: boolean;
  31835. /** @hidden */
  31836. private _sceneRootNodesIndex;
  31837. /**
  31838. * Gets a boolean indicating if the node has been disposed
  31839. * @returns true if the node was disposed
  31840. */
  31841. isDisposed(): boolean;
  31842. /**
  31843. * Gets or sets the parent of the node (without keeping the current position in the scene)
  31844. * @see https://doc.babylonjs.com/how_to/parenting
  31845. */
  31846. set parent(parent: Nullable<Node>);
  31847. get parent(): Nullable<Node>;
  31848. /** @hidden */
  31849. _addToSceneRootNodes(): void;
  31850. /** @hidden */
  31851. _removeFromSceneRootNodes(): void;
  31852. private _animationPropertiesOverride;
  31853. /**
  31854. * Gets or sets the animation properties override
  31855. */
  31856. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31857. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31858. /**
  31859. * Gets a string idenfifying the name of the class
  31860. * @returns "Node" string
  31861. */
  31862. getClassName(): string;
  31863. /** @hidden */
  31864. readonly _isNode: boolean;
  31865. /**
  31866. * An event triggered when the mesh is disposed
  31867. */
  31868. onDisposeObservable: Observable<Node>;
  31869. private _onDisposeObserver;
  31870. /**
  31871. * Sets a callback that will be raised when the node will be disposed
  31872. */
  31873. set onDispose(callback: () => void);
  31874. /**
  31875. * Creates a new Node
  31876. * @param name the name and id to be given to this node
  31877. * @param scene the scene this node will be added to
  31878. */
  31879. constructor(name: string, scene?: Nullable<Scene>);
  31880. /**
  31881. * Gets the scene of the node
  31882. * @returns a scene
  31883. */
  31884. getScene(): Scene;
  31885. /**
  31886. * Gets the engine of the node
  31887. * @returns a Engine
  31888. */
  31889. getEngine(): Engine;
  31890. private _behaviors;
  31891. /**
  31892. * Attach a behavior to the node
  31893. * @see http://doc.babylonjs.com/features/behaviour
  31894. * @param behavior defines the behavior to attach
  31895. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  31896. * @returns the current Node
  31897. */
  31898. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  31899. /**
  31900. * Remove an attached behavior
  31901. * @see http://doc.babylonjs.com/features/behaviour
  31902. * @param behavior defines the behavior to attach
  31903. * @returns the current Node
  31904. */
  31905. removeBehavior(behavior: Behavior<Node>): Node;
  31906. /**
  31907. * Gets the list of attached behaviors
  31908. * @see http://doc.babylonjs.com/features/behaviour
  31909. */
  31910. get behaviors(): Behavior<Node>[];
  31911. /**
  31912. * Gets an attached behavior by name
  31913. * @param name defines the name of the behavior to look for
  31914. * @see http://doc.babylonjs.com/features/behaviour
  31915. * @returns null if behavior was not found else the requested behavior
  31916. */
  31917. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  31918. /**
  31919. * Returns the latest update of the World matrix
  31920. * @returns a Matrix
  31921. */
  31922. getWorldMatrix(): Matrix;
  31923. /** @hidden */
  31924. _getWorldMatrixDeterminant(): number;
  31925. /**
  31926. * Returns directly the latest state of the mesh World matrix.
  31927. * A Matrix is returned.
  31928. */
  31929. get worldMatrixFromCache(): Matrix;
  31930. /** @hidden */
  31931. _initCache(): void;
  31932. /** @hidden */
  31933. updateCache(force?: boolean): void;
  31934. /** @hidden */
  31935. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31936. /** @hidden */
  31937. _updateCache(ignoreParentClass?: boolean): void;
  31938. /** @hidden */
  31939. _isSynchronized(): boolean;
  31940. /** @hidden */
  31941. _markSyncedWithParent(): void;
  31942. /** @hidden */
  31943. isSynchronizedWithParent(): boolean;
  31944. /** @hidden */
  31945. isSynchronized(): boolean;
  31946. /**
  31947. * Is this node ready to be used/rendered
  31948. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  31949. * @return true if the node is ready
  31950. */
  31951. isReady(completeCheck?: boolean): boolean;
  31952. /**
  31953. * Is this node enabled?
  31954. * 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
  31955. * @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
  31956. * @return whether this node (and its parent) is enabled
  31957. */
  31958. isEnabled(checkAncestors?: boolean): boolean;
  31959. /** @hidden */
  31960. protected _syncParentEnabledState(): void;
  31961. /**
  31962. * Set the enabled state of this node
  31963. * @param value defines the new enabled state
  31964. */
  31965. setEnabled(value: boolean): void;
  31966. /**
  31967. * Is this node a descendant of the given node?
  31968. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  31969. * @param ancestor defines the parent node to inspect
  31970. * @returns a boolean indicating if this node is a descendant of the given node
  31971. */
  31972. isDescendantOf(ancestor: Node): boolean;
  31973. /** @hidden */
  31974. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  31975. /**
  31976. * Will return all nodes that have this node as ascendant
  31977. * @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
  31978. * @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
  31979. * @return all children nodes of all types
  31980. */
  31981. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  31982. /**
  31983. * Get all child-meshes of this node
  31984. * @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)
  31985. * @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
  31986. * @returns an array of AbstractMesh
  31987. */
  31988. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  31989. /**
  31990. * Get all direct children of this node
  31991. * @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
  31992. * @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)
  31993. * @returns an array of Node
  31994. */
  31995. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  31996. /** @hidden */
  31997. _setReady(state: boolean): void;
  31998. /**
  31999. * Get an animation by name
  32000. * @param name defines the name of the animation to look for
  32001. * @returns null if not found else the requested animation
  32002. */
  32003. getAnimationByName(name: string): Nullable<Animation>;
  32004. /**
  32005. * Creates an animation range for this node
  32006. * @param name defines the name of the range
  32007. * @param from defines the starting key
  32008. * @param to defines the end key
  32009. */
  32010. createAnimationRange(name: string, from: number, to: number): void;
  32011. /**
  32012. * Delete a specific animation range
  32013. * @param name defines the name of the range to delete
  32014. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32015. */
  32016. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32017. /**
  32018. * Get an animation range by name
  32019. * @param name defines the name of the animation range to look for
  32020. * @returns null if not found else the requested animation range
  32021. */
  32022. getAnimationRange(name: string): Nullable<AnimationRange>;
  32023. /**
  32024. * Gets the list of all animation ranges defined on this node
  32025. * @returns an array
  32026. */
  32027. getAnimationRanges(): Nullable<AnimationRange>[];
  32028. /**
  32029. * Will start the animation sequence
  32030. * @param name defines the range frames for animation sequence
  32031. * @param loop defines if the animation should loop (false by default)
  32032. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32033. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32034. * @returns the object created for this animation. If range does not exist, it will return null
  32035. */
  32036. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32037. /**
  32038. * Serialize animation ranges into a JSON compatible object
  32039. * @returns serialization object
  32040. */
  32041. serializeAnimationRanges(): any;
  32042. /**
  32043. * Computes the world matrix of the node
  32044. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32045. * @returns the world matrix
  32046. */
  32047. computeWorldMatrix(force?: boolean): Matrix;
  32048. /**
  32049. * Releases resources associated with this node.
  32050. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32051. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32052. */
  32053. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32054. /**
  32055. * Parse animation range data from a serialization object and store them into a given node
  32056. * @param node defines where to store the animation ranges
  32057. * @param parsedNode defines the serialization object to read data from
  32058. * @param scene defines the hosting scene
  32059. */
  32060. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32061. /**
  32062. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32063. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32064. * @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
  32065. * @returns the new bounding vectors
  32066. */
  32067. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32068. min: Vector3;
  32069. max: Vector3;
  32070. };
  32071. }
  32072. }
  32073. declare module BABYLON {
  32074. /**
  32075. * @hidden
  32076. */
  32077. export class _IAnimationState {
  32078. key: number;
  32079. repeatCount: number;
  32080. workValue?: any;
  32081. loopMode?: number;
  32082. offsetValue?: any;
  32083. highLimitValue?: any;
  32084. }
  32085. /**
  32086. * Class used to store any kind of animation
  32087. */
  32088. export class Animation {
  32089. /**Name of the animation */
  32090. name: string;
  32091. /**Property to animate */
  32092. targetProperty: string;
  32093. /**The frames per second of the animation */
  32094. framePerSecond: number;
  32095. /**The data type of the animation */
  32096. dataType: number;
  32097. /**The loop mode of the animation */
  32098. loopMode?: number | undefined;
  32099. /**Specifies if blending should be enabled */
  32100. enableBlending?: boolean | undefined;
  32101. /**
  32102. * Use matrix interpolation instead of using direct key value when animating matrices
  32103. */
  32104. static AllowMatricesInterpolation: boolean;
  32105. /**
  32106. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32107. */
  32108. static AllowMatrixDecomposeForInterpolation: boolean;
  32109. /**
  32110. * Stores the key frames of the animation
  32111. */
  32112. private _keys;
  32113. /**
  32114. * Stores the easing function of the animation
  32115. */
  32116. private _easingFunction;
  32117. /**
  32118. * @hidden Internal use only
  32119. */
  32120. _runtimeAnimations: RuntimeAnimation[];
  32121. /**
  32122. * The set of event that will be linked to this animation
  32123. */
  32124. private _events;
  32125. /**
  32126. * Stores an array of target property paths
  32127. */
  32128. targetPropertyPath: string[];
  32129. /**
  32130. * Stores the blending speed of the animation
  32131. */
  32132. blendingSpeed: number;
  32133. /**
  32134. * Stores the animation ranges for the animation
  32135. */
  32136. private _ranges;
  32137. /**
  32138. * @hidden Internal use
  32139. */
  32140. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32141. /**
  32142. * Sets up an animation
  32143. * @param property The property to animate
  32144. * @param animationType The animation type to apply
  32145. * @param framePerSecond The frames per second of the animation
  32146. * @param easingFunction The easing function used in the animation
  32147. * @returns The created animation
  32148. */
  32149. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32150. /**
  32151. * Create and start an animation on a node
  32152. * @param name defines the name of the global animation that will be run on all nodes
  32153. * @param node defines the root node where the animation will take place
  32154. * @param targetProperty defines property to animate
  32155. * @param framePerSecond defines the number of frame per second yo use
  32156. * @param totalFrame defines the number of frames in total
  32157. * @param from defines the initial value
  32158. * @param to defines the final value
  32159. * @param loopMode defines which loop mode you want to use (off by default)
  32160. * @param easingFunction defines the easing function to use (linear by default)
  32161. * @param onAnimationEnd defines the callback to call when animation end
  32162. * @returns the animatable created for this animation
  32163. */
  32164. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32165. /**
  32166. * Create and start an animation on a node and its descendants
  32167. * @param name defines the name of the global animation that will be run on all nodes
  32168. * @param node defines the root node where the animation will take place
  32169. * @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
  32170. * @param targetProperty defines property to animate
  32171. * @param framePerSecond defines the number of frame per second to use
  32172. * @param totalFrame defines the number of frames in total
  32173. * @param from defines the initial value
  32174. * @param to defines the final value
  32175. * @param loopMode defines which loop mode you want to use (off by default)
  32176. * @param easingFunction defines the easing function to use (linear by default)
  32177. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32178. * @returns the list of animatables created for all nodes
  32179. * @example https://www.babylonjs-playground.com/#MH0VLI
  32180. */
  32181. 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[]>;
  32182. /**
  32183. * Creates a new animation, merges it with the existing animations and starts it
  32184. * @param name Name of the animation
  32185. * @param node Node which contains the scene that begins the animations
  32186. * @param targetProperty Specifies which property to animate
  32187. * @param framePerSecond The frames per second of the animation
  32188. * @param totalFrame The total number of frames
  32189. * @param from The frame at the beginning of the animation
  32190. * @param to The frame at the end of the animation
  32191. * @param loopMode Specifies the loop mode of the animation
  32192. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32193. * @param onAnimationEnd Callback to run once the animation is complete
  32194. * @returns Nullable animation
  32195. */
  32196. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32197. /**
  32198. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32199. * @param sourceAnimation defines the Animation containing keyframes to convert
  32200. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32201. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32202. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32203. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32204. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32205. */
  32206. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32207. /**
  32208. * Transition property of an host to the target Value
  32209. * @param property The property to transition
  32210. * @param targetValue The target Value of the property
  32211. * @param host The object where the property to animate belongs
  32212. * @param scene Scene used to run the animation
  32213. * @param frameRate Framerate (in frame/s) to use
  32214. * @param transition The transition type we want to use
  32215. * @param duration The duration of the animation, in milliseconds
  32216. * @param onAnimationEnd Callback trigger at the end of the animation
  32217. * @returns Nullable animation
  32218. */
  32219. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32220. /**
  32221. * Return the array of runtime animations currently using this animation
  32222. */
  32223. get runtimeAnimations(): RuntimeAnimation[];
  32224. /**
  32225. * Specifies if any of the runtime animations are currently running
  32226. */
  32227. get hasRunningRuntimeAnimations(): boolean;
  32228. /**
  32229. * Initializes the animation
  32230. * @param name Name of the animation
  32231. * @param targetProperty Property to animate
  32232. * @param framePerSecond The frames per second of the animation
  32233. * @param dataType The data type of the animation
  32234. * @param loopMode The loop mode of the animation
  32235. * @param enableBlending Specifies if blending should be enabled
  32236. */
  32237. constructor(
  32238. /**Name of the animation */
  32239. name: string,
  32240. /**Property to animate */
  32241. targetProperty: string,
  32242. /**The frames per second of the animation */
  32243. framePerSecond: number,
  32244. /**The data type of the animation */
  32245. dataType: number,
  32246. /**The loop mode of the animation */
  32247. loopMode?: number | undefined,
  32248. /**Specifies if blending should be enabled */
  32249. enableBlending?: boolean | undefined);
  32250. /**
  32251. * Converts the animation to a string
  32252. * @param fullDetails support for multiple levels of logging within scene loading
  32253. * @returns String form of the animation
  32254. */
  32255. toString(fullDetails?: boolean): string;
  32256. /**
  32257. * Add an event to this animation
  32258. * @param event Event to add
  32259. */
  32260. addEvent(event: AnimationEvent): void;
  32261. /**
  32262. * Remove all events found at the given frame
  32263. * @param frame The frame to remove events from
  32264. */
  32265. removeEvents(frame: number): void;
  32266. /**
  32267. * Retrieves all the events from the animation
  32268. * @returns Events from the animation
  32269. */
  32270. getEvents(): AnimationEvent[];
  32271. /**
  32272. * Creates an animation range
  32273. * @param name Name of the animation range
  32274. * @param from Starting frame of the animation range
  32275. * @param to Ending frame of the animation
  32276. */
  32277. createRange(name: string, from: number, to: number): void;
  32278. /**
  32279. * Deletes an animation range by name
  32280. * @param name Name of the animation range to delete
  32281. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32282. */
  32283. deleteRange(name: string, deleteFrames?: boolean): void;
  32284. /**
  32285. * Gets the animation range by name, or null if not defined
  32286. * @param name Name of the animation range
  32287. * @returns Nullable animation range
  32288. */
  32289. getRange(name: string): Nullable<AnimationRange>;
  32290. /**
  32291. * Gets the key frames from the animation
  32292. * @returns The key frames of the animation
  32293. */
  32294. getKeys(): Array<IAnimationKey>;
  32295. /**
  32296. * Gets the highest frame rate of the animation
  32297. * @returns Highest frame rate of the animation
  32298. */
  32299. getHighestFrame(): number;
  32300. /**
  32301. * Gets the easing function of the animation
  32302. * @returns Easing function of the animation
  32303. */
  32304. getEasingFunction(): IEasingFunction;
  32305. /**
  32306. * Sets the easing function of the animation
  32307. * @param easingFunction A custom mathematical formula for animation
  32308. */
  32309. setEasingFunction(easingFunction: EasingFunction): void;
  32310. /**
  32311. * Interpolates a scalar linearly
  32312. * @param startValue Start value of the animation curve
  32313. * @param endValue End value of the animation curve
  32314. * @param gradient Scalar amount to interpolate
  32315. * @returns Interpolated scalar value
  32316. */
  32317. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32318. /**
  32319. * Interpolates a scalar cubically
  32320. * @param startValue Start value of the animation curve
  32321. * @param outTangent End tangent of the animation
  32322. * @param endValue End value of the animation curve
  32323. * @param inTangent Start tangent of the animation curve
  32324. * @param gradient Scalar amount to interpolate
  32325. * @returns Interpolated scalar value
  32326. */
  32327. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32328. /**
  32329. * Interpolates a quaternion using a spherical linear interpolation
  32330. * @param startValue Start value of the animation curve
  32331. * @param endValue End value of the animation curve
  32332. * @param gradient Scalar amount to interpolate
  32333. * @returns Interpolated quaternion value
  32334. */
  32335. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32336. /**
  32337. * Interpolates a quaternion cubically
  32338. * @param startValue Start value of the animation curve
  32339. * @param outTangent End tangent of the animation curve
  32340. * @param endValue End value of the animation curve
  32341. * @param inTangent Start tangent of the animation curve
  32342. * @param gradient Scalar amount to interpolate
  32343. * @returns Interpolated quaternion value
  32344. */
  32345. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32346. /**
  32347. * Interpolates a Vector3 linearl
  32348. * @param startValue Start value of the animation curve
  32349. * @param endValue End value of the animation curve
  32350. * @param gradient Scalar amount to interpolate
  32351. * @returns Interpolated scalar value
  32352. */
  32353. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32354. /**
  32355. * Interpolates a Vector3 cubically
  32356. * @param startValue Start value of the animation curve
  32357. * @param outTangent End tangent of the animation
  32358. * @param endValue End value of the animation curve
  32359. * @param inTangent Start tangent of the animation curve
  32360. * @param gradient Scalar amount to interpolate
  32361. * @returns InterpolatedVector3 value
  32362. */
  32363. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32364. /**
  32365. * Interpolates a Vector2 linearly
  32366. * @param startValue Start value of the animation curve
  32367. * @param endValue End value of the animation curve
  32368. * @param gradient Scalar amount to interpolate
  32369. * @returns Interpolated Vector2 value
  32370. */
  32371. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32372. /**
  32373. * Interpolates a Vector2 cubically
  32374. * @param startValue Start value of the animation curve
  32375. * @param outTangent End tangent of the animation
  32376. * @param endValue End value of the animation curve
  32377. * @param inTangent Start tangent of the animation curve
  32378. * @param gradient Scalar amount to interpolate
  32379. * @returns Interpolated Vector2 value
  32380. */
  32381. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32382. /**
  32383. * Interpolates a size linearly
  32384. * @param startValue Start value of the animation curve
  32385. * @param endValue End value of the animation curve
  32386. * @param gradient Scalar amount to interpolate
  32387. * @returns Interpolated Size value
  32388. */
  32389. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32390. /**
  32391. * Interpolates a Color3 linearly
  32392. * @param startValue Start value of the animation curve
  32393. * @param endValue End value of the animation curve
  32394. * @param gradient Scalar amount to interpolate
  32395. * @returns Interpolated Color3 value
  32396. */
  32397. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32398. /**
  32399. * Interpolates a Color4 linearly
  32400. * @param startValue Start value of the animation curve
  32401. * @param endValue End value of the animation curve
  32402. * @param gradient Scalar amount to interpolate
  32403. * @returns Interpolated Color3 value
  32404. */
  32405. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32406. /**
  32407. * @hidden Internal use only
  32408. */
  32409. _getKeyValue(value: any): any;
  32410. /**
  32411. * @hidden Internal use only
  32412. */
  32413. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32414. /**
  32415. * Defines the function to use to interpolate matrices
  32416. * @param startValue defines the start matrix
  32417. * @param endValue defines the end matrix
  32418. * @param gradient defines the gradient between both matrices
  32419. * @param result defines an optional target matrix where to store the interpolation
  32420. * @returns the interpolated matrix
  32421. */
  32422. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32423. /**
  32424. * Makes a copy of the animation
  32425. * @returns Cloned animation
  32426. */
  32427. clone(): Animation;
  32428. /**
  32429. * Sets the key frames of the animation
  32430. * @param values The animation key frames to set
  32431. */
  32432. setKeys(values: Array<IAnimationKey>): void;
  32433. /**
  32434. * Serializes the animation to an object
  32435. * @returns Serialized object
  32436. */
  32437. serialize(): any;
  32438. /**
  32439. * Float animation type
  32440. */
  32441. static readonly ANIMATIONTYPE_FLOAT: number;
  32442. /**
  32443. * Vector3 animation type
  32444. */
  32445. static readonly ANIMATIONTYPE_VECTOR3: number;
  32446. /**
  32447. * Quaternion animation type
  32448. */
  32449. static readonly ANIMATIONTYPE_QUATERNION: number;
  32450. /**
  32451. * Matrix animation type
  32452. */
  32453. static readonly ANIMATIONTYPE_MATRIX: number;
  32454. /**
  32455. * Color3 animation type
  32456. */
  32457. static readonly ANIMATIONTYPE_COLOR3: number;
  32458. /**
  32459. * Color3 animation type
  32460. */
  32461. static readonly ANIMATIONTYPE_COLOR4: number;
  32462. /**
  32463. * Vector2 animation type
  32464. */
  32465. static readonly ANIMATIONTYPE_VECTOR2: number;
  32466. /**
  32467. * Size animation type
  32468. */
  32469. static readonly ANIMATIONTYPE_SIZE: number;
  32470. /**
  32471. * Relative Loop Mode
  32472. */
  32473. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32474. /**
  32475. * Cycle Loop Mode
  32476. */
  32477. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32478. /**
  32479. * Constant Loop Mode
  32480. */
  32481. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32482. /** @hidden */
  32483. static _UniversalLerp(left: any, right: any, amount: number): any;
  32484. /**
  32485. * Parses an animation object and creates an animation
  32486. * @param parsedAnimation Parsed animation object
  32487. * @returns Animation object
  32488. */
  32489. static Parse(parsedAnimation: any): Animation;
  32490. /**
  32491. * Appends the serialized animations from the source animations
  32492. * @param source Source containing the animations
  32493. * @param destination Target to store the animations
  32494. */
  32495. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32496. }
  32497. }
  32498. declare module BABYLON {
  32499. /**
  32500. * Interface containing an array of animations
  32501. */
  32502. export interface IAnimatable {
  32503. /**
  32504. * Array of animations
  32505. */
  32506. animations: Nullable<Array<Animation>>;
  32507. }
  32508. }
  32509. declare module BABYLON {
  32510. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32511. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32512. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32513. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32514. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32515. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32516. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32517. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32518. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32519. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32520. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32521. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32522. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32523. /**
  32524. * Decorator used to define property that can be serialized as reference to a camera
  32525. * @param sourceName defines the name of the property to decorate
  32526. */
  32527. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32528. /**
  32529. * Class used to help serialization objects
  32530. */
  32531. export class SerializationHelper {
  32532. /** @hidden */
  32533. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32534. /** @hidden */
  32535. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32536. /** @hidden */
  32537. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32538. /** @hidden */
  32539. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32540. /**
  32541. * Appends the serialized animations from the source animations
  32542. * @param source Source containing the animations
  32543. * @param destination Target to store the animations
  32544. */
  32545. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32546. /**
  32547. * Static function used to serialized a specific entity
  32548. * @param entity defines the entity to serialize
  32549. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32550. * @returns a JSON compatible object representing the serialization of the entity
  32551. */
  32552. static Serialize<T>(entity: T, serializationObject?: any): any;
  32553. /**
  32554. * Creates a new entity from a serialization data object
  32555. * @param creationFunction defines a function used to instanciated the new entity
  32556. * @param source defines the source serialization data
  32557. * @param scene defines the hosting scene
  32558. * @param rootUrl defines the root url for resources
  32559. * @returns a new entity
  32560. */
  32561. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32562. /**
  32563. * Clones an object
  32564. * @param creationFunction defines the function used to instanciate the new object
  32565. * @param source defines the source object
  32566. * @returns the cloned object
  32567. */
  32568. static Clone<T>(creationFunction: () => T, source: T): T;
  32569. /**
  32570. * Instanciates a new object based on a source one (some data will be shared between both object)
  32571. * @param creationFunction defines the function used to instanciate the new object
  32572. * @param source defines the source object
  32573. * @returns the new object
  32574. */
  32575. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32576. }
  32577. }
  32578. declare module BABYLON {
  32579. /**
  32580. * Base class of all the textures in babylon.
  32581. * It groups all the common properties the materials, post process, lights... might need
  32582. * in order to make a correct use of the texture.
  32583. */
  32584. export class BaseTexture implements IAnimatable {
  32585. /**
  32586. * Default anisotropic filtering level for the application.
  32587. * It is set to 4 as a good tradeoff between perf and quality.
  32588. */
  32589. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32590. /**
  32591. * Gets or sets the unique id of the texture
  32592. */
  32593. uniqueId: number;
  32594. /**
  32595. * Define the name of the texture.
  32596. */
  32597. name: string;
  32598. /**
  32599. * Gets or sets an object used to store user defined information.
  32600. */
  32601. metadata: any;
  32602. /**
  32603. * For internal use only. Please do not use.
  32604. */
  32605. reservedDataStore: any;
  32606. private _hasAlpha;
  32607. /**
  32608. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32609. */
  32610. set hasAlpha(value: boolean);
  32611. get hasAlpha(): boolean;
  32612. /**
  32613. * Defines if the alpha value should be determined via the rgb values.
  32614. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32615. */
  32616. getAlphaFromRGB: boolean;
  32617. /**
  32618. * Intensity or strength of the texture.
  32619. * It is commonly used by materials to fine tune the intensity of the texture
  32620. */
  32621. level: number;
  32622. /**
  32623. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32624. * This is part of the texture as textures usually maps to one uv set.
  32625. */
  32626. coordinatesIndex: number;
  32627. private _coordinatesMode;
  32628. /**
  32629. * How a texture is mapped.
  32630. *
  32631. * | Value | Type | Description |
  32632. * | ----- | ----------------------------------- | ----------- |
  32633. * | 0 | EXPLICIT_MODE | |
  32634. * | 1 | SPHERICAL_MODE | |
  32635. * | 2 | PLANAR_MODE | |
  32636. * | 3 | CUBIC_MODE | |
  32637. * | 4 | PROJECTION_MODE | |
  32638. * | 5 | SKYBOX_MODE | |
  32639. * | 6 | INVCUBIC_MODE | |
  32640. * | 7 | EQUIRECTANGULAR_MODE | |
  32641. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32642. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32643. */
  32644. set coordinatesMode(value: number);
  32645. get coordinatesMode(): number;
  32646. /**
  32647. * | Value | Type | Description |
  32648. * | ----- | ------------------ | ----------- |
  32649. * | 0 | CLAMP_ADDRESSMODE | |
  32650. * | 1 | WRAP_ADDRESSMODE | |
  32651. * | 2 | MIRROR_ADDRESSMODE | |
  32652. */
  32653. wrapU: number;
  32654. /**
  32655. * | Value | Type | Description |
  32656. * | ----- | ------------------ | ----------- |
  32657. * | 0 | CLAMP_ADDRESSMODE | |
  32658. * | 1 | WRAP_ADDRESSMODE | |
  32659. * | 2 | MIRROR_ADDRESSMODE | |
  32660. */
  32661. wrapV: number;
  32662. /**
  32663. * | Value | Type | Description |
  32664. * | ----- | ------------------ | ----------- |
  32665. * | 0 | CLAMP_ADDRESSMODE | |
  32666. * | 1 | WRAP_ADDRESSMODE | |
  32667. * | 2 | MIRROR_ADDRESSMODE | |
  32668. */
  32669. wrapR: number;
  32670. /**
  32671. * With compliant hardware and browser (supporting anisotropic filtering)
  32672. * this defines the level of anisotropic filtering in the texture.
  32673. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32674. */
  32675. anisotropicFilteringLevel: number;
  32676. /**
  32677. * Define if the texture is a cube texture or if false a 2d texture.
  32678. */
  32679. get isCube(): boolean;
  32680. set isCube(value: boolean);
  32681. /**
  32682. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32683. */
  32684. get is3D(): boolean;
  32685. set is3D(value: boolean);
  32686. /**
  32687. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32688. */
  32689. get is2DArray(): boolean;
  32690. set is2DArray(value: boolean);
  32691. /**
  32692. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  32693. * HDR texture are usually stored in linear space.
  32694. * This only impacts the PBR and Background materials
  32695. */
  32696. gammaSpace: boolean;
  32697. /**
  32698. * Gets or sets whether or not the texture contains RGBD data.
  32699. */
  32700. get isRGBD(): boolean;
  32701. set isRGBD(value: boolean);
  32702. /**
  32703. * Is Z inverted in the texture (useful in a cube texture).
  32704. */
  32705. invertZ: boolean;
  32706. /**
  32707. * Are mip maps generated for this texture or not.
  32708. */
  32709. get noMipmap(): boolean;
  32710. /**
  32711. * @hidden
  32712. */
  32713. lodLevelInAlpha: boolean;
  32714. /**
  32715. * With prefiltered texture, defined the offset used during the prefiltering steps.
  32716. */
  32717. get lodGenerationOffset(): number;
  32718. set lodGenerationOffset(value: number);
  32719. /**
  32720. * With prefiltered texture, defined the scale used during the prefiltering steps.
  32721. */
  32722. get lodGenerationScale(): number;
  32723. set lodGenerationScale(value: number);
  32724. /**
  32725. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  32726. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  32727. * average roughness values.
  32728. */
  32729. get linearSpecularLOD(): boolean;
  32730. set linearSpecularLOD(value: boolean);
  32731. /**
  32732. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  32733. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  32734. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  32735. */
  32736. get irradianceTexture(): Nullable<BaseTexture>;
  32737. set irradianceTexture(value: Nullable<BaseTexture>);
  32738. /**
  32739. * Define if the texture is a render target.
  32740. */
  32741. isRenderTarget: boolean;
  32742. /**
  32743. * Define the unique id of the texture in the scene.
  32744. */
  32745. get uid(): string;
  32746. /**
  32747. * Return a string representation of the texture.
  32748. * @returns the texture as a string
  32749. */
  32750. toString(): string;
  32751. /**
  32752. * Get the class name of the texture.
  32753. * @returns "BaseTexture"
  32754. */
  32755. getClassName(): string;
  32756. private _realTimeFiltering;
  32757. /**
  32758. * Enables realtime filtering on the texture.
  32759. */
  32760. get realTimeFiltering(): boolean;
  32761. set realTimeFiltering(b: boolean);
  32762. private _realTimeFilteringQuality;
  32763. /**
  32764. * Quality switch for realtime filtering
  32765. */
  32766. get realTimeFilteringQuality(): number;
  32767. set realTimeFilteringQuality(n: number);
  32768. /**
  32769. * Define the list of animation attached to the texture.
  32770. */
  32771. animations: Animation[];
  32772. /**
  32773. * An event triggered when the texture is disposed.
  32774. */
  32775. onDisposeObservable: Observable<BaseTexture>;
  32776. private _onDisposeObserver;
  32777. /**
  32778. * Callback triggered when the texture has been disposed.
  32779. * Kept for back compatibility, you can use the onDisposeObservable instead.
  32780. */
  32781. set onDispose(callback: () => void);
  32782. /**
  32783. * Define the current state of the loading sequence when in delayed load mode.
  32784. */
  32785. delayLoadState: number;
  32786. private _scene;
  32787. private _engine;
  32788. /** @hidden */
  32789. _texture: Nullable<InternalTexture>;
  32790. private _uid;
  32791. /**
  32792. * Define if the texture is preventinga material to render or not.
  32793. * If not and the texture is not ready, the engine will use a default black texture instead.
  32794. */
  32795. get isBlocking(): boolean;
  32796. /**
  32797. * Instantiates a new BaseTexture.
  32798. * Base class of all the textures in babylon.
  32799. * It groups all the common properties the materials, post process, lights... might need
  32800. * in order to make a correct use of the texture.
  32801. * @param sceneOrEngine Define the scene or engine the texture blongs to
  32802. */
  32803. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  32804. /**
  32805. * Get the scene the texture belongs to.
  32806. * @returns the scene or null if undefined
  32807. */
  32808. getScene(): Nullable<Scene>;
  32809. /** @hidden */
  32810. protected _getEngine(): Nullable<ThinEngine>;
  32811. /**
  32812. * Get the texture transform matrix used to offset tile the texture for istance.
  32813. * @returns the transformation matrix
  32814. */
  32815. getTextureMatrix(): Matrix;
  32816. /**
  32817. * Get the texture reflection matrix used to rotate/transform the reflection.
  32818. * @returns the reflection matrix
  32819. */
  32820. getReflectionTextureMatrix(): Matrix;
  32821. /**
  32822. * Get the underlying lower level texture from Babylon.
  32823. * @returns the insternal texture
  32824. */
  32825. getInternalTexture(): Nullable<InternalTexture>;
  32826. /**
  32827. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  32828. * @returns true if ready or not blocking
  32829. */
  32830. isReadyOrNotBlocking(): boolean;
  32831. /**
  32832. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  32833. * @returns true if fully ready
  32834. */
  32835. isReady(): boolean;
  32836. private _cachedSize;
  32837. /**
  32838. * Get the size of the texture.
  32839. * @returns the texture size.
  32840. */
  32841. getSize(): ISize;
  32842. /**
  32843. * Get the base size of the texture.
  32844. * It can be different from the size if the texture has been resized for POT for instance
  32845. * @returns the base size
  32846. */
  32847. getBaseSize(): ISize;
  32848. /**
  32849. * Update the sampling mode of the texture.
  32850. * Default is Trilinear mode.
  32851. *
  32852. * | Value | Type | Description |
  32853. * | ----- | ------------------ | ----------- |
  32854. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  32855. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  32856. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  32857. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  32858. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  32859. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  32860. * | 7 | NEAREST_LINEAR | |
  32861. * | 8 | NEAREST_NEAREST | |
  32862. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  32863. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  32864. * | 11 | LINEAR_LINEAR | |
  32865. * | 12 | LINEAR_NEAREST | |
  32866. *
  32867. * > _mag_: magnification filter (close to the viewer)
  32868. * > _min_: minification filter (far from the viewer)
  32869. * > _mip_: filter used between mip map levels
  32870. *@param samplingMode Define the new sampling mode of the texture
  32871. */
  32872. updateSamplingMode(samplingMode: number): void;
  32873. /**
  32874. * Scales the texture if is `canRescale()`
  32875. * @param ratio the resize factor we want to use to rescale
  32876. */
  32877. scale(ratio: number): void;
  32878. /**
  32879. * Get if the texture can rescale.
  32880. */
  32881. get canRescale(): boolean;
  32882. /** @hidden */
  32883. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  32884. /** @hidden */
  32885. _rebuild(): void;
  32886. /**
  32887. * Triggers the load sequence in delayed load mode.
  32888. */
  32889. delayLoad(): void;
  32890. /**
  32891. * Clones the texture.
  32892. * @returns the cloned texture
  32893. */
  32894. clone(): Nullable<BaseTexture>;
  32895. /**
  32896. * Get the texture underlying type (INT, FLOAT...)
  32897. */
  32898. get textureType(): number;
  32899. /**
  32900. * Get the texture underlying format (RGB, RGBA...)
  32901. */
  32902. get textureFormat(): number;
  32903. /**
  32904. * Indicates that textures need to be re-calculated for all materials
  32905. */
  32906. protected _markAllSubMeshesAsTexturesDirty(): void;
  32907. /**
  32908. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  32909. * This will returns an RGBA array buffer containing either in values (0-255) or
  32910. * float values (0-1) depending of the underlying buffer type.
  32911. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  32912. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  32913. * @param buffer defines a user defined buffer to fill with data (can be null)
  32914. * @returns The Array buffer containing the pixels data.
  32915. */
  32916. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  32917. /**
  32918. * Release and destroy the underlying lower level texture aka internalTexture.
  32919. */
  32920. releaseInternalTexture(): void;
  32921. /** @hidden */
  32922. get _lodTextureHigh(): Nullable<BaseTexture>;
  32923. /** @hidden */
  32924. get _lodTextureMid(): Nullable<BaseTexture>;
  32925. /** @hidden */
  32926. get _lodTextureLow(): Nullable<BaseTexture>;
  32927. /**
  32928. * Dispose the texture and release its associated resources.
  32929. */
  32930. dispose(): void;
  32931. /**
  32932. * Serialize the texture into a JSON representation that can be parsed later on.
  32933. * @returns the JSON representation of the texture
  32934. */
  32935. serialize(): any;
  32936. /**
  32937. * Helper function to be called back once a list of texture contains only ready textures.
  32938. * @param textures Define the list of textures to wait for
  32939. * @param callback Define the callback triggered once the entire list will be ready
  32940. */
  32941. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  32942. private static _isScene;
  32943. }
  32944. }
  32945. declare module BABYLON {
  32946. /**
  32947. * Options to be used when creating an effect.
  32948. */
  32949. export interface IEffectCreationOptions {
  32950. /**
  32951. * Atrributes that will be used in the shader.
  32952. */
  32953. attributes: string[];
  32954. /**
  32955. * Uniform varible names that will be set in the shader.
  32956. */
  32957. uniformsNames: string[];
  32958. /**
  32959. * Uniform buffer variable names that will be set in the shader.
  32960. */
  32961. uniformBuffersNames: string[];
  32962. /**
  32963. * Sampler texture variable names that will be set in the shader.
  32964. */
  32965. samplers: string[];
  32966. /**
  32967. * Define statements that will be set in the shader.
  32968. */
  32969. defines: any;
  32970. /**
  32971. * Possible fallbacks for this effect to improve performance when needed.
  32972. */
  32973. fallbacks: Nullable<IEffectFallbacks>;
  32974. /**
  32975. * Callback that will be called when the shader is compiled.
  32976. */
  32977. onCompiled: Nullable<(effect: Effect) => void>;
  32978. /**
  32979. * Callback that will be called if an error occurs during shader compilation.
  32980. */
  32981. onError: Nullable<(effect: Effect, errors: string) => void>;
  32982. /**
  32983. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  32984. */
  32985. indexParameters?: any;
  32986. /**
  32987. * Max number of lights that can be used in the shader.
  32988. */
  32989. maxSimultaneousLights?: number;
  32990. /**
  32991. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  32992. */
  32993. transformFeedbackVaryings?: Nullable<string[]>;
  32994. }
  32995. /**
  32996. * Effect containing vertex and fragment shader that can be executed on an object.
  32997. */
  32998. export class Effect implements IDisposable {
  32999. /**
  33000. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33001. */
  33002. static ShadersRepository: string;
  33003. /**
  33004. * Enable logging of the shader code when a compilation error occurs
  33005. */
  33006. static LogShaderCodeOnCompilationError: boolean;
  33007. /**
  33008. * Name of the effect.
  33009. */
  33010. name: any;
  33011. /**
  33012. * String container all the define statements that should be set on the shader.
  33013. */
  33014. defines: string;
  33015. /**
  33016. * Callback that will be called when the shader is compiled.
  33017. */
  33018. onCompiled: Nullable<(effect: Effect) => void>;
  33019. /**
  33020. * Callback that will be called if an error occurs during shader compilation.
  33021. */
  33022. onError: Nullable<(effect: Effect, errors: string) => void>;
  33023. /**
  33024. * Callback that will be called when effect is bound.
  33025. */
  33026. onBind: Nullable<(effect: Effect) => void>;
  33027. /**
  33028. * Unique ID of the effect.
  33029. */
  33030. uniqueId: number;
  33031. /**
  33032. * Observable that will be called when the shader is compiled.
  33033. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33034. */
  33035. onCompileObservable: Observable<Effect>;
  33036. /**
  33037. * Observable that will be called if an error occurs during shader compilation.
  33038. */
  33039. onErrorObservable: Observable<Effect>;
  33040. /** @hidden */
  33041. _onBindObservable: Nullable<Observable<Effect>>;
  33042. /**
  33043. * @hidden
  33044. * Specifies if the effect was previously ready
  33045. */
  33046. _wasPreviouslyReady: boolean;
  33047. /**
  33048. * Observable that will be called when effect is bound.
  33049. */
  33050. get onBindObservable(): Observable<Effect>;
  33051. /** @hidden */
  33052. _bonesComputationForcedToCPU: boolean;
  33053. private static _uniqueIdSeed;
  33054. private _engine;
  33055. private _uniformBuffersNames;
  33056. private _uniformBuffersNamesList;
  33057. private _uniformsNames;
  33058. private _samplerList;
  33059. private _samplers;
  33060. private _isReady;
  33061. private _compilationError;
  33062. private _allFallbacksProcessed;
  33063. private _attributesNames;
  33064. private _attributes;
  33065. private _attributeLocationByName;
  33066. private _uniforms;
  33067. /**
  33068. * Key for the effect.
  33069. * @hidden
  33070. */
  33071. _key: string;
  33072. private _indexParameters;
  33073. private _fallbacks;
  33074. private _vertexSourceCode;
  33075. private _fragmentSourceCode;
  33076. private _vertexSourceCodeOverride;
  33077. private _fragmentSourceCodeOverride;
  33078. private _transformFeedbackVaryings;
  33079. /**
  33080. * Compiled shader to webGL program.
  33081. * @hidden
  33082. */
  33083. _pipelineContext: Nullable<IPipelineContext>;
  33084. private _valueCache;
  33085. private static _baseCache;
  33086. /**
  33087. * Instantiates an effect.
  33088. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33089. * @param baseName Name of the effect.
  33090. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33091. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33092. * @param samplers List of sampler variables that will be passed to the shader.
  33093. * @param engine Engine to be used to render the effect
  33094. * @param defines Define statements to be added to the shader.
  33095. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33096. * @param onCompiled Callback that will be called when the shader is compiled.
  33097. * @param onError Callback that will be called if an error occurs during shader compilation.
  33098. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33099. */
  33100. 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);
  33101. private _useFinalCode;
  33102. /**
  33103. * Unique key for this effect
  33104. */
  33105. get key(): string;
  33106. /**
  33107. * If the effect has been compiled and prepared.
  33108. * @returns if the effect is compiled and prepared.
  33109. */
  33110. isReady(): boolean;
  33111. private _isReadyInternal;
  33112. /**
  33113. * The engine the effect was initialized with.
  33114. * @returns the engine.
  33115. */
  33116. getEngine(): Engine;
  33117. /**
  33118. * The pipeline context for this effect
  33119. * @returns the associated pipeline context
  33120. */
  33121. getPipelineContext(): Nullable<IPipelineContext>;
  33122. /**
  33123. * The set of names of attribute variables for the shader.
  33124. * @returns An array of attribute names.
  33125. */
  33126. getAttributesNames(): string[];
  33127. /**
  33128. * Returns the attribute at the given index.
  33129. * @param index The index of the attribute.
  33130. * @returns The location of the attribute.
  33131. */
  33132. getAttributeLocation(index: number): number;
  33133. /**
  33134. * Returns the attribute based on the name of the variable.
  33135. * @param name of the attribute to look up.
  33136. * @returns the attribute location.
  33137. */
  33138. getAttributeLocationByName(name: string): number;
  33139. /**
  33140. * The number of attributes.
  33141. * @returns the numnber of attributes.
  33142. */
  33143. getAttributesCount(): number;
  33144. /**
  33145. * Gets the index of a uniform variable.
  33146. * @param uniformName of the uniform to look up.
  33147. * @returns the index.
  33148. */
  33149. getUniformIndex(uniformName: string): number;
  33150. /**
  33151. * Returns the attribute based on the name of the variable.
  33152. * @param uniformName of the uniform to look up.
  33153. * @returns the location of the uniform.
  33154. */
  33155. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33156. /**
  33157. * Returns an array of sampler variable names
  33158. * @returns The array of sampler variable names.
  33159. */
  33160. getSamplers(): string[];
  33161. /**
  33162. * Returns an array of uniform variable names
  33163. * @returns The array of uniform variable names.
  33164. */
  33165. getUniformNames(): string[];
  33166. /**
  33167. * Returns an array of uniform buffer variable names
  33168. * @returns The array of uniform buffer variable names.
  33169. */
  33170. getUniformBuffersNames(): string[];
  33171. /**
  33172. * Returns the index parameters used to create the effect
  33173. * @returns The index parameters object
  33174. */
  33175. getIndexParameters(): any;
  33176. /**
  33177. * The error from the last compilation.
  33178. * @returns the error string.
  33179. */
  33180. getCompilationError(): string;
  33181. /**
  33182. * Gets a boolean indicating that all fallbacks were used during compilation
  33183. * @returns true if all fallbacks were used
  33184. */
  33185. allFallbacksProcessed(): boolean;
  33186. /**
  33187. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33188. * @param func The callback to be used.
  33189. */
  33190. executeWhenCompiled(func: (effect: Effect) => void): void;
  33191. private _checkIsReady;
  33192. private _loadShader;
  33193. /**
  33194. * Gets the vertex shader source code of this effect
  33195. */
  33196. get vertexSourceCode(): string;
  33197. /**
  33198. * Gets the fragment shader source code of this effect
  33199. */
  33200. get fragmentSourceCode(): string;
  33201. /**
  33202. * Recompiles the webGL program
  33203. * @param vertexSourceCode The source code for the vertex shader.
  33204. * @param fragmentSourceCode The source code for the fragment shader.
  33205. * @param onCompiled Callback called when completed.
  33206. * @param onError Callback called on error.
  33207. * @hidden
  33208. */
  33209. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33210. /**
  33211. * Prepares the effect
  33212. * @hidden
  33213. */
  33214. _prepareEffect(): void;
  33215. private _getShaderCodeAndErrorLine;
  33216. private _processCompilationErrors;
  33217. /**
  33218. * Checks if the effect is supported. (Must be called after compilation)
  33219. */
  33220. get isSupported(): boolean;
  33221. /**
  33222. * Binds a texture to the engine to be used as output of the shader.
  33223. * @param channel Name of the output variable.
  33224. * @param texture Texture to bind.
  33225. * @hidden
  33226. */
  33227. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33228. /**
  33229. * Sets a texture on the engine to be used in the shader.
  33230. * @param channel Name of the sampler variable.
  33231. * @param texture Texture to set.
  33232. */
  33233. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33234. /**
  33235. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33236. * @param channel Name of the sampler variable.
  33237. * @param texture Texture to set.
  33238. */
  33239. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33240. /**
  33241. * Sets an array of textures on the engine to be used in the shader.
  33242. * @param channel Name of the variable.
  33243. * @param textures Textures to set.
  33244. */
  33245. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33246. /**
  33247. * 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)
  33248. * @param channel Name of the sampler variable.
  33249. * @param postProcess Post process to get the input texture from.
  33250. */
  33251. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33252. /**
  33253. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33254. * 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)
  33255. * @param channel Name of the sampler variable.
  33256. * @param postProcess Post process to get the output texture from.
  33257. */
  33258. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33259. /** @hidden */
  33260. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33261. /** @hidden */
  33262. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33263. /** @hidden */
  33264. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33265. /** @hidden */
  33266. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33267. /**
  33268. * Binds a buffer to a uniform.
  33269. * @param buffer Buffer to bind.
  33270. * @param name Name of the uniform variable to bind to.
  33271. */
  33272. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33273. /**
  33274. * Binds block to a uniform.
  33275. * @param blockName Name of the block to bind.
  33276. * @param index Index to bind.
  33277. */
  33278. bindUniformBlock(blockName: string, index: number): void;
  33279. /**
  33280. * Sets an interger value on a uniform variable.
  33281. * @param uniformName Name of the variable.
  33282. * @param value Value to be set.
  33283. * @returns this effect.
  33284. */
  33285. setInt(uniformName: string, value: number): Effect;
  33286. /**
  33287. * Sets an int array on a uniform variable.
  33288. * @param uniformName Name of the variable.
  33289. * @param array array to be set.
  33290. * @returns this effect.
  33291. */
  33292. setIntArray(uniformName: string, array: Int32Array): Effect;
  33293. /**
  33294. * 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)
  33295. * @param uniformName Name of the variable.
  33296. * @param array array to be set.
  33297. * @returns this effect.
  33298. */
  33299. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33300. /**
  33301. * 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)
  33302. * @param uniformName Name of the variable.
  33303. * @param array array to be set.
  33304. * @returns this effect.
  33305. */
  33306. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33307. /**
  33308. * 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)
  33309. * @param uniformName Name of the variable.
  33310. * @param array array to be set.
  33311. * @returns this effect.
  33312. */
  33313. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33314. /**
  33315. * Sets an float array on a uniform variable.
  33316. * @param uniformName Name of the variable.
  33317. * @param array array to be set.
  33318. * @returns this effect.
  33319. */
  33320. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33321. /**
  33322. * 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)
  33323. * @param uniformName Name of the variable.
  33324. * @param array array to be set.
  33325. * @returns this effect.
  33326. */
  33327. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33328. /**
  33329. * 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)
  33330. * @param uniformName Name of the variable.
  33331. * @param array array to be set.
  33332. * @returns this effect.
  33333. */
  33334. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33335. /**
  33336. * 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)
  33337. * @param uniformName Name of the variable.
  33338. * @param array array to be set.
  33339. * @returns this effect.
  33340. */
  33341. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33342. /**
  33343. * Sets an array on a uniform variable.
  33344. * @param uniformName Name of the variable.
  33345. * @param array array to be set.
  33346. * @returns this effect.
  33347. */
  33348. setArray(uniformName: string, array: number[]): Effect;
  33349. /**
  33350. * 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)
  33351. * @param uniformName Name of the variable.
  33352. * @param array array to be set.
  33353. * @returns this effect.
  33354. */
  33355. setArray2(uniformName: string, array: number[]): Effect;
  33356. /**
  33357. * 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)
  33358. * @param uniformName Name of the variable.
  33359. * @param array array to be set.
  33360. * @returns this effect.
  33361. */
  33362. setArray3(uniformName: string, array: number[]): Effect;
  33363. /**
  33364. * 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)
  33365. * @param uniformName Name of the variable.
  33366. * @param array array to be set.
  33367. * @returns this effect.
  33368. */
  33369. setArray4(uniformName: string, array: number[]): Effect;
  33370. /**
  33371. * Sets matrices on a uniform variable.
  33372. * @param uniformName Name of the variable.
  33373. * @param matrices matrices to be set.
  33374. * @returns this effect.
  33375. */
  33376. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33377. /**
  33378. * Sets matrix on a uniform variable.
  33379. * @param uniformName Name of the variable.
  33380. * @param matrix matrix to be set.
  33381. * @returns this effect.
  33382. */
  33383. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33384. /**
  33385. * 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)
  33386. * @param uniformName Name of the variable.
  33387. * @param matrix matrix to be set.
  33388. * @returns this effect.
  33389. */
  33390. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33391. /**
  33392. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33393. * @param uniformName Name of the variable.
  33394. * @param matrix matrix to be set.
  33395. * @returns this effect.
  33396. */
  33397. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33398. /**
  33399. * Sets a float on a uniform variable.
  33400. * @param uniformName Name of the variable.
  33401. * @param value value to be set.
  33402. * @returns this effect.
  33403. */
  33404. setFloat(uniformName: string, value: number): Effect;
  33405. /**
  33406. * Sets a boolean on a uniform variable.
  33407. * @param uniformName Name of the variable.
  33408. * @param bool value to be set.
  33409. * @returns this effect.
  33410. */
  33411. setBool(uniformName: string, bool: boolean): Effect;
  33412. /**
  33413. * Sets a Vector2 on a uniform variable.
  33414. * @param uniformName Name of the variable.
  33415. * @param vector2 vector2 to be set.
  33416. * @returns this effect.
  33417. */
  33418. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33419. /**
  33420. * Sets a float2 on a uniform variable.
  33421. * @param uniformName Name of the variable.
  33422. * @param x First float in float2.
  33423. * @param y Second float in float2.
  33424. * @returns this effect.
  33425. */
  33426. setFloat2(uniformName: string, x: number, y: number): Effect;
  33427. /**
  33428. * Sets a Vector3 on a uniform variable.
  33429. * @param uniformName Name of the variable.
  33430. * @param vector3 Value to be set.
  33431. * @returns this effect.
  33432. */
  33433. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33434. /**
  33435. * Sets a float3 on a uniform variable.
  33436. * @param uniformName Name of the variable.
  33437. * @param x First float in float3.
  33438. * @param y Second float in float3.
  33439. * @param z Third float in float3.
  33440. * @returns this effect.
  33441. */
  33442. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33443. /**
  33444. * Sets a Vector4 on a uniform variable.
  33445. * @param uniformName Name of the variable.
  33446. * @param vector4 Value to be set.
  33447. * @returns this effect.
  33448. */
  33449. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33450. /**
  33451. * Sets a float4 on a uniform variable.
  33452. * @param uniformName Name of the variable.
  33453. * @param x First float in float4.
  33454. * @param y Second float in float4.
  33455. * @param z Third float in float4.
  33456. * @param w Fourth float in float4.
  33457. * @returns this effect.
  33458. */
  33459. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33460. /**
  33461. * Sets a Color3 on a uniform variable.
  33462. * @param uniformName Name of the variable.
  33463. * @param color3 Value to be set.
  33464. * @returns this effect.
  33465. */
  33466. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33467. /**
  33468. * Sets a Color4 on a uniform variable.
  33469. * @param uniformName Name of the variable.
  33470. * @param color3 Value to be set.
  33471. * @param alpha Alpha value to be set.
  33472. * @returns this effect.
  33473. */
  33474. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33475. /**
  33476. * Sets a Color4 on a uniform variable
  33477. * @param uniformName defines the name of the variable
  33478. * @param color4 defines the value to be set
  33479. * @returns this effect.
  33480. */
  33481. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33482. /** Release all associated resources */
  33483. dispose(): void;
  33484. /**
  33485. * This function will add a new shader to the shader store
  33486. * @param name the name of the shader
  33487. * @param pixelShader optional pixel shader content
  33488. * @param vertexShader optional vertex shader content
  33489. */
  33490. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33491. /**
  33492. * Store of each shader (The can be looked up using effect.key)
  33493. */
  33494. static ShadersStore: {
  33495. [key: string]: string;
  33496. };
  33497. /**
  33498. * Store of each included file for a shader (The can be looked up using effect.key)
  33499. */
  33500. static IncludesShadersStore: {
  33501. [key: string]: string;
  33502. };
  33503. /**
  33504. * Resets the cache of effects.
  33505. */
  33506. static ResetCache(): void;
  33507. }
  33508. }
  33509. declare module BABYLON {
  33510. /**
  33511. * Interface used to describe the capabilities of the engine relatively to the current browser
  33512. */
  33513. export interface EngineCapabilities {
  33514. /** Maximum textures units per fragment shader */
  33515. maxTexturesImageUnits: number;
  33516. /** Maximum texture units per vertex shader */
  33517. maxVertexTextureImageUnits: number;
  33518. /** Maximum textures units in the entire pipeline */
  33519. maxCombinedTexturesImageUnits: number;
  33520. /** Maximum texture size */
  33521. maxTextureSize: number;
  33522. /** Maximum texture samples */
  33523. maxSamples?: number;
  33524. /** Maximum cube texture size */
  33525. maxCubemapTextureSize: number;
  33526. /** Maximum render texture size */
  33527. maxRenderTextureSize: number;
  33528. /** Maximum number of vertex attributes */
  33529. maxVertexAttribs: number;
  33530. /** Maximum number of varyings */
  33531. maxVaryingVectors: number;
  33532. /** Maximum number of uniforms per vertex shader */
  33533. maxVertexUniformVectors: number;
  33534. /** Maximum number of uniforms per fragment shader */
  33535. maxFragmentUniformVectors: number;
  33536. /** Defines if standard derivates (dx/dy) are supported */
  33537. standardDerivatives: boolean;
  33538. /** Defines if s3tc texture compression is supported */
  33539. s3tc?: WEBGL_compressed_texture_s3tc;
  33540. /** Defines if pvrtc texture compression is supported */
  33541. pvrtc: any;
  33542. /** Defines if etc1 texture compression is supported */
  33543. etc1: any;
  33544. /** Defines if etc2 texture compression is supported */
  33545. etc2: any;
  33546. /** Defines if astc texture compression is supported */
  33547. astc: any;
  33548. /** Defines if float textures are supported */
  33549. textureFloat: boolean;
  33550. /** Defines if vertex array objects are supported */
  33551. vertexArrayObject: boolean;
  33552. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33553. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33554. /** Gets the maximum level of anisotropy supported */
  33555. maxAnisotropy: number;
  33556. /** Defines if instancing is supported */
  33557. instancedArrays: boolean;
  33558. /** Defines if 32 bits indices are supported */
  33559. uintIndices: boolean;
  33560. /** Defines if high precision shaders are supported */
  33561. highPrecisionShaderSupported: boolean;
  33562. /** Defines if depth reading in the fragment shader is supported */
  33563. fragmentDepthSupported: boolean;
  33564. /** Defines if float texture linear filtering is supported*/
  33565. textureFloatLinearFiltering: boolean;
  33566. /** Defines if rendering to float textures is supported */
  33567. textureFloatRender: boolean;
  33568. /** Defines if half float textures are supported*/
  33569. textureHalfFloat: boolean;
  33570. /** Defines if half float texture linear filtering is supported*/
  33571. textureHalfFloatLinearFiltering: boolean;
  33572. /** Defines if rendering to half float textures is supported */
  33573. textureHalfFloatRender: boolean;
  33574. /** Defines if textureLOD shader command is supported */
  33575. textureLOD: boolean;
  33576. /** Defines if draw buffers extension is supported */
  33577. drawBuffersExtension: boolean;
  33578. /** Defines if depth textures are supported */
  33579. depthTextureExtension: boolean;
  33580. /** Defines if float color buffer are supported */
  33581. colorBufferFloat: boolean;
  33582. /** Gets disjoint timer query extension (null if not supported) */
  33583. timerQuery?: EXT_disjoint_timer_query;
  33584. /** Defines if timestamp can be used with timer query */
  33585. canUseTimestampForTimerQuery: boolean;
  33586. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33587. multiview?: any;
  33588. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33589. oculusMultiview?: any;
  33590. /** Function used to let the system compiles shaders in background */
  33591. parallelShaderCompile?: {
  33592. COMPLETION_STATUS_KHR: number;
  33593. };
  33594. /** Max number of texture samples for MSAA */
  33595. maxMSAASamples: number;
  33596. /** Defines if the blend min max extension is supported */
  33597. blendMinMax: boolean;
  33598. }
  33599. }
  33600. declare module BABYLON {
  33601. /**
  33602. * @hidden
  33603. **/
  33604. export class DepthCullingState {
  33605. private _isDepthTestDirty;
  33606. private _isDepthMaskDirty;
  33607. private _isDepthFuncDirty;
  33608. private _isCullFaceDirty;
  33609. private _isCullDirty;
  33610. private _isZOffsetDirty;
  33611. private _isFrontFaceDirty;
  33612. private _depthTest;
  33613. private _depthMask;
  33614. private _depthFunc;
  33615. private _cull;
  33616. private _cullFace;
  33617. private _zOffset;
  33618. private _frontFace;
  33619. /**
  33620. * Initializes the state.
  33621. */
  33622. constructor();
  33623. get isDirty(): boolean;
  33624. get zOffset(): number;
  33625. set zOffset(value: number);
  33626. get cullFace(): Nullable<number>;
  33627. set cullFace(value: Nullable<number>);
  33628. get cull(): Nullable<boolean>;
  33629. set cull(value: Nullable<boolean>);
  33630. get depthFunc(): Nullable<number>;
  33631. set depthFunc(value: Nullable<number>);
  33632. get depthMask(): boolean;
  33633. set depthMask(value: boolean);
  33634. get depthTest(): boolean;
  33635. set depthTest(value: boolean);
  33636. get frontFace(): Nullable<number>;
  33637. set frontFace(value: Nullable<number>);
  33638. reset(): void;
  33639. apply(gl: WebGLRenderingContext): void;
  33640. }
  33641. }
  33642. declare module BABYLON {
  33643. /**
  33644. * @hidden
  33645. **/
  33646. export class StencilState {
  33647. /** 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 */
  33648. static readonly ALWAYS: number;
  33649. /** Passed to stencilOperation to specify that stencil value must be kept */
  33650. static readonly KEEP: number;
  33651. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33652. static readonly REPLACE: number;
  33653. private _isStencilTestDirty;
  33654. private _isStencilMaskDirty;
  33655. private _isStencilFuncDirty;
  33656. private _isStencilOpDirty;
  33657. private _stencilTest;
  33658. private _stencilMask;
  33659. private _stencilFunc;
  33660. private _stencilFuncRef;
  33661. private _stencilFuncMask;
  33662. private _stencilOpStencilFail;
  33663. private _stencilOpDepthFail;
  33664. private _stencilOpStencilDepthPass;
  33665. get isDirty(): boolean;
  33666. get stencilFunc(): number;
  33667. set stencilFunc(value: number);
  33668. get stencilFuncRef(): number;
  33669. set stencilFuncRef(value: number);
  33670. get stencilFuncMask(): number;
  33671. set stencilFuncMask(value: number);
  33672. get stencilOpStencilFail(): number;
  33673. set stencilOpStencilFail(value: number);
  33674. get stencilOpDepthFail(): number;
  33675. set stencilOpDepthFail(value: number);
  33676. get stencilOpStencilDepthPass(): number;
  33677. set stencilOpStencilDepthPass(value: number);
  33678. get stencilMask(): number;
  33679. set stencilMask(value: number);
  33680. get stencilTest(): boolean;
  33681. set stencilTest(value: boolean);
  33682. constructor();
  33683. reset(): void;
  33684. apply(gl: WebGLRenderingContext): void;
  33685. }
  33686. }
  33687. declare module BABYLON {
  33688. /**
  33689. * @hidden
  33690. **/
  33691. export class AlphaState {
  33692. private _isAlphaBlendDirty;
  33693. private _isBlendFunctionParametersDirty;
  33694. private _isBlendEquationParametersDirty;
  33695. private _isBlendConstantsDirty;
  33696. private _alphaBlend;
  33697. private _blendFunctionParameters;
  33698. private _blendEquationParameters;
  33699. private _blendConstants;
  33700. /**
  33701. * Initializes the state.
  33702. */
  33703. constructor();
  33704. get isDirty(): boolean;
  33705. get alphaBlend(): boolean;
  33706. set alphaBlend(value: boolean);
  33707. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33708. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33709. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33710. reset(): void;
  33711. apply(gl: WebGLRenderingContext): void;
  33712. }
  33713. }
  33714. declare module BABYLON {
  33715. /** @hidden */
  33716. export class WebGL2ShaderProcessor implements IShaderProcessor {
  33717. attributeProcessor(attribute: string): string;
  33718. varyingProcessor(varying: string, isFragment: boolean): string;
  33719. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  33720. }
  33721. }
  33722. declare module BABYLON {
  33723. /**
  33724. * Interface for attribute information associated with buffer instanciation
  33725. */
  33726. export interface InstancingAttributeInfo {
  33727. /**
  33728. * Name of the GLSL attribute
  33729. * if attribute index is not specified, this is used to retrieve the index from the effect
  33730. */
  33731. attributeName: string;
  33732. /**
  33733. * Index/offset of the attribute in the vertex shader
  33734. * if not specified, this will be computes from the name.
  33735. */
  33736. index?: number;
  33737. /**
  33738. * size of the attribute, 1, 2, 3 or 4
  33739. */
  33740. attributeSize: number;
  33741. /**
  33742. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  33743. */
  33744. offset: number;
  33745. /**
  33746. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  33747. * default to 1
  33748. */
  33749. divisor?: number;
  33750. /**
  33751. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  33752. * default is FLOAT
  33753. */
  33754. attributeType?: number;
  33755. /**
  33756. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  33757. */
  33758. normalized?: boolean;
  33759. }
  33760. }
  33761. declare module BABYLON {
  33762. interface ThinEngine {
  33763. /**
  33764. * Update a video texture
  33765. * @param texture defines the texture to update
  33766. * @param video defines the video element to use
  33767. * @param invertY defines if data must be stored with Y axis inverted
  33768. */
  33769. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  33770. }
  33771. }
  33772. declare module BABYLON {
  33773. /**
  33774. * Settings for finer control over video usage
  33775. */
  33776. export interface VideoTextureSettings {
  33777. /**
  33778. * Applies `autoplay` to video, if specified
  33779. */
  33780. autoPlay?: boolean;
  33781. /**
  33782. * Applies `loop` to video, if specified
  33783. */
  33784. loop?: boolean;
  33785. /**
  33786. * Automatically updates internal texture from video at every frame in the render loop
  33787. */
  33788. autoUpdateTexture: boolean;
  33789. /**
  33790. * Image src displayed during the video loading or until the user interacts with the video.
  33791. */
  33792. poster?: string;
  33793. }
  33794. /**
  33795. * If you want to display a video in your scene, this is the special texture for that.
  33796. * This special texture works similar to other textures, with the exception of a few parameters.
  33797. * @see https://doc.babylonjs.com/how_to/video_texture
  33798. */
  33799. export class VideoTexture extends Texture {
  33800. /**
  33801. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33802. */
  33803. readonly autoUpdateTexture: boolean;
  33804. /**
  33805. * The video instance used by the texture internally
  33806. */
  33807. readonly video: HTMLVideoElement;
  33808. private _onUserActionRequestedObservable;
  33809. /**
  33810. * Event triggerd when a dom action is required by the user to play the video.
  33811. * This happens due to recent changes in browser policies preventing video to auto start.
  33812. */
  33813. get onUserActionRequestedObservable(): Observable<Texture>;
  33814. private _generateMipMaps;
  33815. private _stillImageCaptured;
  33816. private _displayingPosterTexture;
  33817. private _settings;
  33818. private _createInternalTextureOnEvent;
  33819. private _frameId;
  33820. private _currentSrc;
  33821. /**
  33822. * Creates a video texture.
  33823. * If you want to display a video in your scene, this is the special texture for that.
  33824. * This special texture works similar to other textures, with the exception of a few parameters.
  33825. * @see https://doc.babylonjs.com/how_to/video_texture
  33826. * @param name optional name, will detect from video source, if not defined
  33827. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  33828. * @param scene is obviously the current scene.
  33829. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33830. * @param invertY is false by default but can be used to invert video on Y axis
  33831. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33832. * @param settings allows finer control over video usage
  33833. */
  33834. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  33835. private _getName;
  33836. private _getVideo;
  33837. private _createInternalTexture;
  33838. private reset;
  33839. /**
  33840. * @hidden Internal method to initiate `update`.
  33841. */
  33842. _rebuild(): void;
  33843. /**
  33844. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  33845. */
  33846. update(): void;
  33847. /**
  33848. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  33849. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  33850. */
  33851. updateTexture(isVisible: boolean): void;
  33852. protected _updateInternalTexture: () => void;
  33853. /**
  33854. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  33855. * @param url New url.
  33856. */
  33857. updateURL(url: string): void;
  33858. /**
  33859. * Clones the texture.
  33860. * @returns the cloned texture
  33861. */
  33862. clone(): VideoTexture;
  33863. /**
  33864. * Dispose the texture and release its associated resources.
  33865. */
  33866. dispose(): void;
  33867. /**
  33868. * Creates a video texture straight from a stream.
  33869. * @param scene Define the scene the texture should be created in
  33870. * @param stream Define the stream the texture should be created from
  33871. * @returns The created video texture as a promise
  33872. */
  33873. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  33874. /**
  33875. * Creates a video texture straight from your WebCam video feed.
  33876. * @param scene Define the scene the texture should be created in
  33877. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33878. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33879. * @returns The created video texture as a promise
  33880. */
  33881. static CreateFromWebCamAsync(scene: Scene, constraints: {
  33882. minWidth: number;
  33883. maxWidth: number;
  33884. minHeight: number;
  33885. maxHeight: number;
  33886. deviceId: string;
  33887. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  33888. /**
  33889. * Creates a video texture straight from your WebCam video feed.
  33890. * @param scene Define the scene the texture should be created in
  33891. * @param onReady Define a callback to triggered once the texture will be ready
  33892. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33893. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33894. */
  33895. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  33896. minWidth: number;
  33897. maxWidth: number;
  33898. minHeight: number;
  33899. maxHeight: number;
  33900. deviceId: string;
  33901. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  33902. }
  33903. }
  33904. declare module BABYLON {
  33905. /**
  33906. * Defines the interface used by objects working like Scene
  33907. * @hidden
  33908. */
  33909. export interface ISceneLike {
  33910. _addPendingData(data: any): void;
  33911. _removePendingData(data: any): void;
  33912. offlineProvider: IOfflineProvider;
  33913. }
  33914. /** Interface defining initialization parameters for Engine class */
  33915. export interface EngineOptions extends WebGLContextAttributes {
  33916. /**
  33917. * Defines if the engine should no exceed a specified device ratio
  33918. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  33919. */
  33920. limitDeviceRatio?: number;
  33921. /**
  33922. * Defines if webvr should be enabled automatically
  33923. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33924. */
  33925. autoEnableWebVR?: boolean;
  33926. /**
  33927. * Defines if webgl2 should be turned off even if supported
  33928. * @see http://doc.babylonjs.com/features/webgl2
  33929. */
  33930. disableWebGL2Support?: boolean;
  33931. /**
  33932. * Defines if webaudio should be initialized as well
  33933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33934. */
  33935. audioEngine?: boolean;
  33936. /**
  33937. * Defines if animations should run using a deterministic lock step
  33938. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33939. */
  33940. deterministicLockstep?: boolean;
  33941. /** Defines the maximum steps to use with deterministic lock step mode */
  33942. lockstepMaxSteps?: number;
  33943. /** Defines the seconds between each deterministic lock step */
  33944. timeStep?: number;
  33945. /**
  33946. * Defines that engine should ignore context lost events
  33947. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  33948. */
  33949. doNotHandleContextLost?: boolean;
  33950. /**
  33951. * Defines that engine should ignore modifying touch action attribute and style
  33952. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  33953. */
  33954. doNotHandleTouchAction?: boolean;
  33955. /**
  33956. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  33957. */
  33958. useHighPrecisionFloats?: boolean;
  33959. }
  33960. /**
  33961. * The base engine class (root of all engines)
  33962. */
  33963. export class ThinEngine {
  33964. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  33965. static ExceptionList: ({
  33966. key: string;
  33967. capture: string;
  33968. captureConstraint: number;
  33969. targets: string[];
  33970. } | {
  33971. key: string;
  33972. capture: null;
  33973. captureConstraint: null;
  33974. targets: string[];
  33975. })[];
  33976. /** @hidden */
  33977. static _TextureLoaders: IInternalTextureLoader[];
  33978. /**
  33979. * Returns the current npm package of the sdk
  33980. */
  33981. static get NpmPackage(): string;
  33982. /**
  33983. * Returns the current version of the framework
  33984. */
  33985. static get Version(): string;
  33986. /**
  33987. * Returns a string describing the current engine
  33988. */
  33989. get description(): string;
  33990. /**
  33991. * Gets or sets the epsilon value used by collision engine
  33992. */
  33993. static CollisionsEpsilon: number;
  33994. /**
  33995. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33996. */
  33997. static get ShadersRepository(): string;
  33998. static set ShadersRepository(value: string);
  33999. /** @hidden */
  34000. _shaderProcessor: IShaderProcessor;
  34001. /**
  34002. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34003. */
  34004. forcePOTTextures: boolean;
  34005. /**
  34006. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34007. */
  34008. isFullscreen: boolean;
  34009. /**
  34010. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34011. */
  34012. cullBackFaces: boolean;
  34013. /**
  34014. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34015. */
  34016. renderEvenInBackground: boolean;
  34017. /**
  34018. * Gets or sets a boolean indicating that cache can be kept between frames
  34019. */
  34020. preventCacheWipeBetweenFrames: boolean;
  34021. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34022. validateShaderPrograms: boolean;
  34023. /**
  34024. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34025. * This can provide greater z depth for distant objects.
  34026. */
  34027. useReverseDepthBuffer: boolean;
  34028. /**
  34029. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34030. */
  34031. disableUniformBuffers: boolean;
  34032. /** @hidden */
  34033. _uniformBuffers: UniformBuffer[];
  34034. /**
  34035. * Gets a boolean indicating that the engine supports uniform buffers
  34036. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34037. */
  34038. get supportsUniformBuffers(): boolean;
  34039. /** @hidden */
  34040. _gl: WebGLRenderingContext;
  34041. /** @hidden */
  34042. _webGLVersion: number;
  34043. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34044. protected _windowIsBackground: boolean;
  34045. protected _creationOptions: EngineOptions;
  34046. protected _highPrecisionShadersAllowed: boolean;
  34047. /** @hidden */
  34048. get _shouldUseHighPrecisionShader(): boolean;
  34049. /**
  34050. * Gets a boolean indicating that only power of 2 textures are supported
  34051. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34052. */
  34053. get needPOTTextures(): boolean;
  34054. /** @hidden */
  34055. _badOS: boolean;
  34056. /** @hidden */
  34057. _badDesktopOS: boolean;
  34058. private _hardwareScalingLevel;
  34059. /** @hidden */
  34060. _caps: EngineCapabilities;
  34061. private _isStencilEnable;
  34062. private _glVersion;
  34063. private _glRenderer;
  34064. private _glVendor;
  34065. /** @hidden */
  34066. _videoTextureSupported: boolean;
  34067. protected _renderingQueueLaunched: boolean;
  34068. protected _activeRenderLoops: (() => void)[];
  34069. /**
  34070. * Observable signaled when a context lost event is raised
  34071. */
  34072. onContextLostObservable: Observable<ThinEngine>;
  34073. /**
  34074. * Observable signaled when a context restored event is raised
  34075. */
  34076. onContextRestoredObservable: Observable<ThinEngine>;
  34077. private _onContextLost;
  34078. private _onContextRestored;
  34079. protected _contextWasLost: boolean;
  34080. /** @hidden */
  34081. _doNotHandleContextLost: boolean;
  34082. /**
  34083. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34084. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34085. */
  34086. get doNotHandleContextLost(): boolean;
  34087. set doNotHandleContextLost(value: boolean);
  34088. /**
  34089. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34090. */
  34091. disableVertexArrayObjects: boolean;
  34092. /** @hidden */
  34093. protected _colorWrite: boolean;
  34094. /** @hidden */
  34095. protected _colorWriteChanged: boolean;
  34096. /** @hidden */
  34097. protected _depthCullingState: DepthCullingState;
  34098. /** @hidden */
  34099. protected _stencilState: StencilState;
  34100. /** @hidden */
  34101. _alphaState: AlphaState;
  34102. /** @hidden */
  34103. _alphaMode: number;
  34104. /** @hidden */
  34105. _alphaEquation: number;
  34106. /** @hidden */
  34107. _internalTexturesCache: InternalTexture[];
  34108. /** @hidden */
  34109. protected _activeChannel: number;
  34110. private _currentTextureChannel;
  34111. /** @hidden */
  34112. protected _boundTexturesCache: {
  34113. [key: string]: Nullable<InternalTexture>;
  34114. };
  34115. /** @hidden */
  34116. protected _currentEffect: Nullable<Effect>;
  34117. /** @hidden */
  34118. protected _currentProgram: Nullable<WebGLProgram>;
  34119. private _compiledEffects;
  34120. private _vertexAttribArraysEnabled;
  34121. /** @hidden */
  34122. protected _cachedViewport: Nullable<IViewportLike>;
  34123. private _cachedVertexArrayObject;
  34124. /** @hidden */
  34125. protected _cachedVertexBuffers: any;
  34126. /** @hidden */
  34127. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34128. /** @hidden */
  34129. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34130. /** @hidden */
  34131. _currentRenderTarget: Nullable<InternalTexture>;
  34132. private _uintIndicesCurrentlySet;
  34133. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34134. /** @hidden */
  34135. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34136. /** @hidden */
  34137. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34138. private _currentBufferPointers;
  34139. private _currentInstanceLocations;
  34140. private _currentInstanceBuffers;
  34141. private _textureUnits;
  34142. /** @hidden */
  34143. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34144. /** @hidden */
  34145. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34146. /** @hidden */
  34147. _boundRenderFunction: any;
  34148. private _vaoRecordInProgress;
  34149. private _mustWipeVertexAttributes;
  34150. private _emptyTexture;
  34151. private _emptyCubeTexture;
  34152. private _emptyTexture3D;
  34153. private _emptyTexture2DArray;
  34154. /** @hidden */
  34155. _frameHandler: number;
  34156. private _nextFreeTextureSlots;
  34157. private _maxSimultaneousTextures;
  34158. private _activeRequests;
  34159. /** @hidden */
  34160. _transformTextureUrl: Nullable<(url: string) => string>;
  34161. protected get _supportsHardwareTextureRescaling(): boolean;
  34162. private _framebufferDimensionsObject;
  34163. /**
  34164. * sets the object from which width and height will be taken from when getting render width and height
  34165. * Will fallback to the gl object
  34166. * @param dimensions the framebuffer width and height that will be used.
  34167. */
  34168. set framebufferDimensionsObject(dimensions: Nullable<{
  34169. framebufferWidth: number;
  34170. framebufferHeight: number;
  34171. }>);
  34172. /**
  34173. * Gets the current viewport
  34174. */
  34175. get currentViewport(): Nullable<IViewportLike>;
  34176. /**
  34177. * Gets the default empty texture
  34178. */
  34179. get emptyTexture(): InternalTexture;
  34180. /**
  34181. * Gets the default empty 3D texture
  34182. */
  34183. get emptyTexture3D(): InternalTexture;
  34184. /**
  34185. * Gets the default empty 2D array texture
  34186. */
  34187. get emptyTexture2DArray(): InternalTexture;
  34188. /**
  34189. * Gets the default empty cube texture
  34190. */
  34191. get emptyCubeTexture(): InternalTexture;
  34192. /**
  34193. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34194. */
  34195. readonly premultipliedAlpha: boolean;
  34196. /**
  34197. * Observable event triggered before each texture is initialized
  34198. */
  34199. onBeforeTextureInitObservable: Observable<Texture>;
  34200. /**
  34201. * Creates a new engine
  34202. * @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
  34203. * @param antialias defines enable antialiasing (default: false)
  34204. * @param options defines further options to be sent to the getContext() function
  34205. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34206. */
  34207. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34208. private _rebuildInternalTextures;
  34209. private _rebuildEffects;
  34210. /**
  34211. * Gets a boolean indicating if all created effects are ready
  34212. * @returns true if all effects are ready
  34213. */
  34214. areAllEffectsReady(): boolean;
  34215. protected _rebuildBuffers(): void;
  34216. protected _initGLContext(): void;
  34217. /**
  34218. * Gets version of the current webGL context
  34219. */
  34220. get webGLVersion(): number;
  34221. /**
  34222. * Gets a string idenfifying the name of the class
  34223. * @returns "Engine" string
  34224. */
  34225. getClassName(): string;
  34226. /**
  34227. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34228. */
  34229. get isStencilEnable(): boolean;
  34230. /** @hidden */
  34231. _prepareWorkingCanvas(): void;
  34232. /**
  34233. * Reset the texture cache to empty state
  34234. */
  34235. resetTextureCache(): void;
  34236. /**
  34237. * Gets an object containing information about the current webGL context
  34238. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34239. */
  34240. getGlInfo(): {
  34241. vendor: string;
  34242. renderer: string;
  34243. version: string;
  34244. };
  34245. /**
  34246. * Defines the hardware scaling level.
  34247. * By default the hardware scaling level is computed from the window device ratio.
  34248. * 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.
  34249. * @param level defines the level to use
  34250. */
  34251. setHardwareScalingLevel(level: number): void;
  34252. /**
  34253. * Gets the current hardware scaling level.
  34254. * By default the hardware scaling level is computed from the window device ratio.
  34255. * 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.
  34256. * @returns a number indicating the current hardware scaling level
  34257. */
  34258. getHardwareScalingLevel(): number;
  34259. /**
  34260. * Gets the list of loaded textures
  34261. * @returns an array containing all loaded textures
  34262. */
  34263. getLoadedTexturesCache(): InternalTexture[];
  34264. /**
  34265. * Gets the object containing all engine capabilities
  34266. * @returns the EngineCapabilities object
  34267. */
  34268. getCaps(): EngineCapabilities;
  34269. /**
  34270. * stop executing a render loop function and remove it from the execution array
  34271. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34272. */
  34273. stopRenderLoop(renderFunction?: () => void): void;
  34274. /** @hidden */
  34275. _renderLoop(): void;
  34276. /**
  34277. * Gets the HTML canvas attached with the current webGL context
  34278. * @returns a HTML canvas
  34279. */
  34280. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34281. /**
  34282. * Gets host window
  34283. * @returns the host window object
  34284. */
  34285. getHostWindow(): Nullable<Window>;
  34286. /**
  34287. * Gets the current render width
  34288. * @param useScreen defines if screen size must be used (or the current render target if any)
  34289. * @returns a number defining the current render width
  34290. */
  34291. getRenderWidth(useScreen?: boolean): number;
  34292. /**
  34293. * Gets the current render height
  34294. * @param useScreen defines if screen size must be used (or the current render target if any)
  34295. * @returns a number defining the current render height
  34296. */
  34297. getRenderHeight(useScreen?: boolean): number;
  34298. /**
  34299. * Can be used to override the current requestAnimationFrame requester.
  34300. * @hidden
  34301. */
  34302. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34303. /**
  34304. * Register and execute a render loop. The engine can have more than one render function
  34305. * @param renderFunction defines the function to continuously execute
  34306. */
  34307. runRenderLoop(renderFunction: () => void): void;
  34308. /**
  34309. * Clear the current render buffer or the current render target (if any is set up)
  34310. * @param color defines the color to use
  34311. * @param backBuffer defines if the back buffer must be cleared
  34312. * @param depth defines if the depth buffer must be cleared
  34313. * @param stencil defines if the stencil buffer must be cleared
  34314. */
  34315. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34316. private _viewportCached;
  34317. /** @hidden */
  34318. _viewport(x: number, y: number, width: number, height: number): void;
  34319. /**
  34320. * Set the WebGL's viewport
  34321. * @param viewport defines the viewport element to be used
  34322. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34323. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34324. */
  34325. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34326. /**
  34327. * Begin a new frame
  34328. */
  34329. beginFrame(): void;
  34330. /**
  34331. * Enf the current frame
  34332. */
  34333. endFrame(): void;
  34334. /**
  34335. * Resize the view according to the canvas' size
  34336. */
  34337. resize(): void;
  34338. /**
  34339. * Force a specific size of the canvas
  34340. * @param width defines the new canvas' width
  34341. * @param height defines the new canvas' height
  34342. */
  34343. setSize(width: number, height: number): void;
  34344. /**
  34345. * Binds the frame buffer to the specified texture.
  34346. * @param texture The texture to render to or null for the default canvas
  34347. * @param faceIndex The face of the texture to render to in case of cube texture
  34348. * @param requiredWidth The width of the target to render to
  34349. * @param requiredHeight The height of the target to render to
  34350. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34351. * @param lodLevel defines the lod level to bind to the frame buffer
  34352. * @param layer defines the 2d array index to bind to frame buffer to
  34353. */
  34354. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34355. /** @hidden */
  34356. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34357. /**
  34358. * Unbind the current render target texture from the webGL context
  34359. * @param texture defines the render target texture to unbind
  34360. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34361. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34362. */
  34363. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34364. /**
  34365. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34366. */
  34367. flushFramebuffer(): void;
  34368. /**
  34369. * Unbind the current render target and bind the default framebuffer
  34370. */
  34371. restoreDefaultFramebuffer(): void;
  34372. /** @hidden */
  34373. protected _resetVertexBufferBinding(): void;
  34374. /**
  34375. * Creates a vertex buffer
  34376. * @param data the data for the vertex buffer
  34377. * @returns the new WebGL static buffer
  34378. */
  34379. createVertexBuffer(data: DataArray): DataBuffer;
  34380. private _createVertexBuffer;
  34381. /**
  34382. * Creates a dynamic vertex buffer
  34383. * @param data the data for the dynamic vertex buffer
  34384. * @returns the new WebGL dynamic buffer
  34385. */
  34386. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34387. protected _resetIndexBufferBinding(): void;
  34388. /**
  34389. * Creates a new index buffer
  34390. * @param indices defines the content of the index buffer
  34391. * @param updatable defines if the index buffer must be updatable
  34392. * @returns a new webGL buffer
  34393. */
  34394. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34395. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34396. /**
  34397. * Bind a webGL buffer to the webGL context
  34398. * @param buffer defines the buffer to bind
  34399. */
  34400. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34401. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34402. private bindBuffer;
  34403. /**
  34404. * update the bound buffer with the given data
  34405. * @param data defines the data to update
  34406. */
  34407. updateArrayBuffer(data: Float32Array): void;
  34408. private _vertexAttribPointer;
  34409. /** @hidden */
  34410. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34411. private _bindVertexBuffersAttributes;
  34412. /**
  34413. * Records a vertex array object
  34414. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34415. * @param vertexBuffers defines the list of vertex buffers to store
  34416. * @param indexBuffer defines the index buffer to store
  34417. * @param effect defines the effect to store
  34418. * @returns the new vertex array object
  34419. */
  34420. recordVertexArrayObject(vertexBuffers: {
  34421. [key: string]: VertexBuffer;
  34422. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34423. /**
  34424. * Bind a specific vertex array object
  34425. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34426. * @param vertexArrayObject defines the vertex array object to bind
  34427. * @param indexBuffer defines the index buffer to bind
  34428. */
  34429. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34430. /**
  34431. * Bind webGl buffers directly to the webGL context
  34432. * @param vertexBuffer defines the vertex buffer to bind
  34433. * @param indexBuffer defines the index buffer to bind
  34434. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34435. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34436. * @param effect defines the effect associated with the vertex buffer
  34437. */
  34438. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34439. private _unbindVertexArrayObject;
  34440. /**
  34441. * Bind a list of vertex buffers to the webGL context
  34442. * @param vertexBuffers defines the list of vertex buffers to bind
  34443. * @param indexBuffer defines the index buffer to bind
  34444. * @param effect defines the effect associated with the vertex buffers
  34445. */
  34446. bindBuffers(vertexBuffers: {
  34447. [key: string]: Nullable<VertexBuffer>;
  34448. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34449. /**
  34450. * Unbind all instance attributes
  34451. */
  34452. unbindInstanceAttributes(): void;
  34453. /**
  34454. * Release and free the memory of a vertex array object
  34455. * @param vao defines the vertex array object to delete
  34456. */
  34457. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34458. /** @hidden */
  34459. _releaseBuffer(buffer: DataBuffer): boolean;
  34460. protected _deleteBuffer(buffer: DataBuffer): void;
  34461. /**
  34462. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34463. * @param instancesBuffer defines the webGL buffer to update and bind
  34464. * @param data defines the data to store in the buffer
  34465. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34466. */
  34467. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34468. /**
  34469. * Bind the content of a webGL buffer used with instantiation
  34470. * @param instancesBuffer defines the webGL buffer to bind
  34471. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34472. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34473. */
  34474. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34475. /**
  34476. * Disable the instance attribute corresponding to the name in parameter
  34477. * @param name defines the name of the attribute to disable
  34478. */
  34479. disableInstanceAttributeByName(name: string): void;
  34480. /**
  34481. * Disable the instance attribute corresponding to the location in parameter
  34482. * @param attributeLocation defines the attribute location of the attribute to disable
  34483. */
  34484. disableInstanceAttribute(attributeLocation: number): void;
  34485. /**
  34486. * Disable the attribute corresponding to the location in parameter
  34487. * @param attributeLocation defines the attribute location of the attribute to disable
  34488. */
  34489. disableAttributeByIndex(attributeLocation: number): void;
  34490. /**
  34491. * Send a draw order
  34492. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34493. * @param indexStart defines the starting index
  34494. * @param indexCount defines the number of index to draw
  34495. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34496. */
  34497. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34498. /**
  34499. * Draw a list of points
  34500. * @param verticesStart defines the index of first vertex to draw
  34501. * @param verticesCount defines the count of vertices to draw
  34502. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34503. */
  34504. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34505. /**
  34506. * Draw a list of unindexed primitives
  34507. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34508. * @param verticesStart defines the index of first vertex to draw
  34509. * @param verticesCount defines the count of vertices to draw
  34510. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34511. */
  34512. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34513. /**
  34514. * Draw a list of indexed primitives
  34515. * @param fillMode defines the primitive to use
  34516. * @param indexStart defines the starting index
  34517. * @param indexCount defines the number of index to draw
  34518. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34519. */
  34520. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34521. /**
  34522. * Draw a list of unindexed primitives
  34523. * @param fillMode defines the primitive to use
  34524. * @param verticesStart defines the index of first vertex to draw
  34525. * @param verticesCount defines the count of vertices to draw
  34526. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34527. */
  34528. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34529. private _drawMode;
  34530. /** @hidden */
  34531. protected _reportDrawCall(): void;
  34532. /** @hidden */
  34533. _releaseEffect(effect: Effect): void;
  34534. /** @hidden */
  34535. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34536. /**
  34537. * Create a new effect (used to store vertex/fragment shaders)
  34538. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34539. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34540. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34541. * @param samplers defines an array of string used to represent textures
  34542. * @param defines defines the string containing the defines to use to compile the shaders
  34543. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34544. * @param onCompiled defines a function to call when the effect creation is successful
  34545. * @param onError defines a function to call when the effect creation has failed
  34546. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34547. * @returns the new Effect
  34548. */
  34549. 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;
  34550. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34551. private _compileShader;
  34552. private _compileRawShader;
  34553. /** @hidden */
  34554. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34555. /**
  34556. * Directly creates a webGL program
  34557. * @param pipelineContext defines the pipeline context to attach to
  34558. * @param vertexCode defines the vertex shader code to use
  34559. * @param fragmentCode defines the fragment shader code to use
  34560. * @param context defines the webGL context to use (if not set, the current one will be used)
  34561. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34562. * @returns the new webGL program
  34563. */
  34564. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34565. /**
  34566. * Creates a webGL program
  34567. * @param pipelineContext defines the pipeline context to attach to
  34568. * @param vertexCode defines the vertex shader code to use
  34569. * @param fragmentCode defines the fragment shader code to use
  34570. * @param defines defines the string containing the defines to use to compile the shaders
  34571. * @param context defines the webGL context to use (if not set, the current one will be used)
  34572. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34573. * @returns the new webGL program
  34574. */
  34575. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34576. /**
  34577. * Creates a new pipeline context
  34578. * @returns the new pipeline
  34579. */
  34580. createPipelineContext(): IPipelineContext;
  34581. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34582. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34583. /** @hidden */
  34584. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34585. /** @hidden */
  34586. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34587. /** @hidden */
  34588. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34589. /**
  34590. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34591. * @param pipelineContext defines the pipeline context to use
  34592. * @param uniformsNames defines the list of uniform names
  34593. * @returns an array of webGL uniform locations
  34594. */
  34595. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34596. /**
  34597. * Gets the lsit of active attributes for a given webGL program
  34598. * @param pipelineContext defines the pipeline context to use
  34599. * @param attributesNames defines the list of attribute names to get
  34600. * @returns an array of indices indicating the offset of each attribute
  34601. */
  34602. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34603. /**
  34604. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34605. * @param effect defines the effect to activate
  34606. */
  34607. enableEffect(effect: Nullable<Effect>): void;
  34608. /**
  34609. * Set the value of an uniform to a number (int)
  34610. * @param uniform defines the webGL uniform location where to store the value
  34611. * @param value defines the int number to store
  34612. */
  34613. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34614. /**
  34615. * Set the value of an uniform to an array of int32
  34616. * @param uniform defines the webGL uniform location where to store the value
  34617. * @param array defines the array of int32 to store
  34618. */
  34619. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34620. /**
  34621. * Set the value of an uniform to an array of int32 (stored as vec2)
  34622. * @param uniform defines the webGL uniform location where to store the value
  34623. * @param array defines the array of int32 to store
  34624. */
  34625. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34626. /**
  34627. * Set the value of an uniform to an array of int32 (stored as vec3)
  34628. * @param uniform defines the webGL uniform location where to store the value
  34629. * @param array defines the array of int32 to store
  34630. */
  34631. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34632. /**
  34633. * Set the value of an uniform to an array of int32 (stored as vec4)
  34634. * @param uniform defines the webGL uniform location where to store the value
  34635. * @param array defines the array of int32 to store
  34636. */
  34637. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34638. /**
  34639. * Set the value of an uniform to an array of number
  34640. * @param uniform defines the webGL uniform location where to store the value
  34641. * @param array defines the array of number to store
  34642. */
  34643. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34644. /**
  34645. * Set the value of an uniform to an array of number (stored as vec2)
  34646. * @param uniform defines the webGL uniform location where to store the value
  34647. * @param array defines the array of number to store
  34648. */
  34649. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34650. /**
  34651. * Set the value of an uniform to an array of number (stored as vec3)
  34652. * @param uniform defines the webGL uniform location where to store the value
  34653. * @param array defines the array of number to store
  34654. */
  34655. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34656. /**
  34657. * Set the value of an uniform to an array of number (stored as vec4)
  34658. * @param uniform defines the webGL uniform location where to store the value
  34659. * @param array defines the array of number to store
  34660. */
  34661. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34662. /**
  34663. * Set the value of an uniform to an array of float32 (stored as matrices)
  34664. * @param uniform defines the webGL uniform location where to store the value
  34665. * @param matrices defines the array of float32 to store
  34666. */
  34667. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  34668. /**
  34669. * Set the value of an uniform to a matrix (3x3)
  34670. * @param uniform defines the webGL uniform location where to store the value
  34671. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  34672. */
  34673. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34674. /**
  34675. * Set the value of an uniform to a matrix (2x2)
  34676. * @param uniform defines the webGL uniform location where to store the value
  34677. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  34678. */
  34679. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34680. /**
  34681. * Set the value of an uniform to a number (float)
  34682. * @param uniform defines the webGL uniform location where to store the value
  34683. * @param value defines the float number to store
  34684. */
  34685. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34686. /**
  34687. * Set the value of an uniform to a vec2
  34688. * @param uniform defines the webGL uniform location where to store the value
  34689. * @param x defines the 1st component of the value
  34690. * @param y defines the 2nd component of the value
  34691. */
  34692. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  34693. /**
  34694. * Set the value of an uniform to a vec3
  34695. * @param uniform defines the webGL uniform location where to store the value
  34696. * @param x defines the 1st component of the value
  34697. * @param y defines the 2nd component of the value
  34698. * @param z defines the 3rd component of the value
  34699. */
  34700. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  34701. /**
  34702. * Set the value of an uniform to a vec4
  34703. * @param uniform defines the webGL uniform location where to store the value
  34704. * @param x defines the 1st component of the value
  34705. * @param y defines the 2nd component of the value
  34706. * @param z defines the 3rd component of the value
  34707. * @param w defines the 4th component of the value
  34708. */
  34709. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  34710. /**
  34711. * Apply all cached states (depth, culling, stencil and alpha)
  34712. */
  34713. applyStates(): void;
  34714. /**
  34715. * Enable or disable color writing
  34716. * @param enable defines the state to set
  34717. */
  34718. setColorWrite(enable: boolean): void;
  34719. /**
  34720. * Gets a boolean indicating if color writing is enabled
  34721. * @returns the current color writing state
  34722. */
  34723. getColorWrite(): boolean;
  34724. /**
  34725. * Gets the depth culling state manager
  34726. */
  34727. get depthCullingState(): DepthCullingState;
  34728. /**
  34729. * Gets the alpha state manager
  34730. */
  34731. get alphaState(): AlphaState;
  34732. /**
  34733. * Gets the stencil state manager
  34734. */
  34735. get stencilState(): StencilState;
  34736. /**
  34737. * Clears the list of texture accessible through engine.
  34738. * This can help preventing texture load conflict due to name collision.
  34739. */
  34740. clearInternalTexturesCache(): void;
  34741. /**
  34742. * Force the entire cache to be cleared
  34743. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  34744. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  34745. */
  34746. wipeCaches(bruteForce?: boolean): void;
  34747. /** @hidden */
  34748. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  34749. min: number;
  34750. mag: number;
  34751. };
  34752. /** @hidden */
  34753. _createTexture(): WebGLTexture;
  34754. /**
  34755. * Usually called from Texture.ts.
  34756. * Passed information to create a WebGLTexture
  34757. * @param url defines a value which contains one of the following:
  34758. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  34759. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  34760. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  34761. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  34762. * @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)
  34763. * @param scene needed for loading to the correct scene
  34764. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  34765. * @param onLoad optional callback to be called upon successful completion
  34766. * @param onError optional callback to be called upon failure
  34767. * @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
  34768. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  34769. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  34770. * @param forcedExtension defines the extension to use to pick the right loader
  34771. * @param mimeType defines an optional mime type
  34772. * @returns a InternalTexture for assignment back into BABYLON.Texture
  34773. */
  34774. 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;
  34775. /**
  34776. * Loads an image as an HTMLImageElement.
  34777. * @param input url string, ArrayBuffer, or Blob to load
  34778. * @param onLoad callback called when the image successfully loads
  34779. * @param onError callback called when the image fails to load
  34780. * @param offlineProvider offline provider for caching
  34781. * @param mimeType optional mime type
  34782. * @returns the HTMLImageElement of the loaded image
  34783. * @hidden
  34784. */
  34785. 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>;
  34786. /**
  34787. * @hidden
  34788. */
  34789. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34790. private _unpackFlipYCached;
  34791. /**
  34792. * In case you are sharing the context with other applications, it might
  34793. * be interested to not cache the unpack flip y state to ensure a consistent
  34794. * value would be set.
  34795. */
  34796. enableUnpackFlipYCached: boolean;
  34797. /** @hidden */
  34798. _unpackFlipY(value: boolean): void;
  34799. /** @hidden */
  34800. _getUnpackAlignement(): number;
  34801. private _getTextureTarget;
  34802. /**
  34803. * Update the sampling mode of a given texture
  34804. * @param samplingMode defines the required sampling mode
  34805. * @param texture defines the texture to update
  34806. * @param generateMipMaps defines whether to generate mipmaps for the texture
  34807. */
  34808. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  34809. /**
  34810. * Update the sampling mode of a given texture
  34811. * @param texture defines the texture to update
  34812. * @param wrapU defines the texture wrap mode of the u coordinates
  34813. * @param wrapV defines the texture wrap mode of the v coordinates
  34814. * @param wrapR defines the texture wrap mode of the r coordinates
  34815. */
  34816. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  34817. /** @hidden */
  34818. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  34819. width: number;
  34820. height: number;
  34821. layers?: number;
  34822. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  34823. /** @hidden */
  34824. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34825. /** @hidden */
  34826. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  34827. /**
  34828. * Update a portion of an internal texture
  34829. * @param texture defines the texture to update
  34830. * @param imageData defines the data to store into the texture
  34831. * @param xOffset defines the x coordinates of the update rectangle
  34832. * @param yOffset defines the y coordinates of the update rectangle
  34833. * @param width defines the width of the update rectangle
  34834. * @param height defines the height of the update rectangle
  34835. * @param faceIndex defines the face index if texture is a cube (0 by default)
  34836. * @param lod defines the lod level to update (0 by default)
  34837. */
  34838. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  34839. /** @hidden */
  34840. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34841. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  34842. private _prepareWebGLTexture;
  34843. /** @hidden */
  34844. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  34845. private _getDepthStencilBuffer;
  34846. /** @hidden */
  34847. _releaseFramebufferObjects(texture: InternalTexture): void;
  34848. /** @hidden */
  34849. _releaseTexture(texture: InternalTexture): void;
  34850. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  34851. protected _setProgram(program: WebGLProgram): void;
  34852. protected _boundUniforms: {
  34853. [key: number]: WebGLUniformLocation;
  34854. };
  34855. /**
  34856. * Binds an effect to the webGL context
  34857. * @param effect defines the effect to bind
  34858. */
  34859. bindSamplers(effect: Effect): void;
  34860. private _activateCurrentTexture;
  34861. /** @hidden */
  34862. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  34863. /** @hidden */
  34864. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  34865. /**
  34866. * Unbind all textures from the webGL context
  34867. */
  34868. unbindAllTextures(): void;
  34869. /**
  34870. * Sets a texture to the according uniform.
  34871. * @param channel The texture channel
  34872. * @param uniform The uniform to set
  34873. * @param texture The texture to apply
  34874. */
  34875. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  34876. private _bindSamplerUniformToChannel;
  34877. private _getTextureWrapMode;
  34878. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  34879. /**
  34880. * Sets an array of texture to the webGL context
  34881. * @param channel defines the channel where the texture array must be set
  34882. * @param uniform defines the associated uniform location
  34883. * @param textures defines the array of textures to bind
  34884. */
  34885. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  34886. /** @hidden */
  34887. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  34888. private _setTextureParameterFloat;
  34889. private _setTextureParameterInteger;
  34890. /**
  34891. * Unbind all vertex attributes from the webGL context
  34892. */
  34893. unbindAllAttributes(): void;
  34894. /**
  34895. * 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
  34896. */
  34897. releaseEffects(): void;
  34898. /**
  34899. * Dispose and release all associated resources
  34900. */
  34901. dispose(): void;
  34902. /**
  34903. * Attach a new callback raised when context lost event is fired
  34904. * @param callback defines the callback to call
  34905. */
  34906. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  34907. /**
  34908. * Attach a new callback raised when context restored event is fired
  34909. * @param callback defines the callback to call
  34910. */
  34911. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  34912. /**
  34913. * Get the current error code of the webGL context
  34914. * @returns the error code
  34915. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34916. */
  34917. getError(): number;
  34918. private _canRenderToFloatFramebuffer;
  34919. private _canRenderToHalfFloatFramebuffer;
  34920. private _canRenderToFramebuffer;
  34921. /** @hidden */
  34922. _getWebGLTextureType(type: number): number;
  34923. /** @hidden */
  34924. _getInternalFormat(format: number): number;
  34925. /** @hidden */
  34926. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  34927. /** @hidden */
  34928. _getRGBAMultiSampleBufferFormat(type: number): number;
  34929. /** @hidden */
  34930. _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;
  34931. /**
  34932. * Loads a file from a url
  34933. * @param url url to load
  34934. * @param onSuccess callback called when the file successfully loads
  34935. * @param onProgress callback called while file is loading (if the server supports this mode)
  34936. * @param offlineProvider defines the offline provider for caching
  34937. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34938. * @param onError callback called when the file fails to load
  34939. * @returns a file request object
  34940. * @hidden
  34941. */
  34942. 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;
  34943. /**
  34944. * Reads pixels from the current frame buffer. Please note that this function can be slow
  34945. * @param x defines the x coordinate of the rectangle where pixels must be read
  34946. * @param y defines the y coordinate of the rectangle where pixels must be read
  34947. * @param width defines the width of the rectangle where pixels must be read
  34948. * @param height defines the height of the rectangle where pixels must be read
  34949. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  34950. * @returns a Uint8Array containing RGBA colors
  34951. */
  34952. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  34953. private static _isSupported;
  34954. /**
  34955. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  34956. * @returns true if the engine can be created
  34957. * @ignorenaming
  34958. */
  34959. static isSupported(): boolean;
  34960. /**
  34961. * Find the next highest power of two.
  34962. * @param x Number to start search from.
  34963. * @return Next highest power of two.
  34964. */
  34965. static CeilingPOT(x: number): number;
  34966. /**
  34967. * Find the next lowest power of two.
  34968. * @param x Number to start search from.
  34969. * @return Next lowest power of two.
  34970. */
  34971. static FloorPOT(x: number): number;
  34972. /**
  34973. * Find the nearest power of two.
  34974. * @param x Number to start search from.
  34975. * @return Next nearest power of two.
  34976. */
  34977. static NearestPOT(x: number): number;
  34978. /**
  34979. * Get the closest exponent of two
  34980. * @param value defines the value to approximate
  34981. * @param max defines the maximum value to return
  34982. * @param mode defines how to define the closest value
  34983. * @returns closest exponent of two of the given value
  34984. */
  34985. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  34986. /**
  34987. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  34988. * @param func - the function to be called
  34989. * @param requester - the object that will request the next frame. Falls back to window.
  34990. * @returns frame number
  34991. */
  34992. static QueueNewFrame(func: () => void, requester?: any): number;
  34993. /**
  34994. * Gets host document
  34995. * @returns the host document object
  34996. */
  34997. getHostDocument(): Nullable<Document>;
  34998. }
  34999. }
  35000. declare module BABYLON {
  35001. /**
  35002. * Class representing spherical harmonics coefficients to the 3rd degree
  35003. */
  35004. export class SphericalHarmonics {
  35005. /**
  35006. * Defines whether or not the harmonics have been prescaled for rendering.
  35007. */
  35008. preScaled: boolean;
  35009. /**
  35010. * The l0,0 coefficients of the spherical harmonics
  35011. */
  35012. l00: Vector3;
  35013. /**
  35014. * The l1,-1 coefficients of the spherical harmonics
  35015. */
  35016. l1_1: Vector3;
  35017. /**
  35018. * The l1,0 coefficients of the spherical harmonics
  35019. */
  35020. l10: Vector3;
  35021. /**
  35022. * The l1,1 coefficients of the spherical harmonics
  35023. */
  35024. l11: Vector3;
  35025. /**
  35026. * The l2,-2 coefficients of the spherical harmonics
  35027. */
  35028. l2_2: Vector3;
  35029. /**
  35030. * The l2,-1 coefficients of the spherical harmonics
  35031. */
  35032. l2_1: Vector3;
  35033. /**
  35034. * The l2,0 coefficients of the spherical harmonics
  35035. */
  35036. l20: Vector3;
  35037. /**
  35038. * The l2,1 coefficients of the spherical harmonics
  35039. */
  35040. l21: Vector3;
  35041. /**
  35042. * The l2,2 coefficients of the spherical harmonics
  35043. */
  35044. l22: Vector3;
  35045. /**
  35046. * Adds a light to the spherical harmonics
  35047. * @param direction the direction of the light
  35048. * @param color the color of the light
  35049. * @param deltaSolidAngle the delta solid angle of the light
  35050. */
  35051. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35052. /**
  35053. * Scales the spherical harmonics by the given amount
  35054. * @param scale the amount to scale
  35055. */
  35056. scaleInPlace(scale: number): void;
  35057. /**
  35058. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35059. *
  35060. * ```
  35061. * E_lm = A_l * L_lm
  35062. * ```
  35063. *
  35064. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35065. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35066. * the scaling factors are given in equation 9.
  35067. */
  35068. convertIncidentRadianceToIrradiance(): void;
  35069. /**
  35070. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35071. *
  35072. * ```
  35073. * L = (1/pi) * E * rho
  35074. * ```
  35075. *
  35076. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35077. */
  35078. convertIrradianceToLambertianRadiance(): void;
  35079. /**
  35080. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35081. * required operations at run time.
  35082. *
  35083. * This is simply done by scaling back the SH with Ylm constants parameter.
  35084. * The trigonometric part being applied by the shader at run time.
  35085. */
  35086. preScaleForRendering(): void;
  35087. /**
  35088. * Constructs a spherical harmonics from an array.
  35089. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35090. * @returns the spherical harmonics
  35091. */
  35092. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35093. /**
  35094. * Gets the spherical harmonics from polynomial
  35095. * @param polynomial the spherical polynomial
  35096. * @returns the spherical harmonics
  35097. */
  35098. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35099. }
  35100. /**
  35101. * Class representing spherical polynomial coefficients to the 3rd degree
  35102. */
  35103. export class SphericalPolynomial {
  35104. private _harmonics;
  35105. /**
  35106. * The spherical harmonics used to create the polynomials.
  35107. */
  35108. get preScaledHarmonics(): SphericalHarmonics;
  35109. /**
  35110. * The x coefficients of the spherical polynomial
  35111. */
  35112. x: Vector3;
  35113. /**
  35114. * The y coefficients of the spherical polynomial
  35115. */
  35116. y: Vector3;
  35117. /**
  35118. * The z coefficients of the spherical polynomial
  35119. */
  35120. z: Vector3;
  35121. /**
  35122. * The xx coefficients of the spherical polynomial
  35123. */
  35124. xx: Vector3;
  35125. /**
  35126. * The yy coefficients of the spherical polynomial
  35127. */
  35128. yy: Vector3;
  35129. /**
  35130. * The zz coefficients of the spherical polynomial
  35131. */
  35132. zz: Vector3;
  35133. /**
  35134. * The xy coefficients of the spherical polynomial
  35135. */
  35136. xy: Vector3;
  35137. /**
  35138. * The yz coefficients of the spherical polynomial
  35139. */
  35140. yz: Vector3;
  35141. /**
  35142. * The zx coefficients of the spherical polynomial
  35143. */
  35144. zx: Vector3;
  35145. /**
  35146. * Adds an ambient color to the spherical polynomial
  35147. * @param color the color to add
  35148. */
  35149. addAmbient(color: Color3): void;
  35150. /**
  35151. * Scales the spherical polynomial by the given amount
  35152. * @param scale the amount to scale
  35153. */
  35154. scaleInPlace(scale: number): void;
  35155. /**
  35156. * Gets the spherical polynomial from harmonics
  35157. * @param harmonics the spherical harmonics
  35158. * @returns the spherical polynomial
  35159. */
  35160. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35161. /**
  35162. * Constructs a spherical polynomial from an array.
  35163. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35164. * @returns the spherical polynomial
  35165. */
  35166. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35167. }
  35168. }
  35169. declare module BABYLON {
  35170. /**
  35171. * Defines the source of the internal texture
  35172. */
  35173. export enum InternalTextureSource {
  35174. /**
  35175. * The source of the texture data is unknown
  35176. */
  35177. Unknown = 0,
  35178. /**
  35179. * Texture data comes from an URL
  35180. */
  35181. Url = 1,
  35182. /**
  35183. * Texture data is only used for temporary storage
  35184. */
  35185. Temp = 2,
  35186. /**
  35187. * Texture data comes from raw data (ArrayBuffer)
  35188. */
  35189. Raw = 3,
  35190. /**
  35191. * Texture content is dynamic (video or dynamic texture)
  35192. */
  35193. Dynamic = 4,
  35194. /**
  35195. * Texture content is generated by rendering to it
  35196. */
  35197. RenderTarget = 5,
  35198. /**
  35199. * Texture content is part of a multi render target process
  35200. */
  35201. MultiRenderTarget = 6,
  35202. /**
  35203. * Texture data comes from a cube data file
  35204. */
  35205. Cube = 7,
  35206. /**
  35207. * Texture data comes from a raw cube data
  35208. */
  35209. CubeRaw = 8,
  35210. /**
  35211. * Texture data come from a prefiltered cube data file
  35212. */
  35213. CubePrefiltered = 9,
  35214. /**
  35215. * Texture content is raw 3D data
  35216. */
  35217. Raw3D = 10,
  35218. /**
  35219. * Texture content is raw 2D array data
  35220. */
  35221. Raw2DArray = 11,
  35222. /**
  35223. * Texture content is a depth texture
  35224. */
  35225. Depth = 12,
  35226. /**
  35227. * Texture data comes from a raw cube data encoded with RGBD
  35228. */
  35229. CubeRawRGBD = 13
  35230. }
  35231. /**
  35232. * Class used to store data associated with WebGL texture data for the engine
  35233. * This class should not be used directly
  35234. */
  35235. export class InternalTexture {
  35236. /** @hidden */
  35237. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35238. /**
  35239. * Defines if the texture is ready
  35240. */
  35241. isReady: boolean;
  35242. /**
  35243. * Defines if the texture is a cube texture
  35244. */
  35245. isCube: boolean;
  35246. /**
  35247. * Defines if the texture contains 3D data
  35248. */
  35249. is3D: boolean;
  35250. /**
  35251. * Defines if the texture contains 2D array data
  35252. */
  35253. is2DArray: boolean;
  35254. /**
  35255. * Defines if the texture contains multiview data
  35256. */
  35257. isMultiview: boolean;
  35258. /**
  35259. * Gets the URL used to load this texture
  35260. */
  35261. url: string;
  35262. /**
  35263. * Gets the sampling mode of the texture
  35264. */
  35265. samplingMode: number;
  35266. /**
  35267. * Gets a boolean indicating if the texture needs mipmaps generation
  35268. */
  35269. generateMipMaps: boolean;
  35270. /**
  35271. * Gets the number of samples used by the texture (WebGL2+ only)
  35272. */
  35273. samples: number;
  35274. /**
  35275. * Gets the type of the texture (int, float...)
  35276. */
  35277. type: number;
  35278. /**
  35279. * Gets the format of the texture (RGB, RGBA...)
  35280. */
  35281. format: number;
  35282. /**
  35283. * Observable called when the texture is loaded
  35284. */
  35285. onLoadedObservable: Observable<InternalTexture>;
  35286. /**
  35287. * Gets the width of the texture
  35288. */
  35289. width: number;
  35290. /**
  35291. * Gets the height of the texture
  35292. */
  35293. height: number;
  35294. /**
  35295. * Gets the depth of the texture
  35296. */
  35297. depth: number;
  35298. /**
  35299. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35300. */
  35301. baseWidth: number;
  35302. /**
  35303. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35304. */
  35305. baseHeight: number;
  35306. /**
  35307. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35308. */
  35309. baseDepth: number;
  35310. /**
  35311. * Gets a boolean indicating if the texture is inverted on Y axis
  35312. */
  35313. invertY: boolean;
  35314. /** @hidden */
  35315. _invertVScale: boolean;
  35316. /** @hidden */
  35317. _associatedChannel: number;
  35318. /** @hidden */
  35319. _source: InternalTextureSource;
  35320. /** @hidden */
  35321. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35322. /** @hidden */
  35323. _bufferView: Nullable<ArrayBufferView>;
  35324. /** @hidden */
  35325. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35326. /** @hidden */
  35327. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35328. /** @hidden */
  35329. _size: number;
  35330. /** @hidden */
  35331. _extension: string;
  35332. /** @hidden */
  35333. _files: Nullable<string[]>;
  35334. /** @hidden */
  35335. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35336. /** @hidden */
  35337. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35338. /** @hidden */
  35339. _framebuffer: Nullable<WebGLFramebuffer>;
  35340. /** @hidden */
  35341. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35342. /** @hidden */
  35343. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35344. /** @hidden */
  35345. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35346. /** @hidden */
  35347. _attachments: Nullable<number[]>;
  35348. /** @hidden */
  35349. _cachedCoordinatesMode: Nullable<number>;
  35350. /** @hidden */
  35351. _cachedWrapU: Nullable<number>;
  35352. /** @hidden */
  35353. _cachedWrapV: Nullable<number>;
  35354. /** @hidden */
  35355. _cachedWrapR: Nullable<number>;
  35356. /** @hidden */
  35357. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35358. /** @hidden */
  35359. _isDisabled: boolean;
  35360. /** @hidden */
  35361. _compression: Nullable<string>;
  35362. /** @hidden */
  35363. _generateStencilBuffer: boolean;
  35364. /** @hidden */
  35365. _generateDepthBuffer: boolean;
  35366. /** @hidden */
  35367. _comparisonFunction: number;
  35368. /** @hidden */
  35369. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35370. /** @hidden */
  35371. _lodGenerationScale: number;
  35372. /** @hidden */
  35373. _lodGenerationOffset: number;
  35374. /** @hidden */
  35375. _depthStencilTexture: Nullable<InternalTexture>;
  35376. /** @hidden */
  35377. _colorTextureArray: Nullable<WebGLTexture>;
  35378. /** @hidden */
  35379. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35380. /** @hidden */
  35381. _lodTextureHigh: Nullable<BaseTexture>;
  35382. /** @hidden */
  35383. _lodTextureMid: Nullable<BaseTexture>;
  35384. /** @hidden */
  35385. _lodTextureLow: Nullable<BaseTexture>;
  35386. /** @hidden */
  35387. _isRGBD: boolean;
  35388. /** @hidden */
  35389. _linearSpecularLOD: boolean;
  35390. /** @hidden */
  35391. _irradianceTexture: Nullable<BaseTexture>;
  35392. /** @hidden */
  35393. _webGLTexture: Nullable<WebGLTexture>;
  35394. /** @hidden */
  35395. _references: number;
  35396. private _engine;
  35397. /**
  35398. * Gets the Engine the texture belongs to.
  35399. * @returns The babylon engine
  35400. */
  35401. getEngine(): ThinEngine;
  35402. /**
  35403. * Gets the data source type of the texture
  35404. */
  35405. get source(): InternalTextureSource;
  35406. /**
  35407. * Creates a new InternalTexture
  35408. * @param engine defines the engine to use
  35409. * @param source defines the type of data that will be used
  35410. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35411. */
  35412. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35413. /**
  35414. * Increments the number of references (ie. the number of Texture that point to it)
  35415. */
  35416. incrementReferences(): void;
  35417. /**
  35418. * Change the size of the texture (not the size of the content)
  35419. * @param width defines the new width
  35420. * @param height defines the new height
  35421. * @param depth defines the new depth (1 by default)
  35422. */
  35423. updateSize(width: int, height: int, depth?: int): void;
  35424. /** @hidden */
  35425. _rebuild(): void;
  35426. /** @hidden */
  35427. _swapAndDie(target: InternalTexture): void;
  35428. /**
  35429. * Dispose the current allocated resources
  35430. */
  35431. dispose(): void;
  35432. }
  35433. }
  35434. declare module BABYLON {
  35435. /**
  35436. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35438. */
  35439. export class Analyser {
  35440. /**
  35441. * Gets or sets the smoothing
  35442. * @ignorenaming
  35443. */
  35444. SMOOTHING: number;
  35445. /**
  35446. * Gets or sets the FFT table size
  35447. * @ignorenaming
  35448. */
  35449. FFT_SIZE: number;
  35450. /**
  35451. * Gets or sets the bar graph amplitude
  35452. * @ignorenaming
  35453. */
  35454. BARGRAPHAMPLITUDE: number;
  35455. /**
  35456. * Gets or sets the position of the debug canvas
  35457. * @ignorenaming
  35458. */
  35459. DEBUGCANVASPOS: {
  35460. x: number;
  35461. y: number;
  35462. };
  35463. /**
  35464. * Gets or sets the debug canvas size
  35465. * @ignorenaming
  35466. */
  35467. DEBUGCANVASSIZE: {
  35468. width: number;
  35469. height: number;
  35470. };
  35471. private _byteFreqs;
  35472. private _byteTime;
  35473. private _floatFreqs;
  35474. private _webAudioAnalyser;
  35475. private _debugCanvas;
  35476. private _debugCanvasContext;
  35477. private _scene;
  35478. private _registerFunc;
  35479. private _audioEngine;
  35480. /**
  35481. * Creates a new analyser
  35482. * @param scene defines hosting scene
  35483. */
  35484. constructor(scene: Scene);
  35485. /**
  35486. * Get the number of data values you will have to play with for the visualization
  35487. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35488. * @returns a number
  35489. */
  35490. getFrequencyBinCount(): number;
  35491. /**
  35492. * Gets the current frequency data as a byte array
  35493. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35494. * @returns a Uint8Array
  35495. */
  35496. getByteFrequencyData(): Uint8Array;
  35497. /**
  35498. * Gets the current waveform as a byte array
  35499. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35500. * @returns a Uint8Array
  35501. */
  35502. getByteTimeDomainData(): Uint8Array;
  35503. /**
  35504. * Gets the current frequency data as a float array
  35505. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35506. * @returns a Float32Array
  35507. */
  35508. getFloatFrequencyData(): Float32Array;
  35509. /**
  35510. * Renders the debug canvas
  35511. */
  35512. drawDebugCanvas(): void;
  35513. /**
  35514. * Stops rendering the debug canvas and removes it
  35515. */
  35516. stopDebugCanvas(): void;
  35517. /**
  35518. * Connects two audio nodes
  35519. * @param inputAudioNode defines first node to connect
  35520. * @param outputAudioNode defines second node to connect
  35521. */
  35522. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35523. /**
  35524. * Releases all associated resources
  35525. */
  35526. dispose(): void;
  35527. }
  35528. }
  35529. declare module BABYLON {
  35530. /**
  35531. * This represents an audio engine and it is responsible
  35532. * to play, synchronize and analyse sounds throughout the application.
  35533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35534. */
  35535. export interface IAudioEngine extends IDisposable {
  35536. /**
  35537. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35538. */
  35539. readonly canUseWebAudio: boolean;
  35540. /**
  35541. * Gets the current AudioContext if available.
  35542. */
  35543. readonly audioContext: Nullable<AudioContext>;
  35544. /**
  35545. * The master gain node defines the global audio volume of your audio engine.
  35546. */
  35547. readonly masterGain: GainNode;
  35548. /**
  35549. * Gets whether or not mp3 are supported by your browser.
  35550. */
  35551. readonly isMP3supported: boolean;
  35552. /**
  35553. * Gets whether or not ogg are supported by your browser.
  35554. */
  35555. readonly isOGGsupported: boolean;
  35556. /**
  35557. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35558. * @ignoreNaming
  35559. */
  35560. WarnedWebAudioUnsupported: boolean;
  35561. /**
  35562. * Defines if the audio engine relies on a custom unlocked button.
  35563. * In this case, the embedded button will not be displayed.
  35564. */
  35565. useCustomUnlockedButton: boolean;
  35566. /**
  35567. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35568. */
  35569. readonly unlocked: boolean;
  35570. /**
  35571. * Event raised when audio has been unlocked on the browser.
  35572. */
  35573. onAudioUnlockedObservable: Observable<AudioEngine>;
  35574. /**
  35575. * Event raised when audio has been locked on the browser.
  35576. */
  35577. onAudioLockedObservable: Observable<AudioEngine>;
  35578. /**
  35579. * Flags the audio engine in Locked state.
  35580. * This happens due to new browser policies preventing audio to autoplay.
  35581. */
  35582. lock(): void;
  35583. /**
  35584. * Unlocks the audio engine once a user action has been done on the dom.
  35585. * This is helpful to resume play once browser policies have been satisfied.
  35586. */
  35587. unlock(): void;
  35588. /**
  35589. * Gets the global volume sets on the master gain.
  35590. * @returns the global volume if set or -1 otherwise
  35591. */
  35592. getGlobalVolume(): number;
  35593. /**
  35594. * Sets the global volume of your experience (sets on the master gain).
  35595. * @param newVolume Defines the new global volume of the application
  35596. */
  35597. setGlobalVolume(newVolume: number): void;
  35598. /**
  35599. * Connect the audio engine to an audio analyser allowing some amazing
  35600. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35602. * @param analyser The analyser to connect to the engine
  35603. */
  35604. connectToAnalyser(analyser: Analyser): void;
  35605. }
  35606. /**
  35607. * This represents the default audio engine used in babylon.
  35608. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35610. */
  35611. export class AudioEngine implements IAudioEngine {
  35612. private _audioContext;
  35613. private _audioContextInitialized;
  35614. private _muteButton;
  35615. private _hostElement;
  35616. /**
  35617. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35618. */
  35619. canUseWebAudio: boolean;
  35620. /**
  35621. * The master gain node defines the global audio volume of your audio engine.
  35622. */
  35623. masterGain: GainNode;
  35624. /**
  35625. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35626. * @ignoreNaming
  35627. */
  35628. WarnedWebAudioUnsupported: boolean;
  35629. /**
  35630. * Gets whether or not mp3 are supported by your browser.
  35631. */
  35632. isMP3supported: boolean;
  35633. /**
  35634. * Gets whether or not ogg are supported by your browser.
  35635. */
  35636. isOGGsupported: boolean;
  35637. /**
  35638. * Gets whether audio has been unlocked on the device.
  35639. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35640. * a user interaction has happened.
  35641. */
  35642. unlocked: boolean;
  35643. /**
  35644. * Defines if the audio engine relies on a custom unlocked button.
  35645. * In this case, the embedded button will not be displayed.
  35646. */
  35647. useCustomUnlockedButton: boolean;
  35648. /**
  35649. * Event raised when audio has been unlocked on the browser.
  35650. */
  35651. onAudioUnlockedObservable: Observable<AudioEngine>;
  35652. /**
  35653. * Event raised when audio has been locked on the browser.
  35654. */
  35655. onAudioLockedObservable: Observable<AudioEngine>;
  35656. /**
  35657. * Gets the current AudioContext if available.
  35658. */
  35659. get audioContext(): Nullable<AudioContext>;
  35660. private _connectedAnalyser;
  35661. /**
  35662. * Instantiates a new audio engine.
  35663. *
  35664. * There should be only one per page as some browsers restrict the number
  35665. * of audio contexts you can create.
  35666. * @param hostElement defines the host element where to display the mute icon if necessary
  35667. */
  35668. constructor(hostElement?: Nullable<HTMLElement>);
  35669. /**
  35670. * Flags the audio engine in Locked state.
  35671. * This happens due to new browser policies preventing audio to autoplay.
  35672. */
  35673. lock(): void;
  35674. /**
  35675. * Unlocks the audio engine once a user action has been done on the dom.
  35676. * This is helpful to resume play once browser policies have been satisfied.
  35677. */
  35678. unlock(): void;
  35679. private _resumeAudioContext;
  35680. private _initializeAudioContext;
  35681. private _tryToRun;
  35682. private _triggerRunningState;
  35683. private _triggerSuspendedState;
  35684. private _displayMuteButton;
  35685. private _moveButtonToTopLeft;
  35686. private _onResize;
  35687. private _hideMuteButton;
  35688. /**
  35689. * Destroy and release the resources associated with the audio ccontext.
  35690. */
  35691. dispose(): void;
  35692. /**
  35693. * Gets the global volume sets on the master gain.
  35694. * @returns the global volume if set or -1 otherwise
  35695. */
  35696. getGlobalVolume(): number;
  35697. /**
  35698. * Sets the global volume of your experience (sets on the master gain).
  35699. * @param newVolume Defines the new global volume of the application
  35700. */
  35701. setGlobalVolume(newVolume: number): void;
  35702. /**
  35703. * Connect the audio engine to an audio analyser allowing some amazing
  35704. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35706. * @param analyser The analyser to connect to the engine
  35707. */
  35708. connectToAnalyser(analyser: Analyser): void;
  35709. }
  35710. }
  35711. declare module BABYLON {
  35712. /**
  35713. * Interface used to present a loading screen while loading a scene
  35714. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35715. */
  35716. export interface ILoadingScreen {
  35717. /**
  35718. * Function called to display the loading screen
  35719. */
  35720. displayLoadingUI: () => void;
  35721. /**
  35722. * Function called to hide the loading screen
  35723. */
  35724. hideLoadingUI: () => void;
  35725. /**
  35726. * Gets or sets the color to use for the background
  35727. */
  35728. loadingUIBackgroundColor: string;
  35729. /**
  35730. * Gets or sets the text to display while loading
  35731. */
  35732. loadingUIText: string;
  35733. }
  35734. /**
  35735. * Class used for the default loading screen
  35736. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35737. */
  35738. export class DefaultLoadingScreen implements ILoadingScreen {
  35739. private _renderingCanvas;
  35740. private _loadingText;
  35741. private _loadingDivBackgroundColor;
  35742. private _loadingDiv;
  35743. private _loadingTextDiv;
  35744. /** Gets or sets the logo url to use for the default loading screen */
  35745. static DefaultLogoUrl: string;
  35746. /** Gets or sets the spinner url to use for the default loading screen */
  35747. static DefaultSpinnerUrl: string;
  35748. /**
  35749. * Creates a new default loading screen
  35750. * @param _renderingCanvas defines the canvas used to render the scene
  35751. * @param _loadingText defines the default text to display
  35752. * @param _loadingDivBackgroundColor defines the default background color
  35753. */
  35754. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  35755. /**
  35756. * Function called to display the loading screen
  35757. */
  35758. displayLoadingUI(): void;
  35759. /**
  35760. * Function called to hide the loading screen
  35761. */
  35762. hideLoadingUI(): void;
  35763. /**
  35764. * Gets or sets the text to display while loading
  35765. */
  35766. set loadingUIText(text: string);
  35767. get loadingUIText(): string;
  35768. /**
  35769. * Gets or sets the color to use for the background
  35770. */
  35771. get loadingUIBackgroundColor(): string;
  35772. set loadingUIBackgroundColor(color: string);
  35773. private _resizeLoadingUI;
  35774. }
  35775. }
  35776. declare module BABYLON {
  35777. /**
  35778. * Interface for any object that can request an animation frame
  35779. */
  35780. export interface ICustomAnimationFrameRequester {
  35781. /**
  35782. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  35783. */
  35784. renderFunction?: Function;
  35785. /**
  35786. * Called to request the next frame to render to
  35787. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  35788. */
  35789. requestAnimationFrame: Function;
  35790. /**
  35791. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  35792. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  35793. */
  35794. requestID?: number;
  35795. }
  35796. }
  35797. declare module BABYLON {
  35798. /**
  35799. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  35800. */
  35801. export class PerformanceMonitor {
  35802. private _enabled;
  35803. private _rollingFrameTime;
  35804. private _lastFrameTimeMs;
  35805. /**
  35806. * constructor
  35807. * @param frameSampleSize The number of samples required to saturate the sliding window
  35808. */
  35809. constructor(frameSampleSize?: number);
  35810. /**
  35811. * Samples current frame
  35812. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  35813. */
  35814. sampleFrame(timeMs?: number): void;
  35815. /**
  35816. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35817. */
  35818. get averageFrameTime(): number;
  35819. /**
  35820. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35821. */
  35822. get averageFrameTimeVariance(): number;
  35823. /**
  35824. * Returns the frame time of the most recent frame
  35825. */
  35826. get instantaneousFrameTime(): number;
  35827. /**
  35828. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  35829. */
  35830. get averageFPS(): number;
  35831. /**
  35832. * Returns the average framerate in frames per second using the most recent frame time
  35833. */
  35834. get instantaneousFPS(): number;
  35835. /**
  35836. * Returns true if enough samples have been taken to completely fill the sliding window
  35837. */
  35838. get isSaturated(): boolean;
  35839. /**
  35840. * Enables contributions to the sliding window sample set
  35841. */
  35842. enable(): void;
  35843. /**
  35844. * Disables contributions to the sliding window sample set
  35845. * Samples will not be interpolated over the disabled period
  35846. */
  35847. disable(): void;
  35848. /**
  35849. * Returns true if sampling is enabled
  35850. */
  35851. get isEnabled(): boolean;
  35852. /**
  35853. * Resets performance monitor
  35854. */
  35855. reset(): void;
  35856. }
  35857. /**
  35858. * RollingAverage
  35859. *
  35860. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  35861. */
  35862. export class RollingAverage {
  35863. /**
  35864. * Current average
  35865. */
  35866. average: number;
  35867. /**
  35868. * Current variance
  35869. */
  35870. variance: number;
  35871. protected _samples: Array<number>;
  35872. protected _sampleCount: number;
  35873. protected _pos: number;
  35874. protected _m2: number;
  35875. /**
  35876. * constructor
  35877. * @param length The number of samples required to saturate the sliding window
  35878. */
  35879. constructor(length: number);
  35880. /**
  35881. * Adds a sample to the sample set
  35882. * @param v The sample value
  35883. */
  35884. add(v: number): void;
  35885. /**
  35886. * Returns previously added values or null if outside of history or outside the sliding window domain
  35887. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  35888. * @return Value previously recorded with add() or null if outside of range
  35889. */
  35890. history(i: number): number;
  35891. /**
  35892. * Returns true if enough samples have been taken to completely fill the sliding window
  35893. * @return true if sample-set saturated
  35894. */
  35895. isSaturated(): boolean;
  35896. /**
  35897. * Resets the rolling average (equivalent to 0 samples taken so far)
  35898. */
  35899. reset(): void;
  35900. /**
  35901. * Wraps a value around the sample range boundaries
  35902. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  35903. * @return Wrapped position in sample range
  35904. */
  35905. protected _wrapPosition(i: number): number;
  35906. }
  35907. }
  35908. declare module BABYLON {
  35909. /**
  35910. * This class is used to track a performance counter which is number based.
  35911. * The user has access to many properties which give statistics of different nature.
  35912. *
  35913. * The implementer can track two kinds of Performance Counter: time and count.
  35914. * 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.
  35915. * 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.
  35916. */
  35917. export class PerfCounter {
  35918. /**
  35919. * Gets or sets a global boolean to turn on and off all the counters
  35920. */
  35921. static Enabled: boolean;
  35922. /**
  35923. * Returns the smallest value ever
  35924. */
  35925. get min(): number;
  35926. /**
  35927. * Returns the biggest value ever
  35928. */
  35929. get max(): number;
  35930. /**
  35931. * Returns the average value since the performance counter is running
  35932. */
  35933. get average(): number;
  35934. /**
  35935. * Returns the average value of the last second the counter was monitored
  35936. */
  35937. get lastSecAverage(): number;
  35938. /**
  35939. * Returns the current value
  35940. */
  35941. get current(): number;
  35942. /**
  35943. * Gets the accumulated total
  35944. */
  35945. get total(): number;
  35946. /**
  35947. * Gets the total value count
  35948. */
  35949. get count(): number;
  35950. /**
  35951. * Creates a new counter
  35952. */
  35953. constructor();
  35954. /**
  35955. * Call this method to start monitoring a new frame.
  35956. * 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.
  35957. */
  35958. fetchNewFrame(): void;
  35959. /**
  35960. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  35961. * @param newCount the count value to add to the monitored count
  35962. * @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.
  35963. */
  35964. addCount(newCount: number, fetchResult: boolean): void;
  35965. /**
  35966. * Start monitoring this performance counter
  35967. */
  35968. beginMonitoring(): void;
  35969. /**
  35970. * Compute the time lapsed since the previous beginMonitoring() call.
  35971. * @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
  35972. */
  35973. endMonitoring(newFrame?: boolean): void;
  35974. private _fetchResult;
  35975. private _startMonitoringTime;
  35976. private _min;
  35977. private _max;
  35978. private _average;
  35979. private _current;
  35980. private _totalValueCount;
  35981. private _totalAccumulated;
  35982. private _lastSecAverage;
  35983. private _lastSecAccumulated;
  35984. private _lastSecTime;
  35985. private _lastSecValueCount;
  35986. }
  35987. }
  35988. declare module BABYLON {
  35989. interface ThinEngine {
  35990. /**
  35991. * Sets alpha constants used by some alpha blending modes
  35992. * @param r defines the red component
  35993. * @param g defines the green component
  35994. * @param b defines the blue component
  35995. * @param a defines the alpha component
  35996. */
  35997. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  35998. /**
  35999. * Sets the current alpha mode
  36000. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36001. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36002. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36003. */
  36004. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36005. /**
  36006. * Gets the current alpha mode
  36007. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36008. * @returns the current alpha mode
  36009. */
  36010. getAlphaMode(): number;
  36011. /**
  36012. * Sets the current alpha equation
  36013. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36014. */
  36015. setAlphaEquation(equation: number): void;
  36016. /**
  36017. * Gets the current alpha equation.
  36018. * @returns the current alpha equation
  36019. */
  36020. getAlphaEquation(): number;
  36021. }
  36022. }
  36023. declare module BABYLON {
  36024. interface ThinEngine {
  36025. /** @hidden */
  36026. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36027. }
  36028. }
  36029. declare module BABYLON {
  36030. /**
  36031. * Defines the interface used by display changed events
  36032. */
  36033. export interface IDisplayChangedEventArgs {
  36034. /** Gets the vrDisplay object (if any) */
  36035. vrDisplay: Nullable<any>;
  36036. /** Gets a boolean indicating if webVR is supported */
  36037. vrSupported: boolean;
  36038. }
  36039. /**
  36040. * Defines the interface used by objects containing a viewport (like a camera)
  36041. */
  36042. interface IViewportOwnerLike {
  36043. /**
  36044. * Gets or sets the viewport
  36045. */
  36046. viewport: IViewportLike;
  36047. }
  36048. /**
  36049. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36050. */
  36051. export class Engine extends ThinEngine {
  36052. /** Defines that alpha blending is disabled */
  36053. static readonly ALPHA_DISABLE: number;
  36054. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36055. static readonly ALPHA_ADD: number;
  36056. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36057. static readonly ALPHA_COMBINE: number;
  36058. /** Defines that alpha blending to DEST - SRC * DEST */
  36059. static readonly ALPHA_SUBTRACT: number;
  36060. /** Defines that alpha blending to SRC * DEST */
  36061. static readonly ALPHA_MULTIPLY: number;
  36062. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36063. static readonly ALPHA_MAXIMIZED: number;
  36064. /** Defines that alpha blending to SRC + DEST */
  36065. static readonly ALPHA_ONEONE: number;
  36066. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36067. static readonly ALPHA_PREMULTIPLIED: number;
  36068. /**
  36069. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36070. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36071. */
  36072. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36073. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36074. static readonly ALPHA_INTERPOLATE: number;
  36075. /**
  36076. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36077. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36078. */
  36079. static readonly ALPHA_SCREENMODE: number;
  36080. /** Defines that the ressource is not delayed*/
  36081. static readonly DELAYLOADSTATE_NONE: number;
  36082. /** Defines that the ressource was successfully delay loaded */
  36083. static readonly DELAYLOADSTATE_LOADED: number;
  36084. /** Defines that the ressource is currently delay loading */
  36085. static readonly DELAYLOADSTATE_LOADING: number;
  36086. /** Defines that the ressource is delayed and has not started loading */
  36087. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36088. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36089. static readonly NEVER: number;
  36090. /** 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 */
  36091. static readonly ALWAYS: number;
  36092. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36093. static readonly LESS: number;
  36094. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36095. static readonly EQUAL: number;
  36096. /** 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 */
  36097. static readonly LEQUAL: number;
  36098. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36099. static readonly GREATER: number;
  36100. /** 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 */
  36101. static readonly GEQUAL: number;
  36102. /** 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 */
  36103. static readonly NOTEQUAL: number;
  36104. /** Passed to stencilOperation to specify that stencil value must be kept */
  36105. static readonly KEEP: number;
  36106. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36107. static readonly REPLACE: number;
  36108. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36109. static readonly INCR: number;
  36110. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36111. static readonly DECR: number;
  36112. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36113. static readonly INVERT: number;
  36114. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36115. static readonly INCR_WRAP: number;
  36116. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36117. static readonly DECR_WRAP: number;
  36118. /** Texture is not repeating outside of 0..1 UVs */
  36119. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36120. /** Texture is repeating outside of 0..1 UVs */
  36121. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36122. /** Texture is repeating and mirrored */
  36123. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36124. /** ALPHA */
  36125. static readonly TEXTUREFORMAT_ALPHA: number;
  36126. /** LUMINANCE */
  36127. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36128. /** LUMINANCE_ALPHA */
  36129. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36130. /** RGB */
  36131. static readonly TEXTUREFORMAT_RGB: number;
  36132. /** RGBA */
  36133. static readonly TEXTUREFORMAT_RGBA: number;
  36134. /** RED */
  36135. static readonly TEXTUREFORMAT_RED: number;
  36136. /** RED (2nd reference) */
  36137. static readonly TEXTUREFORMAT_R: number;
  36138. /** RG */
  36139. static readonly TEXTUREFORMAT_RG: number;
  36140. /** RED_INTEGER */
  36141. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36142. /** RED_INTEGER (2nd reference) */
  36143. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36144. /** RG_INTEGER */
  36145. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36146. /** RGB_INTEGER */
  36147. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36148. /** RGBA_INTEGER */
  36149. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36150. /** UNSIGNED_BYTE */
  36151. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36152. /** UNSIGNED_BYTE (2nd reference) */
  36153. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36154. /** FLOAT */
  36155. static readonly TEXTURETYPE_FLOAT: number;
  36156. /** HALF_FLOAT */
  36157. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36158. /** BYTE */
  36159. static readonly TEXTURETYPE_BYTE: number;
  36160. /** SHORT */
  36161. static readonly TEXTURETYPE_SHORT: number;
  36162. /** UNSIGNED_SHORT */
  36163. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36164. /** INT */
  36165. static readonly TEXTURETYPE_INT: number;
  36166. /** UNSIGNED_INT */
  36167. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36168. /** UNSIGNED_SHORT_4_4_4_4 */
  36169. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36170. /** UNSIGNED_SHORT_5_5_5_1 */
  36171. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36172. /** UNSIGNED_SHORT_5_6_5 */
  36173. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36174. /** UNSIGNED_INT_2_10_10_10_REV */
  36175. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36176. /** UNSIGNED_INT_24_8 */
  36177. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36178. /** UNSIGNED_INT_10F_11F_11F_REV */
  36179. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36180. /** UNSIGNED_INT_5_9_9_9_REV */
  36181. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36182. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36183. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36184. /** nearest is mag = nearest and min = nearest and mip = linear */
  36185. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36186. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36187. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36188. /** Trilinear is mag = linear and min = linear and mip = linear */
  36189. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36190. /** nearest is mag = nearest and min = nearest and mip = linear */
  36191. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36192. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36193. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36194. /** Trilinear is mag = linear and min = linear and mip = linear */
  36195. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36196. /** mag = nearest and min = nearest and mip = nearest */
  36197. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36198. /** mag = nearest and min = linear and mip = nearest */
  36199. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36200. /** mag = nearest and min = linear and mip = linear */
  36201. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36202. /** mag = nearest and min = linear and mip = none */
  36203. static readonly TEXTURE_NEAREST_LINEAR: number;
  36204. /** mag = nearest and min = nearest and mip = none */
  36205. static readonly TEXTURE_NEAREST_NEAREST: number;
  36206. /** mag = linear and min = nearest and mip = nearest */
  36207. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36208. /** mag = linear and min = nearest and mip = linear */
  36209. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36210. /** mag = linear and min = linear and mip = none */
  36211. static readonly TEXTURE_LINEAR_LINEAR: number;
  36212. /** mag = linear and min = nearest and mip = none */
  36213. static readonly TEXTURE_LINEAR_NEAREST: number;
  36214. /** Explicit coordinates mode */
  36215. static readonly TEXTURE_EXPLICIT_MODE: number;
  36216. /** Spherical coordinates mode */
  36217. static readonly TEXTURE_SPHERICAL_MODE: number;
  36218. /** Planar coordinates mode */
  36219. static readonly TEXTURE_PLANAR_MODE: number;
  36220. /** Cubic coordinates mode */
  36221. static readonly TEXTURE_CUBIC_MODE: number;
  36222. /** Projection coordinates mode */
  36223. static readonly TEXTURE_PROJECTION_MODE: number;
  36224. /** Skybox coordinates mode */
  36225. static readonly TEXTURE_SKYBOX_MODE: number;
  36226. /** Inverse Cubic coordinates mode */
  36227. static readonly TEXTURE_INVCUBIC_MODE: number;
  36228. /** Equirectangular coordinates mode */
  36229. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36230. /** Equirectangular Fixed coordinates mode */
  36231. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36232. /** Equirectangular Fixed Mirrored coordinates mode */
  36233. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36234. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36235. static readonly SCALEMODE_FLOOR: number;
  36236. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36237. static readonly SCALEMODE_NEAREST: number;
  36238. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36239. static readonly SCALEMODE_CEILING: number;
  36240. /**
  36241. * Returns the current npm package of the sdk
  36242. */
  36243. static get NpmPackage(): string;
  36244. /**
  36245. * Returns the current version of the framework
  36246. */
  36247. static get Version(): string;
  36248. /** Gets the list of created engines */
  36249. static get Instances(): Engine[];
  36250. /**
  36251. * Gets the latest created engine
  36252. */
  36253. static get LastCreatedEngine(): Nullable<Engine>;
  36254. /**
  36255. * Gets the latest created scene
  36256. */
  36257. static get LastCreatedScene(): Nullable<Scene>;
  36258. /**
  36259. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36260. * @param flag defines which part of the materials must be marked as dirty
  36261. * @param predicate defines a predicate used to filter which materials should be affected
  36262. */
  36263. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36264. /**
  36265. * Method called to create the default loading screen.
  36266. * This can be overriden in your own app.
  36267. * @param canvas The rendering canvas element
  36268. * @returns The loading screen
  36269. */
  36270. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36271. /**
  36272. * Method called to create the default rescale post process on each engine.
  36273. */
  36274. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36275. /**
  36276. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36277. **/
  36278. enableOfflineSupport: boolean;
  36279. /**
  36280. * 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)
  36281. **/
  36282. disableManifestCheck: boolean;
  36283. /**
  36284. * Gets the list of created scenes
  36285. */
  36286. scenes: Scene[];
  36287. /**
  36288. * Event raised when a new scene is created
  36289. */
  36290. onNewSceneAddedObservable: Observable<Scene>;
  36291. /**
  36292. * Gets the list of created postprocesses
  36293. */
  36294. postProcesses: PostProcess[];
  36295. /**
  36296. * Gets a boolean indicating if the pointer is currently locked
  36297. */
  36298. isPointerLock: boolean;
  36299. /**
  36300. * Observable event triggered each time the rendering canvas is resized
  36301. */
  36302. onResizeObservable: Observable<Engine>;
  36303. /**
  36304. * Observable event triggered each time the canvas loses focus
  36305. */
  36306. onCanvasBlurObservable: Observable<Engine>;
  36307. /**
  36308. * Observable event triggered each time the canvas gains focus
  36309. */
  36310. onCanvasFocusObservable: Observable<Engine>;
  36311. /**
  36312. * Observable event triggered each time the canvas receives pointerout event
  36313. */
  36314. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36315. /**
  36316. * Observable raised when the engine begins a new frame
  36317. */
  36318. onBeginFrameObservable: Observable<Engine>;
  36319. /**
  36320. * If set, will be used to request the next animation frame for the render loop
  36321. */
  36322. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36323. /**
  36324. * Observable raised when the engine ends the current frame
  36325. */
  36326. onEndFrameObservable: Observable<Engine>;
  36327. /**
  36328. * Observable raised when the engine is about to compile a shader
  36329. */
  36330. onBeforeShaderCompilationObservable: Observable<Engine>;
  36331. /**
  36332. * Observable raised when the engine has jsut compiled a shader
  36333. */
  36334. onAfterShaderCompilationObservable: Observable<Engine>;
  36335. /**
  36336. * Gets the audio engine
  36337. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36338. * @ignorenaming
  36339. */
  36340. static audioEngine: IAudioEngine;
  36341. /**
  36342. * Default AudioEngine factory responsible of creating the Audio Engine.
  36343. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36344. */
  36345. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36346. /**
  36347. * Default offline support factory responsible of creating a tool used to store data locally.
  36348. * By default, this will create a Database object if the workload has been embedded.
  36349. */
  36350. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36351. private _loadingScreen;
  36352. private _pointerLockRequested;
  36353. private _rescalePostProcess;
  36354. private _deterministicLockstep;
  36355. private _lockstepMaxSteps;
  36356. private _timeStep;
  36357. protected get _supportsHardwareTextureRescaling(): boolean;
  36358. private _fps;
  36359. private _deltaTime;
  36360. /** @hidden */
  36361. _drawCalls: PerfCounter;
  36362. /** 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 */
  36363. canvasTabIndex: number;
  36364. /**
  36365. * Turn this value on if you want to pause FPS computation when in background
  36366. */
  36367. disablePerformanceMonitorInBackground: boolean;
  36368. private _performanceMonitor;
  36369. /**
  36370. * Gets the performance monitor attached to this engine
  36371. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36372. */
  36373. get performanceMonitor(): PerformanceMonitor;
  36374. private _onFocus;
  36375. private _onBlur;
  36376. private _onCanvasPointerOut;
  36377. private _onCanvasBlur;
  36378. private _onCanvasFocus;
  36379. private _onFullscreenChange;
  36380. private _onPointerLockChange;
  36381. /**
  36382. * Gets the HTML element used to attach event listeners
  36383. * @returns a HTML element
  36384. */
  36385. getInputElement(): Nullable<HTMLElement>;
  36386. /**
  36387. * Creates a new engine
  36388. * @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
  36389. * @param antialias defines enable antialiasing (default: false)
  36390. * @param options defines further options to be sent to the getContext() function
  36391. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36392. */
  36393. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36394. /**
  36395. * Gets current aspect ratio
  36396. * @param viewportOwner defines the camera to use to get the aspect ratio
  36397. * @param useScreen defines if screen size must be used (or the current render target if any)
  36398. * @returns a number defining the aspect ratio
  36399. */
  36400. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36401. /**
  36402. * Gets current screen aspect ratio
  36403. * @returns a number defining the aspect ratio
  36404. */
  36405. getScreenAspectRatio(): number;
  36406. /**
  36407. * Gets the client rect of the HTML canvas attached with the current webGL context
  36408. * @returns a client rectanglee
  36409. */
  36410. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36411. /**
  36412. * Gets the client rect of the HTML element used for events
  36413. * @returns a client rectanglee
  36414. */
  36415. getInputElementClientRect(): Nullable<ClientRect>;
  36416. /**
  36417. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36418. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36419. * @returns true if engine is in deterministic lock step mode
  36420. */
  36421. isDeterministicLockStep(): boolean;
  36422. /**
  36423. * Gets the max steps when engine is running in deterministic lock step
  36424. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36425. * @returns the max steps
  36426. */
  36427. getLockstepMaxSteps(): number;
  36428. /**
  36429. * Returns the time in ms between steps when using deterministic lock step.
  36430. * @returns time step in (ms)
  36431. */
  36432. getTimeStep(): number;
  36433. /**
  36434. * Force the mipmap generation for the given render target texture
  36435. * @param texture defines the render target texture to use
  36436. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36437. */
  36438. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36439. /** States */
  36440. /**
  36441. * Set various states to the webGL context
  36442. * @param culling defines backface culling state
  36443. * @param zOffset defines the value to apply to zOffset (0 by default)
  36444. * @param force defines if states must be applied even if cache is up to date
  36445. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36446. */
  36447. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36448. /**
  36449. * Set the z offset to apply to current rendering
  36450. * @param value defines the offset to apply
  36451. */
  36452. setZOffset(value: number): void;
  36453. /**
  36454. * Gets the current value of the zOffset
  36455. * @returns the current zOffset state
  36456. */
  36457. getZOffset(): number;
  36458. /**
  36459. * Enable or disable depth buffering
  36460. * @param enable defines the state to set
  36461. */
  36462. setDepthBuffer(enable: boolean): void;
  36463. /**
  36464. * Gets a boolean indicating if depth writing is enabled
  36465. * @returns the current depth writing state
  36466. */
  36467. getDepthWrite(): boolean;
  36468. /**
  36469. * Enable or disable depth writing
  36470. * @param enable defines the state to set
  36471. */
  36472. setDepthWrite(enable: boolean): void;
  36473. /**
  36474. * Gets a boolean indicating if stencil buffer is enabled
  36475. * @returns the current stencil buffer state
  36476. */
  36477. getStencilBuffer(): boolean;
  36478. /**
  36479. * Enable or disable the stencil buffer
  36480. * @param enable defines if the stencil buffer must be enabled or disabled
  36481. */
  36482. setStencilBuffer(enable: boolean): void;
  36483. /**
  36484. * Gets the current stencil mask
  36485. * @returns a number defining the new stencil mask to use
  36486. */
  36487. getStencilMask(): number;
  36488. /**
  36489. * Sets the current stencil mask
  36490. * @param mask defines the new stencil mask to use
  36491. */
  36492. setStencilMask(mask: number): void;
  36493. /**
  36494. * Gets the current stencil function
  36495. * @returns a number defining the stencil function to use
  36496. */
  36497. getStencilFunction(): number;
  36498. /**
  36499. * Gets the current stencil reference value
  36500. * @returns a number defining the stencil reference value to use
  36501. */
  36502. getStencilFunctionReference(): number;
  36503. /**
  36504. * Gets the current stencil mask
  36505. * @returns a number defining the stencil mask to use
  36506. */
  36507. getStencilFunctionMask(): number;
  36508. /**
  36509. * Sets the current stencil function
  36510. * @param stencilFunc defines the new stencil function to use
  36511. */
  36512. setStencilFunction(stencilFunc: number): void;
  36513. /**
  36514. * Sets the current stencil reference
  36515. * @param reference defines the new stencil reference to use
  36516. */
  36517. setStencilFunctionReference(reference: number): void;
  36518. /**
  36519. * Sets the current stencil mask
  36520. * @param mask defines the new stencil mask to use
  36521. */
  36522. setStencilFunctionMask(mask: number): void;
  36523. /**
  36524. * Gets the current stencil operation when stencil fails
  36525. * @returns a number defining stencil operation to use when stencil fails
  36526. */
  36527. getStencilOperationFail(): number;
  36528. /**
  36529. * Gets the current stencil operation when depth fails
  36530. * @returns a number defining stencil operation to use when depth fails
  36531. */
  36532. getStencilOperationDepthFail(): number;
  36533. /**
  36534. * Gets the current stencil operation when stencil passes
  36535. * @returns a number defining stencil operation to use when stencil passes
  36536. */
  36537. getStencilOperationPass(): number;
  36538. /**
  36539. * Sets the stencil operation to use when stencil fails
  36540. * @param operation defines the stencil operation to use when stencil fails
  36541. */
  36542. setStencilOperationFail(operation: number): void;
  36543. /**
  36544. * Sets the stencil operation to use when depth fails
  36545. * @param operation defines the stencil operation to use when depth fails
  36546. */
  36547. setStencilOperationDepthFail(operation: number): void;
  36548. /**
  36549. * Sets the stencil operation to use when stencil passes
  36550. * @param operation defines the stencil operation to use when stencil passes
  36551. */
  36552. setStencilOperationPass(operation: number): void;
  36553. /**
  36554. * Sets a boolean indicating if the dithering state is enabled or disabled
  36555. * @param value defines the dithering state
  36556. */
  36557. setDitheringState(value: boolean): void;
  36558. /**
  36559. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36560. * @param value defines the rasterizer state
  36561. */
  36562. setRasterizerState(value: boolean): void;
  36563. /**
  36564. * Gets the current depth function
  36565. * @returns a number defining the depth function
  36566. */
  36567. getDepthFunction(): Nullable<number>;
  36568. /**
  36569. * Sets the current depth function
  36570. * @param depthFunc defines the function to use
  36571. */
  36572. setDepthFunction(depthFunc: number): void;
  36573. /**
  36574. * Sets the current depth function to GREATER
  36575. */
  36576. setDepthFunctionToGreater(): void;
  36577. /**
  36578. * Sets the current depth function to GEQUAL
  36579. */
  36580. setDepthFunctionToGreaterOrEqual(): void;
  36581. /**
  36582. * Sets the current depth function to LESS
  36583. */
  36584. setDepthFunctionToLess(): void;
  36585. /**
  36586. * Sets the current depth function to LEQUAL
  36587. */
  36588. setDepthFunctionToLessOrEqual(): void;
  36589. private _cachedStencilBuffer;
  36590. private _cachedStencilFunction;
  36591. private _cachedStencilMask;
  36592. private _cachedStencilOperationPass;
  36593. private _cachedStencilOperationFail;
  36594. private _cachedStencilOperationDepthFail;
  36595. private _cachedStencilReference;
  36596. /**
  36597. * Caches the the state of the stencil buffer
  36598. */
  36599. cacheStencilState(): void;
  36600. /**
  36601. * Restores the state of the stencil buffer
  36602. */
  36603. restoreStencilState(): void;
  36604. /**
  36605. * Directly set the WebGL Viewport
  36606. * @param x defines the x coordinate of the viewport (in screen space)
  36607. * @param y defines the y coordinate of the viewport (in screen space)
  36608. * @param width defines the width of the viewport (in screen space)
  36609. * @param height defines the height of the viewport (in screen space)
  36610. * @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
  36611. */
  36612. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36613. /**
  36614. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36615. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36616. * @param y defines the y-coordinate of the corner of the clear rectangle
  36617. * @param width defines the width of the clear rectangle
  36618. * @param height defines the height of the clear rectangle
  36619. * @param clearColor defines the clear color
  36620. */
  36621. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36622. /**
  36623. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36624. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36625. * @param y defines the y-coordinate of the corner of the clear rectangle
  36626. * @param width defines the width of the clear rectangle
  36627. * @param height defines the height of the clear rectangle
  36628. */
  36629. enableScissor(x: number, y: number, width: number, height: number): void;
  36630. /**
  36631. * Disable previously set scissor test rectangle
  36632. */
  36633. disableScissor(): void;
  36634. protected _reportDrawCall(): void;
  36635. /**
  36636. * Initializes a webVR display and starts listening to display change events
  36637. * The onVRDisplayChangedObservable will be notified upon these changes
  36638. * @returns The onVRDisplayChangedObservable
  36639. */
  36640. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36641. /** @hidden */
  36642. _prepareVRComponent(): void;
  36643. /** @hidden */
  36644. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36645. /** @hidden */
  36646. _submitVRFrame(): void;
  36647. /**
  36648. * Call this function to leave webVR mode
  36649. * Will do nothing if webVR is not supported or if there is no webVR device
  36650. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36651. */
  36652. disableVR(): void;
  36653. /**
  36654. * Gets a boolean indicating that the system is in VR mode and is presenting
  36655. * @returns true if VR mode is engaged
  36656. */
  36657. isVRPresenting(): boolean;
  36658. /** @hidden */
  36659. _requestVRFrame(): void;
  36660. /** @hidden */
  36661. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36662. /**
  36663. * Gets the source code of the vertex shader associated with a specific webGL program
  36664. * @param program defines the program to use
  36665. * @returns a string containing the source code of the vertex shader associated with the program
  36666. */
  36667. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  36668. /**
  36669. * Gets the source code of the fragment shader associated with a specific webGL program
  36670. * @param program defines the program to use
  36671. * @returns a string containing the source code of the fragment shader associated with the program
  36672. */
  36673. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  36674. /**
  36675. * Sets a depth stencil texture from a render target to the according uniform.
  36676. * @param channel The texture channel
  36677. * @param uniform The uniform to set
  36678. * @param texture The render target texture containing the depth stencil texture to apply
  36679. */
  36680. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  36681. /**
  36682. * Sets a texture to the webGL context from a postprocess
  36683. * @param channel defines the channel to use
  36684. * @param postProcess defines the source postprocess
  36685. */
  36686. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  36687. /**
  36688. * Binds the output of the passed in post process to the texture channel specified
  36689. * @param channel The channel the texture should be bound to
  36690. * @param postProcess The post process which's output should be bound
  36691. */
  36692. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  36693. protected _rebuildBuffers(): void;
  36694. /** @hidden */
  36695. _renderFrame(): void;
  36696. _renderLoop(): void;
  36697. /** @hidden */
  36698. _renderViews(): boolean;
  36699. /**
  36700. * Toggle full screen mode
  36701. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36702. */
  36703. switchFullscreen(requestPointerLock: boolean): void;
  36704. /**
  36705. * Enters full screen mode
  36706. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36707. */
  36708. enterFullscreen(requestPointerLock: boolean): void;
  36709. /**
  36710. * Exits full screen mode
  36711. */
  36712. exitFullscreen(): void;
  36713. /**
  36714. * Enters Pointerlock mode
  36715. */
  36716. enterPointerlock(): void;
  36717. /**
  36718. * Exits Pointerlock mode
  36719. */
  36720. exitPointerlock(): void;
  36721. /**
  36722. * Begin a new frame
  36723. */
  36724. beginFrame(): void;
  36725. /**
  36726. * Enf the current frame
  36727. */
  36728. endFrame(): void;
  36729. resize(): void;
  36730. /**
  36731. * Force a specific size of the canvas
  36732. * @param width defines the new canvas' width
  36733. * @param height defines the new canvas' height
  36734. */
  36735. setSize(width: number, height: number): void;
  36736. /**
  36737. * Updates a dynamic vertex buffer.
  36738. * @param vertexBuffer the vertex buffer to update
  36739. * @param data the data used to update the vertex buffer
  36740. * @param byteOffset the byte offset of the data
  36741. * @param byteLength the byte length of the data
  36742. */
  36743. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  36744. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36745. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36746. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36747. _releaseTexture(texture: InternalTexture): void;
  36748. /**
  36749. * @hidden
  36750. * Rescales a texture
  36751. * @param source input texutre
  36752. * @param destination destination texture
  36753. * @param scene scene to use to render the resize
  36754. * @param internalFormat format to use when resizing
  36755. * @param onComplete callback to be called when resize has completed
  36756. */
  36757. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36758. /**
  36759. * Gets the current framerate
  36760. * @returns a number representing the framerate
  36761. */
  36762. getFps(): number;
  36763. /**
  36764. * Gets the time spent between current and previous frame
  36765. * @returns a number representing the delta time in ms
  36766. */
  36767. getDeltaTime(): number;
  36768. private _measureFps;
  36769. /** @hidden */
  36770. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  36771. /**
  36772. * Update a dynamic index buffer
  36773. * @param indexBuffer defines the target index buffer
  36774. * @param indices defines the data to update
  36775. * @param offset defines the offset in the target index buffer where update should start
  36776. */
  36777. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  36778. /**
  36779. * Updates the sample count of a render target texture
  36780. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  36781. * @param texture defines the texture to update
  36782. * @param samples defines the sample count to set
  36783. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  36784. */
  36785. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  36786. /**
  36787. * Updates a depth texture Comparison Mode and Function.
  36788. * If the comparison Function is equal to 0, the mode will be set to none.
  36789. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  36790. * @param texture The texture to set the comparison function for
  36791. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  36792. */
  36793. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  36794. /**
  36795. * Creates a webGL buffer to use with instanciation
  36796. * @param capacity defines the size of the buffer
  36797. * @returns the webGL buffer
  36798. */
  36799. createInstancesBuffer(capacity: number): DataBuffer;
  36800. /**
  36801. * Delete a webGL buffer used with instanciation
  36802. * @param buffer defines the webGL buffer to delete
  36803. */
  36804. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  36805. private _clientWaitAsync;
  36806. /** @hidden */
  36807. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  36808. dispose(): void;
  36809. private _disableTouchAction;
  36810. /**
  36811. * Display the loading screen
  36812. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36813. */
  36814. displayLoadingUI(): void;
  36815. /**
  36816. * Hide the loading screen
  36817. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36818. */
  36819. hideLoadingUI(): void;
  36820. /**
  36821. * Gets the current loading screen object
  36822. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36823. */
  36824. get loadingScreen(): ILoadingScreen;
  36825. /**
  36826. * Sets the current loading screen object
  36827. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36828. */
  36829. set loadingScreen(loadingScreen: ILoadingScreen);
  36830. /**
  36831. * Sets the current loading screen text
  36832. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36833. */
  36834. set loadingUIText(text: string);
  36835. /**
  36836. * Sets the current loading screen background color
  36837. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36838. */
  36839. set loadingUIBackgroundColor(color: string);
  36840. /** Pointerlock and fullscreen */
  36841. /**
  36842. * Ask the browser to promote the current element to pointerlock mode
  36843. * @param element defines the DOM element to promote
  36844. */
  36845. static _RequestPointerlock(element: HTMLElement): void;
  36846. /**
  36847. * Asks the browser to exit pointerlock mode
  36848. */
  36849. static _ExitPointerlock(): void;
  36850. /**
  36851. * Ask the browser to promote the current element to fullscreen rendering mode
  36852. * @param element defines the DOM element to promote
  36853. */
  36854. static _RequestFullscreen(element: HTMLElement): void;
  36855. /**
  36856. * Asks the browser to exit fullscreen mode
  36857. */
  36858. static _ExitFullscreen(): void;
  36859. }
  36860. }
  36861. declare module BABYLON {
  36862. /**
  36863. * The engine store class is responsible to hold all the instances of Engine and Scene created
  36864. * during the life time of the application.
  36865. */
  36866. export class EngineStore {
  36867. /** Gets the list of created engines */
  36868. static Instances: Engine[];
  36869. /** @hidden */
  36870. static _LastCreatedScene: Nullable<Scene>;
  36871. /**
  36872. * Gets the latest created engine
  36873. */
  36874. static get LastCreatedEngine(): Nullable<Engine>;
  36875. /**
  36876. * Gets the latest created scene
  36877. */
  36878. static get LastCreatedScene(): Nullable<Scene>;
  36879. /**
  36880. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  36881. * @ignorenaming
  36882. */
  36883. static UseFallbackTexture: boolean;
  36884. /**
  36885. * Texture content used if a texture cannot loaded
  36886. * @ignorenaming
  36887. */
  36888. static FallbackTexture: string;
  36889. }
  36890. }
  36891. declare module BABYLON {
  36892. /**
  36893. * Helper class that provides a small promise polyfill
  36894. */
  36895. export class PromisePolyfill {
  36896. /**
  36897. * Static function used to check if the polyfill is required
  36898. * If this is the case then the function will inject the polyfill to window.Promise
  36899. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  36900. */
  36901. static Apply(force?: boolean): void;
  36902. }
  36903. }
  36904. declare module BABYLON {
  36905. /**
  36906. * Interface for screenshot methods with describe argument called `size` as object with options
  36907. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  36908. */
  36909. export interface IScreenshotSize {
  36910. /**
  36911. * number in pixels for canvas height
  36912. */
  36913. height?: number;
  36914. /**
  36915. * multiplier allowing render at a higher or lower resolution
  36916. * If value is defined then height and width will be ignored and taken from camera
  36917. */
  36918. precision?: number;
  36919. /**
  36920. * number in pixels for canvas width
  36921. */
  36922. width?: number;
  36923. }
  36924. }
  36925. declare module BABYLON {
  36926. interface IColor4Like {
  36927. r: float;
  36928. g: float;
  36929. b: float;
  36930. a: float;
  36931. }
  36932. /**
  36933. * Class containing a set of static utilities functions
  36934. */
  36935. export class Tools {
  36936. /**
  36937. * Gets or sets the base URL to use to load assets
  36938. */
  36939. static get BaseUrl(): string;
  36940. static set BaseUrl(value: string);
  36941. /**
  36942. * Enable/Disable Custom HTTP Request Headers globally.
  36943. * default = false
  36944. * @see CustomRequestHeaders
  36945. */
  36946. static UseCustomRequestHeaders: boolean;
  36947. /**
  36948. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  36949. * i.e. when loading files, where the server/service expects an Authorization header
  36950. */
  36951. static CustomRequestHeaders: {
  36952. [key: string]: string;
  36953. };
  36954. /**
  36955. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  36956. */
  36957. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  36958. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  36959. /**
  36960. * Default behaviour for cors in the application.
  36961. * It can be a string if the expected behavior is identical in the entire app.
  36962. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  36963. */
  36964. static get CorsBehavior(): string | ((url: string | string[]) => string);
  36965. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  36966. /**
  36967. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  36968. * @ignorenaming
  36969. */
  36970. static get UseFallbackTexture(): boolean;
  36971. static set UseFallbackTexture(value: boolean);
  36972. /**
  36973. * Use this object to register external classes like custom textures or material
  36974. * to allow the laoders to instantiate them
  36975. */
  36976. static get RegisteredExternalClasses(): {
  36977. [key: string]: Object;
  36978. };
  36979. static set RegisteredExternalClasses(classes: {
  36980. [key: string]: Object;
  36981. });
  36982. /**
  36983. * Texture content used if a texture cannot loaded
  36984. * @ignorenaming
  36985. */
  36986. static get fallbackTexture(): string;
  36987. static set fallbackTexture(value: string);
  36988. /**
  36989. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  36990. * @param u defines the coordinate on X axis
  36991. * @param v defines the coordinate on Y axis
  36992. * @param width defines the width of the source data
  36993. * @param height defines the height of the source data
  36994. * @param pixels defines the source byte array
  36995. * @param color defines the output color
  36996. */
  36997. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  36998. /**
  36999. * Interpolates between a and b via alpha
  37000. * @param a The lower value (returned when alpha = 0)
  37001. * @param b The upper value (returned when alpha = 1)
  37002. * @param alpha The interpolation-factor
  37003. * @return The mixed value
  37004. */
  37005. static Mix(a: number, b: number, alpha: number): number;
  37006. /**
  37007. * Tries to instantiate a new object from a given class name
  37008. * @param className defines the class name to instantiate
  37009. * @returns the new object or null if the system was not able to do the instantiation
  37010. */
  37011. static Instantiate(className: string): any;
  37012. /**
  37013. * Provides a slice function that will work even on IE
  37014. * @param data defines the array to slice
  37015. * @param start defines the start of the data (optional)
  37016. * @param end defines the end of the data (optional)
  37017. * @returns the new sliced array
  37018. */
  37019. static Slice<T>(data: T, start?: number, end?: number): T;
  37020. /**
  37021. * Polyfill for setImmediate
  37022. * @param action defines the action to execute after the current execution block
  37023. */
  37024. static SetImmediate(action: () => void): void;
  37025. /**
  37026. * Function indicating if a number is an exponent of 2
  37027. * @param value defines the value to test
  37028. * @returns true if the value is an exponent of 2
  37029. */
  37030. static IsExponentOfTwo(value: number): boolean;
  37031. private static _tmpFloatArray;
  37032. /**
  37033. * Returns the nearest 32-bit single precision float representation of a Number
  37034. * @param value A Number. If the parameter is of a different type, it will get converted
  37035. * to a number or to NaN if it cannot be converted
  37036. * @returns number
  37037. */
  37038. static FloatRound(value: number): number;
  37039. /**
  37040. * Extracts the filename from a path
  37041. * @param path defines the path to use
  37042. * @returns the filename
  37043. */
  37044. static GetFilename(path: string): string;
  37045. /**
  37046. * Extracts the "folder" part of a path (everything before the filename).
  37047. * @param uri The URI to extract the info from
  37048. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37049. * @returns The "folder" part of the path
  37050. */
  37051. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37052. /**
  37053. * Extracts text content from a DOM element hierarchy
  37054. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37055. */
  37056. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37057. /**
  37058. * Convert an angle in radians to degrees
  37059. * @param angle defines the angle to convert
  37060. * @returns the angle in degrees
  37061. */
  37062. static ToDegrees(angle: number): number;
  37063. /**
  37064. * Convert an angle in degrees to radians
  37065. * @param angle defines the angle to convert
  37066. * @returns the angle in radians
  37067. */
  37068. static ToRadians(angle: number): number;
  37069. /**
  37070. * Returns an array if obj is not an array
  37071. * @param obj defines the object to evaluate as an array
  37072. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37073. * @returns either obj directly if obj is an array or a new array containing obj
  37074. */
  37075. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37076. /**
  37077. * Gets the pointer prefix to use
  37078. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37079. */
  37080. static GetPointerPrefix(): string;
  37081. /**
  37082. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37083. * @param url define the url we are trying
  37084. * @param element define the dom element where to configure the cors policy
  37085. */
  37086. static SetCorsBehavior(url: string | string[], element: {
  37087. crossOrigin: string | null;
  37088. }): void;
  37089. /**
  37090. * Removes unwanted characters from an url
  37091. * @param url defines the url to clean
  37092. * @returns the cleaned url
  37093. */
  37094. static CleanUrl(url: string): string;
  37095. /**
  37096. * Gets or sets a function used to pre-process url before using them to load assets
  37097. */
  37098. static get PreprocessUrl(): (url: string) => string;
  37099. static set PreprocessUrl(processor: (url: string) => string);
  37100. /**
  37101. * Loads an image as an HTMLImageElement.
  37102. * @param input url string, ArrayBuffer, or Blob to load
  37103. * @param onLoad callback called when the image successfully loads
  37104. * @param onError callback called when the image fails to load
  37105. * @param offlineProvider offline provider for caching
  37106. * @param mimeType optional mime type
  37107. * @returns the HTMLImageElement of the loaded image
  37108. */
  37109. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37110. /**
  37111. * Loads a file from a url
  37112. * @param url url string, ArrayBuffer, or Blob to load
  37113. * @param onSuccess callback called when the file successfully loads
  37114. * @param onProgress callback called while file is loading (if the server supports this mode)
  37115. * @param offlineProvider defines the offline provider for caching
  37116. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37117. * @param onError callback called when the file fails to load
  37118. * @returns a file request object
  37119. */
  37120. 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;
  37121. /**
  37122. * Loads a file from a url
  37123. * @param url the file url to load
  37124. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37125. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37126. */
  37127. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37128. /**
  37129. * Load a script (identified by an url). When the url returns, the
  37130. * content of this file is added into a new script element, attached to the DOM (body element)
  37131. * @param scriptUrl defines the url of the script to laod
  37132. * @param onSuccess defines the callback called when the script is loaded
  37133. * @param onError defines the callback to call if an error occurs
  37134. * @param scriptId defines the id of the script element
  37135. */
  37136. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37137. /**
  37138. * Load an asynchronous script (identified by an url). When the url returns, the
  37139. * content of this file is added into a new script element, attached to the DOM (body element)
  37140. * @param scriptUrl defines the url of the script to laod
  37141. * @param scriptId defines the id of the script element
  37142. * @returns a promise request object
  37143. */
  37144. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37145. /**
  37146. * Loads a file from a blob
  37147. * @param fileToLoad defines the blob to use
  37148. * @param callback defines the callback to call when data is loaded
  37149. * @param progressCallback defines the callback to call during loading process
  37150. * @returns a file request object
  37151. */
  37152. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37153. /**
  37154. * Reads a file from a File object
  37155. * @param file defines the file to load
  37156. * @param onSuccess defines the callback to call when data is loaded
  37157. * @param onProgress defines the callback to call during loading process
  37158. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37159. * @param onError defines the callback to call when an error occurs
  37160. * @returns a file request object
  37161. */
  37162. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37163. /**
  37164. * Creates a data url from a given string content
  37165. * @param content defines the content to convert
  37166. * @returns the new data url link
  37167. */
  37168. static FileAsURL(content: string): string;
  37169. /**
  37170. * Format the given number to a specific decimal format
  37171. * @param value defines the number to format
  37172. * @param decimals defines the number of decimals to use
  37173. * @returns the formatted string
  37174. */
  37175. static Format(value: number, decimals?: number): string;
  37176. /**
  37177. * Tries to copy an object by duplicating every property
  37178. * @param source defines the source object
  37179. * @param destination defines the target object
  37180. * @param doNotCopyList defines a list of properties to avoid
  37181. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37182. */
  37183. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37184. /**
  37185. * Gets a boolean indicating if the given object has no own property
  37186. * @param obj defines the object to test
  37187. * @returns true if object has no own property
  37188. */
  37189. static IsEmpty(obj: any): boolean;
  37190. /**
  37191. * Function used to register events at window level
  37192. * @param windowElement defines the Window object to use
  37193. * @param events defines the events to register
  37194. */
  37195. static RegisterTopRootEvents(windowElement: Window, events: {
  37196. name: string;
  37197. handler: Nullable<(e: FocusEvent) => any>;
  37198. }[]): void;
  37199. /**
  37200. * Function used to unregister events from window level
  37201. * @param windowElement defines the Window object to use
  37202. * @param events defines the events to unregister
  37203. */
  37204. static UnregisterTopRootEvents(windowElement: Window, events: {
  37205. name: string;
  37206. handler: Nullable<(e: FocusEvent) => any>;
  37207. }[]): void;
  37208. /**
  37209. * @ignore
  37210. */
  37211. static _ScreenshotCanvas: HTMLCanvasElement;
  37212. /**
  37213. * Dumps the current bound framebuffer
  37214. * @param width defines the rendering width
  37215. * @param height defines the rendering height
  37216. * @param engine defines the hosting engine
  37217. * @param successCallback defines the callback triggered once the data are available
  37218. * @param mimeType defines the mime type of the result
  37219. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37220. */
  37221. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37222. /**
  37223. * Converts the canvas data to blob.
  37224. * This acts as a polyfill for browsers not supporting the to blob function.
  37225. * @param canvas Defines the canvas to extract the data from
  37226. * @param successCallback Defines the callback triggered once the data are available
  37227. * @param mimeType Defines the mime type of the result
  37228. */
  37229. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37230. /**
  37231. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37232. * @param successCallback defines the callback triggered once the data are available
  37233. * @param mimeType defines the mime type of the result
  37234. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37235. */
  37236. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37237. /**
  37238. * Downloads a blob in the browser
  37239. * @param blob defines the blob to download
  37240. * @param fileName defines the name of the downloaded file
  37241. */
  37242. static Download(blob: Blob, fileName: string): void;
  37243. /**
  37244. * Captures a screenshot of the current rendering
  37245. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37246. * @param engine defines the rendering engine
  37247. * @param camera defines the source camera
  37248. * @param size This parameter can be set to a single number or to an object with the
  37249. * following (optional) properties: precision, width, height. If a single number is passed,
  37250. * it will be used for both width and height. If an object is passed, the screenshot size
  37251. * will be derived from the parameters. The precision property is a multiplier allowing
  37252. * rendering at a higher or lower resolution
  37253. * @param successCallback defines the callback receives a single parameter which contains the
  37254. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37255. * src parameter of an <img> to display it
  37256. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37257. * Check your browser for supported MIME types
  37258. */
  37259. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37260. /**
  37261. * Captures a screenshot of the current rendering
  37262. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37263. * @param engine defines the rendering engine
  37264. * @param camera defines the source camera
  37265. * @param size This parameter can be set to a single number or to an object with the
  37266. * following (optional) properties: precision, width, height. If a single number is passed,
  37267. * it will be used for both width and height. If an object is passed, the screenshot size
  37268. * will be derived from the parameters. The precision property is a multiplier allowing
  37269. * rendering at a higher or lower resolution
  37270. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37271. * Check your browser for supported MIME types
  37272. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37273. * to the src parameter of an <img> to display it
  37274. */
  37275. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37276. /**
  37277. * Generates an image screenshot from the specified camera.
  37278. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37279. * @param engine The engine to use for rendering
  37280. * @param camera The camera to use for rendering
  37281. * @param size This parameter can be set to a single number or to an object with the
  37282. * following (optional) properties: precision, width, height. If a single number is passed,
  37283. * it will be used for both width and height. If an object is passed, the screenshot size
  37284. * will be derived from the parameters. The precision property is a multiplier allowing
  37285. * rendering at a higher or lower resolution
  37286. * @param successCallback The callback receives a single parameter which contains the
  37287. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37288. * src parameter of an <img> to display it
  37289. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37290. * Check your browser for supported MIME types
  37291. * @param samples Texture samples (default: 1)
  37292. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37293. * @param fileName A name for for the downloaded file.
  37294. */
  37295. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37296. /**
  37297. * Generates an image screenshot from the specified camera.
  37298. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37299. * @param engine The engine to use for rendering
  37300. * @param camera The camera to use for rendering
  37301. * @param size This parameter can be set to a single number or to an object with the
  37302. * following (optional) properties: precision, width, height. If a single number is passed,
  37303. * it will be used for both width and height. If an object is passed, the screenshot size
  37304. * will be derived from the parameters. The precision property is a multiplier allowing
  37305. * rendering at a higher or lower resolution
  37306. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37307. * Check your browser for supported MIME types
  37308. * @param samples Texture samples (default: 1)
  37309. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37310. * @param fileName A name for for the downloaded file.
  37311. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37312. * to the src parameter of an <img> to display it
  37313. */
  37314. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37315. /**
  37316. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37317. * Be aware Math.random() could cause collisions, but:
  37318. * "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"
  37319. * @returns a pseudo random id
  37320. */
  37321. static RandomId(): string;
  37322. /**
  37323. * Test if the given uri is a base64 string
  37324. * @param uri The uri to test
  37325. * @return True if the uri is a base64 string or false otherwise
  37326. */
  37327. static IsBase64(uri: string): boolean;
  37328. /**
  37329. * Decode the given base64 uri.
  37330. * @param uri The uri to decode
  37331. * @return The decoded base64 data.
  37332. */
  37333. static DecodeBase64(uri: string): ArrayBuffer;
  37334. /**
  37335. * Gets the absolute url.
  37336. * @param url the input url
  37337. * @return the absolute url
  37338. */
  37339. static GetAbsoluteUrl(url: string): string;
  37340. /**
  37341. * No log
  37342. */
  37343. static readonly NoneLogLevel: number;
  37344. /**
  37345. * Only message logs
  37346. */
  37347. static readonly MessageLogLevel: number;
  37348. /**
  37349. * Only warning logs
  37350. */
  37351. static readonly WarningLogLevel: number;
  37352. /**
  37353. * Only error logs
  37354. */
  37355. static readonly ErrorLogLevel: number;
  37356. /**
  37357. * All logs
  37358. */
  37359. static readonly AllLogLevel: number;
  37360. /**
  37361. * Gets a value indicating the number of loading errors
  37362. * @ignorenaming
  37363. */
  37364. static get errorsCount(): number;
  37365. /**
  37366. * Callback called when a new log is added
  37367. */
  37368. static OnNewCacheEntry: (entry: string) => void;
  37369. /**
  37370. * Log a message to the console
  37371. * @param message defines the message to log
  37372. */
  37373. static Log(message: string): void;
  37374. /**
  37375. * Write a warning message to the console
  37376. * @param message defines the message to log
  37377. */
  37378. static Warn(message: string): void;
  37379. /**
  37380. * Write an error message to the console
  37381. * @param message defines the message to log
  37382. */
  37383. static Error(message: string): void;
  37384. /**
  37385. * Gets current log cache (list of logs)
  37386. */
  37387. static get LogCache(): string;
  37388. /**
  37389. * Clears the log cache
  37390. */
  37391. static ClearLogCache(): void;
  37392. /**
  37393. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37394. */
  37395. static set LogLevels(level: number);
  37396. /**
  37397. * Checks if the window object exists
  37398. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37399. */
  37400. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37401. /**
  37402. * No performance log
  37403. */
  37404. static readonly PerformanceNoneLogLevel: number;
  37405. /**
  37406. * Use user marks to log performance
  37407. */
  37408. static readonly PerformanceUserMarkLogLevel: number;
  37409. /**
  37410. * Log performance to the console
  37411. */
  37412. static readonly PerformanceConsoleLogLevel: number;
  37413. private static _performance;
  37414. /**
  37415. * Sets the current performance log level
  37416. */
  37417. static set PerformanceLogLevel(level: number);
  37418. private static _StartPerformanceCounterDisabled;
  37419. private static _EndPerformanceCounterDisabled;
  37420. private static _StartUserMark;
  37421. private static _EndUserMark;
  37422. private static _StartPerformanceConsole;
  37423. private static _EndPerformanceConsole;
  37424. /**
  37425. * Starts a performance counter
  37426. */
  37427. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37428. /**
  37429. * Ends a specific performance coutner
  37430. */
  37431. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37432. /**
  37433. * Gets either window.performance.now() if supported or Date.now() else
  37434. */
  37435. static get Now(): number;
  37436. /**
  37437. * This method will return the name of the class used to create the instance of the given object.
  37438. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37439. * @param object the object to get the class name from
  37440. * @param isType defines if the object is actually a type
  37441. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37442. */
  37443. static GetClassName(object: any, isType?: boolean): string;
  37444. /**
  37445. * Gets the first element of an array satisfying a given predicate
  37446. * @param array defines the array to browse
  37447. * @param predicate defines the predicate to use
  37448. * @returns null if not found or the element
  37449. */
  37450. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37451. /**
  37452. * This method will return the name of the full name of the class, including its owning module (if any).
  37453. * 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).
  37454. * @param object the object to get the class name from
  37455. * @param isType defines if the object is actually a type
  37456. * @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.
  37457. * @ignorenaming
  37458. */
  37459. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37460. /**
  37461. * Returns a promise that resolves after the given amount of time.
  37462. * @param delay Number of milliseconds to delay
  37463. * @returns Promise that resolves after the given amount of time
  37464. */
  37465. static DelayAsync(delay: number): Promise<void>;
  37466. /**
  37467. * Utility function to detect if the current user agent is Safari
  37468. * @returns whether or not the current user agent is safari
  37469. */
  37470. static IsSafari(): boolean;
  37471. }
  37472. /**
  37473. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37474. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37475. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37476. * @param name The name of the class, case should be preserved
  37477. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37478. */
  37479. export function className(name: string, module?: string): (target: Object) => void;
  37480. /**
  37481. * An implementation of a loop for asynchronous functions.
  37482. */
  37483. export class AsyncLoop {
  37484. /**
  37485. * Defines the number of iterations for the loop
  37486. */
  37487. iterations: number;
  37488. /**
  37489. * Defines the current index of the loop.
  37490. */
  37491. index: number;
  37492. private _done;
  37493. private _fn;
  37494. private _successCallback;
  37495. /**
  37496. * Constructor.
  37497. * @param iterations the number of iterations.
  37498. * @param func the function to run each iteration
  37499. * @param successCallback the callback that will be called upon succesful execution
  37500. * @param offset starting offset.
  37501. */
  37502. constructor(
  37503. /**
  37504. * Defines the number of iterations for the loop
  37505. */
  37506. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37507. /**
  37508. * Execute the next iteration. Must be called after the last iteration was finished.
  37509. */
  37510. executeNext(): void;
  37511. /**
  37512. * Break the loop and run the success callback.
  37513. */
  37514. breakLoop(): void;
  37515. /**
  37516. * Create and run an async loop.
  37517. * @param iterations the number of iterations.
  37518. * @param fn the function to run each iteration
  37519. * @param successCallback the callback that will be called upon succesful execution
  37520. * @param offset starting offset.
  37521. * @returns the created async loop object
  37522. */
  37523. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37524. /**
  37525. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37526. * @param iterations total number of iterations
  37527. * @param syncedIterations number of synchronous iterations in each async iteration.
  37528. * @param fn the function to call each iteration.
  37529. * @param callback a success call back that will be called when iterating stops.
  37530. * @param breakFunction a break condition (optional)
  37531. * @param timeout timeout settings for the setTimeout function. default - 0.
  37532. * @returns the created async loop object
  37533. */
  37534. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37535. }
  37536. }
  37537. declare module BABYLON {
  37538. /**
  37539. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37540. * The underlying implementation relies on an associative array to ensure the best performances.
  37541. * The value can be anything including 'null' but except 'undefined'
  37542. */
  37543. export class StringDictionary<T> {
  37544. /**
  37545. * This will clear this dictionary and copy the content from the 'source' one.
  37546. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37547. * @param source the dictionary to take the content from and copy to this dictionary
  37548. */
  37549. copyFrom(source: StringDictionary<T>): void;
  37550. /**
  37551. * Get a value based from its key
  37552. * @param key the given key to get the matching value from
  37553. * @return the value if found, otherwise undefined is returned
  37554. */
  37555. get(key: string): T | undefined;
  37556. /**
  37557. * Get a value from its key or add it if it doesn't exist.
  37558. * This method will ensure you that a given key/data will be present in the dictionary.
  37559. * @param key the given key to get the matching value from
  37560. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37561. * The factory will only be invoked if there's no data for the given key.
  37562. * @return the value corresponding to the key.
  37563. */
  37564. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37565. /**
  37566. * Get a value from its key if present in the dictionary otherwise add it
  37567. * @param key the key to get the value from
  37568. * @param val if there's no such key/value pair in the dictionary add it with this value
  37569. * @return the value corresponding to the key
  37570. */
  37571. getOrAdd(key: string, val: T): T;
  37572. /**
  37573. * Check if there's a given key in the dictionary
  37574. * @param key the key to check for
  37575. * @return true if the key is present, false otherwise
  37576. */
  37577. contains(key: string): boolean;
  37578. /**
  37579. * Add a new key and its corresponding value
  37580. * @param key the key to add
  37581. * @param value the value corresponding to the key
  37582. * @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
  37583. */
  37584. add(key: string, value: T): boolean;
  37585. /**
  37586. * Update a specific value associated to a key
  37587. * @param key defines the key to use
  37588. * @param value defines the value to store
  37589. * @returns true if the value was updated (or false if the key was not found)
  37590. */
  37591. set(key: string, value: T): boolean;
  37592. /**
  37593. * Get the element of the given key and remove it from the dictionary
  37594. * @param key defines the key to search
  37595. * @returns the value associated with the key or null if not found
  37596. */
  37597. getAndRemove(key: string): Nullable<T>;
  37598. /**
  37599. * Remove a key/value from the dictionary.
  37600. * @param key the key to remove
  37601. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37602. */
  37603. remove(key: string): boolean;
  37604. /**
  37605. * Clear the whole content of the dictionary
  37606. */
  37607. clear(): void;
  37608. /**
  37609. * Gets the current count
  37610. */
  37611. get count(): number;
  37612. /**
  37613. * Execute a callback on each key/val of the dictionary.
  37614. * Note that you can remove any element in this dictionary in the callback implementation
  37615. * @param callback the callback to execute on a given key/value pair
  37616. */
  37617. forEach(callback: (key: string, val: T) => void): void;
  37618. /**
  37619. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37620. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37621. * Note that you can remove any element in this dictionary in the callback implementation
  37622. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37623. * @returns the first item
  37624. */
  37625. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37626. private _count;
  37627. private _data;
  37628. }
  37629. }
  37630. declare module BABYLON {
  37631. /** @hidden */
  37632. export interface ICollisionCoordinator {
  37633. createCollider(): Collider;
  37634. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37635. init(scene: Scene): void;
  37636. }
  37637. /** @hidden */
  37638. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37639. private _scene;
  37640. private _scaledPosition;
  37641. private _scaledVelocity;
  37642. private _finalPosition;
  37643. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37644. createCollider(): Collider;
  37645. init(scene: Scene): void;
  37646. private _collideWithWorld;
  37647. }
  37648. }
  37649. declare module BABYLON {
  37650. /**
  37651. * Class used to manage all inputs for the scene.
  37652. */
  37653. export class InputManager {
  37654. /** The distance in pixel that you have to move to prevent some events */
  37655. static DragMovementThreshold: number;
  37656. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37657. static LongPressDelay: number;
  37658. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37659. static DoubleClickDelay: number;
  37660. /** If you need to check double click without raising a single click at first click, enable this flag */
  37661. static ExclusiveDoubleClickMode: boolean;
  37662. private _wheelEventName;
  37663. private _onPointerMove;
  37664. private _onPointerDown;
  37665. private _onPointerUp;
  37666. private _initClickEvent;
  37667. private _initActionManager;
  37668. private _delayedSimpleClick;
  37669. private _delayedSimpleClickTimeout;
  37670. private _previousDelayedSimpleClickTimeout;
  37671. private _meshPickProceed;
  37672. private _previousButtonPressed;
  37673. private _currentPickResult;
  37674. private _previousPickResult;
  37675. private _totalPointersPressed;
  37676. private _doubleClickOccured;
  37677. private _pointerOverMesh;
  37678. private _pickedDownMesh;
  37679. private _pickedUpMesh;
  37680. private _pointerX;
  37681. private _pointerY;
  37682. private _unTranslatedPointerX;
  37683. private _unTranslatedPointerY;
  37684. private _startingPointerPosition;
  37685. private _previousStartingPointerPosition;
  37686. private _startingPointerTime;
  37687. private _previousStartingPointerTime;
  37688. private _pointerCaptures;
  37689. private _onKeyDown;
  37690. private _onKeyUp;
  37691. private _onCanvasFocusObserver;
  37692. private _onCanvasBlurObserver;
  37693. private _scene;
  37694. /**
  37695. * Creates a new InputManager
  37696. * @param scene defines the hosting scene
  37697. */
  37698. constructor(scene: Scene);
  37699. /**
  37700. * Gets the mesh that is currently under the pointer
  37701. */
  37702. get meshUnderPointer(): Nullable<AbstractMesh>;
  37703. /**
  37704. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  37705. */
  37706. get unTranslatedPointer(): Vector2;
  37707. /**
  37708. * Gets or sets the current on-screen X position of the pointer
  37709. */
  37710. get pointerX(): number;
  37711. set pointerX(value: number);
  37712. /**
  37713. * Gets or sets the current on-screen Y position of the pointer
  37714. */
  37715. get pointerY(): number;
  37716. set pointerY(value: number);
  37717. private _updatePointerPosition;
  37718. private _processPointerMove;
  37719. private _setRayOnPointerInfo;
  37720. private _checkPrePointerObservable;
  37721. /**
  37722. * Use this method to simulate a pointer move on a mesh
  37723. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37724. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37725. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37726. */
  37727. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37728. /**
  37729. * Use this method to simulate a pointer down on a mesh
  37730. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37731. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37732. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37733. */
  37734. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37735. private _processPointerDown;
  37736. /** @hidden */
  37737. _isPointerSwiping(): boolean;
  37738. /**
  37739. * Use this method to simulate a pointer up on a mesh
  37740. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37741. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37742. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37743. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37744. */
  37745. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  37746. private _processPointerUp;
  37747. /**
  37748. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37749. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37750. * @returns true if the pointer was captured
  37751. */
  37752. isPointerCaptured(pointerId?: number): boolean;
  37753. /**
  37754. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37755. * @param attachUp defines if you want to attach events to pointerup
  37756. * @param attachDown defines if you want to attach events to pointerdown
  37757. * @param attachMove defines if you want to attach events to pointermove
  37758. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  37759. */
  37760. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  37761. /**
  37762. * Detaches all event handlers
  37763. */
  37764. detachControl(): void;
  37765. /**
  37766. * Force the value of meshUnderPointer
  37767. * @param mesh defines the mesh to use
  37768. */
  37769. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37770. /**
  37771. * Gets the mesh under the pointer
  37772. * @returns a Mesh or null if no mesh is under the pointer
  37773. */
  37774. getPointerOverMesh(): Nullable<AbstractMesh>;
  37775. }
  37776. }
  37777. declare module BABYLON {
  37778. /**
  37779. * This class defines the direct association between an animation and a target
  37780. */
  37781. export class TargetedAnimation {
  37782. /**
  37783. * Animation to perform
  37784. */
  37785. animation: Animation;
  37786. /**
  37787. * Target to animate
  37788. */
  37789. target: any;
  37790. /**
  37791. * Serialize the object
  37792. * @returns the JSON object representing the current entity
  37793. */
  37794. serialize(): any;
  37795. }
  37796. /**
  37797. * Use this class to create coordinated animations on multiple targets
  37798. */
  37799. export class AnimationGroup implements IDisposable {
  37800. /** The name of the animation group */
  37801. name: string;
  37802. private _scene;
  37803. private _targetedAnimations;
  37804. private _animatables;
  37805. private _from;
  37806. private _to;
  37807. private _isStarted;
  37808. private _isPaused;
  37809. private _speedRatio;
  37810. private _loopAnimation;
  37811. private _isAdditive;
  37812. /**
  37813. * Gets or sets the unique id of the node
  37814. */
  37815. uniqueId: number;
  37816. /**
  37817. * This observable will notify when one animation have ended
  37818. */
  37819. onAnimationEndObservable: Observable<TargetedAnimation>;
  37820. /**
  37821. * Observer raised when one animation loops
  37822. */
  37823. onAnimationLoopObservable: Observable<TargetedAnimation>;
  37824. /**
  37825. * Observer raised when all animations have looped
  37826. */
  37827. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  37828. /**
  37829. * This observable will notify when all animations have ended.
  37830. */
  37831. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  37832. /**
  37833. * This observable will notify when all animations have paused.
  37834. */
  37835. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  37836. /**
  37837. * This observable will notify when all animations are playing.
  37838. */
  37839. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  37840. /**
  37841. * Gets the first frame
  37842. */
  37843. get from(): number;
  37844. /**
  37845. * Gets the last frame
  37846. */
  37847. get to(): number;
  37848. /**
  37849. * Define if the animations are started
  37850. */
  37851. get isStarted(): boolean;
  37852. /**
  37853. * Gets a value indicating that the current group is playing
  37854. */
  37855. get isPlaying(): boolean;
  37856. /**
  37857. * Gets or sets the speed ratio to use for all animations
  37858. */
  37859. get speedRatio(): number;
  37860. /**
  37861. * Gets or sets the speed ratio to use for all animations
  37862. */
  37863. set speedRatio(value: number);
  37864. /**
  37865. * Gets or sets if all animations should loop or not
  37866. */
  37867. get loopAnimation(): boolean;
  37868. set loopAnimation(value: boolean);
  37869. /**
  37870. * Gets or sets if all animations should be evaluated additively
  37871. */
  37872. get isAdditive(): boolean;
  37873. set isAdditive(value: boolean);
  37874. /**
  37875. * Gets the targeted animations for this animation group
  37876. */
  37877. get targetedAnimations(): Array<TargetedAnimation>;
  37878. /**
  37879. * returning the list of animatables controlled by this animation group.
  37880. */
  37881. get animatables(): Array<Animatable>;
  37882. /**
  37883. * Instantiates a new Animation Group.
  37884. * This helps managing several animations at once.
  37885. * @see http://doc.babylonjs.com/how_to/group
  37886. * @param name Defines the name of the group
  37887. * @param scene Defines the scene the group belongs to
  37888. */
  37889. constructor(
  37890. /** The name of the animation group */
  37891. name: string, scene?: Nullable<Scene>);
  37892. /**
  37893. * Add an animation (with its target) in the group
  37894. * @param animation defines the animation we want to add
  37895. * @param target defines the target of the animation
  37896. * @returns the TargetedAnimation object
  37897. */
  37898. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  37899. /**
  37900. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  37901. * It can add constant keys at begin or end
  37902. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  37903. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  37904. * @returns the animation group
  37905. */
  37906. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  37907. private _animationLoopCount;
  37908. private _animationLoopFlags;
  37909. private _processLoop;
  37910. /**
  37911. * Start all animations on given targets
  37912. * @param loop defines if animations must loop
  37913. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  37914. * @param from defines the from key (optional)
  37915. * @param to defines the to key (optional)
  37916. * @param isAdditive defines the additive state for the resulting animatables (optional)
  37917. * @returns the current animation group
  37918. */
  37919. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  37920. /**
  37921. * Pause all animations
  37922. * @returns the animation group
  37923. */
  37924. pause(): AnimationGroup;
  37925. /**
  37926. * Play all animations to initial state
  37927. * This function will start() the animations if they were not started or will restart() them if they were paused
  37928. * @param loop defines if animations must loop
  37929. * @returns the animation group
  37930. */
  37931. play(loop?: boolean): AnimationGroup;
  37932. /**
  37933. * Reset all animations to initial state
  37934. * @returns the animation group
  37935. */
  37936. reset(): AnimationGroup;
  37937. /**
  37938. * Restart animations from key 0
  37939. * @returns the animation group
  37940. */
  37941. restart(): AnimationGroup;
  37942. /**
  37943. * Stop all animations
  37944. * @returns the animation group
  37945. */
  37946. stop(): AnimationGroup;
  37947. /**
  37948. * Set animation weight for all animatables
  37949. * @param weight defines the weight to use
  37950. * @return the animationGroup
  37951. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  37952. */
  37953. setWeightForAllAnimatables(weight: number): AnimationGroup;
  37954. /**
  37955. * Synchronize and normalize all animatables with a source animatable
  37956. * @param root defines the root animatable to synchronize with
  37957. * @return the animationGroup
  37958. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  37959. */
  37960. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  37961. /**
  37962. * Goes to a specific frame in this animation group
  37963. * @param frame the frame number to go to
  37964. * @return the animationGroup
  37965. */
  37966. goToFrame(frame: number): AnimationGroup;
  37967. /**
  37968. * Dispose all associated resources
  37969. */
  37970. dispose(): void;
  37971. private _checkAnimationGroupEnded;
  37972. /**
  37973. * Clone the current animation group and returns a copy
  37974. * @param newName defines the name of the new group
  37975. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  37976. * @returns the new aniamtion group
  37977. */
  37978. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  37979. /**
  37980. * Serializes the animationGroup to an object
  37981. * @returns Serialized object
  37982. */
  37983. serialize(): any;
  37984. /**
  37985. * Returns a new AnimationGroup object parsed from the source provided.
  37986. * @param parsedAnimationGroup defines the source
  37987. * @param scene defines the scene that will receive the animationGroup
  37988. * @returns a new AnimationGroup
  37989. */
  37990. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  37991. /**
  37992. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37993. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  37994. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37995. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  37996. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  37997. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  37998. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  37999. */
  38000. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38001. /**
  38002. * Returns the string "AnimationGroup"
  38003. * @returns "AnimationGroup"
  38004. */
  38005. getClassName(): string;
  38006. /**
  38007. * Creates a detailled string about the object
  38008. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38009. * @returns a string representing the object
  38010. */
  38011. toString(fullDetails?: boolean): string;
  38012. }
  38013. }
  38014. declare module BABYLON {
  38015. /**
  38016. * Define an interface for all classes that will hold resources
  38017. */
  38018. export interface IDisposable {
  38019. /**
  38020. * Releases all held resources
  38021. */
  38022. dispose(): void;
  38023. }
  38024. /** Interface defining initialization parameters for Scene class */
  38025. export interface SceneOptions {
  38026. /**
  38027. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38028. * It will improve performance when the number of geometries becomes important.
  38029. */
  38030. useGeometryUniqueIdsMap?: boolean;
  38031. /**
  38032. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38033. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38034. */
  38035. useMaterialMeshMap?: boolean;
  38036. /**
  38037. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38038. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38039. */
  38040. useClonedMeshMap?: boolean;
  38041. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38042. virtual?: boolean;
  38043. }
  38044. /**
  38045. * Represents a scene to be rendered by the engine.
  38046. * @see http://doc.babylonjs.com/features/scene
  38047. */
  38048. export class Scene extends AbstractScene implements IAnimatable {
  38049. /** The fog is deactivated */
  38050. static readonly FOGMODE_NONE: number;
  38051. /** The fog density is following an exponential function */
  38052. static readonly FOGMODE_EXP: number;
  38053. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38054. static readonly FOGMODE_EXP2: number;
  38055. /** The fog density is following a linear function. */
  38056. static readonly FOGMODE_LINEAR: number;
  38057. /**
  38058. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38059. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38060. */
  38061. static MinDeltaTime: number;
  38062. /**
  38063. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38064. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38065. */
  38066. static MaxDeltaTime: number;
  38067. /**
  38068. * Factory used to create the default material.
  38069. * @param name The name of the material to create
  38070. * @param scene The scene to create the material for
  38071. * @returns The default material
  38072. */
  38073. static DefaultMaterialFactory(scene: Scene): Material;
  38074. /**
  38075. * Factory used to create the a collision coordinator.
  38076. * @returns The collision coordinator
  38077. */
  38078. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38079. /** @hidden */
  38080. _inputManager: InputManager;
  38081. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38082. cameraToUseForPointers: Nullable<Camera>;
  38083. /** @hidden */
  38084. readonly _isScene: boolean;
  38085. /** @hidden */
  38086. _blockEntityCollection: boolean;
  38087. /**
  38088. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38089. */
  38090. autoClear: boolean;
  38091. /**
  38092. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38093. */
  38094. autoClearDepthAndStencil: boolean;
  38095. /**
  38096. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38097. */
  38098. clearColor: Color4;
  38099. /**
  38100. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38101. */
  38102. ambientColor: Color3;
  38103. /**
  38104. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38105. * It should only be one of the following (if not the default embedded one):
  38106. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38107. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38108. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38109. * The material properties need to be setup according to the type of texture in use.
  38110. */
  38111. environmentBRDFTexture: BaseTexture;
  38112. /** @hidden */
  38113. protected _environmentTexture: Nullable<BaseTexture>;
  38114. /**
  38115. * Texture used in all pbr material as the reflection texture.
  38116. * As in the majority of the scene they are the same (exception for multi room and so on),
  38117. * this is easier to reference from here than from all the materials.
  38118. */
  38119. get environmentTexture(): Nullable<BaseTexture>;
  38120. /**
  38121. * Texture used in all pbr material as the reflection texture.
  38122. * As in the majority of the scene they are the same (exception for multi room and so on),
  38123. * this is easier to set here than in all the materials.
  38124. */
  38125. set environmentTexture(value: Nullable<BaseTexture>);
  38126. /** @hidden */
  38127. protected _environmentIntensity: number;
  38128. /**
  38129. * Intensity of the environment in all pbr material.
  38130. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38131. * As in the majority of the scene they are the same (exception for multi room and so on),
  38132. * this is easier to reference from here than from all the materials.
  38133. */
  38134. get environmentIntensity(): number;
  38135. /**
  38136. * Intensity of the environment in all pbr material.
  38137. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38138. * As in the majority of the scene they are the same (exception for multi room and so on),
  38139. * this is easier to set here than in all the materials.
  38140. */
  38141. set environmentIntensity(value: number);
  38142. /** @hidden */
  38143. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38144. /**
  38145. * Default image processing configuration used either in the rendering
  38146. * Forward main pass or through the imageProcessingPostProcess if present.
  38147. * As in the majority of the scene they are the same (exception for multi camera),
  38148. * this is easier to reference from here than from all the materials and post process.
  38149. *
  38150. * No setter as we it is a shared configuration, you can set the values instead.
  38151. */
  38152. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38153. private _forceWireframe;
  38154. /**
  38155. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38156. */
  38157. set forceWireframe(value: boolean);
  38158. get forceWireframe(): boolean;
  38159. private _skipFrustumClipping;
  38160. /**
  38161. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38162. */
  38163. set skipFrustumClipping(value: boolean);
  38164. get skipFrustumClipping(): boolean;
  38165. private _forcePointsCloud;
  38166. /**
  38167. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38168. */
  38169. set forcePointsCloud(value: boolean);
  38170. get forcePointsCloud(): boolean;
  38171. /**
  38172. * Gets or sets the active clipplane 1
  38173. */
  38174. clipPlane: Nullable<Plane>;
  38175. /**
  38176. * Gets or sets the active clipplane 2
  38177. */
  38178. clipPlane2: Nullable<Plane>;
  38179. /**
  38180. * Gets or sets the active clipplane 3
  38181. */
  38182. clipPlane3: Nullable<Plane>;
  38183. /**
  38184. * Gets or sets the active clipplane 4
  38185. */
  38186. clipPlane4: Nullable<Plane>;
  38187. /**
  38188. * Gets or sets the active clipplane 5
  38189. */
  38190. clipPlane5: Nullable<Plane>;
  38191. /**
  38192. * Gets or sets the active clipplane 6
  38193. */
  38194. clipPlane6: Nullable<Plane>;
  38195. /**
  38196. * Gets or sets a boolean indicating if animations are enabled
  38197. */
  38198. animationsEnabled: boolean;
  38199. private _animationPropertiesOverride;
  38200. /**
  38201. * Gets or sets the animation properties override
  38202. */
  38203. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38204. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38205. /**
  38206. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38207. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38208. */
  38209. useConstantAnimationDeltaTime: boolean;
  38210. /**
  38211. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38212. * Please note that it requires to run a ray cast through the scene on every frame
  38213. */
  38214. constantlyUpdateMeshUnderPointer: boolean;
  38215. /**
  38216. * Defines the HTML cursor to use when hovering over interactive elements
  38217. */
  38218. hoverCursor: string;
  38219. /**
  38220. * Defines the HTML default cursor to use (empty by default)
  38221. */
  38222. defaultCursor: string;
  38223. /**
  38224. * Defines whether cursors are handled by the scene.
  38225. */
  38226. doNotHandleCursors: boolean;
  38227. /**
  38228. * This is used to call preventDefault() on pointer down
  38229. * in order to block unwanted artifacts like system double clicks
  38230. */
  38231. preventDefaultOnPointerDown: boolean;
  38232. /**
  38233. * This is used to call preventDefault() on pointer up
  38234. * in order to block unwanted artifacts like system double clicks
  38235. */
  38236. preventDefaultOnPointerUp: boolean;
  38237. /**
  38238. * Gets or sets user defined metadata
  38239. */
  38240. metadata: any;
  38241. /**
  38242. * For internal use only. Please do not use.
  38243. */
  38244. reservedDataStore: any;
  38245. /**
  38246. * Gets the name of the plugin used to load this scene (null by default)
  38247. */
  38248. loadingPluginName: string;
  38249. /**
  38250. * Use this array to add regular expressions used to disable offline support for specific urls
  38251. */
  38252. disableOfflineSupportExceptionRules: RegExp[];
  38253. /**
  38254. * An event triggered when the scene is disposed.
  38255. */
  38256. onDisposeObservable: Observable<Scene>;
  38257. private _onDisposeObserver;
  38258. /** Sets a function to be executed when this scene is disposed. */
  38259. set onDispose(callback: () => void);
  38260. /**
  38261. * An event triggered before rendering the scene (right after animations and physics)
  38262. */
  38263. onBeforeRenderObservable: Observable<Scene>;
  38264. private _onBeforeRenderObserver;
  38265. /** Sets a function to be executed before rendering this scene */
  38266. set beforeRender(callback: Nullable<() => void>);
  38267. /**
  38268. * An event triggered after rendering the scene
  38269. */
  38270. onAfterRenderObservable: Observable<Scene>;
  38271. /**
  38272. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38273. */
  38274. onAfterRenderCameraObservable: Observable<Camera>;
  38275. private _onAfterRenderObserver;
  38276. /** Sets a function to be executed after rendering this scene */
  38277. set afterRender(callback: Nullable<() => void>);
  38278. /**
  38279. * An event triggered before animating the scene
  38280. */
  38281. onBeforeAnimationsObservable: Observable<Scene>;
  38282. /**
  38283. * An event triggered after animations processing
  38284. */
  38285. onAfterAnimationsObservable: Observable<Scene>;
  38286. /**
  38287. * An event triggered before draw calls are ready to be sent
  38288. */
  38289. onBeforeDrawPhaseObservable: Observable<Scene>;
  38290. /**
  38291. * An event triggered after draw calls have been sent
  38292. */
  38293. onAfterDrawPhaseObservable: Observable<Scene>;
  38294. /**
  38295. * An event triggered when the scene is ready
  38296. */
  38297. onReadyObservable: Observable<Scene>;
  38298. /**
  38299. * An event triggered before rendering a camera
  38300. */
  38301. onBeforeCameraRenderObservable: Observable<Camera>;
  38302. private _onBeforeCameraRenderObserver;
  38303. /** Sets a function to be executed before rendering a camera*/
  38304. set beforeCameraRender(callback: () => void);
  38305. /**
  38306. * An event triggered after rendering a camera
  38307. */
  38308. onAfterCameraRenderObservable: Observable<Camera>;
  38309. private _onAfterCameraRenderObserver;
  38310. /** Sets a function to be executed after rendering a camera*/
  38311. set afterCameraRender(callback: () => void);
  38312. /**
  38313. * An event triggered when active meshes evaluation is about to start
  38314. */
  38315. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38316. /**
  38317. * An event triggered when active meshes evaluation is done
  38318. */
  38319. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38320. /**
  38321. * An event triggered when particles rendering is about to start
  38322. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38323. */
  38324. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38325. /**
  38326. * An event triggered when particles rendering is done
  38327. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38328. */
  38329. onAfterParticlesRenderingObservable: Observable<Scene>;
  38330. /**
  38331. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38332. */
  38333. onDataLoadedObservable: Observable<Scene>;
  38334. /**
  38335. * An event triggered when a camera is created
  38336. */
  38337. onNewCameraAddedObservable: Observable<Camera>;
  38338. /**
  38339. * An event triggered when a camera is removed
  38340. */
  38341. onCameraRemovedObservable: Observable<Camera>;
  38342. /**
  38343. * An event triggered when a light is created
  38344. */
  38345. onNewLightAddedObservable: Observable<Light>;
  38346. /**
  38347. * An event triggered when a light is removed
  38348. */
  38349. onLightRemovedObservable: Observable<Light>;
  38350. /**
  38351. * An event triggered when a geometry is created
  38352. */
  38353. onNewGeometryAddedObservable: Observable<Geometry>;
  38354. /**
  38355. * An event triggered when a geometry is removed
  38356. */
  38357. onGeometryRemovedObservable: Observable<Geometry>;
  38358. /**
  38359. * An event triggered when a transform node is created
  38360. */
  38361. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38362. /**
  38363. * An event triggered when a transform node is removed
  38364. */
  38365. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38366. /**
  38367. * An event triggered when a mesh is created
  38368. */
  38369. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38370. /**
  38371. * An event triggered when a mesh is removed
  38372. */
  38373. onMeshRemovedObservable: Observable<AbstractMesh>;
  38374. /**
  38375. * An event triggered when a skeleton is created
  38376. */
  38377. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38378. /**
  38379. * An event triggered when a skeleton is removed
  38380. */
  38381. onSkeletonRemovedObservable: Observable<Skeleton>;
  38382. /**
  38383. * An event triggered when a material is created
  38384. */
  38385. onNewMaterialAddedObservable: Observable<Material>;
  38386. /**
  38387. * An event triggered when a material is removed
  38388. */
  38389. onMaterialRemovedObservable: Observable<Material>;
  38390. /**
  38391. * An event triggered when a texture is created
  38392. */
  38393. onNewTextureAddedObservable: Observable<BaseTexture>;
  38394. /**
  38395. * An event triggered when a texture is removed
  38396. */
  38397. onTextureRemovedObservable: Observable<BaseTexture>;
  38398. /**
  38399. * An event triggered when render targets are about to be rendered
  38400. * Can happen multiple times per frame.
  38401. */
  38402. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38403. /**
  38404. * An event triggered when render targets were rendered.
  38405. * Can happen multiple times per frame.
  38406. */
  38407. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38408. /**
  38409. * An event triggered before calculating deterministic simulation step
  38410. */
  38411. onBeforeStepObservable: Observable<Scene>;
  38412. /**
  38413. * An event triggered after calculating deterministic simulation step
  38414. */
  38415. onAfterStepObservable: Observable<Scene>;
  38416. /**
  38417. * An event triggered when the activeCamera property is updated
  38418. */
  38419. onActiveCameraChanged: Observable<Scene>;
  38420. /**
  38421. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38422. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38423. * 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)
  38424. */
  38425. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38426. /**
  38427. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38428. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38429. * 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)
  38430. */
  38431. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38432. /**
  38433. * This Observable will when a mesh has been imported into the scene.
  38434. */
  38435. onMeshImportedObservable: Observable<AbstractMesh>;
  38436. /**
  38437. * This Observable will when an animation file has been imported into the scene.
  38438. */
  38439. onAnimationFileImportedObservable: Observable<Scene>;
  38440. /**
  38441. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38442. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38443. */
  38444. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38445. /** @hidden */
  38446. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38447. /**
  38448. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38449. */
  38450. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38451. /**
  38452. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38453. */
  38454. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38455. /**
  38456. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38457. */
  38458. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38459. /** Callback called when a pointer move is detected */
  38460. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38461. /** Callback called when a pointer down is detected */
  38462. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38463. /** Callback called when a pointer up is detected */
  38464. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38465. /** Callback called when a pointer pick is detected */
  38466. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38467. /**
  38468. * 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).
  38469. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38470. */
  38471. onPrePointerObservable: Observable<PointerInfoPre>;
  38472. /**
  38473. * Observable event triggered each time an input event is received from the rendering canvas
  38474. */
  38475. onPointerObservable: Observable<PointerInfo>;
  38476. /**
  38477. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38478. */
  38479. get unTranslatedPointer(): Vector2;
  38480. /**
  38481. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38482. */
  38483. static get DragMovementThreshold(): number;
  38484. static set DragMovementThreshold(value: number);
  38485. /**
  38486. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38487. */
  38488. static get LongPressDelay(): number;
  38489. static set LongPressDelay(value: number);
  38490. /**
  38491. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38492. */
  38493. static get DoubleClickDelay(): number;
  38494. static set DoubleClickDelay(value: number);
  38495. /** If you need to check double click without raising a single click at first click, enable this flag */
  38496. static get ExclusiveDoubleClickMode(): boolean;
  38497. static set ExclusiveDoubleClickMode(value: boolean);
  38498. /** @hidden */
  38499. _mirroredCameraPosition: Nullable<Vector3>;
  38500. /**
  38501. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38502. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38503. */
  38504. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38505. /**
  38506. * Observable event triggered each time an keyboard event is received from the hosting window
  38507. */
  38508. onKeyboardObservable: Observable<KeyboardInfo>;
  38509. private _useRightHandedSystem;
  38510. /**
  38511. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38512. */
  38513. set useRightHandedSystem(value: boolean);
  38514. get useRightHandedSystem(): boolean;
  38515. private _timeAccumulator;
  38516. private _currentStepId;
  38517. private _currentInternalStep;
  38518. /**
  38519. * Sets the step Id used by deterministic lock step
  38520. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38521. * @param newStepId defines the step Id
  38522. */
  38523. setStepId(newStepId: number): void;
  38524. /**
  38525. * Gets the step Id used by deterministic lock step
  38526. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38527. * @returns the step Id
  38528. */
  38529. getStepId(): number;
  38530. /**
  38531. * Gets the internal step used by deterministic lock step
  38532. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38533. * @returns the internal step
  38534. */
  38535. getInternalStep(): number;
  38536. private _fogEnabled;
  38537. /**
  38538. * Gets or sets a boolean indicating if fog is enabled on this scene
  38539. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38540. * (Default is true)
  38541. */
  38542. set fogEnabled(value: boolean);
  38543. get fogEnabled(): boolean;
  38544. private _fogMode;
  38545. /**
  38546. * Gets or sets the fog mode to use
  38547. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38548. * | mode | value |
  38549. * | --- | --- |
  38550. * | FOGMODE_NONE | 0 |
  38551. * | FOGMODE_EXP | 1 |
  38552. * | FOGMODE_EXP2 | 2 |
  38553. * | FOGMODE_LINEAR | 3 |
  38554. */
  38555. set fogMode(value: number);
  38556. get fogMode(): number;
  38557. /**
  38558. * Gets or sets the fog color to use
  38559. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38560. * (Default is Color3(0.2, 0.2, 0.3))
  38561. */
  38562. fogColor: Color3;
  38563. /**
  38564. * Gets or sets the fog density to use
  38565. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38566. * (Default is 0.1)
  38567. */
  38568. fogDensity: number;
  38569. /**
  38570. * Gets or sets the fog start distance to use
  38571. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38572. * (Default is 0)
  38573. */
  38574. fogStart: number;
  38575. /**
  38576. * Gets or sets the fog end distance to use
  38577. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38578. * (Default is 1000)
  38579. */
  38580. fogEnd: number;
  38581. private _shadowsEnabled;
  38582. /**
  38583. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38584. */
  38585. set shadowsEnabled(value: boolean);
  38586. get shadowsEnabled(): boolean;
  38587. private _lightsEnabled;
  38588. /**
  38589. * Gets or sets a boolean indicating if lights are enabled on this scene
  38590. */
  38591. set lightsEnabled(value: boolean);
  38592. get lightsEnabled(): boolean;
  38593. /** All of the active cameras added to this scene. */
  38594. activeCameras: Camera[];
  38595. /** @hidden */
  38596. _activeCamera: Nullable<Camera>;
  38597. /** Gets or sets the current active camera */
  38598. get activeCamera(): Nullable<Camera>;
  38599. set activeCamera(value: Nullable<Camera>);
  38600. private _defaultMaterial;
  38601. /** The default material used on meshes when no material is affected */
  38602. get defaultMaterial(): Material;
  38603. /** The default material used on meshes when no material is affected */
  38604. set defaultMaterial(value: Material);
  38605. private _texturesEnabled;
  38606. /**
  38607. * Gets or sets a boolean indicating if textures are enabled on this scene
  38608. */
  38609. set texturesEnabled(value: boolean);
  38610. get texturesEnabled(): boolean;
  38611. /**
  38612. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38613. */
  38614. physicsEnabled: boolean;
  38615. /**
  38616. * Gets or sets a boolean indicating if particles are enabled on this scene
  38617. */
  38618. particlesEnabled: boolean;
  38619. /**
  38620. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38621. */
  38622. spritesEnabled: boolean;
  38623. private _skeletonsEnabled;
  38624. /**
  38625. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38626. */
  38627. set skeletonsEnabled(value: boolean);
  38628. get skeletonsEnabled(): boolean;
  38629. /**
  38630. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38631. */
  38632. lensFlaresEnabled: boolean;
  38633. /**
  38634. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38635. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38636. */
  38637. collisionsEnabled: boolean;
  38638. private _collisionCoordinator;
  38639. /** @hidden */
  38640. get collisionCoordinator(): ICollisionCoordinator;
  38641. /**
  38642. * Defines the gravity applied to this scene (used only for collisions)
  38643. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38644. */
  38645. gravity: Vector3;
  38646. /**
  38647. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38648. */
  38649. postProcessesEnabled: boolean;
  38650. /**
  38651. * The list of postprocesses added to the scene
  38652. */
  38653. postProcesses: PostProcess[];
  38654. /**
  38655. * Gets the current postprocess manager
  38656. */
  38657. postProcessManager: PostProcessManager;
  38658. /**
  38659. * Gets or sets a boolean indicating if render targets are enabled on this scene
  38660. */
  38661. renderTargetsEnabled: boolean;
  38662. /**
  38663. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  38664. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  38665. */
  38666. dumpNextRenderTargets: boolean;
  38667. /**
  38668. * The list of user defined render targets added to the scene
  38669. */
  38670. customRenderTargets: RenderTargetTexture[];
  38671. /**
  38672. * Defines if texture loading must be delayed
  38673. * If true, textures will only be loaded when they need to be rendered
  38674. */
  38675. useDelayedTextureLoading: boolean;
  38676. /**
  38677. * Gets the list of meshes imported to the scene through SceneLoader
  38678. */
  38679. importedMeshesFiles: String[];
  38680. /**
  38681. * Gets or sets a boolean indicating if probes are enabled on this scene
  38682. */
  38683. probesEnabled: boolean;
  38684. /**
  38685. * Gets or sets the current offline provider to use to store scene data
  38686. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  38687. */
  38688. offlineProvider: IOfflineProvider;
  38689. /**
  38690. * Gets or sets the action manager associated with the scene
  38691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38692. */
  38693. actionManager: AbstractActionManager;
  38694. private _meshesForIntersections;
  38695. /**
  38696. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  38697. */
  38698. proceduralTexturesEnabled: boolean;
  38699. private _engine;
  38700. private _totalVertices;
  38701. /** @hidden */
  38702. _activeIndices: PerfCounter;
  38703. /** @hidden */
  38704. _activeParticles: PerfCounter;
  38705. /** @hidden */
  38706. _activeBones: PerfCounter;
  38707. private _animationRatio;
  38708. /** @hidden */
  38709. _animationTimeLast: number;
  38710. /** @hidden */
  38711. _animationTime: number;
  38712. /**
  38713. * Gets or sets a general scale for animation speed
  38714. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  38715. */
  38716. animationTimeScale: number;
  38717. /** @hidden */
  38718. _cachedMaterial: Nullable<Material>;
  38719. /** @hidden */
  38720. _cachedEffect: Nullable<Effect>;
  38721. /** @hidden */
  38722. _cachedVisibility: Nullable<number>;
  38723. private _renderId;
  38724. private _frameId;
  38725. private _executeWhenReadyTimeoutId;
  38726. private _intermediateRendering;
  38727. private _viewUpdateFlag;
  38728. private _projectionUpdateFlag;
  38729. /** @hidden */
  38730. _toBeDisposed: Nullable<IDisposable>[];
  38731. private _activeRequests;
  38732. /** @hidden */
  38733. _pendingData: any[];
  38734. private _isDisposed;
  38735. /**
  38736. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  38737. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  38738. */
  38739. dispatchAllSubMeshesOfActiveMeshes: boolean;
  38740. private _activeMeshes;
  38741. private _processedMaterials;
  38742. private _renderTargets;
  38743. /** @hidden */
  38744. _activeParticleSystems: SmartArray<IParticleSystem>;
  38745. private _activeSkeletons;
  38746. private _softwareSkinnedMeshes;
  38747. private _renderingManager;
  38748. /** @hidden */
  38749. _activeAnimatables: Animatable[];
  38750. private _transformMatrix;
  38751. private _sceneUbo;
  38752. /** @hidden */
  38753. _viewMatrix: Matrix;
  38754. private _projectionMatrix;
  38755. /** @hidden */
  38756. _forcedViewPosition: Nullable<Vector3>;
  38757. /** @hidden */
  38758. _frustumPlanes: Plane[];
  38759. /**
  38760. * Gets the list of frustum planes (built from the active camera)
  38761. */
  38762. get frustumPlanes(): Plane[];
  38763. /**
  38764. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  38765. * This is useful if there are more lights that the maximum simulteanous authorized
  38766. */
  38767. requireLightSorting: boolean;
  38768. /** @hidden */
  38769. readonly useMaterialMeshMap: boolean;
  38770. /** @hidden */
  38771. readonly useClonedMeshMap: boolean;
  38772. private _externalData;
  38773. private _uid;
  38774. /**
  38775. * @hidden
  38776. * Backing store of defined scene components.
  38777. */
  38778. _components: ISceneComponent[];
  38779. /**
  38780. * @hidden
  38781. * Backing store of defined scene components.
  38782. */
  38783. _serializableComponents: ISceneSerializableComponent[];
  38784. /**
  38785. * List of components to register on the next registration step.
  38786. */
  38787. private _transientComponents;
  38788. /**
  38789. * Registers the transient components if needed.
  38790. */
  38791. private _registerTransientComponents;
  38792. /**
  38793. * @hidden
  38794. * Add a component to the scene.
  38795. * Note that the ccomponent could be registered on th next frame if this is called after
  38796. * the register component stage.
  38797. * @param component Defines the component to add to the scene
  38798. */
  38799. _addComponent(component: ISceneComponent): void;
  38800. /**
  38801. * @hidden
  38802. * Gets a component from the scene.
  38803. * @param name defines the name of the component to retrieve
  38804. * @returns the component or null if not present
  38805. */
  38806. _getComponent(name: string): Nullable<ISceneComponent>;
  38807. /**
  38808. * @hidden
  38809. * Defines the actions happening before camera updates.
  38810. */
  38811. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  38812. /**
  38813. * @hidden
  38814. * Defines the actions happening before clear the canvas.
  38815. */
  38816. _beforeClearStage: Stage<SimpleStageAction>;
  38817. /**
  38818. * @hidden
  38819. * Defines the actions when collecting render targets for the frame.
  38820. */
  38821. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38822. /**
  38823. * @hidden
  38824. * Defines the actions happening for one camera in the frame.
  38825. */
  38826. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38827. /**
  38828. * @hidden
  38829. * Defines the actions happening during the per mesh ready checks.
  38830. */
  38831. _isReadyForMeshStage: Stage<MeshStageAction>;
  38832. /**
  38833. * @hidden
  38834. * Defines the actions happening before evaluate active mesh checks.
  38835. */
  38836. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  38837. /**
  38838. * @hidden
  38839. * Defines the actions happening during the evaluate sub mesh checks.
  38840. */
  38841. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  38842. /**
  38843. * @hidden
  38844. * Defines the actions happening during the active mesh stage.
  38845. */
  38846. _activeMeshStage: Stage<ActiveMeshStageAction>;
  38847. /**
  38848. * @hidden
  38849. * Defines the actions happening during the per camera render target step.
  38850. */
  38851. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  38852. /**
  38853. * @hidden
  38854. * Defines the actions happening just before the active camera is drawing.
  38855. */
  38856. _beforeCameraDrawStage: Stage<CameraStageAction>;
  38857. /**
  38858. * @hidden
  38859. * Defines the actions happening just before a render target is drawing.
  38860. */
  38861. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38862. /**
  38863. * @hidden
  38864. * Defines the actions happening just before a rendering group is drawing.
  38865. */
  38866. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38867. /**
  38868. * @hidden
  38869. * Defines the actions happening just before a mesh is drawing.
  38870. */
  38871. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38872. /**
  38873. * @hidden
  38874. * Defines the actions happening just after a mesh has been drawn.
  38875. */
  38876. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38877. /**
  38878. * @hidden
  38879. * Defines the actions happening just after a rendering group has been drawn.
  38880. */
  38881. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38882. /**
  38883. * @hidden
  38884. * Defines the actions happening just after the active camera has been drawn.
  38885. */
  38886. _afterCameraDrawStage: Stage<CameraStageAction>;
  38887. /**
  38888. * @hidden
  38889. * Defines the actions happening just after a render target has been drawn.
  38890. */
  38891. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38892. /**
  38893. * @hidden
  38894. * Defines the actions happening just after rendering all cameras and computing intersections.
  38895. */
  38896. _afterRenderStage: Stage<SimpleStageAction>;
  38897. /**
  38898. * @hidden
  38899. * Defines the actions happening when a pointer move event happens.
  38900. */
  38901. _pointerMoveStage: Stage<PointerMoveStageAction>;
  38902. /**
  38903. * @hidden
  38904. * Defines the actions happening when a pointer down event happens.
  38905. */
  38906. _pointerDownStage: Stage<PointerUpDownStageAction>;
  38907. /**
  38908. * @hidden
  38909. * Defines the actions happening when a pointer up event happens.
  38910. */
  38911. _pointerUpStage: Stage<PointerUpDownStageAction>;
  38912. /**
  38913. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  38914. */
  38915. private geometriesByUniqueId;
  38916. /**
  38917. * Creates a new Scene
  38918. * @param engine defines the engine to use to render this scene
  38919. * @param options defines the scene options
  38920. */
  38921. constructor(engine: Engine, options?: SceneOptions);
  38922. /**
  38923. * Gets a string idenfifying the name of the class
  38924. * @returns "Scene" string
  38925. */
  38926. getClassName(): string;
  38927. private _defaultMeshCandidates;
  38928. /**
  38929. * @hidden
  38930. */
  38931. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  38932. private _defaultSubMeshCandidates;
  38933. /**
  38934. * @hidden
  38935. */
  38936. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  38937. /**
  38938. * Sets the default candidate providers for the scene.
  38939. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  38940. * and getCollidingSubMeshCandidates to their default function
  38941. */
  38942. setDefaultCandidateProviders(): void;
  38943. /**
  38944. * Gets the mesh that is currently under the pointer
  38945. */
  38946. get meshUnderPointer(): Nullable<AbstractMesh>;
  38947. /**
  38948. * Gets or sets the current on-screen X position of the pointer
  38949. */
  38950. get pointerX(): number;
  38951. set pointerX(value: number);
  38952. /**
  38953. * Gets or sets the current on-screen Y position of the pointer
  38954. */
  38955. get pointerY(): number;
  38956. set pointerY(value: number);
  38957. /**
  38958. * Gets the cached material (ie. the latest rendered one)
  38959. * @returns the cached material
  38960. */
  38961. getCachedMaterial(): Nullable<Material>;
  38962. /**
  38963. * Gets the cached effect (ie. the latest rendered one)
  38964. * @returns the cached effect
  38965. */
  38966. getCachedEffect(): Nullable<Effect>;
  38967. /**
  38968. * Gets the cached visibility state (ie. the latest rendered one)
  38969. * @returns the cached visibility state
  38970. */
  38971. getCachedVisibility(): Nullable<number>;
  38972. /**
  38973. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  38974. * @param material defines the current material
  38975. * @param effect defines the current effect
  38976. * @param visibility defines the current visibility state
  38977. * @returns true if one parameter is not cached
  38978. */
  38979. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  38980. /**
  38981. * Gets the engine associated with the scene
  38982. * @returns an Engine
  38983. */
  38984. getEngine(): Engine;
  38985. /**
  38986. * Gets the total number of vertices rendered per frame
  38987. * @returns the total number of vertices rendered per frame
  38988. */
  38989. getTotalVertices(): number;
  38990. /**
  38991. * Gets the performance counter for total vertices
  38992. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  38993. */
  38994. get totalVerticesPerfCounter(): PerfCounter;
  38995. /**
  38996. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  38997. * @returns the total number of active indices rendered per frame
  38998. */
  38999. getActiveIndices(): number;
  39000. /**
  39001. * Gets the performance counter for active indices
  39002. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39003. */
  39004. get totalActiveIndicesPerfCounter(): PerfCounter;
  39005. /**
  39006. * Gets the total number of active particles rendered per frame
  39007. * @returns the total number of active particles rendered per frame
  39008. */
  39009. getActiveParticles(): number;
  39010. /**
  39011. * Gets the performance counter for active particles
  39012. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39013. */
  39014. get activeParticlesPerfCounter(): PerfCounter;
  39015. /**
  39016. * Gets the total number of active bones rendered per frame
  39017. * @returns the total number of active bones rendered per frame
  39018. */
  39019. getActiveBones(): number;
  39020. /**
  39021. * Gets the performance counter for active bones
  39022. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39023. */
  39024. get activeBonesPerfCounter(): PerfCounter;
  39025. /**
  39026. * Gets the array of active meshes
  39027. * @returns an array of AbstractMesh
  39028. */
  39029. getActiveMeshes(): SmartArray<AbstractMesh>;
  39030. /**
  39031. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39032. * @returns a number
  39033. */
  39034. getAnimationRatio(): number;
  39035. /**
  39036. * Gets an unique Id for the current render phase
  39037. * @returns a number
  39038. */
  39039. getRenderId(): number;
  39040. /**
  39041. * Gets an unique Id for the current frame
  39042. * @returns a number
  39043. */
  39044. getFrameId(): number;
  39045. /** Call this function if you want to manually increment the render Id*/
  39046. incrementRenderId(): void;
  39047. private _createUbo;
  39048. /**
  39049. * Use this method to simulate a pointer move on a mesh
  39050. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39051. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39052. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39053. * @returns the current scene
  39054. */
  39055. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39056. /**
  39057. * Use this method to simulate a pointer down on a mesh
  39058. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39059. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39060. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39061. * @returns the current scene
  39062. */
  39063. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39064. /**
  39065. * Use this method to simulate a pointer up on a mesh
  39066. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39067. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39068. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39069. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39070. * @returns the current scene
  39071. */
  39072. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39073. /**
  39074. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39075. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39076. * @returns true if the pointer was captured
  39077. */
  39078. isPointerCaptured(pointerId?: number): boolean;
  39079. /**
  39080. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39081. * @param attachUp defines if you want to attach events to pointerup
  39082. * @param attachDown defines if you want to attach events to pointerdown
  39083. * @param attachMove defines if you want to attach events to pointermove
  39084. */
  39085. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39086. /** Detaches all event handlers*/
  39087. detachControl(): void;
  39088. /**
  39089. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39090. * Delay loaded resources are not taking in account
  39091. * @return true if all required resources are ready
  39092. */
  39093. isReady(): boolean;
  39094. /** Resets all cached information relative to material (including effect and visibility) */
  39095. resetCachedMaterial(): void;
  39096. /**
  39097. * Registers a function to be called before every frame render
  39098. * @param func defines the function to register
  39099. */
  39100. registerBeforeRender(func: () => void): void;
  39101. /**
  39102. * Unregisters a function called before every frame render
  39103. * @param func defines the function to unregister
  39104. */
  39105. unregisterBeforeRender(func: () => void): void;
  39106. /**
  39107. * Registers a function to be called after every frame render
  39108. * @param func defines the function to register
  39109. */
  39110. registerAfterRender(func: () => void): void;
  39111. /**
  39112. * Unregisters a function called after every frame render
  39113. * @param func defines the function to unregister
  39114. */
  39115. unregisterAfterRender(func: () => void): void;
  39116. private _executeOnceBeforeRender;
  39117. /**
  39118. * The provided function will run before render once and will be disposed afterwards.
  39119. * A timeout delay can be provided so that the function will be executed in N ms.
  39120. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39121. * @param func The function to be executed.
  39122. * @param timeout optional delay in ms
  39123. */
  39124. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39125. /** @hidden */
  39126. _addPendingData(data: any): void;
  39127. /** @hidden */
  39128. _removePendingData(data: any): void;
  39129. /**
  39130. * Returns the number of items waiting to be loaded
  39131. * @returns the number of items waiting to be loaded
  39132. */
  39133. getWaitingItemsCount(): number;
  39134. /**
  39135. * Returns a boolean indicating if the scene is still loading data
  39136. */
  39137. get isLoading(): boolean;
  39138. /**
  39139. * Registers a function to be executed when the scene is ready
  39140. * @param {Function} func - the function to be executed
  39141. */
  39142. executeWhenReady(func: () => void): void;
  39143. /**
  39144. * Returns a promise that resolves when the scene is ready
  39145. * @returns A promise that resolves when the scene is ready
  39146. */
  39147. whenReadyAsync(): Promise<void>;
  39148. /** @hidden */
  39149. _checkIsReady(): void;
  39150. /**
  39151. * Gets all animatable attached to the scene
  39152. */
  39153. get animatables(): Animatable[];
  39154. /**
  39155. * Resets the last animation time frame.
  39156. * Useful to override when animations start running when loading a scene for the first time.
  39157. */
  39158. resetLastAnimationTimeFrame(): void;
  39159. /**
  39160. * Gets the current view matrix
  39161. * @returns a Matrix
  39162. */
  39163. getViewMatrix(): Matrix;
  39164. /**
  39165. * Gets the current projection matrix
  39166. * @returns a Matrix
  39167. */
  39168. getProjectionMatrix(): Matrix;
  39169. /**
  39170. * Gets the current transform matrix
  39171. * @returns a Matrix made of View * Projection
  39172. */
  39173. getTransformMatrix(): Matrix;
  39174. /**
  39175. * Sets the current transform matrix
  39176. * @param viewL defines the View matrix to use
  39177. * @param projectionL defines the Projection matrix to use
  39178. * @param viewR defines the right View matrix to use (if provided)
  39179. * @param projectionR defines the right Projection matrix to use (if provided)
  39180. */
  39181. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39182. /**
  39183. * Gets the uniform buffer used to store scene data
  39184. * @returns a UniformBuffer
  39185. */
  39186. getSceneUniformBuffer(): UniformBuffer;
  39187. /**
  39188. * Gets an unique (relatively to the current scene) Id
  39189. * @returns an unique number for the scene
  39190. */
  39191. getUniqueId(): number;
  39192. /**
  39193. * Add a mesh to the list of scene's meshes
  39194. * @param newMesh defines the mesh to add
  39195. * @param recursive if all child meshes should also be added to the scene
  39196. */
  39197. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39198. /**
  39199. * Remove a mesh for the list of scene's meshes
  39200. * @param toRemove defines the mesh to remove
  39201. * @param recursive if all child meshes should also be removed from the scene
  39202. * @returns the index where the mesh was in the mesh list
  39203. */
  39204. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39205. /**
  39206. * Add a transform node to the list of scene's transform nodes
  39207. * @param newTransformNode defines the transform node to add
  39208. */
  39209. addTransformNode(newTransformNode: TransformNode): void;
  39210. /**
  39211. * Remove a transform node for the list of scene's transform nodes
  39212. * @param toRemove defines the transform node to remove
  39213. * @returns the index where the transform node was in the transform node list
  39214. */
  39215. removeTransformNode(toRemove: TransformNode): number;
  39216. /**
  39217. * Remove a skeleton for the list of scene's skeletons
  39218. * @param toRemove defines the skeleton to remove
  39219. * @returns the index where the skeleton was in the skeleton list
  39220. */
  39221. removeSkeleton(toRemove: Skeleton): number;
  39222. /**
  39223. * Remove a morph target for the list of scene's morph targets
  39224. * @param toRemove defines the morph target to remove
  39225. * @returns the index where the morph target was in the morph target list
  39226. */
  39227. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39228. /**
  39229. * Remove a light for the list of scene's lights
  39230. * @param toRemove defines the light to remove
  39231. * @returns the index where the light was in the light list
  39232. */
  39233. removeLight(toRemove: Light): number;
  39234. /**
  39235. * Remove a camera for the list of scene's cameras
  39236. * @param toRemove defines the camera to remove
  39237. * @returns the index where the camera was in the camera list
  39238. */
  39239. removeCamera(toRemove: Camera): number;
  39240. /**
  39241. * Remove a particle system for the list of scene's particle systems
  39242. * @param toRemove defines the particle system to remove
  39243. * @returns the index where the particle system was in the particle system list
  39244. */
  39245. removeParticleSystem(toRemove: IParticleSystem): number;
  39246. /**
  39247. * Remove a animation for the list of scene's animations
  39248. * @param toRemove defines the animation to remove
  39249. * @returns the index where the animation was in the animation list
  39250. */
  39251. removeAnimation(toRemove: Animation): number;
  39252. /**
  39253. * Will stop the animation of the given target
  39254. * @param target - the target
  39255. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39256. * @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)
  39257. */
  39258. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39259. /**
  39260. * Removes the given animation group from this scene.
  39261. * @param toRemove The animation group to remove
  39262. * @returns The index of the removed animation group
  39263. */
  39264. removeAnimationGroup(toRemove: AnimationGroup): number;
  39265. /**
  39266. * Removes the given multi-material from this scene.
  39267. * @param toRemove The multi-material to remove
  39268. * @returns The index of the removed multi-material
  39269. */
  39270. removeMultiMaterial(toRemove: MultiMaterial): number;
  39271. /**
  39272. * Removes the given material from this scene.
  39273. * @param toRemove The material to remove
  39274. * @returns The index of the removed material
  39275. */
  39276. removeMaterial(toRemove: Material): number;
  39277. /**
  39278. * Removes the given action manager from this scene.
  39279. * @param toRemove The action manager to remove
  39280. * @returns The index of the removed action manager
  39281. */
  39282. removeActionManager(toRemove: AbstractActionManager): number;
  39283. /**
  39284. * Removes the given texture from this scene.
  39285. * @param toRemove The texture to remove
  39286. * @returns The index of the removed texture
  39287. */
  39288. removeTexture(toRemove: BaseTexture): number;
  39289. /**
  39290. * Adds the given light to this scene
  39291. * @param newLight The light to add
  39292. */
  39293. addLight(newLight: Light): void;
  39294. /**
  39295. * Sorts the list list based on light priorities
  39296. */
  39297. sortLightsByPriority(): void;
  39298. /**
  39299. * Adds the given camera to this scene
  39300. * @param newCamera The camera to add
  39301. */
  39302. addCamera(newCamera: Camera): void;
  39303. /**
  39304. * Adds the given skeleton to this scene
  39305. * @param newSkeleton The skeleton to add
  39306. */
  39307. addSkeleton(newSkeleton: Skeleton): void;
  39308. /**
  39309. * Adds the given particle system to this scene
  39310. * @param newParticleSystem The particle system to add
  39311. */
  39312. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39313. /**
  39314. * Adds the given animation to this scene
  39315. * @param newAnimation The animation to add
  39316. */
  39317. addAnimation(newAnimation: Animation): void;
  39318. /**
  39319. * Adds the given animation group to this scene.
  39320. * @param newAnimationGroup The animation group to add
  39321. */
  39322. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39323. /**
  39324. * Adds the given multi-material to this scene
  39325. * @param newMultiMaterial The multi-material to add
  39326. */
  39327. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39328. /**
  39329. * Adds the given material to this scene
  39330. * @param newMaterial The material to add
  39331. */
  39332. addMaterial(newMaterial: Material): void;
  39333. /**
  39334. * Adds the given morph target to this scene
  39335. * @param newMorphTargetManager The morph target to add
  39336. */
  39337. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39338. /**
  39339. * Adds the given geometry to this scene
  39340. * @param newGeometry The geometry to add
  39341. */
  39342. addGeometry(newGeometry: Geometry): void;
  39343. /**
  39344. * Adds the given action manager to this scene
  39345. * @param newActionManager The action manager to add
  39346. */
  39347. addActionManager(newActionManager: AbstractActionManager): void;
  39348. /**
  39349. * Adds the given texture to this scene.
  39350. * @param newTexture The texture to add
  39351. */
  39352. addTexture(newTexture: BaseTexture): void;
  39353. /**
  39354. * Switch active camera
  39355. * @param newCamera defines the new active camera
  39356. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39357. */
  39358. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39359. /**
  39360. * sets the active camera of the scene using its ID
  39361. * @param id defines the camera's ID
  39362. * @return the new active camera or null if none found.
  39363. */
  39364. setActiveCameraByID(id: string): Nullable<Camera>;
  39365. /**
  39366. * sets the active camera of the scene using its name
  39367. * @param name defines the camera's name
  39368. * @returns the new active camera or null if none found.
  39369. */
  39370. setActiveCameraByName(name: string): Nullable<Camera>;
  39371. /**
  39372. * get an animation group using its name
  39373. * @param name defines the material's name
  39374. * @return the animation group or null if none found.
  39375. */
  39376. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39377. /**
  39378. * Get a material using its unique id
  39379. * @param uniqueId defines the material's unique id
  39380. * @return the material or null if none found.
  39381. */
  39382. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39383. /**
  39384. * get a material using its id
  39385. * @param id defines the material's ID
  39386. * @return the material or null if none found.
  39387. */
  39388. getMaterialByID(id: string): Nullable<Material>;
  39389. /**
  39390. * Gets a the last added material using a given id
  39391. * @param id defines the material's ID
  39392. * @return the last material with the given id or null if none found.
  39393. */
  39394. getLastMaterialByID(id: string): Nullable<Material>;
  39395. /**
  39396. * Gets a material using its name
  39397. * @param name defines the material's name
  39398. * @return the material or null if none found.
  39399. */
  39400. getMaterialByName(name: string): Nullable<Material>;
  39401. /**
  39402. * Get a texture using its unique id
  39403. * @param uniqueId defines the texture's unique id
  39404. * @return the texture or null if none found.
  39405. */
  39406. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39407. /**
  39408. * Gets a camera using its id
  39409. * @param id defines the id to look for
  39410. * @returns the camera or null if not found
  39411. */
  39412. getCameraByID(id: string): Nullable<Camera>;
  39413. /**
  39414. * Gets a camera using its unique id
  39415. * @param uniqueId defines the unique id to look for
  39416. * @returns the camera or null if not found
  39417. */
  39418. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39419. /**
  39420. * Gets a camera using its name
  39421. * @param name defines the camera's name
  39422. * @return the camera or null if none found.
  39423. */
  39424. getCameraByName(name: string): Nullable<Camera>;
  39425. /**
  39426. * Gets a bone using its id
  39427. * @param id defines the bone's id
  39428. * @return the bone or null if not found
  39429. */
  39430. getBoneByID(id: string): Nullable<Bone>;
  39431. /**
  39432. * Gets a bone using its id
  39433. * @param name defines the bone's name
  39434. * @return the bone or null if not found
  39435. */
  39436. getBoneByName(name: string): Nullable<Bone>;
  39437. /**
  39438. * Gets a light node using its name
  39439. * @param name defines the the light's name
  39440. * @return the light or null if none found.
  39441. */
  39442. getLightByName(name: string): Nullable<Light>;
  39443. /**
  39444. * Gets a light node using its id
  39445. * @param id defines the light's id
  39446. * @return the light or null if none found.
  39447. */
  39448. getLightByID(id: string): Nullable<Light>;
  39449. /**
  39450. * Gets a light node using its scene-generated unique ID
  39451. * @param uniqueId defines the light's unique id
  39452. * @return the light or null if none found.
  39453. */
  39454. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39455. /**
  39456. * Gets a particle system by id
  39457. * @param id defines the particle system id
  39458. * @return the corresponding system or null if none found
  39459. */
  39460. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39461. /**
  39462. * Gets a geometry using its ID
  39463. * @param id defines the geometry's id
  39464. * @return the geometry or null if none found.
  39465. */
  39466. getGeometryByID(id: string): Nullable<Geometry>;
  39467. private _getGeometryByUniqueID;
  39468. /**
  39469. * Add a new geometry to this scene
  39470. * @param geometry defines the geometry to be added to the scene.
  39471. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39472. * @return a boolean defining if the geometry was added or not
  39473. */
  39474. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39475. /**
  39476. * Removes an existing geometry
  39477. * @param geometry defines the geometry to be removed from the scene
  39478. * @return a boolean defining if the geometry was removed or not
  39479. */
  39480. removeGeometry(geometry: Geometry): boolean;
  39481. /**
  39482. * Gets the list of geometries attached to the scene
  39483. * @returns an array of Geometry
  39484. */
  39485. getGeometries(): Geometry[];
  39486. /**
  39487. * Gets the first added mesh found of a given ID
  39488. * @param id defines the id to search for
  39489. * @return the mesh found or null if not found at all
  39490. */
  39491. getMeshByID(id: string): Nullable<AbstractMesh>;
  39492. /**
  39493. * Gets a list of meshes using their id
  39494. * @param id defines the id to search for
  39495. * @returns a list of meshes
  39496. */
  39497. getMeshesByID(id: string): Array<AbstractMesh>;
  39498. /**
  39499. * Gets the first added transform node found of a given ID
  39500. * @param id defines the id to search for
  39501. * @return the found transform node or null if not found at all.
  39502. */
  39503. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39504. /**
  39505. * Gets a transform node with its auto-generated unique id
  39506. * @param uniqueId efines the unique id to search for
  39507. * @return the found transform node or null if not found at all.
  39508. */
  39509. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39510. /**
  39511. * Gets a list of transform nodes using their id
  39512. * @param id defines the id to search for
  39513. * @returns a list of transform nodes
  39514. */
  39515. getTransformNodesByID(id: string): Array<TransformNode>;
  39516. /**
  39517. * Gets a mesh with its auto-generated unique id
  39518. * @param uniqueId defines the unique id to search for
  39519. * @return the found mesh or null if not found at all.
  39520. */
  39521. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39522. /**
  39523. * Gets a the last added mesh using a given id
  39524. * @param id defines the id to search for
  39525. * @return the found mesh or null if not found at all.
  39526. */
  39527. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39528. /**
  39529. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39530. * @param id defines the id to search for
  39531. * @return the found node or null if not found at all
  39532. */
  39533. getLastEntryByID(id: string): Nullable<Node>;
  39534. /**
  39535. * Gets a node (Mesh, Camera, Light) using a given id
  39536. * @param id defines the id to search for
  39537. * @return the found node or null if not found at all
  39538. */
  39539. getNodeByID(id: string): Nullable<Node>;
  39540. /**
  39541. * Gets a node (Mesh, Camera, Light) using a given name
  39542. * @param name defines the name to search for
  39543. * @return the found node or null if not found at all.
  39544. */
  39545. getNodeByName(name: string): Nullable<Node>;
  39546. /**
  39547. * Gets a mesh using a given name
  39548. * @param name defines the name to search for
  39549. * @return the found mesh or null if not found at all.
  39550. */
  39551. getMeshByName(name: string): Nullable<AbstractMesh>;
  39552. /**
  39553. * Gets a transform node using a given name
  39554. * @param name defines the name to search for
  39555. * @return the found transform node or null if not found at all.
  39556. */
  39557. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39558. /**
  39559. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39560. * @param id defines the id to search for
  39561. * @return the found skeleton or null if not found at all.
  39562. */
  39563. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39564. /**
  39565. * Gets a skeleton using a given auto generated unique id
  39566. * @param uniqueId defines the unique id to search for
  39567. * @return the found skeleton or null if not found at all.
  39568. */
  39569. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39570. /**
  39571. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39572. * @param id defines the id to search for
  39573. * @return the found skeleton or null if not found at all.
  39574. */
  39575. getSkeletonById(id: string): Nullable<Skeleton>;
  39576. /**
  39577. * Gets a skeleton using a given name
  39578. * @param name defines the name to search for
  39579. * @return the found skeleton or null if not found at all.
  39580. */
  39581. getSkeletonByName(name: string): Nullable<Skeleton>;
  39582. /**
  39583. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39584. * @param id defines the id to search for
  39585. * @return the found morph target manager or null if not found at all.
  39586. */
  39587. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39588. /**
  39589. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39590. * @param id defines the id to search for
  39591. * @return the found morph target or null if not found at all.
  39592. */
  39593. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39594. /**
  39595. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39596. * @param name defines the name to search for
  39597. * @return the found morph target or null if not found at all.
  39598. */
  39599. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39600. /**
  39601. * Gets a boolean indicating if the given mesh is active
  39602. * @param mesh defines the mesh to look for
  39603. * @returns true if the mesh is in the active list
  39604. */
  39605. isActiveMesh(mesh: AbstractMesh): boolean;
  39606. /**
  39607. * Return a unique id as a string which can serve as an identifier for the scene
  39608. */
  39609. get uid(): string;
  39610. /**
  39611. * Add an externaly attached data from its key.
  39612. * This method call will fail and return false, if such key already exists.
  39613. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39614. * @param key the unique key that identifies the data
  39615. * @param data the data object to associate to the key for this Engine instance
  39616. * @return true if no such key were already present and the data was added successfully, false otherwise
  39617. */
  39618. addExternalData<T>(key: string, data: T): boolean;
  39619. /**
  39620. * Get an externaly attached data from its key
  39621. * @param key the unique key that identifies the data
  39622. * @return the associated data, if present (can be null), or undefined if not present
  39623. */
  39624. getExternalData<T>(key: string): Nullable<T>;
  39625. /**
  39626. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39627. * @param key the unique key that identifies the data
  39628. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39629. * @return the associated data, can be null if the factory returned null.
  39630. */
  39631. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39632. /**
  39633. * Remove an externaly attached data from the Engine instance
  39634. * @param key the unique key that identifies the data
  39635. * @return true if the data was successfully removed, false if it doesn't exist
  39636. */
  39637. removeExternalData(key: string): boolean;
  39638. private _evaluateSubMesh;
  39639. /**
  39640. * Clear the processed materials smart array preventing retention point in material dispose.
  39641. */
  39642. freeProcessedMaterials(): void;
  39643. private _preventFreeActiveMeshesAndRenderingGroups;
  39644. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39645. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39646. * when disposing several meshes in a row or a hierarchy of meshes.
  39647. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39648. */
  39649. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39650. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39651. /**
  39652. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39653. */
  39654. freeActiveMeshes(): void;
  39655. /**
  39656. * Clear the info related to rendering groups preventing retention points during dispose.
  39657. */
  39658. freeRenderingGroups(): void;
  39659. /** @hidden */
  39660. _isInIntermediateRendering(): boolean;
  39661. /**
  39662. * Lambda returning the list of potentially active meshes.
  39663. */
  39664. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  39665. /**
  39666. * Lambda returning the list of potentially active sub meshes.
  39667. */
  39668. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  39669. /**
  39670. * Lambda returning the list of potentially intersecting sub meshes.
  39671. */
  39672. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  39673. /**
  39674. * Lambda returning the list of potentially colliding sub meshes.
  39675. */
  39676. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  39677. private _activeMeshesFrozen;
  39678. private _skipEvaluateActiveMeshesCompletely;
  39679. /**
  39680. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  39681. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  39682. * @returns the current scene
  39683. */
  39684. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  39685. /**
  39686. * Use this function to restart evaluating active meshes on every frame
  39687. * @returns the current scene
  39688. */
  39689. unfreezeActiveMeshes(): Scene;
  39690. private _evaluateActiveMeshes;
  39691. private _activeMesh;
  39692. /**
  39693. * Update the transform matrix to update from the current active camera
  39694. * @param force defines a boolean used to force the update even if cache is up to date
  39695. */
  39696. updateTransformMatrix(force?: boolean): void;
  39697. private _bindFrameBuffer;
  39698. /** @hidden */
  39699. _allowPostProcessClearColor: boolean;
  39700. /** @hidden */
  39701. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  39702. private _processSubCameras;
  39703. private _checkIntersections;
  39704. /** @hidden */
  39705. _advancePhysicsEngineStep(step: number): void;
  39706. /**
  39707. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  39708. */
  39709. getDeterministicFrameTime: () => number;
  39710. /** @hidden */
  39711. _animate(): void;
  39712. /** Execute all animations (for a frame) */
  39713. animate(): void;
  39714. /**
  39715. * Render the scene
  39716. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  39717. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  39718. */
  39719. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  39720. /**
  39721. * Freeze all materials
  39722. * A frozen material will not be updatable but should be faster to render
  39723. */
  39724. freezeMaterials(): void;
  39725. /**
  39726. * Unfreeze all materials
  39727. * A frozen material will not be updatable but should be faster to render
  39728. */
  39729. unfreezeMaterials(): void;
  39730. /**
  39731. * Releases all held ressources
  39732. */
  39733. dispose(): void;
  39734. /**
  39735. * Gets if the scene is already disposed
  39736. */
  39737. get isDisposed(): boolean;
  39738. /**
  39739. * Call this function to reduce memory footprint of the scene.
  39740. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  39741. */
  39742. clearCachedVertexData(): void;
  39743. /**
  39744. * This function will remove the local cached buffer data from texture.
  39745. * It will save memory but will prevent the texture from being rebuilt
  39746. */
  39747. cleanCachedTextureBuffer(): void;
  39748. /**
  39749. * Get the world extend vectors with an optional filter
  39750. *
  39751. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  39752. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  39753. */
  39754. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  39755. min: Vector3;
  39756. max: Vector3;
  39757. };
  39758. /**
  39759. * Creates a ray that can be used to pick in the scene
  39760. * @param x defines the x coordinate of the origin (on-screen)
  39761. * @param y defines the y coordinate of the origin (on-screen)
  39762. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39763. * @param camera defines the camera to use for the picking
  39764. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39765. * @returns a Ray
  39766. */
  39767. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  39768. /**
  39769. * Creates a ray that can be used to pick in the scene
  39770. * @param x defines the x coordinate of the origin (on-screen)
  39771. * @param y defines the y coordinate of the origin (on-screen)
  39772. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39773. * @param result defines the ray where to store the picking ray
  39774. * @param camera defines the camera to use for the picking
  39775. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39776. * @returns the current scene
  39777. */
  39778. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  39779. /**
  39780. * Creates a ray that can be used to pick in the scene
  39781. * @param x defines the x coordinate of the origin (on-screen)
  39782. * @param y defines the y coordinate of the origin (on-screen)
  39783. * @param camera defines the camera to use for the picking
  39784. * @returns a Ray
  39785. */
  39786. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  39787. /**
  39788. * Creates a ray that can be used to pick in the scene
  39789. * @param x defines the x coordinate of the origin (on-screen)
  39790. * @param y defines the y coordinate of the origin (on-screen)
  39791. * @param result defines the ray where to store the picking ray
  39792. * @param camera defines the camera to use for the picking
  39793. * @returns the current scene
  39794. */
  39795. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  39796. /** Launch a ray to try to pick a mesh in the scene
  39797. * @param x position on screen
  39798. * @param y position on screen
  39799. * @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
  39800. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39801. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39802. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39803. * @returns a PickingInfo
  39804. */
  39805. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39806. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  39807. * @param x position on screen
  39808. * @param y position on screen
  39809. * @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
  39810. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39811. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39812. * @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)
  39813. */
  39814. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  39815. /** Use the given ray to pick a mesh in the scene
  39816. * @param ray The ray to use to pick meshes
  39817. * @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
  39818. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39819. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39820. * @returns a PickingInfo
  39821. */
  39822. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39823. /**
  39824. * Launch a ray to try to pick a mesh in the scene
  39825. * @param x X position on screen
  39826. * @param y Y position on screen
  39827. * @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
  39828. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39829. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39830. * @returns an array of PickingInfo
  39831. */
  39832. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39833. /**
  39834. * Launch a ray to try to pick a mesh in the scene
  39835. * @param ray Ray to use
  39836. * @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
  39837. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39838. * @returns an array of PickingInfo
  39839. */
  39840. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39841. /**
  39842. * Force the value of meshUnderPointer
  39843. * @param mesh defines the mesh to use
  39844. */
  39845. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39846. /**
  39847. * Gets the mesh under the pointer
  39848. * @returns a Mesh or null if no mesh is under the pointer
  39849. */
  39850. getPointerOverMesh(): Nullable<AbstractMesh>;
  39851. /** @hidden */
  39852. _rebuildGeometries(): void;
  39853. /** @hidden */
  39854. _rebuildTextures(): void;
  39855. private _getByTags;
  39856. /**
  39857. * Get a list of meshes by tags
  39858. * @param tagsQuery defines the tags query to use
  39859. * @param forEach defines a predicate used to filter results
  39860. * @returns an array of Mesh
  39861. */
  39862. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  39863. /**
  39864. * Get a list of cameras by tags
  39865. * @param tagsQuery defines the tags query to use
  39866. * @param forEach defines a predicate used to filter results
  39867. * @returns an array of Camera
  39868. */
  39869. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  39870. /**
  39871. * Get a list of lights by tags
  39872. * @param tagsQuery defines the tags query to use
  39873. * @param forEach defines a predicate used to filter results
  39874. * @returns an array of Light
  39875. */
  39876. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  39877. /**
  39878. * Get a list of materials by tags
  39879. * @param tagsQuery defines the tags query to use
  39880. * @param forEach defines a predicate used to filter results
  39881. * @returns an array of Material
  39882. */
  39883. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  39884. /**
  39885. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  39886. * This allowed control for front to back rendering or reversly depending of the special needs.
  39887. *
  39888. * @param renderingGroupId The rendering group id corresponding to its index
  39889. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39890. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39891. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39892. */
  39893. 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;
  39894. /**
  39895. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39896. *
  39897. * @param renderingGroupId The rendering group id corresponding to its index
  39898. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39899. * @param depth Automatically clears depth between groups if true and autoClear is true.
  39900. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  39901. */
  39902. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  39903. /**
  39904. * Gets the current auto clear configuration for one rendering group of the rendering
  39905. * manager.
  39906. * @param index the rendering group index to get the information for
  39907. * @returns The auto clear setup for the requested rendering group
  39908. */
  39909. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  39910. private _blockMaterialDirtyMechanism;
  39911. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  39912. get blockMaterialDirtyMechanism(): boolean;
  39913. set blockMaterialDirtyMechanism(value: boolean);
  39914. /**
  39915. * Will flag all materials as dirty to trigger new shader compilation
  39916. * @param flag defines the flag used to specify which material part must be marked as dirty
  39917. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  39918. */
  39919. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  39920. /** @hidden */
  39921. _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;
  39922. /** @hidden */
  39923. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39924. /** @hidden */
  39925. _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;
  39926. /** @hidden */
  39927. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  39928. /** @hidden */
  39929. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39930. /** @hidden */
  39931. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39932. }
  39933. }
  39934. declare module BABYLON {
  39935. /**
  39936. * Set of assets to keep when moving a scene into an asset container.
  39937. */
  39938. export class KeepAssets extends AbstractScene {
  39939. }
  39940. /**
  39941. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  39942. */
  39943. export class InstantiatedEntries {
  39944. /**
  39945. * List of new root nodes (eg. nodes with no parent)
  39946. */
  39947. rootNodes: TransformNode[];
  39948. /**
  39949. * List of new skeletons
  39950. */
  39951. skeletons: Skeleton[];
  39952. /**
  39953. * List of new animation groups
  39954. */
  39955. animationGroups: AnimationGroup[];
  39956. }
  39957. /**
  39958. * Container with a set of assets that can be added or removed from a scene.
  39959. */
  39960. export class AssetContainer extends AbstractScene {
  39961. private _wasAddedToScene;
  39962. /**
  39963. * The scene the AssetContainer belongs to.
  39964. */
  39965. scene: Scene;
  39966. /**
  39967. * Instantiates an AssetContainer.
  39968. * @param scene The scene the AssetContainer belongs to.
  39969. */
  39970. constructor(scene: Scene);
  39971. /**
  39972. * Instantiate or clone all meshes and add the new ones to the scene.
  39973. * Skeletons and animation groups will all be cloned
  39974. * @param nameFunction defines an optional function used to get new names for clones
  39975. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  39976. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  39977. */
  39978. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  39979. /**
  39980. * Adds all the assets from the container to the scene.
  39981. */
  39982. addAllToScene(): void;
  39983. /**
  39984. * Removes all the assets in the container from the scene
  39985. */
  39986. removeAllFromScene(): void;
  39987. /**
  39988. * Disposes all the assets in the container
  39989. */
  39990. dispose(): void;
  39991. private _moveAssets;
  39992. /**
  39993. * Removes all the assets contained in the scene and adds them to the container.
  39994. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  39995. */
  39996. moveAllFromScene(keepAssets?: KeepAssets): void;
  39997. /**
  39998. * 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.
  39999. * @returns the root mesh
  40000. */
  40001. createRootMesh(): Mesh;
  40002. /**
  40003. * Merge animations (direct and animation groups) from this asset container into a scene
  40004. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40005. * @param animatables set of animatables to retarget to a node from the scene
  40006. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40007. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40008. */
  40009. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40010. }
  40011. }
  40012. declare module BABYLON {
  40013. /**
  40014. * Defines how the parser contract is defined.
  40015. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40016. */
  40017. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40018. /**
  40019. * Defines how the individual parser contract is defined.
  40020. * These parser can parse an individual asset
  40021. */
  40022. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40023. /**
  40024. * Base class of the scene acting as a container for the different elements composing a scene.
  40025. * This class is dynamically extended by the different components of the scene increasing
  40026. * flexibility and reducing coupling
  40027. */
  40028. export abstract class AbstractScene {
  40029. /**
  40030. * Stores the list of available parsers in the application.
  40031. */
  40032. private static _BabylonFileParsers;
  40033. /**
  40034. * Stores the list of available individual parsers in the application.
  40035. */
  40036. private static _IndividualBabylonFileParsers;
  40037. /**
  40038. * Adds a parser in the list of available ones
  40039. * @param name Defines the name of the parser
  40040. * @param parser Defines the parser to add
  40041. */
  40042. static AddParser(name: string, parser: BabylonFileParser): void;
  40043. /**
  40044. * Gets a general parser from the list of avaialble ones
  40045. * @param name Defines the name of the parser
  40046. * @returns the requested parser or null
  40047. */
  40048. static GetParser(name: string): Nullable<BabylonFileParser>;
  40049. /**
  40050. * Adds n individual parser in the list of available ones
  40051. * @param name Defines the name of the parser
  40052. * @param parser Defines the parser to add
  40053. */
  40054. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40055. /**
  40056. * Gets an individual parser from the list of avaialble ones
  40057. * @param name Defines the name of the parser
  40058. * @returns the requested parser or null
  40059. */
  40060. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40061. /**
  40062. * Parser json data and populate both a scene and its associated container object
  40063. * @param jsonData Defines the data to parse
  40064. * @param scene Defines the scene to parse the data for
  40065. * @param container Defines the container attached to the parsing sequence
  40066. * @param rootUrl Defines the root url of the data
  40067. */
  40068. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40069. /**
  40070. * Gets the list of root nodes (ie. nodes with no parent)
  40071. */
  40072. rootNodes: Node[];
  40073. /** All of the cameras added to this scene
  40074. * @see http://doc.babylonjs.com/babylon101/cameras
  40075. */
  40076. cameras: Camera[];
  40077. /**
  40078. * All of the lights added to this scene
  40079. * @see http://doc.babylonjs.com/babylon101/lights
  40080. */
  40081. lights: Light[];
  40082. /**
  40083. * All of the (abstract) meshes added to this scene
  40084. */
  40085. meshes: AbstractMesh[];
  40086. /**
  40087. * The list of skeletons added to the scene
  40088. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40089. */
  40090. skeletons: Skeleton[];
  40091. /**
  40092. * All of the particle systems added to this scene
  40093. * @see http://doc.babylonjs.com/babylon101/particles
  40094. */
  40095. particleSystems: IParticleSystem[];
  40096. /**
  40097. * Gets a list of Animations associated with the scene
  40098. */
  40099. animations: Animation[];
  40100. /**
  40101. * All of the animation groups added to this scene
  40102. * @see http://doc.babylonjs.com/how_to/group
  40103. */
  40104. animationGroups: AnimationGroup[];
  40105. /**
  40106. * All of the multi-materials added to this scene
  40107. * @see http://doc.babylonjs.com/how_to/multi_materials
  40108. */
  40109. multiMaterials: MultiMaterial[];
  40110. /**
  40111. * All of the materials added to this scene
  40112. * In the context of a Scene, it is not supposed to be modified manually.
  40113. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40114. * Note also that the order of the Material within the array is not significant and might change.
  40115. * @see http://doc.babylonjs.com/babylon101/materials
  40116. */
  40117. materials: Material[];
  40118. /**
  40119. * The list of morph target managers added to the scene
  40120. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40121. */
  40122. morphTargetManagers: MorphTargetManager[];
  40123. /**
  40124. * The list of geometries used in the scene.
  40125. */
  40126. geometries: Geometry[];
  40127. /**
  40128. * All of the tranform nodes added to this scene
  40129. * In the context of a Scene, it is not supposed to be modified manually.
  40130. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40131. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40132. * @see http://doc.babylonjs.com/how_to/transformnode
  40133. */
  40134. transformNodes: TransformNode[];
  40135. /**
  40136. * ActionManagers available on the scene.
  40137. */
  40138. actionManagers: AbstractActionManager[];
  40139. /**
  40140. * Textures to keep.
  40141. */
  40142. textures: BaseTexture[];
  40143. /**
  40144. * Environment texture for the scene
  40145. */
  40146. environmentTexture: Nullable<BaseTexture>;
  40147. /**
  40148. * @returns all meshes, lights, cameras, transformNodes and bones
  40149. */
  40150. getNodes(): Array<Node>;
  40151. }
  40152. }
  40153. declare module BABYLON {
  40154. /**
  40155. * Interface used to define options for Sound class
  40156. */
  40157. export interface ISoundOptions {
  40158. /**
  40159. * Does the sound autoplay once loaded.
  40160. */
  40161. autoplay?: boolean;
  40162. /**
  40163. * Does the sound loop after it finishes playing once.
  40164. */
  40165. loop?: boolean;
  40166. /**
  40167. * Sound's volume
  40168. */
  40169. volume?: number;
  40170. /**
  40171. * Is it a spatial sound?
  40172. */
  40173. spatialSound?: boolean;
  40174. /**
  40175. * Maximum distance to hear that sound
  40176. */
  40177. maxDistance?: number;
  40178. /**
  40179. * Uses user defined attenuation function
  40180. */
  40181. useCustomAttenuation?: boolean;
  40182. /**
  40183. * Define the roll off factor of spatial sounds.
  40184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40185. */
  40186. rolloffFactor?: number;
  40187. /**
  40188. * Define the reference distance the sound should be heard perfectly.
  40189. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40190. */
  40191. refDistance?: number;
  40192. /**
  40193. * Define the distance attenuation model the sound will follow.
  40194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40195. */
  40196. distanceModel?: string;
  40197. /**
  40198. * Defines the playback speed (1 by default)
  40199. */
  40200. playbackRate?: number;
  40201. /**
  40202. * Defines if the sound is from a streaming source
  40203. */
  40204. streaming?: boolean;
  40205. /**
  40206. * Defines an optional length (in seconds) inside the sound file
  40207. */
  40208. length?: number;
  40209. /**
  40210. * Defines an optional offset (in seconds) inside the sound file
  40211. */
  40212. offset?: number;
  40213. /**
  40214. * If true, URLs will not be required to state the audio file codec to use.
  40215. */
  40216. skipCodecCheck?: boolean;
  40217. }
  40218. /**
  40219. * Defines a sound that can be played in the application.
  40220. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40222. */
  40223. export class Sound {
  40224. /**
  40225. * The name of the sound in the scene.
  40226. */
  40227. name: string;
  40228. /**
  40229. * Does the sound autoplay once loaded.
  40230. */
  40231. autoplay: boolean;
  40232. /**
  40233. * Does the sound loop after it finishes playing once.
  40234. */
  40235. loop: boolean;
  40236. /**
  40237. * Does the sound use a custom attenuation curve to simulate the falloff
  40238. * happening when the source gets further away from the camera.
  40239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40240. */
  40241. useCustomAttenuation: boolean;
  40242. /**
  40243. * The sound track id this sound belongs to.
  40244. */
  40245. soundTrackId: number;
  40246. /**
  40247. * Is this sound currently played.
  40248. */
  40249. isPlaying: boolean;
  40250. /**
  40251. * Is this sound currently paused.
  40252. */
  40253. isPaused: boolean;
  40254. /**
  40255. * Does this sound enables spatial sound.
  40256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40257. */
  40258. spatialSound: boolean;
  40259. /**
  40260. * Define the reference distance the sound should be heard perfectly.
  40261. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40262. */
  40263. refDistance: number;
  40264. /**
  40265. * Define the roll off factor of spatial sounds.
  40266. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40267. */
  40268. rolloffFactor: number;
  40269. /**
  40270. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40272. */
  40273. maxDistance: number;
  40274. /**
  40275. * Define the distance attenuation model the sound will follow.
  40276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40277. */
  40278. distanceModel: string;
  40279. /**
  40280. * @hidden
  40281. * Back Compat
  40282. **/
  40283. onended: () => any;
  40284. /**
  40285. * Gets or sets an object used to store user defined information for the sound.
  40286. */
  40287. metadata: any;
  40288. /**
  40289. * Observable event when the current playing sound finishes.
  40290. */
  40291. onEndedObservable: Observable<Sound>;
  40292. private _panningModel;
  40293. private _playbackRate;
  40294. private _streaming;
  40295. private _startTime;
  40296. private _startOffset;
  40297. private _position;
  40298. /** @hidden */
  40299. _positionInEmitterSpace: boolean;
  40300. private _localDirection;
  40301. private _volume;
  40302. private _isReadyToPlay;
  40303. private _isDirectional;
  40304. private _readyToPlayCallback;
  40305. private _audioBuffer;
  40306. private _soundSource;
  40307. private _streamingSource;
  40308. private _soundPanner;
  40309. private _soundGain;
  40310. private _inputAudioNode;
  40311. private _outputAudioNode;
  40312. private _coneInnerAngle;
  40313. private _coneOuterAngle;
  40314. private _coneOuterGain;
  40315. private _scene;
  40316. private _connectedTransformNode;
  40317. private _customAttenuationFunction;
  40318. private _registerFunc;
  40319. private _isOutputConnected;
  40320. private _htmlAudioElement;
  40321. private _urlType;
  40322. private _length?;
  40323. private _offset?;
  40324. /** @hidden */
  40325. static _SceneComponentInitialization: (scene: Scene) => void;
  40326. /**
  40327. * Create a sound and attach it to a scene
  40328. * @param name Name of your sound
  40329. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40330. * @param scene defines the scene the sound belongs to
  40331. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40332. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40333. */
  40334. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40335. /**
  40336. * Release the sound and its associated resources
  40337. */
  40338. dispose(): void;
  40339. /**
  40340. * Gets if the sounds is ready to be played or not.
  40341. * @returns true if ready, otherwise false
  40342. */
  40343. isReady(): boolean;
  40344. private _soundLoaded;
  40345. /**
  40346. * Sets the data of the sound from an audiobuffer
  40347. * @param audioBuffer The audioBuffer containing the data
  40348. */
  40349. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40350. /**
  40351. * Updates the current sounds options such as maxdistance, loop...
  40352. * @param options A JSON object containing values named as the object properties
  40353. */
  40354. updateOptions(options: ISoundOptions): void;
  40355. private _createSpatialParameters;
  40356. private _updateSpatialParameters;
  40357. /**
  40358. * Switch the panning model to HRTF:
  40359. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40361. */
  40362. switchPanningModelToHRTF(): void;
  40363. /**
  40364. * Switch the panning model to Equal Power:
  40365. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40367. */
  40368. switchPanningModelToEqualPower(): void;
  40369. private _switchPanningModel;
  40370. /**
  40371. * Connect this sound to a sound track audio node like gain...
  40372. * @param soundTrackAudioNode the sound track audio node to connect to
  40373. */
  40374. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40375. /**
  40376. * Transform this sound into a directional source
  40377. * @param coneInnerAngle Size of the inner cone in degree
  40378. * @param coneOuterAngle Size of the outer cone in degree
  40379. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40380. */
  40381. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40382. /**
  40383. * Gets or sets the inner angle for the directional cone.
  40384. */
  40385. get directionalConeInnerAngle(): number;
  40386. /**
  40387. * Gets or sets the inner angle for the directional cone.
  40388. */
  40389. set directionalConeInnerAngle(value: number);
  40390. /**
  40391. * Gets or sets the outer angle for the directional cone.
  40392. */
  40393. get directionalConeOuterAngle(): number;
  40394. /**
  40395. * Gets or sets the outer angle for the directional cone.
  40396. */
  40397. set directionalConeOuterAngle(value: number);
  40398. /**
  40399. * Sets the position of the emitter if spatial sound is enabled
  40400. * @param newPosition Defines the new posisiton
  40401. */
  40402. setPosition(newPosition: Vector3): void;
  40403. /**
  40404. * Sets the local direction of the emitter if spatial sound is enabled
  40405. * @param newLocalDirection Defines the new local direction
  40406. */
  40407. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40408. private _updateDirection;
  40409. /** @hidden */
  40410. updateDistanceFromListener(): void;
  40411. /**
  40412. * Sets a new custom attenuation function for the sound.
  40413. * @param callback Defines the function used for the attenuation
  40414. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40415. */
  40416. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40417. /**
  40418. * Play the sound
  40419. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40420. * @param offset (optional) Start the sound at a specific time in seconds
  40421. * @param length (optional) Sound duration (in seconds)
  40422. */
  40423. play(time?: number, offset?: number, length?: number): void;
  40424. private _onended;
  40425. /**
  40426. * Stop the sound
  40427. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40428. */
  40429. stop(time?: number): void;
  40430. /**
  40431. * Put the sound in pause
  40432. */
  40433. pause(): void;
  40434. /**
  40435. * Sets a dedicated volume for this sounds
  40436. * @param newVolume Define the new volume of the sound
  40437. * @param time Define time for gradual change to new volume
  40438. */
  40439. setVolume(newVolume: number, time?: number): void;
  40440. /**
  40441. * Set the sound play back rate
  40442. * @param newPlaybackRate Define the playback rate the sound should be played at
  40443. */
  40444. setPlaybackRate(newPlaybackRate: number): void;
  40445. /**
  40446. * Gets the volume of the sound.
  40447. * @returns the volume of the sound
  40448. */
  40449. getVolume(): number;
  40450. /**
  40451. * Attach the sound to a dedicated mesh
  40452. * @param transformNode The transform node to connect the sound with
  40453. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40454. */
  40455. attachToMesh(transformNode: TransformNode): void;
  40456. /**
  40457. * Detach the sound from the previously attached mesh
  40458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40459. */
  40460. detachFromMesh(): void;
  40461. private _onRegisterAfterWorldMatrixUpdate;
  40462. /**
  40463. * Clone the current sound in the scene.
  40464. * @returns the new sound clone
  40465. */
  40466. clone(): Nullable<Sound>;
  40467. /**
  40468. * Gets the current underlying audio buffer containing the data
  40469. * @returns the audio buffer
  40470. */
  40471. getAudioBuffer(): Nullable<AudioBuffer>;
  40472. /**
  40473. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40474. * @returns the source node
  40475. */
  40476. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40477. /**
  40478. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40479. * @returns the gain node
  40480. */
  40481. getSoundGain(): Nullable<GainNode>;
  40482. /**
  40483. * Serializes the Sound in a JSON representation
  40484. * @returns the JSON representation of the sound
  40485. */
  40486. serialize(): any;
  40487. /**
  40488. * Parse a JSON representation of a sound to innstantiate in a given scene
  40489. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40490. * @param scene Define the scene the new parsed sound should be created in
  40491. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40492. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40493. * @returns the newly parsed sound
  40494. */
  40495. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40496. }
  40497. }
  40498. declare module BABYLON {
  40499. /**
  40500. * This defines an action helpful to play a defined sound on a triggered action.
  40501. */
  40502. export class PlaySoundAction extends Action {
  40503. private _sound;
  40504. /**
  40505. * Instantiate the action
  40506. * @param triggerOptions defines the trigger options
  40507. * @param sound defines the sound to play
  40508. * @param condition defines the trigger related conditions
  40509. */
  40510. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40511. /** @hidden */
  40512. _prepare(): void;
  40513. /**
  40514. * Execute the action and play the sound.
  40515. */
  40516. execute(): void;
  40517. /**
  40518. * Serializes the actions and its related information.
  40519. * @param parent defines the object to serialize in
  40520. * @returns the serialized object
  40521. */
  40522. serialize(parent: any): any;
  40523. }
  40524. /**
  40525. * This defines an action helpful to stop a defined sound on a triggered action.
  40526. */
  40527. export class StopSoundAction extends Action {
  40528. private _sound;
  40529. /**
  40530. * Instantiate the action
  40531. * @param triggerOptions defines the trigger options
  40532. * @param sound defines the sound to stop
  40533. * @param condition defines the trigger related conditions
  40534. */
  40535. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40536. /** @hidden */
  40537. _prepare(): void;
  40538. /**
  40539. * Execute the action and stop the sound.
  40540. */
  40541. execute(): void;
  40542. /**
  40543. * Serializes the actions and its related information.
  40544. * @param parent defines the object to serialize in
  40545. * @returns the serialized object
  40546. */
  40547. serialize(parent: any): any;
  40548. }
  40549. }
  40550. declare module BABYLON {
  40551. /**
  40552. * This defines an action responsible to change the value of a property
  40553. * by interpolating between its current value and the newly set one once triggered.
  40554. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40555. */
  40556. export class InterpolateValueAction extends Action {
  40557. /**
  40558. * Defines the path of the property where the value should be interpolated
  40559. */
  40560. propertyPath: string;
  40561. /**
  40562. * Defines the target value at the end of the interpolation.
  40563. */
  40564. value: any;
  40565. /**
  40566. * Defines the time it will take for the property to interpolate to the value.
  40567. */
  40568. duration: number;
  40569. /**
  40570. * Defines if the other scene animations should be stopped when the action has been triggered
  40571. */
  40572. stopOtherAnimations?: boolean;
  40573. /**
  40574. * Defines a callback raised once the interpolation animation has been done.
  40575. */
  40576. onInterpolationDone?: () => void;
  40577. /**
  40578. * Observable triggered once the interpolation animation has been done.
  40579. */
  40580. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40581. private _target;
  40582. private _effectiveTarget;
  40583. private _property;
  40584. /**
  40585. * Instantiate the action
  40586. * @param triggerOptions defines the trigger options
  40587. * @param target defines the object containing the value to interpolate
  40588. * @param propertyPath defines the path to the property in the target object
  40589. * @param value defines the target value at the end of the interpolation
  40590. * @param duration deines the time it will take for the property to interpolate to the value.
  40591. * @param condition defines the trigger related conditions
  40592. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40593. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40594. */
  40595. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40596. /** @hidden */
  40597. _prepare(): void;
  40598. /**
  40599. * Execute the action starts the value interpolation.
  40600. */
  40601. execute(): void;
  40602. /**
  40603. * Serializes the actions and its related information.
  40604. * @param parent defines the object to serialize in
  40605. * @returns the serialized object
  40606. */
  40607. serialize(parent: any): any;
  40608. }
  40609. }
  40610. declare module BABYLON {
  40611. /**
  40612. * Options allowed during the creation of a sound track.
  40613. */
  40614. export interface ISoundTrackOptions {
  40615. /**
  40616. * The volume the sound track should take during creation
  40617. */
  40618. volume?: number;
  40619. /**
  40620. * Define if the sound track is the main sound track of the scene
  40621. */
  40622. mainTrack?: boolean;
  40623. }
  40624. /**
  40625. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40626. * It will be also used in a future release to apply effects on a specific track.
  40627. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40628. */
  40629. export class SoundTrack {
  40630. /**
  40631. * The unique identifier of the sound track in the scene.
  40632. */
  40633. id: number;
  40634. /**
  40635. * The list of sounds included in the sound track.
  40636. */
  40637. soundCollection: Array<Sound>;
  40638. private _outputAudioNode;
  40639. private _scene;
  40640. private _connectedAnalyser;
  40641. private _options;
  40642. private _isInitialized;
  40643. /**
  40644. * Creates a new sound track.
  40645. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40646. * @param scene Define the scene the sound track belongs to
  40647. * @param options
  40648. */
  40649. constructor(scene: Scene, options?: ISoundTrackOptions);
  40650. private _initializeSoundTrackAudioGraph;
  40651. /**
  40652. * Release the sound track and its associated resources
  40653. */
  40654. dispose(): void;
  40655. /**
  40656. * Adds a sound to this sound track
  40657. * @param sound define the cound to add
  40658. * @ignoreNaming
  40659. */
  40660. AddSound(sound: Sound): void;
  40661. /**
  40662. * Removes a sound to this sound track
  40663. * @param sound define the cound to remove
  40664. * @ignoreNaming
  40665. */
  40666. RemoveSound(sound: Sound): void;
  40667. /**
  40668. * Set a global volume for the full sound track.
  40669. * @param newVolume Define the new volume of the sound track
  40670. */
  40671. setVolume(newVolume: number): void;
  40672. /**
  40673. * Switch the panning model to HRTF:
  40674. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40676. */
  40677. switchPanningModelToHRTF(): void;
  40678. /**
  40679. * Switch the panning model to Equal Power:
  40680. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40682. */
  40683. switchPanningModelToEqualPower(): void;
  40684. /**
  40685. * Connect the sound track to an audio analyser allowing some amazing
  40686. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40687. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40688. * @param analyser The analyser to connect to the engine
  40689. */
  40690. connectToAnalyser(analyser: Analyser): void;
  40691. }
  40692. }
  40693. declare module BABYLON {
  40694. interface AbstractScene {
  40695. /**
  40696. * The list of sounds used in the scene.
  40697. */
  40698. sounds: Nullable<Array<Sound>>;
  40699. }
  40700. interface Scene {
  40701. /**
  40702. * @hidden
  40703. * Backing field
  40704. */
  40705. _mainSoundTrack: SoundTrack;
  40706. /**
  40707. * The main sound track played by the scene.
  40708. * It cotains your primary collection of sounds.
  40709. */
  40710. mainSoundTrack: SoundTrack;
  40711. /**
  40712. * The list of sound tracks added to the scene
  40713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40714. */
  40715. soundTracks: Nullable<Array<SoundTrack>>;
  40716. /**
  40717. * Gets a sound using a given name
  40718. * @param name defines the name to search for
  40719. * @return the found sound or null if not found at all.
  40720. */
  40721. getSoundByName(name: string): Nullable<Sound>;
  40722. /**
  40723. * Gets or sets if audio support is enabled
  40724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40725. */
  40726. audioEnabled: boolean;
  40727. /**
  40728. * Gets or sets if audio will be output to headphones
  40729. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40730. */
  40731. headphone: boolean;
  40732. /**
  40733. * Gets or sets custom audio listener position provider
  40734. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40735. */
  40736. audioListenerPositionProvider: Nullable<() => Vector3>;
  40737. /**
  40738. * Gets or sets a refresh rate when using 3D audio positioning
  40739. */
  40740. audioPositioningRefreshRate: number;
  40741. }
  40742. /**
  40743. * Defines the sound scene component responsible to manage any sounds
  40744. * in a given scene.
  40745. */
  40746. export class AudioSceneComponent implements ISceneSerializableComponent {
  40747. /**
  40748. * The component name helpfull to identify the component in the list of scene components.
  40749. */
  40750. readonly name: string;
  40751. /**
  40752. * The scene the component belongs to.
  40753. */
  40754. scene: Scene;
  40755. private _audioEnabled;
  40756. /**
  40757. * Gets whether audio is enabled or not.
  40758. * Please use related enable/disable method to switch state.
  40759. */
  40760. get audioEnabled(): boolean;
  40761. private _headphone;
  40762. /**
  40763. * Gets whether audio is outputing to headphone or not.
  40764. * Please use the according Switch methods to change output.
  40765. */
  40766. get headphone(): boolean;
  40767. /**
  40768. * Gets or sets a refresh rate when using 3D audio positioning
  40769. */
  40770. audioPositioningRefreshRate: number;
  40771. private _audioListenerPositionProvider;
  40772. /**
  40773. * Gets the current audio listener position provider
  40774. */
  40775. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  40776. /**
  40777. * Sets a custom listener position for all sounds in the scene
  40778. * By default, this is the position of the first active camera
  40779. */
  40780. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  40781. /**
  40782. * Creates a new instance of the component for the given scene
  40783. * @param scene Defines the scene to register the component in
  40784. */
  40785. constructor(scene: Scene);
  40786. /**
  40787. * Registers the component in a given scene
  40788. */
  40789. register(): void;
  40790. /**
  40791. * Rebuilds the elements related to this component in case of
  40792. * context lost for instance.
  40793. */
  40794. rebuild(): void;
  40795. /**
  40796. * Serializes the component data to the specified json object
  40797. * @param serializationObject The object to serialize to
  40798. */
  40799. serialize(serializationObject: any): void;
  40800. /**
  40801. * Adds all the elements from the container to the scene
  40802. * @param container the container holding the elements
  40803. */
  40804. addFromContainer(container: AbstractScene): void;
  40805. /**
  40806. * Removes all the elements in the container from the scene
  40807. * @param container contains the elements to remove
  40808. * @param dispose if the removed element should be disposed (default: false)
  40809. */
  40810. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  40811. /**
  40812. * Disposes the component and the associated ressources.
  40813. */
  40814. dispose(): void;
  40815. /**
  40816. * Disables audio in the associated scene.
  40817. */
  40818. disableAudio(): void;
  40819. /**
  40820. * Enables audio in the associated scene.
  40821. */
  40822. enableAudio(): void;
  40823. /**
  40824. * Switch audio to headphone output.
  40825. */
  40826. switchAudioModeForHeadphones(): void;
  40827. /**
  40828. * Switch audio to normal speakers.
  40829. */
  40830. switchAudioModeForNormalSpeakers(): void;
  40831. private _cachedCameraDirection;
  40832. private _cachedCameraPosition;
  40833. private _lastCheck;
  40834. private _afterRender;
  40835. }
  40836. }
  40837. declare module BABYLON {
  40838. /**
  40839. * Wraps one or more Sound objects and selects one with random weight for playback.
  40840. */
  40841. export class WeightedSound {
  40842. /** When true a Sound will be selected and played when the current playing Sound completes. */
  40843. loop: boolean;
  40844. private _coneInnerAngle;
  40845. private _coneOuterAngle;
  40846. private _volume;
  40847. /** A Sound is currently playing. */
  40848. isPlaying: boolean;
  40849. /** A Sound is currently paused. */
  40850. isPaused: boolean;
  40851. private _sounds;
  40852. private _weights;
  40853. private _currentIndex?;
  40854. /**
  40855. * Creates a new WeightedSound from the list of sounds given.
  40856. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  40857. * @param sounds Array of Sounds that will be selected from.
  40858. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  40859. */
  40860. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  40861. /**
  40862. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  40863. */
  40864. get directionalConeInnerAngle(): number;
  40865. /**
  40866. * The size of cone in degress for a directional sound in which there will be no attenuation.
  40867. */
  40868. set directionalConeInnerAngle(value: number);
  40869. /**
  40870. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40871. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40872. */
  40873. get directionalConeOuterAngle(): number;
  40874. /**
  40875. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40876. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40877. */
  40878. set directionalConeOuterAngle(value: number);
  40879. /**
  40880. * Playback volume.
  40881. */
  40882. get volume(): number;
  40883. /**
  40884. * Playback volume.
  40885. */
  40886. set volume(value: number);
  40887. private _onended;
  40888. /**
  40889. * Suspend playback
  40890. */
  40891. pause(): void;
  40892. /**
  40893. * Stop playback
  40894. */
  40895. stop(): void;
  40896. /**
  40897. * Start playback.
  40898. * @param startOffset Position the clip head at a specific time in seconds.
  40899. */
  40900. play(startOffset?: number): void;
  40901. }
  40902. }
  40903. declare module BABYLON {
  40904. /**
  40905. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40906. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40907. */
  40908. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40909. /**
  40910. * Gets the name of the behavior.
  40911. */
  40912. get name(): string;
  40913. /**
  40914. * The easing function used by animations
  40915. */
  40916. static EasingFunction: BackEase;
  40917. /**
  40918. * The easing mode used by animations
  40919. */
  40920. static EasingMode: number;
  40921. /**
  40922. * The duration of the animation, in milliseconds
  40923. */
  40924. transitionDuration: number;
  40925. /**
  40926. * Length of the distance animated by the transition when lower radius is reached
  40927. */
  40928. lowerRadiusTransitionRange: number;
  40929. /**
  40930. * Length of the distance animated by the transition when upper radius is reached
  40931. */
  40932. upperRadiusTransitionRange: number;
  40933. private _autoTransitionRange;
  40934. /**
  40935. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40936. */
  40937. get autoTransitionRange(): boolean;
  40938. /**
  40939. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40940. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40941. */
  40942. set autoTransitionRange(value: boolean);
  40943. private _attachedCamera;
  40944. private _onAfterCheckInputsObserver;
  40945. private _onMeshTargetChangedObserver;
  40946. /**
  40947. * Initializes the behavior.
  40948. */
  40949. init(): void;
  40950. /**
  40951. * Attaches the behavior to its arc rotate camera.
  40952. * @param camera Defines the camera to attach the behavior to
  40953. */
  40954. attach(camera: ArcRotateCamera): void;
  40955. /**
  40956. * Detaches the behavior from its current arc rotate camera.
  40957. */
  40958. detach(): void;
  40959. private _radiusIsAnimating;
  40960. private _radiusBounceTransition;
  40961. private _animatables;
  40962. private _cachedWheelPrecision;
  40963. /**
  40964. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40965. * @param radiusLimit The limit to check against.
  40966. * @return Bool to indicate if at limit.
  40967. */
  40968. private _isRadiusAtLimit;
  40969. /**
  40970. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40971. * @param radiusDelta The delta by which to animate to. Can be negative.
  40972. */
  40973. private _applyBoundRadiusAnimation;
  40974. /**
  40975. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40976. */
  40977. protected _clearAnimationLocks(): void;
  40978. /**
  40979. * Stops and removes all animations that have been applied to the camera
  40980. */
  40981. stopAllAnimations(): void;
  40982. }
  40983. }
  40984. declare module BABYLON {
  40985. /**
  40986. * 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.
  40987. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40988. */
  40989. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  40990. /**
  40991. * Gets the name of the behavior.
  40992. */
  40993. get name(): string;
  40994. private _mode;
  40995. private _radiusScale;
  40996. private _positionScale;
  40997. private _defaultElevation;
  40998. private _elevationReturnTime;
  40999. private _elevationReturnWaitTime;
  41000. private _zoomStopsAnimation;
  41001. private _framingTime;
  41002. /**
  41003. * The easing function used by animations
  41004. */
  41005. static EasingFunction: ExponentialEase;
  41006. /**
  41007. * The easing mode used by animations
  41008. */
  41009. static EasingMode: number;
  41010. /**
  41011. * Sets the current mode used by the behavior
  41012. */
  41013. set mode(mode: number);
  41014. /**
  41015. * Gets current mode used by the behavior.
  41016. */
  41017. get mode(): number;
  41018. /**
  41019. * Sets the scale applied to the radius (1 by default)
  41020. */
  41021. set radiusScale(radius: number);
  41022. /**
  41023. * Gets the scale applied to the radius
  41024. */
  41025. get radiusScale(): number;
  41026. /**
  41027. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41028. */
  41029. set positionScale(scale: number);
  41030. /**
  41031. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41032. */
  41033. get positionScale(): number;
  41034. /**
  41035. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41036. * behaviour is triggered, in radians.
  41037. */
  41038. set defaultElevation(elevation: number);
  41039. /**
  41040. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41041. * behaviour is triggered, in radians.
  41042. */
  41043. get defaultElevation(): number;
  41044. /**
  41045. * Sets the time (in milliseconds) taken to return to the default beta position.
  41046. * Negative value indicates camera should not return to default.
  41047. */
  41048. set elevationReturnTime(speed: number);
  41049. /**
  41050. * Gets the time (in milliseconds) taken to return to the default beta position.
  41051. * Negative value indicates camera should not return to default.
  41052. */
  41053. get elevationReturnTime(): number;
  41054. /**
  41055. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41056. */
  41057. set elevationReturnWaitTime(time: number);
  41058. /**
  41059. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41060. */
  41061. get elevationReturnWaitTime(): number;
  41062. /**
  41063. * Sets the flag that indicates if user zooming should stop animation.
  41064. */
  41065. set zoomStopsAnimation(flag: boolean);
  41066. /**
  41067. * Gets the flag that indicates if user zooming should stop animation.
  41068. */
  41069. get zoomStopsAnimation(): boolean;
  41070. /**
  41071. * Sets the transition time when framing the mesh, in milliseconds
  41072. */
  41073. set framingTime(time: number);
  41074. /**
  41075. * Gets the transition time when framing the mesh, in milliseconds
  41076. */
  41077. get framingTime(): number;
  41078. /**
  41079. * Define if the behavior should automatically change the configured
  41080. * camera limits and sensibilities.
  41081. */
  41082. autoCorrectCameraLimitsAndSensibility: boolean;
  41083. private _onPrePointerObservableObserver;
  41084. private _onAfterCheckInputsObserver;
  41085. private _onMeshTargetChangedObserver;
  41086. private _attachedCamera;
  41087. private _isPointerDown;
  41088. private _lastInteractionTime;
  41089. /**
  41090. * Initializes the behavior.
  41091. */
  41092. init(): void;
  41093. /**
  41094. * Attaches the behavior to its arc rotate camera.
  41095. * @param camera Defines the camera to attach the behavior to
  41096. */
  41097. attach(camera: ArcRotateCamera): void;
  41098. /**
  41099. * Detaches the behavior from its current arc rotate camera.
  41100. */
  41101. detach(): void;
  41102. private _animatables;
  41103. private _betaIsAnimating;
  41104. private _betaTransition;
  41105. private _radiusTransition;
  41106. private _vectorTransition;
  41107. /**
  41108. * Targets the given mesh and updates zoom level accordingly.
  41109. * @param mesh The mesh to target.
  41110. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41111. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41112. */
  41113. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41114. /**
  41115. * Targets the given mesh with its children and updates zoom level accordingly.
  41116. * @param mesh The mesh to target.
  41117. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41118. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41119. */
  41120. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41121. /**
  41122. * Targets the given meshes with their children and updates zoom level accordingly.
  41123. * @param meshes The mesh to target.
  41124. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41125. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41126. */
  41127. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41128. /**
  41129. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41130. * @param minimumWorld Determines the smaller position of the bounding box extend
  41131. * @param maximumWorld Determines the bigger position of the bounding box extend
  41132. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41133. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41134. */
  41135. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41136. /**
  41137. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41138. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41139. * frustum width.
  41140. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41141. * to fully enclose the mesh in the viewing frustum.
  41142. */
  41143. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41144. /**
  41145. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41146. * is automatically returned to its default position (expected to be above ground plane).
  41147. */
  41148. private _maintainCameraAboveGround;
  41149. /**
  41150. * Returns the frustum slope based on the canvas ratio and camera FOV
  41151. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41152. */
  41153. private _getFrustumSlope;
  41154. /**
  41155. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41156. */
  41157. private _clearAnimationLocks;
  41158. /**
  41159. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41160. */
  41161. private _applyUserInteraction;
  41162. /**
  41163. * Stops and removes all animations that have been applied to the camera
  41164. */
  41165. stopAllAnimations(): void;
  41166. /**
  41167. * Gets a value indicating if the user is moving the camera
  41168. */
  41169. get isUserIsMoving(): boolean;
  41170. /**
  41171. * The camera can move all the way towards the mesh.
  41172. */
  41173. static IgnoreBoundsSizeMode: number;
  41174. /**
  41175. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41176. */
  41177. static FitFrustumSidesMode: number;
  41178. }
  41179. }
  41180. declare module BABYLON {
  41181. /**
  41182. * Base class for Camera Pointer Inputs.
  41183. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41184. * for example usage.
  41185. */
  41186. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41187. /**
  41188. * Defines the camera the input is attached to.
  41189. */
  41190. abstract camera: Camera;
  41191. /**
  41192. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41193. */
  41194. protected _altKey: boolean;
  41195. protected _ctrlKey: boolean;
  41196. protected _metaKey: boolean;
  41197. protected _shiftKey: boolean;
  41198. /**
  41199. * Which mouse buttons were pressed at time of last mouse event.
  41200. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41201. */
  41202. protected _buttonsPressed: number;
  41203. /**
  41204. * Defines the buttons associated with the input to handle camera move.
  41205. */
  41206. buttons: number[];
  41207. /**
  41208. * Attach the input controls to a specific dom element to get the input from.
  41209. * @param element Defines the element the controls should be listened from
  41210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41211. */
  41212. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41213. /**
  41214. * Detach the current controls from the specified dom element.
  41215. * @param element Defines the element to stop listening the inputs from
  41216. */
  41217. detachControl(element: Nullable<HTMLElement>): void;
  41218. /**
  41219. * Gets the class name of the current input.
  41220. * @returns the class name
  41221. */
  41222. getClassName(): string;
  41223. /**
  41224. * Get the friendly name associated with the input class.
  41225. * @returns the input friendly name
  41226. */
  41227. getSimpleName(): string;
  41228. /**
  41229. * Called on pointer POINTERDOUBLETAP event.
  41230. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41231. */
  41232. protected onDoubleTap(type: string): void;
  41233. /**
  41234. * Called on pointer POINTERMOVE event if only a single touch is active.
  41235. * Override this method to provide functionality.
  41236. */
  41237. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41238. /**
  41239. * Called on pointer POINTERMOVE event if multiple touches are active.
  41240. * Override this method to provide functionality.
  41241. */
  41242. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41243. /**
  41244. * Called on JS contextmenu event.
  41245. * Override this method to provide functionality.
  41246. */
  41247. protected onContextMenu(evt: PointerEvent): void;
  41248. /**
  41249. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41250. * press.
  41251. * Override this method to provide functionality.
  41252. */
  41253. protected onButtonDown(evt: PointerEvent): void;
  41254. /**
  41255. * Called each time a new POINTERUP event occurs. Ie, for each button
  41256. * release.
  41257. * Override this method to provide functionality.
  41258. */
  41259. protected onButtonUp(evt: PointerEvent): void;
  41260. /**
  41261. * Called when window becomes inactive.
  41262. * Override this method to provide functionality.
  41263. */
  41264. protected onLostFocus(): void;
  41265. private _pointerInput;
  41266. private _observer;
  41267. private _onLostFocus;
  41268. private pointA;
  41269. private pointB;
  41270. }
  41271. }
  41272. declare module BABYLON {
  41273. /**
  41274. * Manage the pointers inputs to control an arc rotate camera.
  41275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41276. */
  41277. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41278. /**
  41279. * Defines the camera the input is attached to.
  41280. */
  41281. camera: ArcRotateCamera;
  41282. /**
  41283. * Gets the class name of the current input.
  41284. * @returns the class name
  41285. */
  41286. getClassName(): string;
  41287. /**
  41288. * Defines the buttons associated with the input to handle camera move.
  41289. */
  41290. buttons: number[];
  41291. /**
  41292. * Defines the pointer angular sensibility along the X axis or how fast is
  41293. * the camera rotating.
  41294. */
  41295. angularSensibilityX: number;
  41296. /**
  41297. * Defines the pointer angular sensibility along the Y axis or how fast is
  41298. * the camera rotating.
  41299. */
  41300. angularSensibilityY: number;
  41301. /**
  41302. * Defines the pointer pinch precision or how fast is the camera zooming.
  41303. */
  41304. pinchPrecision: number;
  41305. /**
  41306. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41307. * from 0.
  41308. * It defines the percentage of current camera.radius to use as delta when
  41309. * pinch zoom is used.
  41310. */
  41311. pinchDeltaPercentage: number;
  41312. /**
  41313. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41314. * that any object in the plane at the camera's target point will scale
  41315. * perfectly with finger motion.
  41316. * Overrides pinchDeltaPercentage and pinchPrecision.
  41317. */
  41318. useNaturalPinchZoom: boolean;
  41319. /**
  41320. * Defines the pointer panning sensibility or how fast is the camera moving.
  41321. */
  41322. panningSensibility: number;
  41323. /**
  41324. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41325. */
  41326. multiTouchPanning: boolean;
  41327. /**
  41328. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41329. * zoom (pinch) through multitouch.
  41330. */
  41331. multiTouchPanAndZoom: boolean;
  41332. /**
  41333. * Revers pinch action direction.
  41334. */
  41335. pinchInwards: boolean;
  41336. private _isPanClick;
  41337. private _twoFingerActivityCount;
  41338. private _isPinching;
  41339. /**
  41340. * Called on pointer POINTERMOVE event if only a single touch is active.
  41341. */
  41342. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41343. /**
  41344. * Called on pointer POINTERDOUBLETAP event.
  41345. */
  41346. protected onDoubleTap(type: string): void;
  41347. /**
  41348. * Called on pointer POINTERMOVE event if multiple touches are active.
  41349. */
  41350. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41351. /**
  41352. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41353. * press.
  41354. */
  41355. protected onButtonDown(evt: PointerEvent): void;
  41356. /**
  41357. * Called each time a new POINTERUP event occurs. Ie, for each button
  41358. * release.
  41359. */
  41360. protected onButtonUp(evt: PointerEvent): void;
  41361. /**
  41362. * Called when window becomes inactive.
  41363. */
  41364. protected onLostFocus(): void;
  41365. }
  41366. }
  41367. declare module BABYLON {
  41368. /**
  41369. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41371. */
  41372. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41373. /**
  41374. * Defines the camera the input is attached to.
  41375. */
  41376. camera: ArcRotateCamera;
  41377. /**
  41378. * Defines the list of key codes associated with the up action (increase alpha)
  41379. */
  41380. keysUp: number[];
  41381. /**
  41382. * Defines the list of key codes associated with the down action (decrease alpha)
  41383. */
  41384. keysDown: number[];
  41385. /**
  41386. * Defines the list of key codes associated with the left action (increase beta)
  41387. */
  41388. keysLeft: number[];
  41389. /**
  41390. * Defines the list of key codes associated with the right action (decrease beta)
  41391. */
  41392. keysRight: number[];
  41393. /**
  41394. * Defines the list of key codes associated with the reset action.
  41395. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41396. */
  41397. keysReset: number[];
  41398. /**
  41399. * Defines the panning sensibility of the inputs.
  41400. * (How fast is the camera panning)
  41401. */
  41402. panningSensibility: number;
  41403. /**
  41404. * Defines the zooming sensibility of the inputs.
  41405. * (How fast is the camera zooming)
  41406. */
  41407. zoomingSensibility: number;
  41408. /**
  41409. * Defines whether maintaining the alt key down switch the movement mode from
  41410. * orientation to zoom.
  41411. */
  41412. useAltToZoom: boolean;
  41413. /**
  41414. * Rotation speed of the camera
  41415. */
  41416. angularSpeed: number;
  41417. private _keys;
  41418. private _ctrlPressed;
  41419. private _altPressed;
  41420. private _onCanvasBlurObserver;
  41421. private _onKeyboardObserver;
  41422. private _engine;
  41423. private _scene;
  41424. /**
  41425. * Attach the input controls to a specific dom element to get the input from.
  41426. * @param element Defines the element the controls should be listened from
  41427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41428. */
  41429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41430. /**
  41431. * Detach the current controls from the specified dom element.
  41432. * @param element Defines the element to stop listening the inputs from
  41433. */
  41434. detachControl(element: Nullable<HTMLElement>): void;
  41435. /**
  41436. * Update the current camera state depending on the inputs that have been used this frame.
  41437. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41438. */
  41439. checkInputs(): void;
  41440. /**
  41441. * Gets the class name of the current intput.
  41442. * @returns the class name
  41443. */
  41444. getClassName(): string;
  41445. /**
  41446. * Get the friendly name associated with the input class.
  41447. * @returns the input friendly name
  41448. */
  41449. getSimpleName(): string;
  41450. }
  41451. }
  41452. declare module BABYLON {
  41453. /**
  41454. * Manage the mouse wheel inputs to control an arc rotate camera.
  41455. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41456. */
  41457. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41458. /**
  41459. * Defines the camera the input is attached to.
  41460. */
  41461. camera: ArcRotateCamera;
  41462. /**
  41463. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41464. */
  41465. wheelPrecision: number;
  41466. /**
  41467. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41468. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41469. */
  41470. wheelDeltaPercentage: number;
  41471. private _wheel;
  41472. private _observer;
  41473. private computeDeltaFromMouseWheelLegacyEvent;
  41474. /**
  41475. * Attach the input controls to a specific dom element to get the input from.
  41476. * @param element Defines the element the controls should be listened from
  41477. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41478. */
  41479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41480. /**
  41481. * Detach the current controls from the specified dom element.
  41482. * @param element Defines the element to stop listening the inputs from
  41483. */
  41484. detachControl(element: Nullable<HTMLElement>): void;
  41485. /**
  41486. * Gets the class name of the current intput.
  41487. * @returns the class name
  41488. */
  41489. getClassName(): string;
  41490. /**
  41491. * Get the friendly name associated with the input class.
  41492. * @returns the input friendly name
  41493. */
  41494. getSimpleName(): string;
  41495. }
  41496. }
  41497. declare module BABYLON {
  41498. /**
  41499. * Default Inputs manager for the ArcRotateCamera.
  41500. * It groups all the default supported inputs for ease of use.
  41501. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41502. */
  41503. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41504. /**
  41505. * Instantiates a new ArcRotateCameraInputsManager.
  41506. * @param camera Defines the camera the inputs belong to
  41507. */
  41508. constructor(camera: ArcRotateCamera);
  41509. /**
  41510. * Add mouse wheel input support to the input manager.
  41511. * @returns the current input manager
  41512. */
  41513. addMouseWheel(): ArcRotateCameraInputsManager;
  41514. /**
  41515. * Add pointers input support to the input manager.
  41516. * @returns the current input manager
  41517. */
  41518. addPointers(): ArcRotateCameraInputsManager;
  41519. /**
  41520. * Add keyboard input support to the input manager.
  41521. * @returns the current input manager
  41522. */
  41523. addKeyboard(): ArcRotateCameraInputsManager;
  41524. }
  41525. }
  41526. declare module BABYLON {
  41527. /**
  41528. * This represents an orbital type of camera.
  41529. *
  41530. * 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.
  41531. * 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.
  41532. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41533. */
  41534. export class ArcRotateCamera extends TargetCamera {
  41535. /**
  41536. * Defines the rotation angle of the camera along the longitudinal axis.
  41537. */
  41538. alpha: number;
  41539. /**
  41540. * Defines the rotation angle of the camera along the latitudinal axis.
  41541. */
  41542. beta: number;
  41543. /**
  41544. * Defines the radius of the camera from it s target point.
  41545. */
  41546. radius: number;
  41547. protected _target: Vector3;
  41548. protected _targetHost: Nullable<AbstractMesh>;
  41549. /**
  41550. * Defines the target point of the camera.
  41551. * The camera looks towards it form the radius distance.
  41552. */
  41553. get target(): Vector3;
  41554. set target(value: Vector3);
  41555. /**
  41556. * Define the current local position of the camera in the scene
  41557. */
  41558. get position(): Vector3;
  41559. set position(newPosition: Vector3);
  41560. protected _upVector: Vector3;
  41561. protected _upToYMatrix: Matrix;
  41562. protected _YToUpMatrix: Matrix;
  41563. /**
  41564. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41565. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41566. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41567. */
  41568. set upVector(vec: Vector3);
  41569. get upVector(): Vector3;
  41570. /**
  41571. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41572. */
  41573. setMatUp(): void;
  41574. /**
  41575. * Current inertia value on the longitudinal axis.
  41576. * The bigger this number the longer it will take for the camera to stop.
  41577. */
  41578. inertialAlphaOffset: number;
  41579. /**
  41580. * Current inertia value on the latitudinal axis.
  41581. * The bigger this number the longer it will take for the camera to stop.
  41582. */
  41583. inertialBetaOffset: number;
  41584. /**
  41585. * Current inertia value on the radius axis.
  41586. * The bigger this number the longer it will take for the camera to stop.
  41587. */
  41588. inertialRadiusOffset: number;
  41589. /**
  41590. * Minimum allowed angle on the longitudinal axis.
  41591. * This can help limiting how the Camera is able to move in the scene.
  41592. */
  41593. lowerAlphaLimit: Nullable<number>;
  41594. /**
  41595. * Maximum allowed angle on the longitudinal axis.
  41596. * This can help limiting how the Camera is able to move in the scene.
  41597. */
  41598. upperAlphaLimit: Nullable<number>;
  41599. /**
  41600. * Minimum allowed angle on the latitudinal axis.
  41601. * This can help limiting how the Camera is able to move in the scene.
  41602. */
  41603. lowerBetaLimit: number;
  41604. /**
  41605. * Maximum allowed angle on the latitudinal axis.
  41606. * This can help limiting how the Camera is able to move in the scene.
  41607. */
  41608. upperBetaLimit: number;
  41609. /**
  41610. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41611. * This can help limiting how the Camera is able to move in the scene.
  41612. */
  41613. lowerRadiusLimit: Nullable<number>;
  41614. /**
  41615. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41616. * This can help limiting how the Camera is able to move in the scene.
  41617. */
  41618. upperRadiusLimit: Nullable<number>;
  41619. /**
  41620. * Defines the current inertia value used during panning of the camera along the X axis.
  41621. */
  41622. inertialPanningX: number;
  41623. /**
  41624. * Defines the current inertia value used during panning of the camera along the Y axis.
  41625. */
  41626. inertialPanningY: number;
  41627. /**
  41628. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41629. * Basically if your fingers moves away from more than this distance you will be considered
  41630. * in pinch mode.
  41631. */
  41632. pinchToPanMaxDistance: number;
  41633. /**
  41634. * Defines the maximum distance the camera can pan.
  41635. * This could help keeping the cammera always in your scene.
  41636. */
  41637. panningDistanceLimit: Nullable<number>;
  41638. /**
  41639. * Defines the target of the camera before paning.
  41640. */
  41641. panningOriginTarget: Vector3;
  41642. /**
  41643. * Defines the value of the inertia used during panning.
  41644. * 0 would mean stop inertia and one would mean no decelleration at all.
  41645. */
  41646. panningInertia: number;
  41647. /**
  41648. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41649. */
  41650. get angularSensibilityX(): number;
  41651. set angularSensibilityX(value: number);
  41652. /**
  41653. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41654. */
  41655. get angularSensibilityY(): number;
  41656. set angularSensibilityY(value: number);
  41657. /**
  41658. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  41659. */
  41660. get pinchPrecision(): number;
  41661. set pinchPrecision(value: number);
  41662. /**
  41663. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  41664. * It will be used instead of pinchDeltaPrecision if different from 0.
  41665. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41666. */
  41667. get pinchDeltaPercentage(): number;
  41668. set pinchDeltaPercentage(value: number);
  41669. /**
  41670. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  41671. * and pinch delta percentage.
  41672. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41673. * that any object in the plane at the camera's target point will scale
  41674. * perfectly with finger motion.
  41675. */
  41676. get useNaturalPinchZoom(): boolean;
  41677. set useNaturalPinchZoom(value: boolean);
  41678. /**
  41679. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  41680. */
  41681. get panningSensibility(): number;
  41682. set panningSensibility(value: number);
  41683. /**
  41684. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  41685. */
  41686. get keysUp(): number[];
  41687. set keysUp(value: number[]);
  41688. /**
  41689. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  41690. */
  41691. get keysDown(): number[];
  41692. set keysDown(value: number[]);
  41693. /**
  41694. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  41695. */
  41696. get keysLeft(): number[];
  41697. set keysLeft(value: number[]);
  41698. /**
  41699. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  41700. */
  41701. get keysRight(): number[];
  41702. set keysRight(value: number[]);
  41703. /**
  41704. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41705. */
  41706. get wheelPrecision(): number;
  41707. set wheelPrecision(value: number);
  41708. /**
  41709. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  41710. * It will be used instead of pinchDeltaPrecision if different from 0.
  41711. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41712. */
  41713. get wheelDeltaPercentage(): number;
  41714. set wheelDeltaPercentage(value: number);
  41715. /**
  41716. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  41717. */
  41718. zoomOnFactor: number;
  41719. /**
  41720. * Defines a screen offset for the camera position.
  41721. */
  41722. targetScreenOffset: Vector2;
  41723. /**
  41724. * Allows the camera to be completely reversed.
  41725. * If false the camera can not arrive upside down.
  41726. */
  41727. allowUpsideDown: boolean;
  41728. /**
  41729. * Define if double tap/click is used to restore the previously saved state of the camera.
  41730. */
  41731. useInputToRestoreState: boolean;
  41732. /** @hidden */
  41733. _viewMatrix: Matrix;
  41734. /** @hidden */
  41735. _useCtrlForPanning: boolean;
  41736. /** @hidden */
  41737. _panningMouseButton: number;
  41738. /**
  41739. * Defines the input associated to the camera.
  41740. */
  41741. inputs: ArcRotateCameraInputsManager;
  41742. /** @hidden */
  41743. _reset: () => void;
  41744. /**
  41745. * Defines the allowed panning axis.
  41746. */
  41747. panningAxis: Vector3;
  41748. protected _localDirection: Vector3;
  41749. protected _transformedDirection: Vector3;
  41750. private _bouncingBehavior;
  41751. /**
  41752. * Gets the bouncing behavior of the camera if it has been enabled.
  41753. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41754. */
  41755. get bouncingBehavior(): Nullable<BouncingBehavior>;
  41756. /**
  41757. * Defines if the bouncing behavior of the camera is enabled on the camera.
  41758. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41759. */
  41760. get useBouncingBehavior(): boolean;
  41761. set useBouncingBehavior(value: boolean);
  41762. private _framingBehavior;
  41763. /**
  41764. * Gets the framing behavior of the camera if it has been enabled.
  41765. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41766. */
  41767. get framingBehavior(): Nullable<FramingBehavior>;
  41768. /**
  41769. * Defines if the framing behavior of the camera is enabled on the camera.
  41770. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41771. */
  41772. get useFramingBehavior(): boolean;
  41773. set useFramingBehavior(value: boolean);
  41774. private _autoRotationBehavior;
  41775. /**
  41776. * Gets the auto rotation behavior of the camera if it has been enabled.
  41777. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41778. */
  41779. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  41780. /**
  41781. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  41782. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41783. */
  41784. get useAutoRotationBehavior(): boolean;
  41785. set useAutoRotationBehavior(value: boolean);
  41786. /**
  41787. * Observable triggered when the mesh target has been changed on the camera.
  41788. */
  41789. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  41790. /**
  41791. * Event raised when the camera is colliding with a mesh.
  41792. */
  41793. onCollide: (collidedMesh: AbstractMesh) => void;
  41794. /**
  41795. * Defines whether the camera should check collision with the objects oh the scene.
  41796. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  41797. */
  41798. checkCollisions: boolean;
  41799. /**
  41800. * Defines the collision radius of the camera.
  41801. * This simulates a sphere around the camera.
  41802. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41803. */
  41804. collisionRadius: Vector3;
  41805. protected _collider: Collider;
  41806. protected _previousPosition: Vector3;
  41807. protected _collisionVelocity: Vector3;
  41808. protected _newPosition: Vector3;
  41809. protected _previousAlpha: number;
  41810. protected _previousBeta: number;
  41811. protected _previousRadius: number;
  41812. protected _collisionTriggered: boolean;
  41813. protected _targetBoundingCenter: Nullable<Vector3>;
  41814. private _computationVector;
  41815. /**
  41816. * Instantiates a new ArcRotateCamera in a given scene
  41817. * @param name Defines the name of the camera
  41818. * @param alpha Defines the camera rotation along the logitudinal axis
  41819. * @param beta Defines the camera rotation along the latitudinal axis
  41820. * @param radius Defines the camera distance from its target
  41821. * @param target Defines the camera target
  41822. * @param scene Defines the scene the camera belongs to
  41823. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  41824. */
  41825. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41826. /** @hidden */
  41827. _initCache(): void;
  41828. /** @hidden */
  41829. _updateCache(ignoreParentClass?: boolean): void;
  41830. protected _getTargetPosition(): Vector3;
  41831. private _storedAlpha;
  41832. private _storedBeta;
  41833. private _storedRadius;
  41834. private _storedTarget;
  41835. private _storedTargetScreenOffset;
  41836. /**
  41837. * Stores the current state of the camera (alpha, beta, radius and target)
  41838. * @returns the camera itself
  41839. */
  41840. storeState(): Camera;
  41841. /**
  41842. * @hidden
  41843. * Restored camera state. You must call storeState() first
  41844. */
  41845. _restoreStateValues(): boolean;
  41846. /** @hidden */
  41847. _isSynchronizedViewMatrix(): boolean;
  41848. /**
  41849. * Attached controls to the current camera.
  41850. * @param element Defines the element the controls should be listened from
  41851. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41852. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  41853. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  41854. */
  41855. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  41856. /**
  41857. * Detach the current controls from the camera.
  41858. * The camera will stop reacting to inputs.
  41859. * @param element Defines the element to stop listening the inputs from
  41860. */
  41861. detachControl(element: HTMLElement): void;
  41862. /** @hidden */
  41863. _checkInputs(): void;
  41864. protected _checkLimits(): void;
  41865. /**
  41866. * Rebuilds angles (alpha, beta) and radius from the give position and target
  41867. */
  41868. rebuildAnglesAndRadius(): void;
  41869. /**
  41870. * Use a position to define the current camera related information like alpha, beta and radius
  41871. * @param position Defines the position to set the camera at
  41872. */
  41873. setPosition(position: Vector3): void;
  41874. /**
  41875. * Defines the target the camera should look at.
  41876. * This will automatically adapt alpha beta and radius to fit within the new target.
  41877. * @param target Defines the new target as a Vector or a mesh
  41878. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  41879. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  41880. */
  41881. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  41882. /** @hidden */
  41883. _getViewMatrix(): Matrix;
  41884. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  41885. /**
  41886. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  41887. * @param meshes Defines the mesh to zoom on
  41888. * @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)
  41889. */
  41890. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  41891. /**
  41892. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  41893. * The target will be changed but the radius
  41894. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  41895. * @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)
  41896. */
  41897. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  41898. min: Vector3;
  41899. max: Vector3;
  41900. distance: number;
  41901. }, doNotUpdateMaxZ?: boolean): void;
  41902. /**
  41903. * @override
  41904. * Override Camera.createRigCamera
  41905. */
  41906. createRigCamera(name: string, cameraIndex: number): Camera;
  41907. /**
  41908. * @hidden
  41909. * @override
  41910. * Override Camera._updateRigCameras
  41911. */
  41912. _updateRigCameras(): void;
  41913. /**
  41914. * Destroy the camera and release the current resources hold by it.
  41915. */
  41916. dispose(): void;
  41917. /**
  41918. * Gets the current object class name.
  41919. * @return the class name
  41920. */
  41921. getClassName(): string;
  41922. }
  41923. }
  41924. declare module BABYLON {
  41925. /**
  41926. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  41927. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41928. */
  41929. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  41930. /**
  41931. * Gets the name of the behavior.
  41932. */
  41933. get name(): string;
  41934. private _zoomStopsAnimation;
  41935. private _idleRotationSpeed;
  41936. private _idleRotationWaitTime;
  41937. private _idleRotationSpinupTime;
  41938. /**
  41939. * Sets the flag that indicates if user zooming should stop animation.
  41940. */
  41941. set zoomStopsAnimation(flag: boolean);
  41942. /**
  41943. * Gets the flag that indicates if user zooming should stop animation.
  41944. */
  41945. get zoomStopsAnimation(): boolean;
  41946. /**
  41947. * Sets the default speed at which the camera rotates around the model.
  41948. */
  41949. set idleRotationSpeed(speed: number);
  41950. /**
  41951. * Gets the default speed at which the camera rotates around the model.
  41952. */
  41953. get idleRotationSpeed(): number;
  41954. /**
  41955. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  41956. */
  41957. set idleRotationWaitTime(time: number);
  41958. /**
  41959. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  41960. */
  41961. get idleRotationWaitTime(): number;
  41962. /**
  41963. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  41964. */
  41965. set idleRotationSpinupTime(time: number);
  41966. /**
  41967. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  41968. */
  41969. get idleRotationSpinupTime(): number;
  41970. /**
  41971. * Gets a value indicating if the camera is currently rotating because of this behavior
  41972. */
  41973. get rotationInProgress(): boolean;
  41974. private _onPrePointerObservableObserver;
  41975. private _onAfterCheckInputsObserver;
  41976. private _attachedCamera;
  41977. private _isPointerDown;
  41978. private _lastFrameTime;
  41979. private _lastInteractionTime;
  41980. private _cameraRotationSpeed;
  41981. /**
  41982. * Initializes the behavior.
  41983. */
  41984. init(): void;
  41985. /**
  41986. * Attaches the behavior to its arc rotate camera.
  41987. * @param camera Defines the camera to attach the behavior to
  41988. */
  41989. attach(camera: ArcRotateCamera): void;
  41990. /**
  41991. * Detaches the behavior from its current arc rotate camera.
  41992. */
  41993. detach(): void;
  41994. /**
  41995. * Returns true if user is scrolling.
  41996. * @return true if user is scrolling.
  41997. */
  41998. private _userIsZooming;
  41999. private _lastFrameRadius;
  42000. private _shouldAnimationStopForInteraction;
  42001. /**
  42002. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42003. */
  42004. private _applyUserInteraction;
  42005. private _userIsMoving;
  42006. }
  42007. }
  42008. declare module BABYLON {
  42009. /**
  42010. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42011. */
  42012. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42013. private ui;
  42014. /**
  42015. * The name of the behavior
  42016. */
  42017. name: string;
  42018. /**
  42019. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42020. */
  42021. distanceAwayFromFace: number;
  42022. /**
  42023. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42024. */
  42025. distanceAwayFromBottomOfFace: number;
  42026. private _faceVectors;
  42027. private _target;
  42028. private _scene;
  42029. private _onRenderObserver;
  42030. private _tmpMatrix;
  42031. private _tmpVector;
  42032. /**
  42033. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42034. * @param ui The transform node that should be attched to the mesh
  42035. */
  42036. constructor(ui: TransformNode);
  42037. /**
  42038. * Initializes the behavior
  42039. */
  42040. init(): void;
  42041. private _closestFace;
  42042. private _zeroVector;
  42043. private _lookAtTmpMatrix;
  42044. private _lookAtToRef;
  42045. /**
  42046. * Attaches the AttachToBoxBehavior to the passed in mesh
  42047. * @param target The mesh that the specified node will be attached to
  42048. */
  42049. attach(target: Mesh): void;
  42050. /**
  42051. * Detaches the behavior from the mesh
  42052. */
  42053. detach(): void;
  42054. }
  42055. }
  42056. declare module BABYLON {
  42057. /**
  42058. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42059. */
  42060. export class FadeInOutBehavior implements Behavior<Mesh> {
  42061. /**
  42062. * Time in milliseconds to delay before fading in (Default: 0)
  42063. */
  42064. delay: number;
  42065. /**
  42066. * Time in milliseconds for the mesh to fade in (Default: 300)
  42067. */
  42068. fadeInTime: number;
  42069. private _millisecondsPerFrame;
  42070. private _hovered;
  42071. private _hoverValue;
  42072. private _ownerNode;
  42073. /**
  42074. * Instatiates the FadeInOutBehavior
  42075. */
  42076. constructor();
  42077. /**
  42078. * The name of the behavior
  42079. */
  42080. get name(): string;
  42081. /**
  42082. * Initializes the behavior
  42083. */
  42084. init(): void;
  42085. /**
  42086. * Attaches the fade behavior on the passed in mesh
  42087. * @param ownerNode The mesh that will be faded in/out once attached
  42088. */
  42089. attach(ownerNode: Mesh): void;
  42090. /**
  42091. * Detaches the behavior from the mesh
  42092. */
  42093. detach(): void;
  42094. /**
  42095. * Triggers the mesh to begin fading in or out
  42096. * @param value if the object should fade in or out (true to fade in)
  42097. */
  42098. fadeIn(value: boolean): void;
  42099. private _update;
  42100. private _setAllVisibility;
  42101. }
  42102. }
  42103. declare module BABYLON {
  42104. /**
  42105. * Class containing a set of static utilities functions for managing Pivots
  42106. * @hidden
  42107. */
  42108. export class PivotTools {
  42109. private static _PivotCached;
  42110. private static _OldPivotPoint;
  42111. private static _PivotTranslation;
  42112. private static _PivotTmpVector;
  42113. /** @hidden */
  42114. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42115. /** @hidden */
  42116. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42117. }
  42118. }
  42119. declare module BABYLON {
  42120. /**
  42121. * Class containing static functions to help procedurally build meshes
  42122. */
  42123. export class PlaneBuilder {
  42124. /**
  42125. * Creates a plane mesh
  42126. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42127. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42128. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42130. * * 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
  42131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42132. * @param name defines the name of the mesh
  42133. * @param options defines the options used to create the mesh
  42134. * @param scene defines the hosting scene
  42135. * @returns the plane mesh
  42136. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42137. */
  42138. static CreatePlane(name: string, options: {
  42139. size?: number;
  42140. width?: number;
  42141. height?: number;
  42142. sideOrientation?: number;
  42143. frontUVs?: Vector4;
  42144. backUVs?: Vector4;
  42145. updatable?: boolean;
  42146. sourcePlane?: Plane;
  42147. }, scene?: Nullable<Scene>): Mesh;
  42148. }
  42149. }
  42150. declare module BABYLON {
  42151. /**
  42152. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42153. */
  42154. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42155. private static _AnyMouseID;
  42156. /**
  42157. * Abstract mesh the behavior is set on
  42158. */
  42159. attachedNode: AbstractMesh;
  42160. private _dragPlane;
  42161. private _scene;
  42162. private _pointerObserver;
  42163. private _beforeRenderObserver;
  42164. private static _planeScene;
  42165. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42166. /**
  42167. * 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)
  42168. */
  42169. maxDragAngle: number;
  42170. /**
  42171. * @hidden
  42172. */
  42173. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42174. /**
  42175. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42176. */
  42177. currentDraggingPointerID: number;
  42178. /**
  42179. * The last position where the pointer hit the drag plane in world space
  42180. */
  42181. lastDragPosition: Vector3;
  42182. /**
  42183. * If the behavior is currently in a dragging state
  42184. */
  42185. dragging: boolean;
  42186. /**
  42187. * 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)
  42188. */
  42189. dragDeltaRatio: number;
  42190. /**
  42191. * If the drag plane orientation should be updated during the dragging (Default: true)
  42192. */
  42193. updateDragPlane: boolean;
  42194. private _debugMode;
  42195. private _moving;
  42196. /**
  42197. * Fires each time the attached mesh is dragged with the pointer
  42198. * * delta between last drag position and current drag position in world space
  42199. * * dragDistance along the drag axis
  42200. * * dragPlaneNormal normal of the current drag plane used during the drag
  42201. * * dragPlanePoint in world space where the drag intersects the drag plane
  42202. */
  42203. onDragObservable: Observable<{
  42204. delta: Vector3;
  42205. dragPlanePoint: Vector3;
  42206. dragPlaneNormal: Vector3;
  42207. dragDistance: number;
  42208. pointerId: number;
  42209. }>;
  42210. /**
  42211. * Fires each time a drag begins (eg. mouse down on mesh)
  42212. */
  42213. onDragStartObservable: Observable<{
  42214. dragPlanePoint: Vector3;
  42215. pointerId: number;
  42216. }>;
  42217. /**
  42218. * Fires each time a drag ends (eg. mouse release after drag)
  42219. */
  42220. onDragEndObservable: Observable<{
  42221. dragPlanePoint: Vector3;
  42222. pointerId: number;
  42223. }>;
  42224. /**
  42225. * If the attached mesh should be moved when dragged
  42226. */
  42227. moveAttached: boolean;
  42228. /**
  42229. * If the drag behavior will react to drag events (Default: true)
  42230. */
  42231. enabled: boolean;
  42232. /**
  42233. * If pointer events should start and release the drag (Default: true)
  42234. */
  42235. startAndReleaseDragOnPointerEvents: boolean;
  42236. /**
  42237. * If camera controls should be detached during the drag
  42238. */
  42239. detachCameraControls: boolean;
  42240. /**
  42241. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42242. */
  42243. useObjectOrientationForDragging: boolean;
  42244. private _options;
  42245. /**
  42246. * Gets the options used by the behavior
  42247. */
  42248. get options(): {
  42249. dragAxis?: Vector3;
  42250. dragPlaneNormal?: Vector3;
  42251. };
  42252. /**
  42253. * Sets the options used by the behavior
  42254. */
  42255. set options(options: {
  42256. dragAxis?: Vector3;
  42257. dragPlaneNormal?: Vector3;
  42258. });
  42259. /**
  42260. * Creates a pointer drag behavior that can be attached to a mesh
  42261. * @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)
  42262. */
  42263. constructor(options?: {
  42264. dragAxis?: Vector3;
  42265. dragPlaneNormal?: Vector3;
  42266. });
  42267. /**
  42268. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42269. */
  42270. validateDrag: (targetPosition: Vector3) => boolean;
  42271. /**
  42272. * The name of the behavior
  42273. */
  42274. get name(): string;
  42275. /**
  42276. * Initializes the behavior
  42277. */
  42278. init(): void;
  42279. private _tmpVector;
  42280. private _alternatePickedPoint;
  42281. private _worldDragAxis;
  42282. private _targetPosition;
  42283. private _attachedElement;
  42284. /**
  42285. * Attaches the drag behavior the passed in mesh
  42286. * @param ownerNode The mesh that will be dragged around once attached
  42287. * @param predicate Predicate to use for pick filtering
  42288. */
  42289. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42290. /**
  42291. * Force relase the drag action by code.
  42292. */
  42293. releaseDrag(): void;
  42294. private _startDragRay;
  42295. private _lastPointerRay;
  42296. /**
  42297. * Simulates the start of a pointer drag event on the behavior
  42298. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42299. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42300. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42301. */
  42302. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42303. private _startDrag;
  42304. private _dragDelta;
  42305. private _moveDrag;
  42306. private _pickWithRayOnDragPlane;
  42307. private _pointA;
  42308. private _pointB;
  42309. private _pointC;
  42310. private _lineA;
  42311. private _lineB;
  42312. private _localAxis;
  42313. private _lookAt;
  42314. private _updateDragPlanePosition;
  42315. /**
  42316. * Detaches the behavior from the mesh
  42317. */
  42318. detach(): void;
  42319. }
  42320. }
  42321. declare module BABYLON {
  42322. /**
  42323. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42324. */
  42325. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42326. private _dragBehaviorA;
  42327. private _dragBehaviorB;
  42328. private _startDistance;
  42329. private _initialScale;
  42330. private _targetScale;
  42331. private _ownerNode;
  42332. private _sceneRenderObserver;
  42333. /**
  42334. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42335. */
  42336. constructor();
  42337. /**
  42338. * The name of the behavior
  42339. */
  42340. get name(): string;
  42341. /**
  42342. * Initializes the behavior
  42343. */
  42344. init(): void;
  42345. private _getCurrentDistance;
  42346. /**
  42347. * Attaches the scale behavior the passed in mesh
  42348. * @param ownerNode The mesh that will be scaled around once attached
  42349. */
  42350. attach(ownerNode: Mesh): void;
  42351. /**
  42352. * Detaches the behavior from the mesh
  42353. */
  42354. detach(): void;
  42355. }
  42356. }
  42357. declare module BABYLON {
  42358. /**
  42359. * 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
  42360. */
  42361. export class SixDofDragBehavior implements Behavior<Mesh> {
  42362. private static _virtualScene;
  42363. private _ownerNode;
  42364. private _sceneRenderObserver;
  42365. private _scene;
  42366. private _targetPosition;
  42367. private _virtualOriginMesh;
  42368. private _virtualDragMesh;
  42369. private _pointerObserver;
  42370. private _moving;
  42371. private _startingOrientation;
  42372. private _attachedElement;
  42373. /**
  42374. * 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)
  42375. */
  42376. private zDragFactor;
  42377. /**
  42378. * If the object should rotate to face the drag origin
  42379. */
  42380. rotateDraggedObject: boolean;
  42381. /**
  42382. * If the behavior is currently in a dragging state
  42383. */
  42384. dragging: boolean;
  42385. /**
  42386. * 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)
  42387. */
  42388. dragDeltaRatio: number;
  42389. /**
  42390. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42391. */
  42392. currentDraggingPointerID: number;
  42393. /**
  42394. * If camera controls should be detached during the drag
  42395. */
  42396. detachCameraControls: boolean;
  42397. /**
  42398. * Fires each time a drag starts
  42399. */
  42400. onDragStartObservable: Observable<{}>;
  42401. /**
  42402. * Fires each time a drag ends (eg. mouse release after drag)
  42403. */
  42404. onDragEndObservable: Observable<{}>;
  42405. /**
  42406. * 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
  42407. */
  42408. constructor();
  42409. /**
  42410. * The name of the behavior
  42411. */
  42412. get name(): string;
  42413. /**
  42414. * Initializes the behavior
  42415. */
  42416. init(): void;
  42417. /**
  42418. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42419. */
  42420. private get _pointerCamera();
  42421. /**
  42422. * Attaches the scale behavior the passed in mesh
  42423. * @param ownerNode The mesh that will be scaled around once attached
  42424. */
  42425. attach(ownerNode: Mesh): void;
  42426. /**
  42427. * Detaches the behavior from the mesh
  42428. */
  42429. detach(): void;
  42430. }
  42431. }
  42432. declare module BABYLON {
  42433. /**
  42434. * Class used to apply inverse kinematics to bones
  42435. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42436. */
  42437. export class BoneIKController {
  42438. private static _tmpVecs;
  42439. private static _tmpQuat;
  42440. private static _tmpMats;
  42441. /**
  42442. * Gets or sets the target mesh
  42443. */
  42444. targetMesh: AbstractMesh;
  42445. /** Gets or sets the mesh used as pole */
  42446. poleTargetMesh: AbstractMesh;
  42447. /**
  42448. * Gets or sets the bone used as pole
  42449. */
  42450. poleTargetBone: Nullable<Bone>;
  42451. /**
  42452. * Gets or sets the target position
  42453. */
  42454. targetPosition: Vector3;
  42455. /**
  42456. * Gets or sets the pole target position
  42457. */
  42458. poleTargetPosition: Vector3;
  42459. /**
  42460. * Gets or sets the pole target local offset
  42461. */
  42462. poleTargetLocalOffset: Vector3;
  42463. /**
  42464. * Gets or sets the pole angle
  42465. */
  42466. poleAngle: number;
  42467. /**
  42468. * Gets or sets the mesh associated with the controller
  42469. */
  42470. mesh: AbstractMesh;
  42471. /**
  42472. * 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)
  42473. */
  42474. slerpAmount: number;
  42475. private _bone1Quat;
  42476. private _bone1Mat;
  42477. private _bone2Ang;
  42478. private _bone1;
  42479. private _bone2;
  42480. private _bone1Length;
  42481. private _bone2Length;
  42482. private _maxAngle;
  42483. private _maxReach;
  42484. private _rightHandedSystem;
  42485. private _bendAxis;
  42486. private _slerping;
  42487. private _adjustRoll;
  42488. /**
  42489. * Gets or sets maximum allowed angle
  42490. */
  42491. get maxAngle(): number;
  42492. set maxAngle(value: number);
  42493. /**
  42494. * Creates a new BoneIKController
  42495. * @param mesh defines the mesh to control
  42496. * @param bone defines the bone to control
  42497. * @param options defines options to set up the controller
  42498. */
  42499. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42500. targetMesh?: AbstractMesh;
  42501. poleTargetMesh?: AbstractMesh;
  42502. poleTargetBone?: Bone;
  42503. poleTargetLocalOffset?: Vector3;
  42504. poleAngle?: number;
  42505. bendAxis?: Vector3;
  42506. maxAngle?: number;
  42507. slerpAmount?: number;
  42508. });
  42509. private _setMaxAngle;
  42510. /**
  42511. * Force the controller to update the bones
  42512. */
  42513. update(): void;
  42514. }
  42515. }
  42516. declare module BABYLON {
  42517. /**
  42518. * Class used to make a bone look toward a point in space
  42519. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42520. */
  42521. export class BoneLookController {
  42522. private static _tmpVecs;
  42523. private static _tmpQuat;
  42524. private static _tmpMats;
  42525. /**
  42526. * The target Vector3 that the bone will look at
  42527. */
  42528. target: Vector3;
  42529. /**
  42530. * The mesh that the bone is attached to
  42531. */
  42532. mesh: AbstractMesh;
  42533. /**
  42534. * The bone that will be looking to the target
  42535. */
  42536. bone: Bone;
  42537. /**
  42538. * The up axis of the coordinate system that is used when the bone is rotated
  42539. */
  42540. upAxis: Vector3;
  42541. /**
  42542. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42543. */
  42544. upAxisSpace: Space;
  42545. /**
  42546. * Used to make an adjustment to the yaw of the bone
  42547. */
  42548. adjustYaw: number;
  42549. /**
  42550. * Used to make an adjustment to the pitch of the bone
  42551. */
  42552. adjustPitch: number;
  42553. /**
  42554. * Used to make an adjustment to the roll of the bone
  42555. */
  42556. adjustRoll: number;
  42557. /**
  42558. * 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)
  42559. */
  42560. slerpAmount: number;
  42561. private _minYaw;
  42562. private _maxYaw;
  42563. private _minPitch;
  42564. private _maxPitch;
  42565. private _minYawSin;
  42566. private _minYawCos;
  42567. private _maxYawSin;
  42568. private _maxYawCos;
  42569. private _midYawConstraint;
  42570. private _minPitchTan;
  42571. private _maxPitchTan;
  42572. private _boneQuat;
  42573. private _slerping;
  42574. private _transformYawPitch;
  42575. private _transformYawPitchInv;
  42576. private _firstFrameSkipped;
  42577. private _yawRange;
  42578. private _fowardAxis;
  42579. /**
  42580. * Gets or sets the minimum yaw angle that the bone can look to
  42581. */
  42582. get minYaw(): number;
  42583. set minYaw(value: number);
  42584. /**
  42585. * Gets or sets the maximum yaw angle that the bone can look to
  42586. */
  42587. get maxYaw(): number;
  42588. set maxYaw(value: number);
  42589. /**
  42590. * Gets or sets the minimum pitch angle that the bone can look to
  42591. */
  42592. get minPitch(): number;
  42593. set minPitch(value: number);
  42594. /**
  42595. * Gets or sets the maximum pitch angle that the bone can look to
  42596. */
  42597. get maxPitch(): number;
  42598. set maxPitch(value: number);
  42599. /**
  42600. * Create a BoneLookController
  42601. * @param mesh the mesh that the bone belongs to
  42602. * @param bone the bone that will be looking to the target
  42603. * @param target the target Vector3 to look at
  42604. * @param options optional settings:
  42605. * * maxYaw: the maximum angle the bone will yaw to
  42606. * * minYaw: the minimum angle the bone will yaw to
  42607. * * maxPitch: the maximum angle the bone will pitch to
  42608. * * minPitch: the minimum angle the bone will yaw to
  42609. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42610. * * upAxis: the up axis of the coordinate system
  42611. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42612. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42613. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42614. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42615. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42616. * * adjustRoll: used to make an adjustment to the roll of the bone
  42617. **/
  42618. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42619. maxYaw?: number;
  42620. minYaw?: number;
  42621. maxPitch?: number;
  42622. minPitch?: number;
  42623. slerpAmount?: number;
  42624. upAxis?: Vector3;
  42625. upAxisSpace?: Space;
  42626. yawAxis?: Vector3;
  42627. pitchAxis?: Vector3;
  42628. adjustYaw?: number;
  42629. adjustPitch?: number;
  42630. adjustRoll?: number;
  42631. });
  42632. /**
  42633. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42634. */
  42635. update(): void;
  42636. private _getAngleDiff;
  42637. private _getAngleBetween;
  42638. private _isAngleBetween;
  42639. }
  42640. }
  42641. declare module BABYLON {
  42642. /**
  42643. * Manage the gamepad inputs to control an arc rotate camera.
  42644. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42645. */
  42646. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42647. /**
  42648. * Defines the camera the input is attached to.
  42649. */
  42650. camera: ArcRotateCamera;
  42651. /**
  42652. * Defines the gamepad the input is gathering event from.
  42653. */
  42654. gamepad: Nullable<Gamepad>;
  42655. /**
  42656. * Defines the gamepad rotation sensiblity.
  42657. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42658. */
  42659. gamepadRotationSensibility: number;
  42660. /**
  42661. * Defines the gamepad move sensiblity.
  42662. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42663. */
  42664. gamepadMoveSensibility: number;
  42665. private _yAxisScale;
  42666. /**
  42667. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42668. */
  42669. get invertYAxis(): boolean;
  42670. set invertYAxis(value: boolean);
  42671. private _onGamepadConnectedObserver;
  42672. private _onGamepadDisconnectedObserver;
  42673. /**
  42674. * Attach the input controls to a specific dom element to get the input from.
  42675. * @param element Defines the element the controls should be listened from
  42676. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42677. */
  42678. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42679. /**
  42680. * Detach the current controls from the specified dom element.
  42681. * @param element Defines the element to stop listening the inputs from
  42682. */
  42683. detachControl(element: Nullable<HTMLElement>): void;
  42684. /**
  42685. * Update the current camera state depending on the inputs that have been used this frame.
  42686. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42687. */
  42688. checkInputs(): void;
  42689. /**
  42690. * Gets the class name of the current intput.
  42691. * @returns the class name
  42692. */
  42693. getClassName(): string;
  42694. /**
  42695. * Get the friendly name associated with the input class.
  42696. * @returns the input friendly name
  42697. */
  42698. getSimpleName(): string;
  42699. }
  42700. }
  42701. declare module BABYLON {
  42702. interface ArcRotateCameraInputsManager {
  42703. /**
  42704. * Add orientation input support to the input manager.
  42705. * @returns the current input manager
  42706. */
  42707. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  42708. }
  42709. /**
  42710. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42712. */
  42713. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42714. /**
  42715. * Defines the camera the input is attached to.
  42716. */
  42717. camera: ArcRotateCamera;
  42718. /**
  42719. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  42720. */
  42721. alphaCorrection: number;
  42722. /**
  42723. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  42724. */
  42725. gammaCorrection: number;
  42726. private _alpha;
  42727. private _gamma;
  42728. private _dirty;
  42729. private _deviceOrientationHandler;
  42730. /**
  42731. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  42732. */
  42733. constructor();
  42734. /**
  42735. * Attach the input controls to a specific dom element to get the input from.
  42736. * @param element Defines the element the controls should be listened from
  42737. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42738. */
  42739. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42740. /** @hidden */
  42741. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  42742. /**
  42743. * Update the current camera state depending on the inputs that have been used this frame.
  42744. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42745. */
  42746. checkInputs(): void;
  42747. /**
  42748. * Detach the current controls from the specified dom element.
  42749. * @param element Defines the element to stop listening the inputs from
  42750. */
  42751. detachControl(element: Nullable<HTMLElement>): void;
  42752. /**
  42753. * Gets the class name of the current intput.
  42754. * @returns the class name
  42755. */
  42756. getClassName(): string;
  42757. /**
  42758. * Get the friendly name associated with the input class.
  42759. * @returns the input friendly name
  42760. */
  42761. getSimpleName(): string;
  42762. }
  42763. }
  42764. declare module BABYLON {
  42765. /**
  42766. * Listen to mouse events to control the camera.
  42767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42768. */
  42769. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  42770. /**
  42771. * Defines the camera the input is attached to.
  42772. */
  42773. camera: FlyCamera;
  42774. /**
  42775. * Defines if touch is enabled. (Default is true.)
  42776. */
  42777. touchEnabled: boolean;
  42778. /**
  42779. * Defines the buttons associated with the input to handle camera rotation.
  42780. */
  42781. buttons: number[];
  42782. /**
  42783. * Assign buttons for Yaw control.
  42784. */
  42785. buttonsYaw: number[];
  42786. /**
  42787. * Assign buttons for Pitch control.
  42788. */
  42789. buttonsPitch: number[];
  42790. /**
  42791. * Assign buttons for Roll control.
  42792. */
  42793. buttonsRoll: number[];
  42794. /**
  42795. * Detect if any button is being pressed while mouse is moved.
  42796. * -1 = Mouse locked.
  42797. * 0 = Left button.
  42798. * 1 = Middle Button.
  42799. * 2 = Right Button.
  42800. */
  42801. activeButton: number;
  42802. /**
  42803. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42804. * Higher values reduce its sensitivity.
  42805. */
  42806. angularSensibility: number;
  42807. private _mousemoveCallback;
  42808. private _observer;
  42809. private _rollObserver;
  42810. private previousPosition;
  42811. private noPreventDefault;
  42812. private element;
  42813. /**
  42814. * Listen to mouse events to control the camera.
  42815. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42816. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42817. */
  42818. constructor(touchEnabled?: boolean);
  42819. /**
  42820. * Attach the mouse control to the HTML DOM element.
  42821. * @param element Defines the element that listens to the input events.
  42822. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  42823. */
  42824. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42825. /**
  42826. * Detach the current controls from the specified dom element.
  42827. * @param element Defines the element to stop listening the inputs from
  42828. */
  42829. detachControl(element: Nullable<HTMLElement>): void;
  42830. /**
  42831. * Gets the class name of the current input.
  42832. * @returns the class name.
  42833. */
  42834. getClassName(): string;
  42835. /**
  42836. * Get the friendly name associated with the input class.
  42837. * @returns the input's friendly name.
  42838. */
  42839. getSimpleName(): string;
  42840. private _pointerInput;
  42841. private _onMouseMove;
  42842. /**
  42843. * Rotate camera by mouse offset.
  42844. */
  42845. private rotateCamera;
  42846. }
  42847. }
  42848. declare module BABYLON {
  42849. /**
  42850. * Default Inputs manager for the FlyCamera.
  42851. * It groups all the default supported inputs for ease of use.
  42852. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42853. */
  42854. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  42855. /**
  42856. * Instantiates a new FlyCameraInputsManager.
  42857. * @param camera Defines the camera the inputs belong to.
  42858. */
  42859. constructor(camera: FlyCamera);
  42860. /**
  42861. * Add keyboard input support to the input manager.
  42862. * @returns the new FlyCameraKeyboardMoveInput().
  42863. */
  42864. addKeyboard(): FlyCameraInputsManager;
  42865. /**
  42866. * Add mouse input support to the input manager.
  42867. * @param touchEnabled Enable touch screen support.
  42868. * @returns the new FlyCameraMouseInput().
  42869. */
  42870. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  42871. }
  42872. }
  42873. declare module BABYLON {
  42874. /**
  42875. * This is a flying camera, designed for 3D movement and rotation in all directions,
  42876. * such as in a 3D Space Shooter or a Flight Simulator.
  42877. */
  42878. export class FlyCamera extends TargetCamera {
  42879. /**
  42880. * Define the collision ellipsoid of the camera.
  42881. * This is helpful for simulating a camera body, like a player's body.
  42882. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42883. */
  42884. ellipsoid: Vector3;
  42885. /**
  42886. * Define an offset for the position of the ellipsoid around the camera.
  42887. * This can be helpful if the camera is attached away from the player's body center,
  42888. * such as at its head.
  42889. */
  42890. ellipsoidOffset: Vector3;
  42891. /**
  42892. * Enable or disable collisions of the camera with the rest of the scene objects.
  42893. */
  42894. checkCollisions: boolean;
  42895. /**
  42896. * Enable or disable gravity on the camera.
  42897. */
  42898. applyGravity: boolean;
  42899. /**
  42900. * Define the current direction the camera is moving to.
  42901. */
  42902. cameraDirection: Vector3;
  42903. /**
  42904. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  42905. * This overrides and empties cameraRotation.
  42906. */
  42907. rotationQuaternion: Quaternion;
  42908. /**
  42909. * Track Roll to maintain the wanted Rolling when looking around.
  42910. */
  42911. _trackRoll: number;
  42912. /**
  42913. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  42914. */
  42915. rollCorrect: number;
  42916. /**
  42917. * Mimic a banked turn, Rolling the camera when Yawing.
  42918. * It's recommended to use rollCorrect = 10 for faster banking correction.
  42919. */
  42920. bankedTurn: boolean;
  42921. /**
  42922. * Limit in radians for how much Roll banking will add. (Default: 90°)
  42923. */
  42924. bankedTurnLimit: number;
  42925. /**
  42926. * Value of 0 disables the banked Roll.
  42927. * Value of 1 is equal to the Yaw angle in radians.
  42928. */
  42929. bankedTurnMultiplier: number;
  42930. /**
  42931. * The inputs manager loads all the input sources, such as keyboard and mouse.
  42932. */
  42933. inputs: FlyCameraInputsManager;
  42934. /**
  42935. * Gets the input sensibility for mouse input.
  42936. * Higher values reduce sensitivity.
  42937. */
  42938. get angularSensibility(): number;
  42939. /**
  42940. * Sets the input sensibility for a mouse input.
  42941. * Higher values reduce sensitivity.
  42942. */
  42943. set angularSensibility(value: number);
  42944. /**
  42945. * Get the keys for camera movement forward.
  42946. */
  42947. get keysForward(): number[];
  42948. /**
  42949. * Set the keys for camera movement forward.
  42950. */
  42951. set keysForward(value: number[]);
  42952. /**
  42953. * Get the keys for camera movement backward.
  42954. */
  42955. get keysBackward(): number[];
  42956. set keysBackward(value: number[]);
  42957. /**
  42958. * Get the keys for camera movement up.
  42959. */
  42960. get keysUp(): number[];
  42961. /**
  42962. * Set the keys for camera movement up.
  42963. */
  42964. set keysUp(value: number[]);
  42965. /**
  42966. * Get the keys for camera movement down.
  42967. */
  42968. get keysDown(): number[];
  42969. /**
  42970. * Set the keys for camera movement down.
  42971. */
  42972. set keysDown(value: number[]);
  42973. /**
  42974. * Get the keys for camera movement left.
  42975. */
  42976. get keysLeft(): number[];
  42977. /**
  42978. * Set the keys for camera movement left.
  42979. */
  42980. set keysLeft(value: number[]);
  42981. /**
  42982. * Set the keys for camera movement right.
  42983. */
  42984. get keysRight(): number[];
  42985. /**
  42986. * Set the keys for camera movement right.
  42987. */
  42988. set keysRight(value: number[]);
  42989. /**
  42990. * Event raised when the camera collides with a mesh in the scene.
  42991. */
  42992. onCollide: (collidedMesh: AbstractMesh) => void;
  42993. private _collider;
  42994. private _needMoveForGravity;
  42995. private _oldPosition;
  42996. private _diffPosition;
  42997. private _newPosition;
  42998. /** @hidden */
  42999. _localDirection: Vector3;
  43000. /** @hidden */
  43001. _transformedDirection: Vector3;
  43002. /**
  43003. * Instantiates a FlyCamera.
  43004. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43005. * such as in a 3D Space Shooter or a Flight Simulator.
  43006. * @param name Define the name of the camera in the scene.
  43007. * @param position Define the starting position of the camera in the scene.
  43008. * @param scene Define the scene the camera belongs to.
  43009. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43010. */
  43011. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43012. /**
  43013. * Attach a control to the HTML DOM element.
  43014. * @param element Defines the element that listens to the input events.
  43015. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43016. */
  43017. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43018. /**
  43019. * Detach a control from the HTML DOM element.
  43020. * The camera will stop reacting to that input.
  43021. * @param element Defines the element that listens to the input events.
  43022. */
  43023. detachControl(element: HTMLElement): void;
  43024. private _collisionMask;
  43025. /**
  43026. * Get the mask that the camera ignores in collision events.
  43027. */
  43028. get collisionMask(): number;
  43029. /**
  43030. * Set the mask that the camera ignores in collision events.
  43031. */
  43032. set collisionMask(mask: number);
  43033. /** @hidden */
  43034. _collideWithWorld(displacement: Vector3): void;
  43035. /** @hidden */
  43036. private _onCollisionPositionChange;
  43037. /** @hidden */
  43038. _checkInputs(): void;
  43039. /** @hidden */
  43040. _decideIfNeedsToMove(): boolean;
  43041. /** @hidden */
  43042. _updatePosition(): void;
  43043. /**
  43044. * Restore the Roll to its target value at the rate specified.
  43045. * @param rate - Higher means slower restoring.
  43046. * @hidden
  43047. */
  43048. restoreRoll(rate: number): void;
  43049. /**
  43050. * Destroy the camera and release the current resources held by it.
  43051. */
  43052. dispose(): void;
  43053. /**
  43054. * Get the current object class name.
  43055. * @returns the class name.
  43056. */
  43057. getClassName(): string;
  43058. }
  43059. }
  43060. declare module BABYLON {
  43061. /**
  43062. * Listen to keyboard events to control the camera.
  43063. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43064. */
  43065. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43066. /**
  43067. * Defines the camera the input is attached to.
  43068. */
  43069. camera: FlyCamera;
  43070. /**
  43071. * The list of keyboard keys used to control the forward move of the camera.
  43072. */
  43073. keysForward: number[];
  43074. /**
  43075. * The list of keyboard keys used to control the backward move of the camera.
  43076. */
  43077. keysBackward: number[];
  43078. /**
  43079. * The list of keyboard keys used to control the forward move of the camera.
  43080. */
  43081. keysUp: number[];
  43082. /**
  43083. * The list of keyboard keys used to control the backward move of the camera.
  43084. */
  43085. keysDown: number[];
  43086. /**
  43087. * The list of keyboard keys used to control the right strafe move of the camera.
  43088. */
  43089. keysRight: number[];
  43090. /**
  43091. * The list of keyboard keys used to control the left strafe move of the camera.
  43092. */
  43093. keysLeft: number[];
  43094. private _keys;
  43095. private _onCanvasBlurObserver;
  43096. private _onKeyboardObserver;
  43097. private _engine;
  43098. private _scene;
  43099. /**
  43100. * Attach the input controls to a specific dom element to get the input from.
  43101. * @param element Defines the element the controls should be listened from
  43102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43103. */
  43104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43105. /**
  43106. * Detach the current controls from the specified dom element.
  43107. * @param element Defines the element to stop listening the inputs from
  43108. */
  43109. detachControl(element: Nullable<HTMLElement>): void;
  43110. /**
  43111. * Gets the class name of the current intput.
  43112. * @returns the class name
  43113. */
  43114. getClassName(): string;
  43115. /** @hidden */
  43116. _onLostFocus(e: FocusEvent): void;
  43117. /**
  43118. * Get the friendly name associated with the input class.
  43119. * @returns the input friendly name
  43120. */
  43121. getSimpleName(): string;
  43122. /**
  43123. * Update the current camera state depending on the inputs that have been used this frame.
  43124. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43125. */
  43126. checkInputs(): void;
  43127. }
  43128. }
  43129. declare module BABYLON {
  43130. /**
  43131. * Manage the mouse wheel inputs to control a follow camera.
  43132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43133. */
  43134. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43135. /**
  43136. * Defines the camera the input is attached to.
  43137. */
  43138. camera: FollowCamera;
  43139. /**
  43140. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43141. */
  43142. axisControlRadius: boolean;
  43143. /**
  43144. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43145. */
  43146. axisControlHeight: boolean;
  43147. /**
  43148. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43149. */
  43150. axisControlRotation: boolean;
  43151. /**
  43152. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43153. * relation to mouseWheel events.
  43154. */
  43155. wheelPrecision: number;
  43156. /**
  43157. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43158. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43159. */
  43160. wheelDeltaPercentage: number;
  43161. private _wheel;
  43162. private _observer;
  43163. /**
  43164. * Attach the input controls to a specific dom element to get the input from.
  43165. * @param element Defines the element the controls should be listened from
  43166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43167. */
  43168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43169. /**
  43170. * Detach the current controls from the specified dom element.
  43171. * @param element Defines the element to stop listening the inputs from
  43172. */
  43173. detachControl(element: Nullable<HTMLElement>): void;
  43174. /**
  43175. * Gets the class name of the current intput.
  43176. * @returns the class name
  43177. */
  43178. getClassName(): string;
  43179. /**
  43180. * Get the friendly name associated with the input class.
  43181. * @returns the input friendly name
  43182. */
  43183. getSimpleName(): string;
  43184. }
  43185. }
  43186. declare module BABYLON {
  43187. /**
  43188. * Manage the pointers inputs to control an follow camera.
  43189. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43190. */
  43191. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43192. /**
  43193. * Defines the camera the input is attached to.
  43194. */
  43195. camera: FollowCamera;
  43196. /**
  43197. * Gets the class name of the current input.
  43198. * @returns the class name
  43199. */
  43200. getClassName(): string;
  43201. /**
  43202. * Defines the pointer angular sensibility along the X axis or how fast is
  43203. * the camera rotating.
  43204. * A negative number will reverse the axis direction.
  43205. */
  43206. angularSensibilityX: number;
  43207. /**
  43208. * Defines the pointer angular sensibility along the Y axis or how fast is
  43209. * the camera rotating.
  43210. * A negative number will reverse the axis direction.
  43211. */
  43212. angularSensibilityY: number;
  43213. /**
  43214. * Defines the pointer pinch precision or how fast is the camera zooming.
  43215. * A negative number will reverse the axis direction.
  43216. */
  43217. pinchPrecision: number;
  43218. /**
  43219. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43220. * from 0.
  43221. * It defines the percentage of current camera.radius to use as delta when
  43222. * pinch zoom is used.
  43223. */
  43224. pinchDeltaPercentage: number;
  43225. /**
  43226. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43227. */
  43228. axisXControlRadius: boolean;
  43229. /**
  43230. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43231. */
  43232. axisXControlHeight: boolean;
  43233. /**
  43234. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43235. */
  43236. axisXControlRotation: boolean;
  43237. /**
  43238. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43239. */
  43240. axisYControlRadius: boolean;
  43241. /**
  43242. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43243. */
  43244. axisYControlHeight: boolean;
  43245. /**
  43246. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43247. */
  43248. axisYControlRotation: boolean;
  43249. /**
  43250. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43251. */
  43252. axisPinchControlRadius: boolean;
  43253. /**
  43254. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43255. */
  43256. axisPinchControlHeight: boolean;
  43257. /**
  43258. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43259. */
  43260. axisPinchControlRotation: boolean;
  43261. /**
  43262. * Log error messages if basic misconfiguration has occurred.
  43263. */
  43264. warningEnable: boolean;
  43265. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43266. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43267. private _warningCounter;
  43268. private _warning;
  43269. }
  43270. }
  43271. declare module BABYLON {
  43272. /**
  43273. * Default Inputs manager for the FollowCamera.
  43274. * It groups all the default supported inputs for ease of use.
  43275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43276. */
  43277. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43278. /**
  43279. * Instantiates a new FollowCameraInputsManager.
  43280. * @param camera Defines the camera the inputs belong to
  43281. */
  43282. constructor(camera: FollowCamera);
  43283. /**
  43284. * Add keyboard input support to the input manager.
  43285. * @returns the current input manager
  43286. */
  43287. addKeyboard(): FollowCameraInputsManager;
  43288. /**
  43289. * Add mouse wheel input support to the input manager.
  43290. * @returns the current input manager
  43291. */
  43292. addMouseWheel(): FollowCameraInputsManager;
  43293. /**
  43294. * Add pointers input support to the input manager.
  43295. * @returns the current input manager
  43296. */
  43297. addPointers(): FollowCameraInputsManager;
  43298. /**
  43299. * Add orientation input support to the input manager.
  43300. * @returns the current input manager
  43301. */
  43302. addVRDeviceOrientation(): FollowCameraInputsManager;
  43303. }
  43304. }
  43305. declare module BABYLON {
  43306. /**
  43307. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43308. * an arc rotate version arcFollowCamera are available.
  43309. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43310. */
  43311. export class FollowCamera extends TargetCamera {
  43312. /**
  43313. * Distance the follow camera should follow an object at
  43314. */
  43315. radius: number;
  43316. /**
  43317. * Minimum allowed distance of the camera to the axis of rotation
  43318. * (The camera can not get closer).
  43319. * This can help limiting how the Camera is able to move in the scene.
  43320. */
  43321. lowerRadiusLimit: Nullable<number>;
  43322. /**
  43323. * Maximum allowed distance of the camera to the axis of rotation
  43324. * (The camera can not get further).
  43325. * This can help limiting how the Camera is able to move in the scene.
  43326. */
  43327. upperRadiusLimit: Nullable<number>;
  43328. /**
  43329. * Define a rotation offset between the camera and the object it follows
  43330. */
  43331. rotationOffset: number;
  43332. /**
  43333. * Minimum allowed angle to camera position relative to target object.
  43334. * This can help limiting how the Camera is able to move in the scene.
  43335. */
  43336. lowerRotationOffsetLimit: Nullable<number>;
  43337. /**
  43338. * Maximum allowed angle to camera position relative to target object.
  43339. * This can help limiting how the Camera is able to move in the scene.
  43340. */
  43341. upperRotationOffsetLimit: Nullable<number>;
  43342. /**
  43343. * Define a height offset between the camera and the object it follows.
  43344. * It can help following an object from the top (like a car chaing a plane)
  43345. */
  43346. heightOffset: number;
  43347. /**
  43348. * Minimum allowed height of camera position relative to target object.
  43349. * This can help limiting how the Camera is able to move in the scene.
  43350. */
  43351. lowerHeightOffsetLimit: Nullable<number>;
  43352. /**
  43353. * Maximum allowed height of camera position relative to target object.
  43354. * This can help limiting how the Camera is able to move in the scene.
  43355. */
  43356. upperHeightOffsetLimit: Nullable<number>;
  43357. /**
  43358. * Define how fast the camera can accelerate to follow it s target.
  43359. */
  43360. cameraAcceleration: number;
  43361. /**
  43362. * Define the speed limit of the camera following an object.
  43363. */
  43364. maxCameraSpeed: number;
  43365. /**
  43366. * Define the target of the camera.
  43367. */
  43368. lockedTarget: Nullable<AbstractMesh>;
  43369. /**
  43370. * Defines the input associated with the camera.
  43371. */
  43372. inputs: FollowCameraInputsManager;
  43373. /**
  43374. * Instantiates the follow camera.
  43375. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43376. * @param name Define the name of the camera in the scene
  43377. * @param position Define the position of the camera
  43378. * @param scene Define the scene the camera belong to
  43379. * @param lockedTarget Define the target of the camera
  43380. */
  43381. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43382. private _follow;
  43383. /**
  43384. * Attached controls to the current camera.
  43385. * @param element Defines the element the controls should be listened from
  43386. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43387. */
  43388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43389. /**
  43390. * Detach the current controls from the camera.
  43391. * The camera will stop reacting to inputs.
  43392. * @param element Defines the element to stop listening the inputs from
  43393. */
  43394. detachControl(element: HTMLElement): void;
  43395. /** @hidden */
  43396. _checkInputs(): void;
  43397. private _checkLimits;
  43398. /**
  43399. * Gets the camera class name.
  43400. * @returns the class name
  43401. */
  43402. getClassName(): string;
  43403. }
  43404. /**
  43405. * Arc Rotate version of the follow camera.
  43406. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43407. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43408. */
  43409. export class ArcFollowCamera extends TargetCamera {
  43410. /** The longitudinal angle of the camera */
  43411. alpha: number;
  43412. /** The latitudinal angle of the camera */
  43413. beta: number;
  43414. /** The radius of the camera from its target */
  43415. radius: number;
  43416. /** Define the camera target (the messh it should follow) */
  43417. target: Nullable<AbstractMesh>;
  43418. private _cartesianCoordinates;
  43419. /**
  43420. * Instantiates a new ArcFollowCamera
  43421. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43422. * @param name Define the name of the camera
  43423. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43424. * @param beta Define the rotation angle of the camera around the elevation axis
  43425. * @param radius Define the radius of the camera from its target point
  43426. * @param target Define the target of the camera
  43427. * @param scene Define the scene the camera belongs to
  43428. */
  43429. constructor(name: string,
  43430. /** The longitudinal angle of the camera */
  43431. alpha: number,
  43432. /** The latitudinal angle of the camera */
  43433. beta: number,
  43434. /** The radius of the camera from its target */
  43435. radius: number,
  43436. /** Define the camera target (the messh it should follow) */
  43437. target: Nullable<AbstractMesh>, scene: Scene);
  43438. private _follow;
  43439. /** @hidden */
  43440. _checkInputs(): void;
  43441. /**
  43442. * Returns the class name of the object.
  43443. * It is mostly used internally for serialization purposes.
  43444. */
  43445. getClassName(): string;
  43446. }
  43447. }
  43448. declare module BABYLON {
  43449. /**
  43450. * Manage the keyboard inputs to control the movement of a follow camera.
  43451. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43452. */
  43453. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43454. /**
  43455. * Defines the camera the input is attached to.
  43456. */
  43457. camera: FollowCamera;
  43458. /**
  43459. * Defines the list of key codes associated with the up action (increase heightOffset)
  43460. */
  43461. keysHeightOffsetIncr: number[];
  43462. /**
  43463. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43464. */
  43465. keysHeightOffsetDecr: number[];
  43466. /**
  43467. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43468. */
  43469. keysHeightOffsetModifierAlt: boolean;
  43470. /**
  43471. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43472. */
  43473. keysHeightOffsetModifierCtrl: boolean;
  43474. /**
  43475. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43476. */
  43477. keysHeightOffsetModifierShift: boolean;
  43478. /**
  43479. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43480. */
  43481. keysRotationOffsetIncr: number[];
  43482. /**
  43483. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43484. */
  43485. keysRotationOffsetDecr: number[];
  43486. /**
  43487. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43488. */
  43489. keysRotationOffsetModifierAlt: boolean;
  43490. /**
  43491. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43492. */
  43493. keysRotationOffsetModifierCtrl: boolean;
  43494. /**
  43495. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43496. */
  43497. keysRotationOffsetModifierShift: boolean;
  43498. /**
  43499. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43500. */
  43501. keysRadiusIncr: number[];
  43502. /**
  43503. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43504. */
  43505. keysRadiusDecr: number[];
  43506. /**
  43507. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43508. */
  43509. keysRadiusModifierAlt: boolean;
  43510. /**
  43511. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43512. */
  43513. keysRadiusModifierCtrl: boolean;
  43514. /**
  43515. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43516. */
  43517. keysRadiusModifierShift: boolean;
  43518. /**
  43519. * Defines the rate of change of heightOffset.
  43520. */
  43521. heightSensibility: number;
  43522. /**
  43523. * Defines the rate of change of rotationOffset.
  43524. */
  43525. rotationSensibility: number;
  43526. /**
  43527. * Defines the rate of change of radius.
  43528. */
  43529. radiusSensibility: number;
  43530. private _keys;
  43531. private _ctrlPressed;
  43532. private _altPressed;
  43533. private _shiftPressed;
  43534. private _onCanvasBlurObserver;
  43535. private _onKeyboardObserver;
  43536. private _engine;
  43537. private _scene;
  43538. /**
  43539. * Attach the input controls to a specific dom element to get the input from.
  43540. * @param element Defines the element the controls should be listened from
  43541. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43542. */
  43543. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43544. /**
  43545. * Detach the current controls from the specified dom element.
  43546. * @param element Defines the element to stop listening the inputs from
  43547. */
  43548. detachControl(element: Nullable<HTMLElement>): void;
  43549. /**
  43550. * Update the current camera state depending on the inputs that have been used this frame.
  43551. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43552. */
  43553. checkInputs(): void;
  43554. /**
  43555. * Gets the class name of the current input.
  43556. * @returns the class name
  43557. */
  43558. getClassName(): string;
  43559. /**
  43560. * Get the friendly name associated with the input class.
  43561. * @returns the input friendly name
  43562. */
  43563. getSimpleName(): string;
  43564. /**
  43565. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43566. * allow modification of the heightOffset value.
  43567. */
  43568. private _modifierHeightOffset;
  43569. /**
  43570. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43571. * allow modification of the rotationOffset value.
  43572. */
  43573. private _modifierRotationOffset;
  43574. /**
  43575. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43576. * allow modification of the radius value.
  43577. */
  43578. private _modifierRadius;
  43579. }
  43580. }
  43581. declare module BABYLON {
  43582. interface FreeCameraInputsManager {
  43583. /**
  43584. * @hidden
  43585. */
  43586. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43587. /**
  43588. * Add orientation input support to the input manager.
  43589. * @returns the current input manager
  43590. */
  43591. addDeviceOrientation(): FreeCameraInputsManager;
  43592. }
  43593. /**
  43594. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43595. * Screen rotation is taken into account.
  43596. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43597. */
  43598. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43599. private _camera;
  43600. private _screenOrientationAngle;
  43601. private _constantTranform;
  43602. private _screenQuaternion;
  43603. private _alpha;
  43604. private _beta;
  43605. private _gamma;
  43606. /**
  43607. * Can be used to detect if a device orientation sensor is available on a device
  43608. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43609. * @returns a promise that will resolve on orientation change
  43610. */
  43611. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43612. /**
  43613. * @hidden
  43614. */
  43615. _onDeviceOrientationChangedObservable: Observable<void>;
  43616. /**
  43617. * Instantiates a new input
  43618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43619. */
  43620. constructor();
  43621. /**
  43622. * Define the camera controlled by the input.
  43623. */
  43624. get camera(): FreeCamera;
  43625. set camera(camera: FreeCamera);
  43626. /**
  43627. * Attach the input controls to a specific dom element to get the input from.
  43628. * @param element Defines the element the controls should be listened from
  43629. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43630. */
  43631. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43632. private _orientationChanged;
  43633. private _deviceOrientation;
  43634. /**
  43635. * Detach the current controls from the specified dom element.
  43636. * @param element Defines the element to stop listening the inputs from
  43637. */
  43638. detachControl(element: Nullable<HTMLElement>): void;
  43639. /**
  43640. * Update the current camera state depending on the inputs that have been used this frame.
  43641. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43642. */
  43643. checkInputs(): void;
  43644. /**
  43645. * Gets the class name of the current intput.
  43646. * @returns the class name
  43647. */
  43648. getClassName(): string;
  43649. /**
  43650. * Get the friendly name associated with the input class.
  43651. * @returns the input friendly name
  43652. */
  43653. getSimpleName(): string;
  43654. }
  43655. }
  43656. declare module BABYLON {
  43657. /**
  43658. * Manage the gamepad inputs to control a free camera.
  43659. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43660. */
  43661. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43662. /**
  43663. * Define the camera the input is attached to.
  43664. */
  43665. camera: FreeCamera;
  43666. /**
  43667. * Define the Gamepad controlling the input
  43668. */
  43669. gamepad: Nullable<Gamepad>;
  43670. /**
  43671. * Defines the gamepad rotation sensiblity.
  43672. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43673. */
  43674. gamepadAngularSensibility: number;
  43675. /**
  43676. * Defines the gamepad move sensiblity.
  43677. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43678. */
  43679. gamepadMoveSensibility: number;
  43680. private _yAxisScale;
  43681. /**
  43682. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43683. */
  43684. get invertYAxis(): boolean;
  43685. set invertYAxis(value: boolean);
  43686. private _onGamepadConnectedObserver;
  43687. private _onGamepadDisconnectedObserver;
  43688. private _cameraTransform;
  43689. private _deltaTransform;
  43690. private _vector3;
  43691. private _vector2;
  43692. /**
  43693. * Attach the input controls to a specific dom element to get the input from.
  43694. * @param element Defines the element the controls should be listened from
  43695. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43696. */
  43697. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43698. /**
  43699. * Detach the current controls from the specified dom element.
  43700. * @param element Defines the element to stop listening the inputs from
  43701. */
  43702. detachControl(element: Nullable<HTMLElement>): void;
  43703. /**
  43704. * Update the current camera state depending on the inputs that have been used this frame.
  43705. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43706. */
  43707. checkInputs(): void;
  43708. /**
  43709. * Gets the class name of the current intput.
  43710. * @returns the class name
  43711. */
  43712. getClassName(): string;
  43713. /**
  43714. * Get the friendly name associated with the input class.
  43715. * @returns the input friendly name
  43716. */
  43717. getSimpleName(): string;
  43718. }
  43719. }
  43720. declare module BABYLON {
  43721. /**
  43722. * Defines the potential axis of a Joystick
  43723. */
  43724. export enum JoystickAxis {
  43725. /** X axis */
  43726. X = 0,
  43727. /** Y axis */
  43728. Y = 1,
  43729. /** Z axis */
  43730. Z = 2
  43731. }
  43732. /**
  43733. * Class used to define virtual joystick (used in touch mode)
  43734. */
  43735. export class VirtualJoystick {
  43736. /**
  43737. * Gets or sets a boolean indicating that left and right values must be inverted
  43738. */
  43739. reverseLeftRight: boolean;
  43740. /**
  43741. * Gets or sets a boolean indicating that up and down values must be inverted
  43742. */
  43743. reverseUpDown: boolean;
  43744. /**
  43745. * Gets the offset value for the position (ie. the change of the position value)
  43746. */
  43747. deltaPosition: Vector3;
  43748. /**
  43749. * Gets a boolean indicating if the virtual joystick was pressed
  43750. */
  43751. pressed: boolean;
  43752. /**
  43753. * Canvas the virtual joystick will render onto, default z-index of this is 5
  43754. */
  43755. static Canvas: Nullable<HTMLCanvasElement>;
  43756. private static _globalJoystickIndex;
  43757. private static vjCanvasContext;
  43758. private static vjCanvasWidth;
  43759. private static vjCanvasHeight;
  43760. private static halfWidth;
  43761. private _action;
  43762. private _axisTargetedByLeftAndRight;
  43763. private _axisTargetedByUpAndDown;
  43764. private _joystickSensibility;
  43765. private _inversedSensibility;
  43766. private _joystickPointerID;
  43767. private _joystickColor;
  43768. private _joystickPointerPos;
  43769. private _joystickPreviousPointerPos;
  43770. private _joystickPointerStartPos;
  43771. private _deltaJoystickVector;
  43772. private _leftJoystick;
  43773. private _touches;
  43774. private _onPointerDownHandlerRef;
  43775. private _onPointerMoveHandlerRef;
  43776. private _onPointerUpHandlerRef;
  43777. private _onResize;
  43778. /**
  43779. * Creates a new virtual joystick
  43780. * @param leftJoystick defines that the joystick is for left hand (false by default)
  43781. */
  43782. constructor(leftJoystick?: boolean);
  43783. /**
  43784. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  43785. * @param newJoystickSensibility defines the new sensibility
  43786. */
  43787. setJoystickSensibility(newJoystickSensibility: number): void;
  43788. private _onPointerDown;
  43789. private _onPointerMove;
  43790. private _onPointerUp;
  43791. /**
  43792. * Change the color of the virtual joystick
  43793. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  43794. */
  43795. setJoystickColor(newColor: string): void;
  43796. /**
  43797. * Defines a callback to call when the joystick is touched
  43798. * @param action defines the callback
  43799. */
  43800. setActionOnTouch(action: () => any): void;
  43801. /**
  43802. * Defines which axis you'd like to control for left & right
  43803. * @param axis defines the axis to use
  43804. */
  43805. setAxisForLeftRight(axis: JoystickAxis): void;
  43806. /**
  43807. * Defines which axis you'd like to control for up & down
  43808. * @param axis defines the axis to use
  43809. */
  43810. setAxisForUpDown(axis: JoystickAxis): void;
  43811. private _drawVirtualJoystick;
  43812. /**
  43813. * Release internal HTML canvas
  43814. */
  43815. releaseCanvas(): void;
  43816. }
  43817. }
  43818. declare module BABYLON {
  43819. interface FreeCameraInputsManager {
  43820. /**
  43821. * Add virtual joystick input support to the input manager.
  43822. * @returns the current input manager
  43823. */
  43824. addVirtualJoystick(): FreeCameraInputsManager;
  43825. }
  43826. /**
  43827. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  43828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43829. */
  43830. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  43831. /**
  43832. * Defines the camera the input is attached to.
  43833. */
  43834. camera: FreeCamera;
  43835. private _leftjoystick;
  43836. private _rightjoystick;
  43837. /**
  43838. * Gets the left stick of the virtual joystick.
  43839. * @returns The virtual Joystick
  43840. */
  43841. getLeftJoystick(): VirtualJoystick;
  43842. /**
  43843. * Gets the right stick of the virtual joystick.
  43844. * @returns The virtual Joystick
  43845. */
  43846. getRightJoystick(): VirtualJoystick;
  43847. /**
  43848. * Update the current camera state depending on the inputs that have been used this frame.
  43849. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43850. */
  43851. checkInputs(): void;
  43852. /**
  43853. * Attach the input controls to a specific dom element to get the input from.
  43854. * @param element Defines the element the controls should be listened from
  43855. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43856. */
  43857. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43858. /**
  43859. * Detach the current controls from the specified dom element.
  43860. * @param element Defines the element to stop listening the inputs from
  43861. */
  43862. detachControl(element: Nullable<HTMLElement>): void;
  43863. /**
  43864. * Gets the class name of the current intput.
  43865. * @returns the class name
  43866. */
  43867. getClassName(): string;
  43868. /**
  43869. * Get the friendly name associated with the input class.
  43870. * @returns the input friendly name
  43871. */
  43872. getSimpleName(): string;
  43873. }
  43874. }
  43875. declare module BABYLON {
  43876. /**
  43877. * This represents a FPS type of camera controlled by touch.
  43878. * This is like a universal camera minus the Gamepad controls.
  43879. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43880. */
  43881. export class TouchCamera extends FreeCamera {
  43882. /**
  43883. * Defines the touch sensibility for rotation.
  43884. * The higher the faster.
  43885. */
  43886. get touchAngularSensibility(): number;
  43887. set touchAngularSensibility(value: number);
  43888. /**
  43889. * Defines the touch sensibility for move.
  43890. * The higher the faster.
  43891. */
  43892. get touchMoveSensibility(): number;
  43893. set touchMoveSensibility(value: number);
  43894. /**
  43895. * Instantiates a new touch camera.
  43896. * This represents a FPS type of camera controlled by touch.
  43897. * This is like a universal camera minus the Gamepad controls.
  43898. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43899. * @param name Define the name of the camera in the scene
  43900. * @param position Define the start position of the camera in the scene
  43901. * @param scene Define the scene the camera belongs to
  43902. */
  43903. constructor(name: string, position: Vector3, scene: Scene);
  43904. /**
  43905. * Gets the current object class name.
  43906. * @return the class name
  43907. */
  43908. getClassName(): string;
  43909. /** @hidden */
  43910. _setupInputs(): void;
  43911. }
  43912. }
  43913. declare module BABYLON {
  43914. /**
  43915. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  43916. * being tilted forward or back and left or right.
  43917. */
  43918. export class DeviceOrientationCamera extends FreeCamera {
  43919. private _initialQuaternion;
  43920. private _quaternionCache;
  43921. private _tmpDragQuaternion;
  43922. private _disablePointerInputWhenUsingDeviceOrientation;
  43923. /**
  43924. * Creates a new device orientation camera
  43925. * @param name The name of the camera
  43926. * @param position The start position camera
  43927. * @param scene The scene the camera belongs to
  43928. */
  43929. constructor(name: string, position: Vector3, scene: Scene);
  43930. /**
  43931. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  43932. */
  43933. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  43934. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  43935. private _dragFactor;
  43936. /**
  43937. * Enabled turning on the y axis when the orientation sensor is active
  43938. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  43939. */
  43940. enableHorizontalDragging(dragFactor?: number): void;
  43941. /**
  43942. * Gets the current instance class name ("DeviceOrientationCamera").
  43943. * This helps avoiding instanceof at run time.
  43944. * @returns the class name
  43945. */
  43946. getClassName(): string;
  43947. /**
  43948. * @hidden
  43949. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  43950. */
  43951. _checkInputs(): void;
  43952. /**
  43953. * Reset the camera to its default orientation on the specified axis only.
  43954. * @param axis The axis to reset
  43955. */
  43956. resetToCurrentRotation(axis?: Axis): void;
  43957. }
  43958. }
  43959. declare module BABYLON {
  43960. /**
  43961. * Defines supported buttons for XBox360 compatible gamepads
  43962. */
  43963. export enum Xbox360Button {
  43964. /** A */
  43965. A = 0,
  43966. /** B */
  43967. B = 1,
  43968. /** X */
  43969. X = 2,
  43970. /** Y */
  43971. Y = 3,
  43972. /** Left button */
  43973. LB = 4,
  43974. /** Right button */
  43975. RB = 5,
  43976. /** Back */
  43977. Back = 8,
  43978. /** Start */
  43979. Start = 9,
  43980. /** Left stick */
  43981. LeftStick = 10,
  43982. /** Right stick */
  43983. RightStick = 11
  43984. }
  43985. /** Defines values for XBox360 DPad */
  43986. export enum Xbox360Dpad {
  43987. /** Up */
  43988. Up = 12,
  43989. /** Down */
  43990. Down = 13,
  43991. /** Left */
  43992. Left = 14,
  43993. /** Right */
  43994. Right = 15
  43995. }
  43996. /**
  43997. * Defines a XBox360 gamepad
  43998. */
  43999. export class Xbox360Pad extends Gamepad {
  44000. private _leftTrigger;
  44001. private _rightTrigger;
  44002. private _onlefttriggerchanged;
  44003. private _onrighttriggerchanged;
  44004. private _onbuttondown;
  44005. private _onbuttonup;
  44006. private _ondpaddown;
  44007. private _ondpadup;
  44008. /** Observable raised when a button is pressed */
  44009. onButtonDownObservable: Observable<Xbox360Button>;
  44010. /** Observable raised when a button is released */
  44011. onButtonUpObservable: Observable<Xbox360Button>;
  44012. /** Observable raised when a pad is pressed */
  44013. onPadDownObservable: Observable<Xbox360Dpad>;
  44014. /** Observable raised when a pad is released */
  44015. onPadUpObservable: Observable<Xbox360Dpad>;
  44016. private _buttonA;
  44017. private _buttonB;
  44018. private _buttonX;
  44019. private _buttonY;
  44020. private _buttonBack;
  44021. private _buttonStart;
  44022. private _buttonLB;
  44023. private _buttonRB;
  44024. private _buttonLeftStick;
  44025. private _buttonRightStick;
  44026. private _dPadUp;
  44027. private _dPadDown;
  44028. private _dPadLeft;
  44029. private _dPadRight;
  44030. private _isXboxOnePad;
  44031. /**
  44032. * Creates a new XBox360 gamepad object
  44033. * @param id defines the id of this gamepad
  44034. * @param index defines its index
  44035. * @param gamepad defines the internal HTML gamepad object
  44036. * @param xboxOne defines if it is a XBox One gamepad
  44037. */
  44038. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44039. /**
  44040. * Defines the callback to call when left trigger is pressed
  44041. * @param callback defines the callback to use
  44042. */
  44043. onlefttriggerchanged(callback: (value: number) => void): void;
  44044. /**
  44045. * Defines the callback to call when right trigger is pressed
  44046. * @param callback defines the callback to use
  44047. */
  44048. onrighttriggerchanged(callback: (value: number) => void): void;
  44049. /**
  44050. * Gets the left trigger value
  44051. */
  44052. get leftTrigger(): number;
  44053. /**
  44054. * Sets the left trigger value
  44055. */
  44056. set leftTrigger(newValue: number);
  44057. /**
  44058. * Gets the right trigger value
  44059. */
  44060. get rightTrigger(): number;
  44061. /**
  44062. * Sets the right trigger value
  44063. */
  44064. set rightTrigger(newValue: number);
  44065. /**
  44066. * Defines the callback to call when a button is pressed
  44067. * @param callback defines the callback to use
  44068. */
  44069. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44070. /**
  44071. * Defines the callback to call when a button is released
  44072. * @param callback defines the callback to use
  44073. */
  44074. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44075. /**
  44076. * Defines the callback to call when a pad is pressed
  44077. * @param callback defines the callback to use
  44078. */
  44079. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44080. /**
  44081. * Defines the callback to call when a pad is released
  44082. * @param callback defines the callback to use
  44083. */
  44084. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44085. private _setButtonValue;
  44086. private _setDPadValue;
  44087. /**
  44088. * Gets the value of the `A` button
  44089. */
  44090. get buttonA(): number;
  44091. /**
  44092. * Sets the value of the `A` button
  44093. */
  44094. set buttonA(value: number);
  44095. /**
  44096. * Gets the value of the `B` button
  44097. */
  44098. get buttonB(): number;
  44099. /**
  44100. * Sets the value of the `B` button
  44101. */
  44102. set buttonB(value: number);
  44103. /**
  44104. * Gets the value of the `X` button
  44105. */
  44106. get buttonX(): number;
  44107. /**
  44108. * Sets the value of the `X` button
  44109. */
  44110. set buttonX(value: number);
  44111. /**
  44112. * Gets the value of the `Y` button
  44113. */
  44114. get buttonY(): number;
  44115. /**
  44116. * Sets the value of the `Y` button
  44117. */
  44118. set buttonY(value: number);
  44119. /**
  44120. * Gets the value of the `Start` button
  44121. */
  44122. get buttonStart(): number;
  44123. /**
  44124. * Sets the value of the `Start` button
  44125. */
  44126. set buttonStart(value: number);
  44127. /**
  44128. * Gets the value of the `Back` button
  44129. */
  44130. get buttonBack(): number;
  44131. /**
  44132. * Sets the value of the `Back` button
  44133. */
  44134. set buttonBack(value: number);
  44135. /**
  44136. * Gets the value of the `Left` button
  44137. */
  44138. get buttonLB(): number;
  44139. /**
  44140. * Sets the value of the `Left` button
  44141. */
  44142. set buttonLB(value: number);
  44143. /**
  44144. * Gets the value of the `Right` button
  44145. */
  44146. get buttonRB(): number;
  44147. /**
  44148. * Sets the value of the `Right` button
  44149. */
  44150. set buttonRB(value: number);
  44151. /**
  44152. * Gets the value of the Left joystick
  44153. */
  44154. get buttonLeftStick(): number;
  44155. /**
  44156. * Sets the value of the Left joystick
  44157. */
  44158. set buttonLeftStick(value: number);
  44159. /**
  44160. * Gets the value of the Right joystick
  44161. */
  44162. get buttonRightStick(): number;
  44163. /**
  44164. * Sets the value of the Right joystick
  44165. */
  44166. set buttonRightStick(value: number);
  44167. /**
  44168. * Gets the value of D-pad up
  44169. */
  44170. get dPadUp(): number;
  44171. /**
  44172. * Sets the value of D-pad up
  44173. */
  44174. set dPadUp(value: number);
  44175. /**
  44176. * Gets the value of D-pad down
  44177. */
  44178. get dPadDown(): number;
  44179. /**
  44180. * Sets the value of D-pad down
  44181. */
  44182. set dPadDown(value: number);
  44183. /**
  44184. * Gets the value of D-pad left
  44185. */
  44186. get dPadLeft(): number;
  44187. /**
  44188. * Sets the value of D-pad left
  44189. */
  44190. set dPadLeft(value: number);
  44191. /**
  44192. * Gets the value of D-pad right
  44193. */
  44194. get dPadRight(): number;
  44195. /**
  44196. * Sets the value of D-pad right
  44197. */
  44198. set dPadRight(value: number);
  44199. /**
  44200. * Force the gamepad to synchronize with device values
  44201. */
  44202. update(): void;
  44203. /**
  44204. * Disposes the gamepad
  44205. */
  44206. dispose(): void;
  44207. }
  44208. }
  44209. declare module BABYLON {
  44210. /**
  44211. * Defines supported buttons for DualShock compatible gamepads
  44212. */
  44213. export enum DualShockButton {
  44214. /** Cross */
  44215. Cross = 0,
  44216. /** Circle */
  44217. Circle = 1,
  44218. /** Square */
  44219. Square = 2,
  44220. /** Triangle */
  44221. Triangle = 3,
  44222. /** L1 */
  44223. L1 = 4,
  44224. /** R1 */
  44225. R1 = 5,
  44226. /** Share */
  44227. Share = 8,
  44228. /** Options */
  44229. Options = 9,
  44230. /** Left stick */
  44231. LeftStick = 10,
  44232. /** Right stick */
  44233. RightStick = 11
  44234. }
  44235. /** Defines values for DualShock DPad */
  44236. export enum DualShockDpad {
  44237. /** Up */
  44238. Up = 12,
  44239. /** Down */
  44240. Down = 13,
  44241. /** Left */
  44242. Left = 14,
  44243. /** Right */
  44244. Right = 15
  44245. }
  44246. /**
  44247. * Defines a DualShock gamepad
  44248. */
  44249. export class DualShockPad extends Gamepad {
  44250. private _leftTrigger;
  44251. private _rightTrigger;
  44252. private _onlefttriggerchanged;
  44253. private _onrighttriggerchanged;
  44254. private _onbuttondown;
  44255. private _onbuttonup;
  44256. private _ondpaddown;
  44257. private _ondpadup;
  44258. /** Observable raised when a button is pressed */
  44259. onButtonDownObservable: Observable<DualShockButton>;
  44260. /** Observable raised when a button is released */
  44261. onButtonUpObservable: Observable<DualShockButton>;
  44262. /** Observable raised when a pad is pressed */
  44263. onPadDownObservable: Observable<DualShockDpad>;
  44264. /** Observable raised when a pad is released */
  44265. onPadUpObservable: Observable<DualShockDpad>;
  44266. private _buttonCross;
  44267. private _buttonCircle;
  44268. private _buttonSquare;
  44269. private _buttonTriangle;
  44270. private _buttonShare;
  44271. private _buttonOptions;
  44272. private _buttonL1;
  44273. private _buttonR1;
  44274. private _buttonLeftStick;
  44275. private _buttonRightStick;
  44276. private _dPadUp;
  44277. private _dPadDown;
  44278. private _dPadLeft;
  44279. private _dPadRight;
  44280. /**
  44281. * Creates a new DualShock gamepad object
  44282. * @param id defines the id of this gamepad
  44283. * @param index defines its index
  44284. * @param gamepad defines the internal HTML gamepad object
  44285. */
  44286. constructor(id: string, index: number, gamepad: any);
  44287. /**
  44288. * Defines the callback to call when left trigger is pressed
  44289. * @param callback defines the callback to use
  44290. */
  44291. onlefttriggerchanged(callback: (value: number) => void): void;
  44292. /**
  44293. * Defines the callback to call when right trigger is pressed
  44294. * @param callback defines the callback to use
  44295. */
  44296. onrighttriggerchanged(callback: (value: number) => void): void;
  44297. /**
  44298. * Gets the left trigger value
  44299. */
  44300. get leftTrigger(): number;
  44301. /**
  44302. * Sets the left trigger value
  44303. */
  44304. set leftTrigger(newValue: number);
  44305. /**
  44306. * Gets the right trigger value
  44307. */
  44308. get rightTrigger(): number;
  44309. /**
  44310. * Sets the right trigger value
  44311. */
  44312. set rightTrigger(newValue: number);
  44313. /**
  44314. * Defines the callback to call when a button is pressed
  44315. * @param callback defines the callback to use
  44316. */
  44317. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44318. /**
  44319. * Defines the callback to call when a button is released
  44320. * @param callback defines the callback to use
  44321. */
  44322. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44323. /**
  44324. * Defines the callback to call when a pad is pressed
  44325. * @param callback defines the callback to use
  44326. */
  44327. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44328. /**
  44329. * Defines the callback to call when a pad is released
  44330. * @param callback defines the callback to use
  44331. */
  44332. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44333. private _setButtonValue;
  44334. private _setDPadValue;
  44335. /**
  44336. * Gets the value of the `Cross` button
  44337. */
  44338. get buttonCross(): number;
  44339. /**
  44340. * Sets the value of the `Cross` button
  44341. */
  44342. set buttonCross(value: number);
  44343. /**
  44344. * Gets the value of the `Circle` button
  44345. */
  44346. get buttonCircle(): number;
  44347. /**
  44348. * Sets the value of the `Circle` button
  44349. */
  44350. set buttonCircle(value: number);
  44351. /**
  44352. * Gets the value of the `Square` button
  44353. */
  44354. get buttonSquare(): number;
  44355. /**
  44356. * Sets the value of the `Square` button
  44357. */
  44358. set buttonSquare(value: number);
  44359. /**
  44360. * Gets the value of the `Triangle` button
  44361. */
  44362. get buttonTriangle(): number;
  44363. /**
  44364. * Sets the value of the `Triangle` button
  44365. */
  44366. set buttonTriangle(value: number);
  44367. /**
  44368. * Gets the value of the `Options` button
  44369. */
  44370. get buttonOptions(): number;
  44371. /**
  44372. * Sets the value of the `Options` button
  44373. */
  44374. set buttonOptions(value: number);
  44375. /**
  44376. * Gets the value of the `Share` button
  44377. */
  44378. get buttonShare(): number;
  44379. /**
  44380. * Sets the value of the `Share` button
  44381. */
  44382. set buttonShare(value: number);
  44383. /**
  44384. * Gets the value of the `L1` button
  44385. */
  44386. get buttonL1(): number;
  44387. /**
  44388. * Sets the value of the `L1` button
  44389. */
  44390. set buttonL1(value: number);
  44391. /**
  44392. * Gets the value of the `R1` button
  44393. */
  44394. get buttonR1(): number;
  44395. /**
  44396. * Sets the value of the `R1` button
  44397. */
  44398. set buttonR1(value: number);
  44399. /**
  44400. * Gets the value of the Left joystick
  44401. */
  44402. get buttonLeftStick(): number;
  44403. /**
  44404. * Sets the value of the Left joystick
  44405. */
  44406. set buttonLeftStick(value: number);
  44407. /**
  44408. * Gets the value of the Right joystick
  44409. */
  44410. get buttonRightStick(): number;
  44411. /**
  44412. * Sets the value of the Right joystick
  44413. */
  44414. set buttonRightStick(value: number);
  44415. /**
  44416. * Gets the value of D-pad up
  44417. */
  44418. get dPadUp(): number;
  44419. /**
  44420. * Sets the value of D-pad up
  44421. */
  44422. set dPadUp(value: number);
  44423. /**
  44424. * Gets the value of D-pad down
  44425. */
  44426. get dPadDown(): number;
  44427. /**
  44428. * Sets the value of D-pad down
  44429. */
  44430. set dPadDown(value: number);
  44431. /**
  44432. * Gets the value of D-pad left
  44433. */
  44434. get dPadLeft(): number;
  44435. /**
  44436. * Sets the value of D-pad left
  44437. */
  44438. set dPadLeft(value: number);
  44439. /**
  44440. * Gets the value of D-pad right
  44441. */
  44442. get dPadRight(): number;
  44443. /**
  44444. * Sets the value of D-pad right
  44445. */
  44446. set dPadRight(value: number);
  44447. /**
  44448. * Force the gamepad to synchronize with device values
  44449. */
  44450. update(): void;
  44451. /**
  44452. * Disposes the gamepad
  44453. */
  44454. dispose(): void;
  44455. }
  44456. }
  44457. declare module BABYLON {
  44458. /**
  44459. * Manager for handling gamepads
  44460. */
  44461. export class GamepadManager {
  44462. private _scene?;
  44463. private _babylonGamepads;
  44464. private _oneGamepadConnected;
  44465. /** @hidden */
  44466. _isMonitoring: boolean;
  44467. private _gamepadEventSupported;
  44468. private _gamepadSupport?;
  44469. /**
  44470. * observable to be triggered when the gamepad controller has been connected
  44471. */
  44472. onGamepadConnectedObservable: Observable<Gamepad>;
  44473. /**
  44474. * observable to be triggered when the gamepad controller has been disconnected
  44475. */
  44476. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44477. private _onGamepadConnectedEvent;
  44478. private _onGamepadDisconnectedEvent;
  44479. /**
  44480. * Initializes the gamepad manager
  44481. * @param _scene BabylonJS scene
  44482. */
  44483. constructor(_scene?: Scene | undefined);
  44484. /**
  44485. * The gamepads in the game pad manager
  44486. */
  44487. get gamepads(): Gamepad[];
  44488. /**
  44489. * Get the gamepad controllers based on type
  44490. * @param type The type of gamepad controller
  44491. * @returns Nullable gamepad
  44492. */
  44493. getGamepadByType(type?: number): Nullable<Gamepad>;
  44494. /**
  44495. * Disposes the gamepad manager
  44496. */
  44497. dispose(): void;
  44498. private _addNewGamepad;
  44499. private _startMonitoringGamepads;
  44500. private _stopMonitoringGamepads;
  44501. /** @hidden */
  44502. _checkGamepadsStatus(): void;
  44503. private _updateGamepadObjects;
  44504. }
  44505. }
  44506. declare module BABYLON {
  44507. interface Scene {
  44508. /** @hidden */
  44509. _gamepadManager: Nullable<GamepadManager>;
  44510. /**
  44511. * Gets the gamepad manager associated with the scene
  44512. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44513. */
  44514. gamepadManager: GamepadManager;
  44515. }
  44516. /**
  44517. * Interface representing a free camera inputs manager
  44518. */
  44519. interface FreeCameraInputsManager {
  44520. /**
  44521. * Adds gamepad input support to the FreeCameraInputsManager.
  44522. * @returns the FreeCameraInputsManager
  44523. */
  44524. addGamepad(): FreeCameraInputsManager;
  44525. }
  44526. /**
  44527. * Interface representing an arc rotate camera inputs manager
  44528. */
  44529. interface ArcRotateCameraInputsManager {
  44530. /**
  44531. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44532. * @returns the camera inputs manager
  44533. */
  44534. addGamepad(): ArcRotateCameraInputsManager;
  44535. }
  44536. /**
  44537. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44538. */
  44539. export class GamepadSystemSceneComponent implements ISceneComponent {
  44540. /**
  44541. * The component name helpfull to identify the component in the list of scene components.
  44542. */
  44543. readonly name: string;
  44544. /**
  44545. * The scene the component belongs to.
  44546. */
  44547. scene: Scene;
  44548. /**
  44549. * Creates a new instance of the component for the given scene
  44550. * @param scene Defines the scene to register the component in
  44551. */
  44552. constructor(scene: Scene);
  44553. /**
  44554. * Registers the component in a given scene
  44555. */
  44556. register(): void;
  44557. /**
  44558. * Rebuilds the elements related to this component in case of
  44559. * context lost for instance.
  44560. */
  44561. rebuild(): void;
  44562. /**
  44563. * Disposes the component and the associated ressources
  44564. */
  44565. dispose(): void;
  44566. private _beforeCameraUpdate;
  44567. }
  44568. }
  44569. declare module BABYLON {
  44570. /**
  44571. * 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,
  44572. * which still works and will still be found in many Playgrounds.
  44573. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44574. */
  44575. export class UniversalCamera extends TouchCamera {
  44576. /**
  44577. * Defines the gamepad rotation sensiblity.
  44578. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44579. */
  44580. get gamepadAngularSensibility(): number;
  44581. set gamepadAngularSensibility(value: number);
  44582. /**
  44583. * Defines the gamepad move sensiblity.
  44584. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44585. */
  44586. get gamepadMoveSensibility(): number;
  44587. set gamepadMoveSensibility(value: number);
  44588. /**
  44589. * 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,
  44590. * which still works and will still be found in many Playgrounds.
  44591. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44592. * @param name Define the name of the camera in the scene
  44593. * @param position Define the start position of the camera in the scene
  44594. * @param scene Define the scene the camera belongs to
  44595. */
  44596. constructor(name: string, position: Vector3, scene: Scene);
  44597. /**
  44598. * Gets the current object class name.
  44599. * @return the class name
  44600. */
  44601. getClassName(): string;
  44602. }
  44603. }
  44604. declare module BABYLON {
  44605. /**
  44606. * This represents a FPS type of camera. This is only here for back compat purpose.
  44607. * Please use the UniversalCamera instead as both are identical.
  44608. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44609. */
  44610. export class GamepadCamera extends UniversalCamera {
  44611. /**
  44612. * Instantiates a new Gamepad Camera
  44613. * This represents a FPS type of camera. This is only here for back compat purpose.
  44614. * Please use the UniversalCamera instead as both are identical.
  44615. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44616. * @param name Define the name of the camera in the scene
  44617. * @param position Define the start position of the camera in the scene
  44618. * @param scene Define the scene the camera belongs to
  44619. */
  44620. constructor(name: string, position: Vector3, scene: Scene);
  44621. /**
  44622. * Gets the current object class name.
  44623. * @return the class name
  44624. */
  44625. getClassName(): string;
  44626. }
  44627. }
  44628. declare module BABYLON {
  44629. /** @hidden */
  44630. export var passPixelShader: {
  44631. name: string;
  44632. shader: string;
  44633. };
  44634. }
  44635. declare module BABYLON {
  44636. /** @hidden */
  44637. export var passCubePixelShader: {
  44638. name: string;
  44639. shader: string;
  44640. };
  44641. }
  44642. declare module BABYLON {
  44643. /**
  44644. * PassPostProcess which produces an output the same as it's input
  44645. */
  44646. export class PassPostProcess extends PostProcess {
  44647. /**
  44648. * Creates the PassPostProcess
  44649. * @param name The name of the effect.
  44650. * @param options The required width/height ratio to downsize to before computing the render pass.
  44651. * @param camera The camera to apply the render pass to.
  44652. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44653. * @param engine The engine which the post process will be applied. (default: current engine)
  44654. * @param reusable If the post process can be reused on the same frame. (default: false)
  44655. * @param textureType The type of texture to be used when performing the post processing.
  44656. * @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)
  44657. */
  44658. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44659. }
  44660. /**
  44661. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  44662. */
  44663. export class PassCubePostProcess extends PostProcess {
  44664. private _face;
  44665. /**
  44666. * Gets or sets the cube face to display.
  44667. * * 0 is +X
  44668. * * 1 is -X
  44669. * * 2 is +Y
  44670. * * 3 is -Y
  44671. * * 4 is +Z
  44672. * * 5 is -Z
  44673. */
  44674. get face(): number;
  44675. set face(value: number);
  44676. /**
  44677. * Creates the PassCubePostProcess
  44678. * @param name The name of the effect.
  44679. * @param options The required width/height ratio to downsize to before computing the render pass.
  44680. * @param camera The camera to apply the render pass to.
  44681. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44682. * @param engine The engine which the post process will be applied. (default: current engine)
  44683. * @param reusable If the post process can be reused on the same frame. (default: false)
  44684. * @param textureType The type of texture to be used when performing the post processing.
  44685. * @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)
  44686. */
  44687. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44688. }
  44689. }
  44690. declare module BABYLON {
  44691. /** @hidden */
  44692. export var anaglyphPixelShader: {
  44693. name: string;
  44694. shader: string;
  44695. };
  44696. }
  44697. declare module BABYLON {
  44698. /**
  44699. * Postprocess used to generate anaglyphic rendering
  44700. */
  44701. export class AnaglyphPostProcess extends PostProcess {
  44702. private _passedProcess;
  44703. /**
  44704. * Creates a new AnaglyphPostProcess
  44705. * @param name defines postprocess name
  44706. * @param options defines creation options or target ratio scale
  44707. * @param rigCameras defines cameras using this postprocess
  44708. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  44709. * @param engine defines hosting engine
  44710. * @param reusable defines if the postprocess will be reused multiple times per frame
  44711. */
  44712. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  44713. }
  44714. }
  44715. declare module BABYLON {
  44716. /**
  44717. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  44718. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44719. */
  44720. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  44721. /**
  44722. * Creates a new AnaglyphArcRotateCamera
  44723. * @param name defines camera name
  44724. * @param alpha defines alpha angle (in radians)
  44725. * @param beta defines beta angle (in radians)
  44726. * @param radius defines radius
  44727. * @param target defines camera target
  44728. * @param interaxialDistance defines distance between each color axis
  44729. * @param scene defines the hosting scene
  44730. */
  44731. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  44732. /**
  44733. * Gets camera class name
  44734. * @returns AnaglyphArcRotateCamera
  44735. */
  44736. getClassName(): string;
  44737. }
  44738. }
  44739. declare module BABYLON {
  44740. /**
  44741. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  44742. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44743. */
  44744. export class AnaglyphFreeCamera extends FreeCamera {
  44745. /**
  44746. * Creates a new AnaglyphFreeCamera
  44747. * @param name defines camera name
  44748. * @param position defines initial position
  44749. * @param interaxialDistance defines distance between each color axis
  44750. * @param scene defines the hosting scene
  44751. */
  44752. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44753. /**
  44754. * Gets camera class name
  44755. * @returns AnaglyphFreeCamera
  44756. */
  44757. getClassName(): string;
  44758. }
  44759. }
  44760. declare module BABYLON {
  44761. /**
  44762. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  44763. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44764. */
  44765. export class AnaglyphGamepadCamera extends GamepadCamera {
  44766. /**
  44767. * Creates a new AnaglyphGamepadCamera
  44768. * @param name defines camera name
  44769. * @param position defines initial position
  44770. * @param interaxialDistance defines distance between each color axis
  44771. * @param scene defines the hosting scene
  44772. */
  44773. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44774. /**
  44775. * Gets camera class name
  44776. * @returns AnaglyphGamepadCamera
  44777. */
  44778. getClassName(): string;
  44779. }
  44780. }
  44781. declare module BABYLON {
  44782. /**
  44783. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  44784. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44785. */
  44786. export class AnaglyphUniversalCamera extends UniversalCamera {
  44787. /**
  44788. * Creates a new AnaglyphUniversalCamera
  44789. * @param name defines camera name
  44790. * @param position defines initial position
  44791. * @param interaxialDistance defines distance between each color axis
  44792. * @param scene defines the hosting scene
  44793. */
  44794. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44795. /**
  44796. * Gets camera class name
  44797. * @returns AnaglyphUniversalCamera
  44798. */
  44799. getClassName(): string;
  44800. }
  44801. }
  44802. declare module BABYLON {
  44803. /**
  44804. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  44805. * @see http://doc.babylonjs.com/features/cameras
  44806. */
  44807. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  44808. /**
  44809. * Creates a new StereoscopicArcRotateCamera
  44810. * @param name defines camera name
  44811. * @param alpha defines alpha angle (in radians)
  44812. * @param beta defines beta angle (in radians)
  44813. * @param radius defines radius
  44814. * @param target defines camera target
  44815. * @param interaxialDistance defines distance between each color axis
  44816. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44817. * @param scene defines the hosting scene
  44818. */
  44819. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44820. /**
  44821. * Gets camera class name
  44822. * @returns StereoscopicArcRotateCamera
  44823. */
  44824. getClassName(): string;
  44825. }
  44826. }
  44827. declare module BABYLON {
  44828. /**
  44829. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  44830. * @see http://doc.babylonjs.com/features/cameras
  44831. */
  44832. export class StereoscopicFreeCamera extends FreeCamera {
  44833. /**
  44834. * Creates a new StereoscopicFreeCamera
  44835. * @param name defines camera name
  44836. * @param position defines initial position
  44837. * @param interaxialDistance defines distance between each color axis
  44838. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44839. * @param scene defines the hosting scene
  44840. */
  44841. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44842. /**
  44843. * Gets camera class name
  44844. * @returns StereoscopicFreeCamera
  44845. */
  44846. getClassName(): string;
  44847. }
  44848. }
  44849. declare module BABYLON {
  44850. /**
  44851. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  44852. * @see http://doc.babylonjs.com/features/cameras
  44853. */
  44854. export class StereoscopicGamepadCamera extends GamepadCamera {
  44855. /**
  44856. * Creates a new StereoscopicGamepadCamera
  44857. * @param name defines camera name
  44858. * @param position defines initial position
  44859. * @param interaxialDistance defines distance between each color axis
  44860. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44861. * @param scene defines the hosting scene
  44862. */
  44863. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44864. /**
  44865. * Gets camera class name
  44866. * @returns StereoscopicGamepadCamera
  44867. */
  44868. getClassName(): string;
  44869. }
  44870. }
  44871. declare module BABYLON {
  44872. /**
  44873. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  44874. * @see http://doc.babylonjs.com/features/cameras
  44875. */
  44876. export class StereoscopicUniversalCamera extends UniversalCamera {
  44877. /**
  44878. * Creates a new StereoscopicUniversalCamera
  44879. * @param name defines camera name
  44880. * @param position defines initial position
  44881. * @param interaxialDistance defines distance between each color axis
  44882. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44883. * @param scene defines the hosting scene
  44884. */
  44885. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44886. /**
  44887. * Gets camera class name
  44888. * @returns StereoscopicUniversalCamera
  44889. */
  44890. getClassName(): string;
  44891. }
  44892. }
  44893. declare module BABYLON {
  44894. /**
  44895. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  44896. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44897. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44898. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  44899. */
  44900. export class VirtualJoysticksCamera extends FreeCamera {
  44901. /**
  44902. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  44903. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44904. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44905. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  44906. * @param name Define the name of the camera in the scene
  44907. * @param position Define the start position of the camera in the scene
  44908. * @param scene Define the scene the camera belongs to
  44909. */
  44910. constructor(name: string, position: Vector3, scene: Scene);
  44911. /**
  44912. * Gets the current object class name.
  44913. * @return the class name
  44914. */
  44915. getClassName(): string;
  44916. }
  44917. }
  44918. declare module BABYLON {
  44919. /**
  44920. * This represents all the required metrics to create a VR camera.
  44921. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  44922. */
  44923. export class VRCameraMetrics {
  44924. /**
  44925. * Define the horizontal resolution off the screen.
  44926. */
  44927. hResolution: number;
  44928. /**
  44929. * Define the vertical resolution off the screen.
  44930. */
  44931. vResolution: number;
  44932. /**
  44933. * Define the horizontal screen size.
  44934. */
  44935. hScreenSize: number;
  44936. /**
  44937. * Define the vertical screen size.
  44938. */
  44939. vScreenSize: number;
  44940. /**
  44941. * Define the vertical screen center position.
  44942. */
  44943. vScreenCenter: number;
  44944. /**
  44945. * Define the distance of the eyes to the screen.
  44946. */
  44947. eyeToScreenDistance: number;
  44948. /**
  44949. * Define the distance between both lenses
  44950. */
  44951. lensSeparationDistance: number;
  44952. /**
  44953. * Define the distance between both viewer's eyes.
  44954. */
  44955. interpupillaryDistance: number;
  44956. /**
  44957. * Define the distortion factor of the VR postprocess.
  44958. * Please, touch with care.
  44959. */
  44960. distortionK: number[];
  44961. /**
  44962. * Define the chromatic aberration correction factors for the VR post process.
  44963. */
  44964. chromaAbCorrection: number[];
  44965. /**
  44966. * Define the scale factor of the post process.
  44967. * The smaller the better but the slower.
  44968. */
  44969. postProcessScaleFactor: number;
  44970. /**
  44971. * Define an offset for the lens center.
  44972. */
  44973. lensCenterOffset: number;
  44974. /**
  44975. * Define if the current vr camera should compensate the distortion of the lense or not.
  44976. */
  44977. compensateDistortion: boolean;
  44978. /**
  44979. * Defines if multiview should be enabled when rendering (Default: false)
  44980. */
  44981. multiviewEnabled: boolean;
  44982. /**
  44983. * Gets the rendering aspect ratio based on the provided resolutions.
  44984. */
  44985. get aspectRatio(): number;
  44986. /**
  44987. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  44988. */
  44989. get aspectRatioFov(): number;
  44990. /**
  44991. * @hidden
  44992. */
  44993. get leftHMatrix(): Matrix;
  44994. /**
  44995. * @hidden
  44996. */
  44997. get rightHMatrix(): Matrix;
  44998. /**
  44999. * @hidden
  45000. */
  45001. get leftPreViewMatrix(): Matrix;
  45002. /**
  45003. * @hidden
  45004. */
  45005. get rightPreViewMatrix(): Matrix;
  45006. /**
  45007. * Get the default VRMetrics based on the most generic setup.
  45008. * @returns the default vr metrics
  45009. */
  45010. static GetDefault(): VRCameraMetrics;
  45011. }
  45012. }
  45013. declare module BABYLON {
  45014. /** @hidden */
  45015. export var vrDistortionCorrectionPixelShader: {
  45016. name: string;
  45017. shader: string;
  45018. };
  45019. }
  45020. declare module BABYLON {
  45021. /**
  45022. * VRDistortionCorrectionPostProcess used for mobile VR
  45023. */
  45024. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45025. private _isRightEye;
  45026. private _distortionFactors;
  45027. private _postProcessScaleFactor;
  45028. private _lensCenterOffset;
  45029. private _scaleIn;
  45030. private _scaleFactor;
  45031. private _lensCenter;
  45032. /**
  45033. * Initializes the VRDistortionCorrectionPostProcess
  45034. * @param name The name of the effect.
  45035. * @param camera The camera to apply the render pass to.
  45036. * @param isRightEye If this is for the right eye distortion
  45037. * @param vrMetrics All the required metrics for the VR camera
  45038. */
  45039. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45040. }
  45041. }
  45042. declare module BABYLON {
  45043. /**
  45044. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45045. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45046. */
  45047. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45048. /**
  45049. * Creates a new VRDeviceOrientationArcRotateCamera
  45050. * @param name defines camera name
  45051. * @param alpha defines the camera rotation along the logitudinal axis
  45052. * @param beta defines the camera rotation along the latitudinal axis
  45053. * @param radius defines the camera distance from its target
  45054. * @param target defines the camera target
  45055. * @param scene defines the scene the camera belongs to
  45056. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45057. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45058. */
  45059. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45060. /**
  45061. * Gets camera class name
  45062. * @returns VRDeviceOrientationArcRotateCamera
  45063. */
  45064. getClassName(): string;
  45065. }
  45066. }
  45067. declare module BABYLON {
  45068. /**
  45069. * Camera used to simulate VR rendering (based on FreeCamera)
  45070. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45071. */
  45072. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45073. /**
  45074. * Creates a new VRDeviceOrientationFreeCamera
  45075. * @param name defines camera name
  45076. * @param position defines the start position of the camera
  45077. * @param scene defines the scene the camera belongs to
  45078. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45079. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45080. */
  45081. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45082. /**
  45083. * Gets camera class name
  45084. * @returns VRDeviceOrientationFreeCamera
  45085. */
  45086. getClassName(): string;
  45087. }
  45088. }
  45089. declare module BABYLON {
  45090. /**
  45091. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45092. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45093. */
  45094. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45095. /**
  45096. * Creates a new VRDeviceOrientationGamepadCamera
  45097. * @param name defines camera name
  45098. * @param position defines the start position of the camera
  45099. * @param scene defines the scene the camera belongs to
  45100. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45101. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45102. */
  45103. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45104. /**
  45105. * Gets camera class name
  45106. * @returns VRDeviceOrientationGamepadCamera
  45107. */
  45108. getClassName(): string;
  45109. }
  45110. }
  45111. declare module BABYLON {
  45112. /** @hidden */
  45113. export var imageProcessingPixelShader: {
  45114. name: string;
  45115. shader: string;
  45116. };
  45117. }
  45118. declare module BABYLON {
  45119. /**
  45120. * ImageProcessingPostProcess
  45121. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45122. */
  45123. export class ImageProcessingPostProcess extends PostProcess {
  45124. /**
  45125. * Default configuration related to image processing available in the PBR Material.
  45126. */
  45127. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45128. /**
  45129. * Gets the image processing configuration used either in this material.
  45130. */
  45131. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45132. /**
  45133. * Sets the Default image processing configuration used either in the this material.
  45134. *
  45135. * If sets to null, the scene one is in use.
  45136. */
  45137. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45138. /**
  45139. * Keep track of the image processing observer to allow dispose and replace.
  45140. */
  45141. private _imageProcessingObserver;
  45142. /**
  45143. * Attaches a new image processing configuration to the PBR Material.
  45144. * @param configuration
  45145. */
  45146. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45147. /**
  45148. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45149. */
  45150. get colorCurves(): Nullable<ColorCurves>;
  45151. /**
  45152. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45153. */
  45154. set colorCurves(value: Nullable<ColorCurves>);
  45155. /**
  45156. * Gets wether the color curves effect is enabled.
  45157. */
  45158. get colorCurvesEnabled(): boolean;
  45159. /**
  45160. * Sets wether the color curves effect is enabled.
  45161. */
  45162. set colorCurvesEnabled(value: boolean);
  45163. /**
  45164. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45165. */
  45166. get colorGradingTexture(): Nullable<BaseTexture>;
  45167. /**
  45168. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45169. */
  45170. set colorGradingTexture(value: Nullable<BaseTexture>);
  45171. /**
  45172. * Gets wether the color grading effect is enabled.
  45173. */
  45174. get colorGradingEnabled(): boolean;
  45175. /**
  45176. * Gets wether the color grading effect is enabled.
  45177. */
  45178. set colorGradingEnabled(value: boolean);
  45179. /**
  45180. * Gets exposure used in the effect.
  45181. */
  45182. get exposure(): number;
  45183. /**
  45184. * Sets exposure used in the effect.
  45185. */
  45186. set exposure(value: number);
  45187. /**
  45188. * Gets wether tonemapping is enabled or not.
  45189. */
  45190. get toneMappingEnabled(): boolean;
  45191. /**
  45192. * Sets wether tonemapping is enabled or not
  45193. */
  45194. set toneMappingEnabled(value: boolean);
  45195. /**
  45196. * Gets the type of tone mapping effect.
  45197. */
  45198. get toneMappingType(): number;
  45199. /**
  45200. * Sets the type of tone mapping effect.
  45201. */
  45202. set toneMappingType(value: number);
  45203. /**
  45204. * Gets contrast used in the effect.
  45205. */
  45206. get contrast(): number;
  45207. /**
  45208. * Sets contrast used in the effect.
  45209. */
  45210. set contrast(value: number);
  45211. /**
  45212. * Gets Vignette stretch size.
  45213. */
  45214. get vignetteStretch(): number;
  45215. /**
  45216. * Sets Vignette stretch size.
  45217. */
  45218. set vignetteStretch(value: number);
  45219. /**
  45220. * Gets Vignette centre X Offset.
  45221. */
  45222. get vignetteCentreX(): number;
  45223. /**
  45224. * Sets Vignette centre X Offset.
  45225. */
  45226. set vignetteCentreX(value: number);
  45227. /**
  45228. * Gets Vignette centre Y Offset.
  45229. */
  45230. get vignetteCentreY(): number;
  45231. /**
  45232. * Sets Vignette centre Y Offset.
  45233. */
  45234. set vignetteCentreY(value: number);
  45235. /**
  45236. * Gets Vignette weight or intensity of the vignette effect.
  45237. */
  45238. get vignetteWeight(): number;
  45239. /**
  45240. * Sets Vignette weight or intensity of the vignette effect.
  45241. */
  45242. set vignetteWeight(value: number);
  45243. /**
  45244. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45245. * if vignetteEnabled is set to true.
  45246. */
  45247. get vignetteColor(): Color4;
  45248. /**
  45249. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45250. * if vignetteEnabled is set to true.
  45251. */
  45252. set vignetteColor(value: Color4);
  45253. /**
  45254. * Gets Camera field of view used by the Vignette effect.
  45255. */
  45256. get vignetteCameraFov(): number;
  45257. /**
  45258. * Sets Camera field of view used by the Vignette effect.
  45259. */
  45260. set vignetteCameraFov(value: number);
  45261. /**
  45262. * Gets the vignette blend mode allowing different kind of effect.
  45263. */
  45264. get vignetteBlendMode(): number;
  45265. /**
  45266. * Sets the vignette blend mode allowing different kind of effect.
  45267. */
  45268. set vignetteBlendMode(value: number);
  45269. /**
  45270. * Gets wether the vignette effect is enabled.
  45271. */
  45272. get vignetteEnabled(): boolean;
  45273. /**
  45274. * Sets wether the vignette effect is enabled.
  45275. */
  45276. set vignetteEnabled(value: boolean);
  45277. private _fromLinearSpace;
  45278. /**
  45279. * Gets wether the input of the processing is in Gamma or Linear Space.
  45280. */
  45281. get fromLinearSpace(): boolean;
  45282. /**
  45283. * Sets wether the input of the processing is in Gamma or Linear Space.
  45284. */
  45285. set fromLinearSpace(value: boolean);
  45286. /**
  45287. * Defines cache preventing GC.
  45288. */
  45289. private _defines;
  45290. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45291. /**
  45292. * "ImageProcessingPostProcess"
  45293. * @returns "ImageProcessingPostProcess"
  45294. */
  45295. getClassName(): string;
  45296. protected _updateParameters(): void;
  45297. dispose(camera?: Camera): void;
  45298. }
  45299. }
  45300. declare module BABYLON {
  45301. /**
  45302. * Class containing static functions to help procedurally build meshes
  45303. */
  45304. export class GroundBuilder {
  45305. /**
  45306. * Creates a ground mesh
  45307. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45308. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45310. * @param name defines the name of the mesh
  45311. * @param options defines the options used to create the mesh
  45312. * @param scene defines the hosting scene
  45313. * @returns the ground mesh
  45314. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45315. */
  45316. static CreateGround(name: string, options: {
  45317. width?: number;
  45318. height?: number;
  45319. subdivisions?: number;
  45320. subdivisionsX?: number;
  45321. subdivisionsY?: number;
  45322. updatable?: boolean;
  45323. }, scene: any): Mesh;
  45324. /**
  45325. * Creates a tiled ground mesh
  45326. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45327. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45328. * * 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
  45329. * * 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
  45330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45331. * @param name defines the name of the mesh
  45332. * @param options defines the options used to create the mesh
  45333. * @param scene defines the hosting scene
  45334. * @returns the tiled ground mesh
  45335. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45336. */
  45337. static CreateTiledGround(name: string, options: {
  45338. xmin: number;
  45339. zmin: number;
  45340. xmax: number;
  45341. zmax: number;
  45342. subdivisions?: {
  45343. w: number;
  45344. h: number;
  45345. };
  45346. precision?: {
  45347. w: number;
  45348. h: number;
  45349. };
  45350. updatable?: boolean;
  45351. }, scene?: Nullable<Scene>): Mesh;
  45352. /**
  45353. * Creates a ground mesh from a height map
  45354. * * The parameter `url` sets the URL of the height map image resource.
  45355. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45356. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45357. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45358. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45359. * * 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.
  45360. * * 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).
  45361. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45363. * @param name defines the name of the mesh
  45364. * @param url defines the url to the height map
  45365. * @param options defines the options used to create the mesh
  45366. * @param scene defines the hosting scene
  45367. * @returns the ground mesh
  45368. * @see https://doc.babylonjs.com/babylon101/height_map
  45369. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45370. */
  45371. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45372. width?: number;
  45373. height?: number;
  45374. subdivisions?: number;
  45375. minHeight?: number;
  45376. maxHeight?: number;
  45377. colorFilter?: Color3;
  45378. alphaFilter?: number;
  45379. updatable?: boolean;
  45380. onReady?: (mesh: GroundMesh) => void;
  45381. }, scene?: Nullable<Scene>): GroundMesh;
  45382. }
  45383. }
  45384. declare module BABYLON {
  45385. /**
  45386. * Class containing static functions to help procedurally build meshes
  45387. */
  45388. export class TorusBuilder {
  45389. /**
  45390. * Creates a torus mesh
  45391. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45392. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45393. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45395. * * 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
  45396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45397. * @param name defines the name of the mesh
  45398. * @param options defines the options used to create the mesh
  45399. * @param scene defines the hosting scene
  45400. * @returns the torus mesh
  45401. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45402. */
  45403. static CreateTorus(name: string, options: {
  45404. diameter?: number;
  45405. thickness?: number;
  45406. tessellation?: number;
  45407. updatable?: boolean;
  45408. sideOrientation?: number;
  45409. frontUVs?: Vector4;
  45410. backUVs?: Vector4;
  45411. }, scene: any): Mesh;
  45412. }
  45413. }
  45414. declare module BABYLON {
  45415. /**
  45416. * Class containing static functions to help procedurally build meshes
  45417. */
  45418. export class CylinderBuilder {
  45419. /**
  45420. * Creates a cylinder or a cone mesh
  45421. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45422. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45423. * * 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.
  45424. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45425. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45426. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45427. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45428. * * 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).
  45429. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45430. * * 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).
  45431. * * 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
  45432. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45433. * * 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
  45434. * * 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.
  45435. * * If `enclose` is false, a ring surface is one element.
  45436. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45437. * * 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
  45438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45439. * * 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
  45440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45441. * @param name defines the name of the mesh
  45442. * @param options defines the options used to create the mesh
  45443. * @param scene defines the hosting scene
  45444. * @returns the cylinder mesh
  45445. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45446. */
  45447. static CreateCylinder(name: string, options: {
  45448. height?: number;
  45449. diameterTop?: number;
  45450. diameterBottom?: number;
  45451. diameter?: number;
  45452. tessellation?: number;
  45453. subdivisions?: number;
  45454. arc?: number;
  45455. faceColors?: Color4[];
  45456. faceUV?: Vector4[];
  45457. updatable?: boolean;
  45458. hasRings?: boolean;
  45459. enclose?: boolean;
  45460. cap?: number;
  45461. sideOrientation?: number;
  45462. frontUVs?: Vector4;
  45463. backUVs?: Vector4;
  45464. }, scene: any): Mesh;
  45465. }
  45466. }
  45467. declare module BABYLON {
  45468. /**
  45469. * States of the webXR experience
  45470. */
  45471. export enum WebXRState {
  45472. /**
  45473. * Transitioning to being in XR mode
  45474. */
  45475. ENTERING_XR = 0,
  45476. /**
  45477. * Transitioning to non XR mode
  45478. */
  45479. EXITING_XR = 1,
  45480. /**
  45481. * In XR mode and presenting
  45482. */
  45483. IN_XR = 2,
  45484. /**
  45485. * Not entered XR mode
  45486. */
  45487. NOT_IN_XR = 3
  45488. }
  45489. /**
  45490. * Abstraction of the XR render target
  45491. */
  45492. export interface WebXRRenderTarget extends IDisposable {
  45493. /**
  45494. * xrpresent context of the canvas which can be used to display/mirror xr content
  45495. */
  45496. canvasContext: WebGLRenderingContext;
  45497. /**
  45498. * xr layer for the canvas
  45499. */
  45500. xrLayer: Nullable<XRWebGLLayer>;
  45501. /**
  45502. * Initializes the xr layer for the session
  45503. * @param xrSession xr session
  45504. * @returns a promise that will resolve once the XR Layer has been created
  45505. */
  45506. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45507. }
  45508. }
  45509. declare module BABYLON {
  45510. /**
  45511. * COnfiguration object for WebXR output canvas
  45512. */
  45513. export class WebXRManagedOutputCanvasOptions {
  45514. /**
  45515. * An optional canvas in case you wish to create it yourself and provide it here.
  45516. * If not provided, a new canvas will be created
  45517. */
  45518. canvasElement?: HTMLCanvasElement;
  45519. /**
  45520. * Options for this XR Layer output
  45521. */
  45522. canvasOptions?: XRWebGLLayerOptions;
  45523. /**
  45524. * CSS styling for a newly created canvas (if not provided)
  45525. */
  45526. newCanvasCssStyle?: string;
  45527. /**
  45528. * Get the default values of the configuration object
  45529. * @returns default values of this configuration object
  45530. */
  45531. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45532. }
  45533. /**
  45534. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45535. */
  45536. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45537. private _options;
  45538. private _canvas;
  45539. private _engine;
  45540. /**
  45541. * Rendering context of the canvas which can be used to display/mirror xr content
  45542. */
  45543. canvasContext: WebGLRenderingContext;
  45544. /**
  45545. * xr layer for the canvas
  45546. */
  45547. xrLayer: Nullable<XRWebGLLayer>;
  45548. /**
  45549. * Initializes the canvas to be added/removed upon entering/exiting xr
  45550. * @param _xrSessionManager The XR Session manager
  45551. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45552. */
  45553. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45554. /**
  45555. * Disposes of the object
  45556. */
  45557. dispose(): void;
  45558. /**
  45559. * Initializes the xr layer for the session
  45560. * @param xrSession xr session
  45561. * @returns a promise that will resolve once the XR Layer has been created
  45562. */
  45563. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45564. private _addCanvas;
  45565. private _removeCanvas;
  45566. private _setManagedOutputCanvas;
  45567. }
  45568. }
  45569. declare module BABYLON {
  45570. /**
  45571. * Manages an XRSession to work with Babylon's engine
  45572. * @see https://doc.babylonjs.com/how_to/webxr
  45573. */
  45574. export class WebXRSessionManager implements IDisposable {
  45575. /** The scene which the session should be created for */
  45576. scene: Scene;
  45577. private _referenceSpace;
  45578. private _rttProvider;
  45579. private _sessionEnded;
  45580. private _xrNavigator;
  45581. private baseLayer;
  45582. /**
  45583. * The base reference space from which the session started. good if you want to reset your
  45584. * reference space
  45585. */
  45586. baseReferenceSpace: XRReferenceSpace;
  45587. /**
  45588. * Current XR frame
  45589. */
  45590. currentFrame: Nullable<XRFrame>;
  45591. /** WebXR timestamp updated every frame */
  45592. currentTimestamp: number;
  45593. /**
  45594. * Used just in case of a failure to initialize an immersive session.
  45595. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45596. */
  45597. defaultHeightCompensation: number;
  45598. /**
  45599. * Fires every time a new xrFrame arrives which can be used to update the camera
  45600. */
  45601. onXRFrameObservable: Observable<XRFrame>;
  45602. /**
  45603. * Fires when the reference space changed
  45604. */
  45605. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45606. /**
  45607. * Fires when the xr session is ended either by the device or manually done
  45608. */
  45609. onXRSessionEnded: Observable<any>;
  45610. /**
  45611. * Fires when the xr session is ended either by the device or manually done
  45612. */
  45613. onXRSessionInit: Observable<XRSession>;
  45614. /**
  45615. * Underlying xr session
  45616. */
  45617. session: XRSession;
  45618. /**
  45619. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45620. * or get the offset the player is currently at.
  45621. */
  45622. viewerReferenceSpace: XRReferenceSpace;
  45623. /**
  45624. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45625. * @param scene The scene which the session should be created for
  45626. */
  45627. constructor(
  45628. /** The scene which the session should be created for */
  45629. scene: Scene);
  45630. /**
  45631. * The current reference space used in this session. This reference space can constantly change!
  45632. * It is mainly used to offset the camera's position.
  45633. */
  45634. get referenceSpace(): XRReferenceSpace;
  45635. /**
  45636. * Set a new reference space and triggers the observable
  45637. */
  45638. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45639. /**
  45640. * Disposes of the session manager
  45641. */
  45642. dispose(): void;
  45643. /**
  45644. * Stops the xrSession and restores the render loop
  45645. * @returns Promise which resolves after it exits XR
  45646. */
  45647. exitXRAsync(): Promise<void>;
  45648. /**
  45649. * Gets the correct render target texture to be rendered this frame for this eye
  45650. * @param eye the eye for which to get the render target
  45651. * @returns the render target for the specified eye
  45652. */
  45653. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  45654. /**
  45655. * Creates a WebXRRenderTarget object for the XR session
  45656. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  45657. * @param options optional options to provide when creating a new render target
  45658. * @returns a WebXR render target to which the session can render
  45659. */
  45660. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  45661. /**
  45662. * Initializes the manager
  45663. * After initialization enterXR can be called to start an XR session
  45664. * @returns Promise which resolves after it is initialized
  45665. */
  45666. initializeAsync(): Promise<void>;
  45667. /**
  45668. * Initializes an xr session
  45669. * @param xrSessionMode mode to initialize
  45670. * @param xrSessionInit defines optional and required values to pass to the session builder
  45671. * @returns a promise which will resolve once the session has been initialized
  45672. */
  45673. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  45674. /**
  45675. * Checks if a session would be supported for the creation options specified
  45676. * @param sessionMode session mode to check if supported eg. immersive-vr
  45677. * @returns A Promise that resolves to true if supported and false if not
  45678. */
  45679. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45680. /**
  45681. * Resets the reference space to the one started the session
  45682. */
  45683. resetReferenceSpace(): void;
  45684. /**
  45685. * Starts rendering to the xr layer
  45686. */
  45687. runXRRenderLoop(): void;
  45688. /**
  45689. * Sets the reference space on the xr session
  45690. * @param referenceSpaceType space to set
  45691. * @returns a promise that will resolve once the reference space has been set
  45692. */
  45693. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  45694. /**
  45695. * Updates the render state of the session
  45696. * @param state state to set
  45697. * @returns a promise that resolves once the render state has been updated
  45698. */
  45699. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  45700. /**
  45701. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  45702. * @param sessionMode defines the session to test
  45703. * @returns a promise with boolean as final value
  45704. */
  45705. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45706. private _createRenderTargetTexture;
  45707. }
  45708. }
  45709. declare module BABYLON {
  45710. /**
  45711. * WebXR Camera which holds the views for the xrSession
  45712. * @see https://doc.babylonjs.com/how_to/webxr_camera
  45713. */
  45714. export class WebXRCamera extends FreeCamera {
  45715. private _xrSessionManager;
  45716. private _firstFrame;
  45717. private _referenceQuaternion;
  45718. private _referencedPosition;
  45719. private _xrInvPositionCache;
  45720. private _xrInvQuaternionCache;
  45721. /**
  45722. * Should position compensation execute on first frame.
  45723. * This is used when copying the position from a native (non XR) camera
  45724. */
  45725. compensateOnFirstFrame: boolean;
  45726. /**
  45727. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  45728. * @param name the name of the camera
  45729. * @param scene the scene to add the camera to
  45730. * @param _xrSessionManager a constructed xr session manager
  45731. */
  45732. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  45733. /**
  45734. * Return the user's height, unrelated to the current ground.
  45735. * This will be the y position of this camera, when ground level is 0.
  45736. */
  45737. get realWorldHeight(): number;
  45738. /** @hidden */
  45739. _updateForDualEyeDebugging(): void;
  45740. /**
  45741. * Sets this camera's transformation based on a non-vr camera
  45742. * @param otherCamera the non-vr camera to copy the transformation from
  45743. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  45744. */
  45745. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  45746. /**
  45747. * Gets the current instance class name ("WebXRCamera").
  45748. * @returns the class name
  45749. */
  45750. getClassName(): string;
  45751. /**
  45752. * Overriding the _getViewMatrix function, as it is computed by WebXR
  45753. */
  45754. _getViewMatrix(): Matrix;
  45755. private _updateFromXRSession;
  45756. private _updateNumberOfRigCameras;
  45757. private _updateReferenceSpace;
  45758. private _updateReferenceSpaceOffset;
  45759. }
  45760. }
  45761. declare module BABYLON {
  45762. /**
  45763. * Defining the interface required for a (webxr) feature
  45764. */
  45765. export interface IWebXRFeature extends IDisposable {
  45766. /**
  45767. * Is this feature attached
  45768. */
  45769. attached: boolean;
  45770. /**
  45771. * Should auto-attach be disabled?
  45772. */
  45773. disableAutoAttach: boolean;
  45774. /**
  45775. * Attach the feature to the session
  45776. * Will usually be called by the features manager
  45777. *
  45778. * @param force should attachment be forced (even when already attached)
  45779. * @returns true if successful.
  45780. */
  45781. attach(force?: boolean): boolean;
  45782. /**
  45783. * Detach the feature from the session
  45784. * Will usually be called by the features manager
  45785. *
  45786. * @returns true if successful.
  45787. */
  45788. detach(): boolean;
  45789. }
  45790. /**
  45791. * A list of the currently available features without referencing them
  45792. */
  45793. export class WebXRFeatureName {
  45794. /**
  45795. * The name of the anchor system feature
  45796. */
  45797. static ANCHOR_SYSTEM: string;
  45798. /**
  45799. * The name of the background remover feature
  45800. */
  45801. static BACKGROUND_REMOVER: string;
  45802. /**
  45803. * The name of the hit test feature
  45804. */
  45805. static HIT_TEST: string;
  45806. /**
  45807. * physics impostors for xr controllers feature
  45808. */
  45809. static PHYSICS_CONTROLLERS: string;
  45810. /**
  45811. * The name of the plane detection feature
  45812. */
  45813. static PLANE_DETECTION: string;
  45814. /**
  45815. * The name of the pointer selection feature
  45816. */
  45817. static POINTER_SELECTION: string;
  45818. /**
  45819. * The name of the teleportation feature
  45820. */
  45821. static TELEPORTATION: string;
  45822. }
  45823. /**
  45824. * Defining the constructor of a feature. Used to register the modules.
  45825. */
  45826. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  45827. /**
  45828. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  45829. * It is mainly used in AR sessions.
  45830. *
  45831. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  45832. */
  45833. export class WebXRFeaturesManager implements IDisposable {
  45834. private _xrSessionManager;
  45835. private static readonly _AvailableFeatures;
  45836. private _features;
  45837. /**
  45838. * constructs a new features manages.
  45839. *
  45840. * @param _xrSessionManager an instance of WebXRSessionManager
  45841. */
  45842. constructor(_xrSessionManager: WebXRSessionManager);
  45843. /**
  45844. * Used to register a module. After calling this function a developer can use this feature in the scene.
  45845. * Mainly used internally.
  45846. *
  45847. * @param featureName the name of the feature to register
  45848. * @param constructorFunction the function used to construct the module
  45849. * @param version the (babylon) version of the module
  45850. * @param stable is that a stable version of this module
  45851. */
  45852. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  45853. /**
  45854. * Returns a constructor of a specific feature.
  45855. *
  45856. * @param featureName the name of the feature to construct
  45857. * @param version the version of the feature to load
  45858. * @param xrSessionManager the xrSessionManager. Used to construct the module
  45859. * @param options optional options provided to the module.
  45860. * @returns a function that, when called, will return a new instance of this feature
  45861. */
  45862. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  45863. /**
  45864. * Can be used to return the list of features currently registered
  45865. *
  45866. * @returns an Array of available features
  45867. */
  45868. static GetAvailableFeatures(): string[];
  45869. /**
  45870. * Gets the versions available for a specific feature
  45871. * @param featureName the name of the feature
  45872. * @returns an array with the available versions
  45873. */
  45874. static GetAvailableVersions(featureName: string): string[];
  45875. /**
  45876. * Return the latest unstable version of this feature
  45877. * @param featureName the name of the feature to search
  45878. * @returns the version number. if not found will return -1
  45879. */
  45880. static GetLatestVersionOfFeature(featureName: string): number;
  45881. /**
  45882. * Return the latest stable version of this feature
  45883. * @param featureName the name of the feature to search
  45884. * @returns the version number. if not found will return -1
  45885. */
  45886. static GetStableVersionOfFeature(featureName: string): number;
  45887. /**
  45888. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  45889. * Can be used during a session to start a feature
  45890. * @param featureName the name of feature to attach
  45891. */
  45892. attachFeature(featureName: string): void;
  45893. /**
  45894. * Can be used inside a session or when the session ends to detach a specific feature
  45895. * @param featureName the name of the feature to detach
  45896. */
  45897. detachFeature(featureName: string): void;
  45898. /**
  45899. * Used to disable an already-enabled feature
  45900. * The feature will be disposed and will be recreated once enabled.
  45901. * @param featureName the feature to disable
  45902. * @returns true if disable was successful
  45903. */
  45904. disableFeature(featureName: string | {
  45905. Name: string;
  45906. }): boolean;
  45907. /**
  45908. * dispose this features manager
  45909. */
  45910. dispose(): void;
  45911. /**
  45912. * 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.
  45913. * 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.
  45914. *
  45915. * @param featureName the name of the feature to load or the class of the feature
  45916. * @param version optional version to load. if not provided the latest version will be enabled
  45917. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  45918. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  45919. * @returns a new constructed feature or throws an error if feature not found.
  45920. */
  45921. enableFeature(featureName: string | {
  45922. Name: string;
  45923. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  45924. /**
  45925. * get the implementation of an enabled feature.
  45926. * @param featureName the name of the feature to load
  45927. * @returns the feature class, if found
  45928. */
  45929. getEnabledFeature(featureName: string): IWebXRFeature;
  45930. /**
  45931. * Get the list of enabled features
  45932. * @returns an array of enabled features
  45933. */
  45934. getEnabledFeatures(): string[];
  45935. }
  45936. }
  45937. declare module BABYLON {
  45938. /**
  45939. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  45940. * @see https://doc.babylonjs.com/how_to/webxr
  45941. */
  45942. export class WebXRExperienceHelper implements IDisposable {
  45943. private scene;
  45944. private _nonVRCamera;
  45945. private _originalSceneAutoClear;
  45946. private _supported;
  45947. /**
  45948. * Camera used to render xr content
  45949. */
  45950. camera: WebXRCamera;
  45951. /** A features manager for this xr session */
  45952. featuresManager: WebXRFeaturesManager;
  45953. /**
  45954. * Observers registered here will be triggered after the camera's initial transformation is set
  45955. * This can be used to set a different ground level or an extra rotation.
  45956. *
  45957. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  45958. * to the position set after this observable is done executing.
  45959. */
  45960. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  45961. /**
  45962. * Fires when the state of the experience helper has changed
  45963. */
  45964. onStateChangedObservable: Observable<WebXRState>;
  45965. /** Session manager used to keep track of xr session */
  45966. sessionManager: WebXRSessionManager;
  45967. /**
  45968. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  45969. */
  45970. state: WebXRState;
  45971. /**
  45972. * Creates a WebXRExperienceHelper
  45973. * @param scene The scene the helper should be created in
  45974. */
  45975. private constructor();
  45976. /**
  45977. * Creates the experience helper
  45978. * @param scene the scene to attach the experience helper to
  45979. * @returns a promise for the experience helper
  45980. */
  45981. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  45982. /**
  45983. * Disposes of the experience helper
  45984. */
  45985. dispose(): void;
  45986. /**
  45987. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  45988. * @param sessionMode options for the XR session
  45989. * @param referenceSpaceType frame of reference of the XR session
  45990. * @param renderTarget the output canvas that will be used to enter XR mode
  45991. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  45992. * @returns promise that resolves after xr mode has entered
  45993. */
  45994. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  45995. /**
  45996. * Exits XR mode and returns the scene to its original state
  45997. * @returns promise that resolves after xr mode has exited
  45998. */
  45999. exitXRAsync(): Promise<void>;
  46000. private _nonXRToXRCamera;
  46001. private _setState;
  46002. }
  46003. }
  46004. declare module BABYLON {
  46005. /**
  46006. * X-Y values for axes in WebXR
  46007. */
  46008. export interface IWebXRMotionControllerAxesValue {
  46009. /**
  46010. * The value of the x axis
  46011. */
  46012. x: number;
  46013. /**
  46014. * The value of the y-axis
  46015. */
  46016. y: number;
  46017. }
  46018. /**
  46019. * changed / previous values for the values of this component
  46020. */
  46021. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46022. /**
  46023. * current (this frame) value
  46024. */
  46025. current: T;
  46026. /**
  46027. * previous (last change) value
  46028. */
  46029. previous: T;
  46030. }
  46031. /**
  46032. * Represents changes in the component between current frame and last values recorded
  46033. */
  46034. export interface IWebXRMotionControllerComponentChanges {
  46035. /**
  46036. * will be populated with previous and current values if axes changed
  46037. */
  46038. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46039. /**
  46040. * will be populated with previous and current values if pressed changed
  46041. */
  46042. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46043. /**
  46044. * will be populated with previous and current values if touched changed
  46045. */
  46046. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46047. /**
  46048. * will be populated with previous and current values if value changed
  46049. */
  46050. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46051. }
  46052. /**
  46053. * This class represents a single component (for example button or thumbstick) of a motion controller
  46054. */
  46055. export class WebXRControllerComponent implements IDisposable {
  46056. /**
  46057. * the id of this component
  46058. */
  46059. id: string;
  46060. /**
  46061. * the type of the component
  46062. */
  46063. type: MotionControllerComponentType;
  46064. private _buttonIndex;
  46065. private _axesIndices;
  46066. private _axes;
  46067. private _changes;
  46068. private _currentValue;
  46069. private _hasChanges;
  46070. private _pressed;
  46071. private _touched;
  46072. /**
  46073. * button component type
  46074. */
  46075. static BUTTON_TYPE: MotionControllerComponentType;
  46076. /**
  46077. * squeeze component type
  46078. */
  46079. static SQUEEZE_TYPE: MotionControllerComponentType;
  46080. /**
  46081. * Thumbstick component type
  46082. */
  46083. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46084. /**
  46085. * Touchpad component type
  46086. */
  46087. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46088. /**
  46089. * trigger component type
  46090. */
  46091. static TRIGGER_TYPE: MotionControllerComponentType;
  46092. /**
  46093. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46094. * the axes data changes
  46095. */
  46096. onAxisValueChangedObservable: Observable<{
  46097. x: number;
  46098. y: number;
  46099. }>;
  46100. /**
  46101. * Observers registered here will be triggered when the state of a button changes
  46102. * State change is either pressed / touched / value
  46103. */
  46104. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46105. /**
  46106. * Creates a new component for a motion controller.
  46107. * It is created by the motion controller itself
  46108. *
  46109. * @param id the id of this component
  46110. * @param type the type of the component
  46111. * @param _buttonIndex index in the buttons array of the gamepad
  46112. * @param _axesIndices indices of the values in the axes array of the gamepad
  46113. */
  46114. constructor(
  46115. /**
  46116. * the id of this component
  46117. */
  46118. id: string,
  46119. /**
  46120. * the type of the component
  46121. */
  46122. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46123. /**
  46124. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46125. */
  46126. get axes(): IWebXRMotionControllerAxesValue;
  46127. /**
  46128. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46129. */
  46130. get changes(): IWebXRMotionControllerComponentChanges;
  46131. /**
  46132. * Return whether or not the component changed the last frame
  46133. */
  46134. get hasChanges(): boolean;
  46135. /**
  46136. * is the button currently pressed
  46137. */
  46138. get pressed(): boolean;
  46139. /**
  46140. * is the button currently touched
  46141. */
  46142. get touched(): boolean;
  46143. /**
  46144. * Get the current value of this component
  46145. */
  46146. get value(): number;
  46147. /**
  46148. * Dispose this component
  46149. */
  46150. dispose(): void;
  46151. /**
  46152. * Are there axes correlating to this component
  46153. * @return true is axes data is available
  46154. */
  46155. isAxes(): boolean;
  46156. /**
  46157. * Is this component a button (hence - pressable)
  46158. * @returns true if can be pressed
  46159. */
  46160. isButton(): boolean;
  46161. /**
  46162. * update this component using the gamepad object it is in. Called on every frame
  46163. * @param nativeController the native gamepad controller object
  46164. */
  46165. update(nativeController: IMinimalMotionControllerObject): void;
  46166. }
  46167. }
  46168. declare module BABYLON {
  46169. /**
  46170. * Class used to represent data loading progression
  46171. */
  46172. export class SceneLoaderProgressEvent {
  46173. /** defines if data length to load can be evaluated */
  46174. readonly lengthComputable: boolean;
  46175. /** defines the loaded data length */
  46176. readonly loaded: number;
  46177. /** defines the data length to load */
  46178. readonly total: number;
  46179. /**
  46180. * Create a new progress event
  46181. * @param lengthComputable defines if data length to load can be evaluated
  46182. * @param loaded defines the loaded data length
  46183. * @param total defines the data length to load
  46184. */
  46185. constructor(
  46186. /** defines if data length to load can be evaluated */
  46187. lengthComputable: boolean,
  46188. /** defines the loaded data length */
  46189. loaded: number,
  46190. /** defines the data length to load */
  46191. total: number);
  46192. /**
  46193. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  46194. * @param event defines the source event
  46195. * @returns a new SceneLoaderProgressEvent
  46196. */
  46197. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  46198. }
  46199. /**
  46200. * Interface used by SceneLoader plugins to define supported file extensions
  46201. */
  46202. export interface ISceneLoaderPluginExtensions {
  46203. /**
  46204. * Defines the list of supported extensions
  46205. */
  46206. [extension: string]: {
  46207. isBinary: boolean;
  46208. };
  46209. }
  46210. /**
  46211. * Interface used by SceneLoader plugin factory
  46212. */
  46213. export interface ISceneLoaderPluginFactory {
  46214. /**
  46215. * Defines the name of the factory
  46216. */
  46217. name: string;
  46218. /**
  46219. * Function called to create a new plugin
  46220. * @return the new plugin
  46221. */
  46222. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46223. /**
  46224. * The callback that returns true if the data can be directly loaded.
  46225. * @param data string containing the file data
  46226. * @returns if the data can be loaded directly
  46227. */
  46228. canDirectLoad?(data: string): boolean;
  46229. }
  46230. /**
  46231. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46232. */
  46233. export interface ISceneLoaderPluginBase {
  46234. /**
  46235. * The friendly name of this plugin.
  46236. */
  46237. name: string;
  46238. /**
  46239. * The file extensions supported by this plugin.
  46240. */
  46241. extensions: string | ISceneLoaderPluginExtensions;
  46242. /**
  46243. * The callback called when loading from a url.
  46244. * @param scene scene loading this url
  46245. * @param url url to load
  46246. * @param onSuccess callback called when the file successfully loads
  46247. * @param onProgress callback called while file is loading (if the server supports this mode)
  46248. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46249. * @param onError callback called when the file fails to load
  46250. * @returns a file request object
  46251. */
  46252. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46253. /**
  46254. * The callback called when loading from a file object.
  46255. * @param scene scene loading this file
  46256. * @param file defines the file to load
  46257. * @param onSuccess defines the callback to call when data is loaded
  46258. * @param onProgress defines the callback to call during loading process
  46259. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46260. * @param onError defines the callback to call when an error occurs
  46261. * @returns a file request object
  46262. */
  46263. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46264. /**
  46265. * The callback that returns true if the data can be directly loaded.
  46266. * @param data string containing the file data
  46267. * @returns if the data can be loaded directly
  46268. */
  46269. canDirectLoad?(data: string): boolean;
  46270. /**
  46271. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46272. * @param scene scene loading this data
  46273. * @param data string containing the data
  46274. * @returns data to pass to the plugin
  46275. */
  46276. directLoad?(scene: Scene, data: string): any;
  46277. /**
  46278. * The callback that allows custom handling of the root url based on the response url.
  46279. * @param rootUrl the original root url
  46280. * @param responseURL the response url if available
  46281. * @returns the new root url
  46282. */
  46283. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46284. }
  46285. /**
  46286. * Interface used to define a SceneLoader plugin
  46287. */
  46288. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46289. /**
  46290. * Import meshes into a scene.
  46291. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46292. * @param scene The scene to import into
  46293. * @param data The data to import
  46294. * @param rootUrl The root url for scene and resources
  46295. * @param meshes The meshes array to import into
  46296. * @param particleSystems The particle systems array to import into
  46297. * @param skeletons The skeletons array to import into
  46298. * @param onError The callback when import fails
  46299. * @returns True if successful or false otherwise
  46300. */
  46301. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46302. /**
  46303. * Load into a scene.
  46304. * @param scene The scene to load into
  46305. * @param data The data to import
  46306. * @param rootUrl The root url for scene and resources
  46307. * @param onError The callback when import fails
  46308. * @returns True if successful or false otherwise
  46309. */
  46310. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46311. /**
  46312. * Load into an asset container.
  46313. * @param scene The scene to load into
  46314. * @param data The data to import
  46315. * @param rootUrl The root url for scene and resources
  46316. * @param onError The callback when import fails
  46317. * @returns The loaded asset container
  46318. */
  46319. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46320. }
  46321. /**
  46322. * Interface used to define an async SceneLoader plugin
  46323. */
  46324. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46325. /**
  46326. * Import meshes into a scene.
  46327. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46328. * @param scene The scene to import into
  46329. * @param data The data to import
  46330. * @param rootUrl The root url for scene and resources
  46331. * @param onProgress The callback when the load progresses
  46332. * @param fileName Defines the name of the file to load
  46333. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46334. */
  46335. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46336. meshes: AbstractMesh[];
  46337. particleSystems: IParticleSystem[];
  46338. skeletons: Skeleton[];
  46339. animationGroups: AnimationGroup[];
  46340. }>;
  46341. /**
  46342. * Load into a scene.
  46343. * @param scene The scene to load into
  46344. * @param data The data to import
  46345. * @param rootUrl The root url for scene and resources
  46346. * @param onProgress The callback when the load progresses
  46347. * @param fileName Defines the name of the file to load
  46348. * @returns Nothing
  46349. */
  46350. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46351. /**
  46352. * Load into an asset container.
  46353. * @param scene The scene to load into
  46354. * @param data The data to import
  46355. * @param rootUrl The root url for scene and resources
  46356. * @param onProgress The callback when the load progresses
  46357. * @param fileName Defines the name of the file to load
  46358. * @returns The loaded asset container
  46359. */
  46360. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46361. }
  46362. /**
  46363. * Mode that determines how to handle old animation groups before loading new ones.
  46364. */
  46365. export enum SceneLoaderAnimationGroupLoadingMode {
  46366. /**
  46367. * Reset all old animations to initial state then dispose them.
  46368. */
  46369. Clean = 0,
  46370. /**
  46371. * Stop all old animations.
  46372. */
  46373. Stop = 1,
  46374. /**
  46375. * Restart old animations from first frame.
  46376. */
  46377. Sync = 2,
  46378. /**
  46379. * Old animations remains untouched.
  46380. */
  46381. NoSync = 3
  46382. }
  46383. /**
  46384. * Class used to load scene from various file formats using registered plugins
  46385. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46386. */
  46387. export class SceneLoader {
  46388. /**
  46389. * No logging while loading
  46390. */
  46391. static readonly NO_LOGGING: number;
  46392. /**
  46393. * Minimal logging while loading
  46394. */
  46395. static readonly MINIMAL_LOGGING: number;
  46396. /**
  46397. * Summary logging while loading
  46398. */
  46399. static readonly SUMMARY_LOGGING: number;
  46400. /**
  46401. * Detailled logging while loading
  46402. */
  46403. static readonly DETAILED_LOGGING: number;
  46404. /**
  46405. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46406. */
  46407. static get ForceFullSceneLoadingForIncremental(): boolean;
  46408. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46409. /**
  46410. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46411. */
  46412. static get ShowLoadingScreen(): boolean;
  46413. static set ShowLoadingScreen(value: boolean);
  46414. /**
  46415. * Defines the current logging level (while loading the scene)
  46416. * @ignorenaming
  46417. */
  46418. static get loggingLevel(): number;
  46419. static set loggingLevel(value: number);
  46420. /**
  46421. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46422. */
  46423. static get CleanBoneMatrixWeights(): boolean;
  46424. static set CleanBoneMatrixWeights(value: boolean);
  46425. /**
  46426. * Event raised when a plugin is used to load a scene
  46427. */
  46428. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46429. private static _registeredPlugins;
  46430. private static _getDefaultPlugin;
  46431. private static _getPluginForExtension;
  46432. private static _getPluginForDirectLoad;
  46433. private static _getPluginForFilename;
  46434. private static _getDirectLoad;
  46435. private static _loadData;
  46436. private static _getFileInfo;
  46437. /**
  46438. * Gets a plugin that can load the given extension
  46439. * @param extension defines the extension to load
  46440. * @returns a plugin or null if none works
  46441. */
  46442. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46443. /**
  46444. * Gets a boolean indicating that the given extension can be loaded
  46445. * @param extension defines the extension to load
  46446. * @returns true if the extension is supported
  46447. */
  46448. static IsPluginForExtensionAvailable(extension: string): boolean;
  46449. /**
  46450. * Adds a new plugin to the list of registered plugins
  46451. * @param plugin defines the plugin to add
  46452. */
  46453. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46454. /**
  46455. * Import meshes into a scene
  46456. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46457. * @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)
  46458. * @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)
  46459. * @param scene the instance of BABYLON.Scene to append to
  46460. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46461. * @param onProgress a callback with a progress event for each file being loaded
  46462. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46463. * @param pluginExtension the extension used to determine the plugin
  46464. * @returns The loaded plugin
  46465. */
  46466. 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>;
  46467. /**
  46468. * Import meshes into a scene
  46469. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46470. * @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)
  46471. * @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)
  46472. * @param scene the instance of BABYLON.Scene to append to
  46473. * @param onProgress a callback with a progress event for each file being loaded
  46474. * @param pluginExtension the extension used to determine the plugin
  46475. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46476. */
  46477. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46478. meshes: AbstractMesh[];
  46479. particleSystems: IParticleSystem[];
  46480. skeletons: Skeleton[];
  46481. animationGroups: AnimationGroup[];
  46482. }>;
  46483. /**
  46484. * Load a scene
  46485. * @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)
  46486. * @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)
  46487. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46488. * @param onSuccess a callback with the scene when import succeeds
  46489. * @param onProgress a callback with a progress event for each file being loaded
  46490. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46491. * @param pluginExtension the extension used to determine the plugin
  46492. * @returns The loaded plugin
  46493. */
  46494. 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>;
  46495. /**
  46496. * Load a scene
  46497. * @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)
  46498. * @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)
  46499. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46500. * @param onProgress a callback with a progress event for each file being loaded
  46501. * @param pluginExtension the extension used to determine the plugin
  46502. * @returns The loaded scene
  46503. */
  46504. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46505. /**
  46506. * Append a scene
  46507. * @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)
  46508. * @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)
  46509. * @param scene is the instance of BABYLON.Scene to append to
  46510. * @param onSuccess a callback with the scene when import succeeds
  46511. * @param onProgress a callback with a progress event for each file being loaded
  46512. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46513. * @param pluginExtension the extension used to determine the plugin
  46514. * @returns The loaded plugin
  46515. */
  46516. 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>;
  46517. /**
  46518. * Append a scene
  46519. * @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)
  46520. * @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)
  46521. * @param scene is the instance of BABYLON.Scene to append to
  46522. * @param onProgress a callback with a progress event for each file being loaded
  46523. * @param pluginExtension the extension used to determine the plugin
  46524. * @returns The given scene
  46525. */
  46526. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46527. /**
  46528. * Load a scene into an asset container
  46529. * @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)
  46530. * @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)
  46531. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46532. * @param onSuccess a callback with the scene when import succeeds
  46533. * @param onProgress a callback with a progress event for each file being loaded
  46534. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46535. * @param pluginExtension the extension used to determine the plugin
  46536. * @returns The loaded plugin
  46537. */
  46538. 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>;
  46539. /**
  46540. * Load a scene into an asset container
  46541. * @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)
  46542. * @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)
  46543. * @param scene is the instance of Scene to append to
  46544. * @param onProgress a callback with a progress event for each file being loaded
  46545. * @param pluginExtension the extension used to determine the plugin
  46546. * @returns The loaded asset container
  46547. */
  46548. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46549. /**
  46550. * Import animations from a file into a scene
  46551. * @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)
  46552. * @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)
  46553. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46554. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46555. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46556. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46557. * @param onSuccess a callback with the scene when import succeeds
  46558. * @param onProgress a callback with a progress event for each file being loaded
  46559. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46560. */
  46561. 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;
  46562. /**
  46563. * Import animations from a file into a scene
  46564. * @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)
  46565. * @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)
  46566. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46567. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46568. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46569. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46570. * @param onSuccess a callback with the scene when import succeeds
  46571. * @param onProgress a callback with a progress event for each file being loaded
  46572. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46573. * @returns the updated scene with imported animations
  46574. */
  46575. 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>;
  46576. }
  46577. }
  46578. declare module BABYLON {
  46579. /**
  46580. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46581. */
  46582. export type MotionControllerHandedness = "none" | "left" | "right";
  46583. /**
  46584. * The type of components available in motion controllers.
  46585. * This is not the name of the component.
  46586. */
  46587. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46588. /**
  46589. * The state of a controller component
  46590. */
  46591. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46592. /**
  46593. * The schema of motion controller layout.
  46594. * No object will be initialized using this interface
  46595. * This is used just to define the profile.
  46596. */
  46597. export interface IMotionControllerLayout {
  46598. /**
  46599. * Path to load the assets. Usually relative to the base path
  46600. */
  46601. assetPath: string;
  46602. /**
  46603. * Available components (unsorted)
  46604. */
  46605. components: {
  46606. /**
  46607. * A map of component Ids
  46608. */
  46609. [componentId: string]: {
  46610. /**
  46611. * The type of input the component outputs
  46612. */
  46613. type: MotionControllerComponentType;
  46614. /**
  46615. * The indices of this component in the gamepad object
  46616. */
  46617. gamepadIndices: {
  46618. /**
  46619. * Index of button
  46620. */
  46621. button?: number;
  46622. /**
  46623. * If available, index of x-axis
  46624. */
  46625. xAxis?: number;
  46626. /**
  46627. * If available, index of y-axis
  46628. */
  46629. yAxis?: number;
  46630. };
  46631. /**
  46632. * The mesh's root node name
  46633. */
  46634. rootNodeName: string;
  46635. /**
  46636. * Animation definitions for this model
  46637. */
  46638. visualResponses: {
  46639. [stateKey: string]: {
  46640. /**
  46641. * What property will be animated
  46642. */
  46643. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46644. /**
  46645. * What states influence this visual response
  46646. */
  46647. states: MotionControllerComponentStateType[];
  46648. /**
  46649. * Type of animation - movement or visibility
  46650. */
  46651. valueNodeProperty: "transform" | "visibility";
  46652. /**
  46653. * Base node name to move. Its position will be calculated according to the min and max nodes
  46654. */
  46655. valueNodeName?: string;
  46656. /**
  46657. * Minimum movement node
  46658. */
  46659. minNodeName?: string;
  46660. /**
  46661. * Max movement node
  46662. */
  46663. maxNodeName?: string;
  46664. };
  46665. };
  46666. /**
  46667. * If touch enabled, what is the name of node to display user feedback
  46668. */
  46669. touchPointNodeName?: string;
  46670. };
  46671. };
  46672. /**
  46673. * Is it xr standard mapping or not
  46674. */
  46675. gamepadMapping: "" | "xr-standard";
  46676. /**
  46677. * Base root node of this entire model
  46678. */
  46679. rootNodeName: string;
  46680. /**
  46681. * Defines the main button component id
  46682. */
  46683. selectComponentId: string;
  46684. }
  46685. /**
  46686. * A definition for the layout map in the input profile
  46687. */
  46688. export interface IMotionControllerLayoutMap {
  46689. /**
  46690. * Layouts with handedness type as a key
  46691. */
  46692. [handedness: string]: IMotionControllerLayout;
  46693. }
  46694. /**
  46695. * The XR Input profile schema
  46696. * Profiles can be found here:
  46697. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  46698. */
  46699. export interface IMotionControllerProfile {
  46700. /**
  46701. * fallback profiles for this profileId
  46702. */
  46703. fallbackProfileIds: string[];
  46704. /**
  46705. * The layout map, with handedness as key
  46706. */
  46707. layouts: IMotionControllerLayoutMap;
  46708. /**
  46709. * The id of this profile
  46710. * correlates to the profile(s) in the xrInput.profiles array
  46711. */
  46712. profileId: string;
  46713. }
  46714. /**
  46715. * A helper-interface for the 3 meshes needed for controller button animation
  46716. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  46717. */
  46718. export interface IMotionControllerButtonMeshMap {
  46719. /**
  46720. * the mesh that defines the pressed value mesh position.
  46721. * This is used to find the max-position of this button
  46722. */
  46723. pressedMesh: AbstractMesh;
  46724. /**
  46725. * the mesh that defines the unpressed value mesh position.
  46726. * This is used to find the min (or initial) position of this button
  46727. */
  46728. unpressedMesh: AbstractMesh;
  46729. /**
  46730. * The mesh that will be changed when value changes
  46731. */
  46732. valueMesh: AbstractMesh;
  46733. }
  46734. /**
  46735. * A helper-interface for the 3 meshes needed for controller axis animation.
  46736. * This will be expanded when touchpad animations are fully supported
  46737. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  46738. */
  46739. export interface IMotionControllerMeshMap {
  46740. /**
  46741. * the mesh that defines the maximum value mesh position.
  46742. */
  46743. maxMesh?: AbstractMesh;
  46744. /**
  46745. * the mesh that defines the minimum value mesh position.
  46746. */
  46747. minMesh?: AbstractMesh;
  46748. /**
  46749. * The mesh that will be changed when axis value changes
  46750. */
  46751. valueMesh: AbstractMesh;
  46752. }
  46753. /**
  46754. * The elements needed for change-detection of the gamepad objects in motion controllers
  46755. */
  46756. export interface IMinimalMotionControllerObject {
  46757. /**
  46758. * Available axes of this controller
  46759. */
  46760. axes: number[];
  46761. /**
  46762. * An array of available buttons
  46763. */
  46764. buttons: Array<{
  46765. /**
  46766. * Value of the button/trigger
  46767. */
  46768. value: number;
  46769. /**
  46770. * If the button/trigger is currently touched
  46771. */
  46772. touched: boolean;
  46773. /**
  46774. * If the button/trigger is currently pressed
  46775. */
  46776. pressed: boolean;
  46777. }>;
  46778. /**
  46779. * EXPERIMENTAL haptic support.
  46780. */
  46781. hapticActuators?: Array<{
  46782. pulse: (value: number, duration: number) => Promise<boolean>;
  46783. }>;
  46784. }
  46785. /**
  46786. * An Abstract Motion controller
  46787. * This class receives an xrInput and a profile layout and uses those to initialize the components
  46788. * Each component has an observable to check for changes in value and state
  46789. */
  46790. export abstract class WebXRAbstractMotionController implements IDisposable {
  46791. protected scene: Scene;
  46792. protected layout: IMotionControllerLayout;
  46793. /**
  46794. * The gamepad object correlating to this controller
  46795. */
  46796. gamepadObject: IMinimalMotionControllerObject;
  46797. /**
  46798. * handedness (left/right/none) of this controller
  46799. */
  46800. handedness: MotionControllerHandedness;
  46801. private _initComponent;
  46802. private _modelReady;
  46803. /**
  46804. * A map of components (WebXRControllerComponent) in this motion controller
  46805. * Components have a ComponentType and can also have both button and axis definitions
  46806. */
  46807. readonly components: {
  46808. [id: string]: WebXRControllerComponent;
  46809. };
  46810. /**
  46811. * Disable the model's animation. Can be set at any time.
  46812. */
  46813. disableAnimation: boolean;
  46814. /**
  46815. * Observers registered here will be triggered when the model of this controller is done loading
  46816. */
  46817. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  46818. /**
  46819. * The profile id of this motion controller
  46820. */
  46821. abstract profileId: string;
  46822. /**
  46823. * The root mesh of the model. It is null if the model was not yet initialized
  46824. */
  46825. rootMesh: Nullable<AbstractMesh>;
  46826. /**
  46827. * constructs a new abstract motion controller
  46828. * @param scene the scene to which the model of the controller will be added
  46829. * @param layout The profile layout to load
  46830. * @param gamepadObject The gamepad object correlating to this controller
  46831. * @param handedness handedness (left/right/none) of this controller
  46832. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  46833. */
  46834. constructor(scene: Scene, layout: IMotionControllerLayout,
  46835. /**
  46836. * The gamepad object correlating to this controller
  46837. */
  46838. gamepadObject: IMinimalMotionControllerObject,
  46839. /**
  46840. * handedness (left/right/none) of this controller
  46841. */
  46842. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  46843. /**
  46844. * Dispose this controller, the model mesh and all its components
  46845. */
  46846. dispose(): void;
  46847. /**
  46848. * Returns all components of specific type
  46849. * @param type the type to search for
  46850. * @return an array of components with this type
  46851. */
  46852. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  46853. /**
  46854. * get a component based an its component id as defined in layout.components
  46855. * @param id the id of the component
  46856. * @returns the component correlates to the id or undefined if not found
  46857. */
  46858. getComponent(id: string): WebXRControllerComponent;
  46859. /**
  46860. * Get the list of components available in this motion controller
  46861. * @returns an array of strings correlating to available components
  46862. */
  46863. getComponentIds(): string[];
  46864. /**
  46865. * Get the first component of specific type
  46866. * @param type type of component to find
  46867. * @return a controller component or null if not found
  46868. */
  46869. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  46870. /**
  46871. * Get the main (Select) component of this controller as defined in the layout
  46872. * @returns the main component of this controller
  46873. */
  46874. getMainComponent(): WebXRControllerComponent;
  46875. /**
  46876. * Loads the model correlating to this controller
  46877. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  46878. * @returns A promise fulfilled with the result of the model loading
  46879. */
  46880. loadModel(): Promise<boolean>;
  46881. /**
  46882. * Update this model using the current XRFrame
  46883. * @param xrFrame the current xr frame to use and update the model
  46884. */
  46885. updateFromXRFrame(xrFrame: XRFrame): void;
  46886. /**
  46887. * Backwards compatibility due to a deeply-integrated typo
  46888. */
  46889. get handness(): XREye;
  46890. /**
  46891. * Pulse (vibrate) this controller
  46892. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  46893. * Consecutive calls to this function will cancel the last pulse call
  46894. *
  46895. * @param value the strength of the pulse in 0.0...1.0 range
  46896. * @param duration Duration of the pulse in milliseconds
  46897. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  46898. * @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
  46899. */
  46900. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  46901. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46902. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46903. /**
  46904. * Moves the axis on the controller mesh based on its current state
  46905. * @param axis the index of the axis
  46906. * @param axisValue the value of the axis which determines the meshes new position
  46907. * @hidden
  46908. */
  46909. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  46910. /**
  46911. * Update the model itself with the current frame data
  46912. * @param xrFrame the frame to use for updating the model mesh
  46913. */
  46914. protected updateModel(xrFrame: XRFrame): void;
  46915. /**
  46916. * Get the filename and path for this controller's model
  46917. * @returns a map of filename and path
  46918. */
  46919. protected abstract _getFilenameAndPath(): {
  46920. filename: string;
  46921. path: string;
  46922. };
  46923. /**
  46924. * This function is called before the mesh is loaded. It checks for loading constraints.
  46925. * For example, this function can check if the GLB loader is available
  46926. * If this function returns false, the generic controller will be loaded instead
  46927. * @returns Is the client ready to load the mesh
  46928. */
  46929. protected abstract _getModelLoadingConstraints(): boolean;
  46930. /**
  46931. * This function will be called after the model was successfully loaded and can be used
  46932. * for mesh transformations before it is available for the user
  46933. * @param meshes the loaded meshes
  46934. */
  46935. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  46936. /**
  46937. * Set the root mesh for this controller. Important for the WebXR controller class
  46938. * @param meshes the loaded meshes
  46939. */
  46940. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  46941. /**
  46942. * A function executed each frame that updates the mesh (if needed)
  46943. * @param xrFrame the current xrFrame
  46944. */
  46945. protected abstract _updateModel(xrFrame: XRFrame): void;
  46946. private _getGenericFilenameAndPath;
  46947. private _getGenericParentMesh;
  46948. }
  46949. }
  46950. declare module BABYLON {
  46951. /**
  46952. * A generic trigger-only motion controller for WebXR
  46953. */
  46954. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  46955. /**
  46956. * Static version of the profile id of this controller
  46957. */
  46958. static ProfileId: string;
  46959. profileId: string;
  46960. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  46961. protected _getFilenameAndPath(): {
  46962. filename: string;
  46963. path: string;
  46964. };
  46965. protected _getModelLoadingConstraints(): boolean;
  46966. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  46967. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46968. protected _updateModel(): void;
  46969. }
  46970. }
  46971. declare module BABYLON {
  46972. /**
  46973. * Class containing static functions to help procedurally build meshes
  46974. */
  46975. export class SphereBuilder {
  46976. /**
  46977. * Creates a sphere mesh
  46978. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46979. * * 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`)
  46980. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46981. * * 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
  46982. * * 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)
  46983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46984. * * 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
  46985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46986. * @param name defines the name of the mesh
  46987. * @param options defines the options used to create the mesh
  46988. * @param scene defines the hosting scene
  46989. * @returns the sphere mesh
  46990. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46991. */
  46992. static CreateSphere(name: string, options: {
  46993. segments?: number;
  46994. diameter?: number;
  46995. diameterX?: number;
  46996. diameterY?: number;
  46997. diameterZ?: number;
  46998. arc?: number;
  46999. slice?: number;
  47000. sideOrientation?: number;
  47001. frontUVs?: Vector4;
  47002. backUVs?: Vector4;
  47003. updatable?: boolean;
  47004. }, scene?: Nullable<Scene>): Mesh;
  47005. }
  47006. }
  47007. declare module BABYLON {
  47008. /**
  47009. * A profiled motion controller has its profile loaded from an online repository.
  47010. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47011. */
  47012. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47013. private _repositoryUrl;
  47014. private _buttonMeshMapping;
  47015. private _touchDots;
  47016. /**
  47017. * The profile ID of this controller. Will be populated when the controller initializes.
  47018. */
  47019. profileId: string;
  47020. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47021. dispose(): void;
  47022. protected _getFilenameAndPath(): {
  47023. filename: string;
  47024. path: string;
  47025. };
  47026. protected _getModelLoadingConstraints(): boolean;
  47027. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47028. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47029. protected _updateModel(_xrFrame: XRFrame): void;
  47030. }
  47031. }
  47032. declare module BABYLON {
  47033. /**
  47034. * A construction function type to create a new controller based on an xrInput object
  47035. */
  47036. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47037. /**
  47038. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47039. *
  47040. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47041. * it should be replaced with auto-loaded controllers.
  47042. *
  47043. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47044. */
  47045. export class WebXRMotionControllerManager {
  47046. private static _AvailableControllers;
  47047. private static _Fallbacks;
  47048. private static _ProfileLoadingPromises;
  47049. private static _ProfilesList;
  47050. /**
  47051. * The base URL of the online controller repository. Can be changed at any time.
  47052. */
  47053. static BaseRepositoryUrl: string;
  47054. /**
  47055. * Which repository gets priority - local or online
  47056. */
  47057. static PrioritizeOnlineRepository: boolean;
  47058. /**
  47059. * Use the online repository, or use only locally-defined controllers
  47060. */
  47061. static UseOnlineRepository: boolean;
  47062. /**
  47063. * Clear the cache used for profile loading and reload when requested again
  47064. */
  47065. static ClearProfilesCache(): void;
  47066. /**
  47067. * Register the default fallbacks.
  47068. * This function is called automatically when this file is imported.
  47069. */
  47070. static DefaultFallbacks(): void;
  47071. /**
  47072. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47073. * @param profileId the profile to which a fallback needs to be found
  47074. * @return an array with corresponding fallback profiles
  47075. */
  47076. static FindFallbackWithProfileId(profileId: string): string[];
  47077. /**
  47078. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47079. * The order of search:
  47080. *
  47081. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47082. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47083. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47084. * 4) return the generic trigger controller if none were found
  47085. *
  47086. * @param xrInput the xrInput to which a new controller is initialized
  47087. * @param scene the scene to which the model will be added
  47088. * @param forceProfile force a certain profile for this controller
  47089. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47090. */
  47091. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47092. /**
  47093. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47094. *
  47095. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47096. *
  47097. * @param type the profile type to register
  47098. * @param constructFunction the function to be called when loading this profile
  47099. */
  47100. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47101. /**
  47102. * Register a fallback to a specific profile.
  47103. * @param profileId the profileId that will receive the fallbacks
  47104. * @param fallbacks A list of fallback profiles
  47105. */
  47106. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47107. /**
  47108. * Will update the list of profiles available in the repository
  47109. * @return a promise that resolves to a map of profiles available online
  47110. */
  47111. static UpdateProfilesList(): Promise<{
  47112. [profile: string]: string;
  47113. }>;
  47114. private static _LoadProfileFromRepository;
  47115. private static _LoadProfilesFromAvailableControllers;
  47116. }
  47117. }
  47118. declare module BABYLON {
  47119. /**
  47120. * Configuration options for the WebXR controller creation
  47121. */
  47122. export interface IWebXRControllerOptions {
  47123. /**
  47124. * Should the controller mesh be animated when a user interacts with it
  47125. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47126. */
  47127. disableMotionControllerAnimation?: boolean;
  47128. /**
  47129. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47130. */
  47131. doNotLoadControllerMesh?: boolean;
  47132. /**
  47133. * Force a specific controller type for this controller.
  47134. * This can be used when creating your own profile or when testing different controllers
  47135. */
  47136. forceControllerProfile?: string;
  47137. /**
  47138. * Defines a rendering group ID for meshes that will be loaded.
  47139. * This is for the default controllers only.
  47140. */
  47141. renderingGroupId?: number;
  47142. }
  47143. /**
  47144. * Represents an XR controller
  47145. */
  47146. export class WebXRInputSource {
  47147. private _scene;
  47148. /** The underlying input source for the controller */
  47149. inputSource: XRInputSource;
  47150. private _options;
  47151. private _tmpVector;
  47152. private _uniqueId;
  47153. /**
  47154. * 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
  47155. */
  47156. grip?: AbstractMesh;
  47157. /**
  47158. * If available, this is the gamepad object related to this controller.
  47159. * Using this object it is possible to get click events and trackpad changes of the
  47160. * webxr controller that is currently being used.
  47161. */
  47162. motionController?: WebXRAbstractMotionController;
  47163. /**
  47164. * Event that fires when the controller is removed/disposed.
  47165. * The object provided as event data is this controller, after associated assets were disposed.
  47166. * uniqueId is still available.
  47167. */
  47168. onDisposeObservable: Observable<WebXRInputSource>;
  47169. /**
  47170. * Will be triggered when the mesh associated with the motion controller is done loading.
  47171. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47172. * A shortened version of controller -> motion controller -> on mesh loaded.
  47173. */
  47174. onMeshLoadedObservable: Observable<AbstractMesh>;
  47175. /**
  47176. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47177. */
  47178. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47179. /**
  47180. * Pointer which can be used to select objects or attach a visible laser to
  47181. */
  47182. pointer: AbstractMesh;
  47183. /**
  47184. * Creates the controller
  47185. * @see https://doc.babylonjs.com/how_to/webxr
  47186. * @param _scene the scene which the controller should be associated to
  47187. * @param inputSource the underlying input source for the controller
  47188. * @param _options options for this controller creation
  47189. */
  47190. constructor(_scene: Scene,
  47191. /** The underlying input source for the controller */
  47192. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47193. /**
  47194. * Get this controllers unique id
  47195. */
  47196. get uniqueId(): string;
  47197. /**
  47198. * Disposes of the object
  47199. */
  47200. dispose(): void;
  47201. /**
  47202. * Gets a world space ray coming from the pointer or grip
  47203. * @param result the resulting ray
  47204. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47205. */
  47206. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47207. /**
  47208. * Updates the controller pose based on the given XRFrame
  47209. * @param xrFrame xr frame to update the pose with
  47210. * @param referenceSpace reference space to use
  47211. */
  47212. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47213. }
  47214. }
  47215. declare module BABYLON {
  47216. /**
  47217. * The schema for initialization options of the XR Input class
  47218. */
  47219. export interface IWebXRInputOptions {
  47220. /**
  47221. * If set to true no model will be automatically loaded
  47222. */
  47223. doNotLoadControllerMeshes?: boolean;
  47224. /**
  47225. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47226. * If not found, the xr input profile data will be used.
  47227. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47228. */
  47229. forceInputProfile?: string;
  47230. /**
  47231. * Do not send a request to the controller repository to load the profile.
  47232. *
  47233. * Instead, use the controllers available in babylon itself.
  47234. */
  47235. disableOnlineControllerRepository?: boolean;
  47236. /**
  47237. * A custom URL for the controllers repository
  47238. */
  47239. customControllersRepositoryURL?: string;
  47240. /**
  47241. * Should the controller model's components not move according to the user input
  47242. */
  47243. disableControllerAnimation?: boolean;
  47244. /**
  47245. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47246. */
  47247. controllerOptions?: IWebXRControllerOptions;
  47248. }
  47249. /**
  47250. * XR input used to track XR inputs such as controllers/rays
  47251. */
  47252. export class WebXRInput implements IDisposable {
  47253. /**
  47254. * the xr session manager for this session
  47255. */
  47256. xrSessionManager: WebXRSessionManager;
  47257. /**
  47258. * the WebXR camera for this session. Mainly used for teleportation
  47259. */
  47260. xrCamera: WebXRCamera;
  47261. private readonly options;
  47262. /**
  47263. * XR controllers being tracked
  47264. */
  47265. controllers: Array<WebXRInputSource>;
  47266. private _frameObserver;
  47267. private _sessionEndedObserver;
  47268. private _sessionInitObserver;
  47269. /**
  47270. * Event when a controller has been connected/added
  47271. */
  47272. onControllerAddedObservable: Observable<WebXRInputSource>;
  47273. /**
  47274. * Event when a controller has been removed/disconnected
  47275. */
  47276. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47277. /**
  47278. * Initializes the WebXRInput
  47279. * @param xrSessionManager the xr session manager for this session
  47280. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47281. * @param options = initialization options for this xr input
  47282. */
  47283. constructor(
  47284. /**
  47285. * the xr session manager for this session
  47286. */
  47287. xrSessionManager: WebXRSessionManager,
  47288. /**
  47289. * the WebXR camera for this session. Mainly used for teleportation
  47290. */
  47291. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47292. private _onInputSourcesChange;
  47293. private _addAndRemoveControllers;
  47294. /**
  47295. * Disposes of the object
  47296. */
  47297. dispose(): void;
  47298. }
  47299. }
  47300. declare module BABYLON {
  47301. /**
  47302. * This is the base class for all WebXR features.
  47303. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47304. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47305. */
  47306. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47307. protected _xrSessionManager: WebXRSessionManager;
  47308. private _attached;
  47309. private _removeOnDetach;
  47310. /**
  47311. * Should auto-attach be disabled?
  47312. */
  47313. disableAutoAttach: boolean;
  47314. /**
  47315. * Construct a new (abstract) WebXR feature
  47316. * @param _xrSessionManager the xr session manager for this feature
  47317. */
  47318. constructor(_xrSessionManager: WebXRSessionManager);
  47319. /**
  47320. * Is this feature attached
  47321. */
  47322. get attached(): boolean;
  47323. /**
  47324. * attach this feature
  47325. *
  47326. * @param force should attachment be forced (even when already attached)
  47327. * @returns true if successful, false is failed or already attached
  47328. */
  47329. attach(force?: boolean): boolean;
  47330. /**
  47331. * detach this feature.
  47332. *
  47333. * @returns true if successful, false if failed or already detached
  47334. */
  47335. detach(): boolean;
  47336. /**
  47337. * Dispose this feature and all of the resources attached
  47338. */
  47339. dispose(): void;
  47340. /**
  47341. * This is used to register callbacks that will automatically be removed when detach is called.
  47342. * @param observable the observable to which the observer will be attached
  47343. * @param callback the callback to register
  47344. */
  47345. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47346. /**
  47347. * Code in this function will be executed on each xrFrame received from the browser.
  47348. * This function will not execute after the feature is detached.
  47349. * @param _xrFrame the current frame
  47350. */
  47351. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47352. }
  47353. }
  47354. declare module BABYLON {
  47355. /**
  47356. * Renders a layer on top of an existing scene
  47357. */
  47358. export class UtilityLayerRenderer implements IDisposable {
  47359. /** the original scene that will be rendered on top of */
  47360. originalScene: Scene;
  47361. private _pointerCaptures;
  47362. private _lastPointerEvents;
  47363. private static _DefaultUtilityLayer;
  47364. private static _DefaultKeepDepthUtilityLayer;
  47365. private _sharedGizmoLight;
  47366. private _renderCamera;
  47367. /**
  47368. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47369. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47370. * @returns the camera that is used when rendering the utility layer
  47371. */
  47372. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47373. /**
  47374. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47375. * @param cam the camera that should be used when rendering the utility layer
  47376. */
  47377. setRenderCamera(cam: Nullable<Camera>): void;
  47378. /**
  47379. * @hidden
  47380. * Light which used by gizmos to get light shading
  47381. */
  47382. _getSharedGizmoLight(): HemisphericLight;
  47383. /**
  47384. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47385. */
  47386. pickUtilitySceneFirst: boolean;
  47387. /**
  47388. * 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)
  47389. */
  47390. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47391. /**
  47392. * 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)
  47393. */
  47394. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47395. /**
  47396. * The scene that is rendered on top of the original scene
  47397. */
  47398. utilityLayerScene: Scene;
  47399. /**
  47400. * If the utility layer should automatically be rendered on top of existing scene
  47401. */
  47402. shouldRender: boolean;
  47403. /**
  47404. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47405. */
  47406. onlyCheckPointerDownEvents: boolean;
  47407. /**
  47408. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47409. */
  47410. processAllEvents: boolean;
  47411. /**
  47412. * Observable raised when the pointer move from the utility layer scene to the main scene
  47413. */
  47414. onPointerOutObservable: Observable<number>;
  47415. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47416. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47417. private _afterRenderObserver;
  47418. private _sceneDisposeObserver;
  47419. private _originalPointerObserver;
  47420. /**
  47421. * Instantiates a UtilityLayerRenderer
  47422. * @param originalScene the original scene that will be rendered on top of
  47423. * @param handleEvents boolean indicating if the utility layer should handle events
  47424. */
  47425. constructor(
  47426. /** the original scene that will be rendered on top of */
  47427. originalScene: Scene, handleEvents?: boolean);
  47428. private _notifyObservers;
  47429. /**
  47430. * Renders the utility layers scene on top of the original scene
  47431. */
  47432. render(): void;
  47433. /**
  47434. * Disposes of the renderer
  47435. */
  47436. dispose(): void;
  47437. private _updateCamera;
  47438. }
  47439. }
  47440. declare module BABYLON {
  47441. /**
  47442. * Options interface for the pointer selection module
  47443. */
  47444. export interface IWebXRControllerPointerSelectionOptions {
  47445. /**
  47446. * if provided, this scene will be used to render meshes.
  47447. */
  47448. customUtilityLayerScene?: Scene;
  47449. /**
  47450. * 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)
  47451. * If not disabled, the last picked point will be used to execute a pointer up event
  47452. * If disabled, pointer up event will be triggered right after the pointer down event.
  47453. * Used in screen and gaze target ray mode only
  47454. */
  47455. disablePointerUpOnTouchOut: boolean;
  47456. /**
  47457. * For gaze mode (time to select instead of press)
  47458. */
  47459. forceGazeMode: boolean;
  47460. /**
  47461. * 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
  47462. * to start a new countdown to the pointer down event.
  47463. * Defaults to 1.
  47464. */
  47465. gazeModePointerMovedFactor?: number;
  47466. /**
  47467. * Different button type to use instead of the main component
  47468. */
  47469. overrideButtonId?: string;
  47470. /**
  47471. * use this rendering group id for the meshes (optional)
  47472. */
  47473. renderingGroupId?: number;
  47474. /**
  47475. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47476. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47477. * 3000 means 3 seconds between pointing at something and selecting it
  47478. */
  47479. timeToSelect?: number;
  47480. /**
  47481. * Should meshes created here be added to a utility layer or the main scene
  47482. */
  47483. useUtilityLayer?: boolean;
  47484. /**
  47485. * the xr input to use with this pointer selection
  47486. */
  47487. xrInput: WebXRInput;
  47488. }
  47489. /**
  47490. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47491. */
  47492. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47493. private readonly _options;
  47494. private static _idCounter;
  47495. private _attachController;
  47496. private _controllers;
  47497. private _scene;
  47498. private _tmpVectorForPickCompare;
  47499. /**
  47500. * The module's name
  47501. */
  47502. static readonly Name: string;
  47503. /**
  47504. * The (Babylon) version of this module.
  47505. * This is an integer representing the implementation version.
  47506. * This number does not correspond to the WebXR specs version
  47507. */
  47508. static readonly Version: number;
  47509. /**
  47510. * Disable lighting on the laser pointer (so it will always be visible)
  47511. */
  47512. disablePointerLighting: boolean;
  47513. /**
  47514. * Disable lighting on the selection mesh (so it will always be visible)
  47515. */
  47516. disableSelectionMeshLighting: boolean;
  47517. /**
  47518. * Should the laser pointer be displayed
  47519. */
  47520. displayLaserPointer: boolean;
  47521. /**
  47522. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47523. */
  47524. displaySelectionMesh: boolean;
  47525. /**
  47526. * This color will be set to the laser pointer when selection is triggered
  47527. */
  47528. laserPointerPickedColor: Color3;
  47529. /**
  47530. * Default color of the laser pointer
  47531. */
  47532. lasterPointerDefaultColor: Color3;
  47533. /**
  47534. * default color of the selection ring
  47535. */
  47536. selectionMeshDefaultColor: Color3;
  47537. /**
  47538. * This color will be applied to the selection ring when selection is triggered
  47539. */
  47540. selectionMeshPickedColor: Color3;
  47541. /**
  47542. * Optional filter to be used for ray selection. This predicate shares behavior with
  47543. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47544. */
  47545. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47546. /**
  47547. * constructs a new background remover module
  47548. * @param _xrSessionManager the session manager for this module
  47549. * @param _options read-only options to be used in this module
  47550. */
  47551. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47552. /**
  47553. * attach this feature
  47554. * Will usually be called by the features manager
  47555. *
  47556. * @returns true if successful.
  47557. */
  47558. attach(): boolean;
  47559. /**
  47560. * detach this feature.
  47561. * Will usually be called by the features manager
  47562. *
  47563. * @returns true if successful.
  47564. */
  47565. detach(): boolean;
  47566. /**
  47567. * Will get the mesh under a specific pointer.
  47568. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47569. * @param controllerId the controllerId to check
  47570. * @returns The mesh under pointer or null if no mesh is under the pointer
  47571. */
  47572. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47573. /**
  47574. * Get the xr controller that correlates to the pointer id in the pointer event
  47575. *
  47576. * @param id the pointer id to search for
  47577. * @returns the controller that correlates to this id or null if not found
  47578. */
  47579. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47580. protected _onXRFrame(_xrFrame: XRFrame): void;
  47581. private _attachGazeMode;
  47582. private _attachScreenRayMode;
  47583. private _attachTrackedPointerRayMode;
  47584. private _convertNormalToDirectionOfRay;
  47585. private _detachController;
  47586. private _generateNewMeshPair;
  47587. private _pickingMoved;
  47588. private _updatePointerDistance;
  47589. }
  47590. }
  47591. declare module BABYLON {
  47592. /**
  47593. * Button which can be used to enter a different mode of XR
  47594. */
  47595. export class WebXREnterExitUIButton {
  47596. /** button element */
  47597. element: HTMLElement;
  47598. /** XR initialization options for the button */
  47599. sessionMode: XRSessionMode;
  47600. /** Reference space type */
  47601. referenceSpaceType: XRReferenceSpaceType;
  47602. /**
  47603. * Creates a WebXREnterExitUIButton
  47604. * @param element button element
  47605. * @param sessionMode XR initialization session mode
  47606. * @param referenceSpaceType the type of reference space to be used
  47607. */
  47608. constructor(
  47609. /** button element */
  47610. element: HTMLElement,
  47611. /** XR initialization options for the button */
  47612. sessionMode: XRSessionMode,
  47613. /** Reference space type */
  47614. referenceSpaceType: XRReferenceSpaceType);
  47615. /**
  47616. * Extendable function which can be used to update the button's visuals when the state changes
  47617. * @param activeButton the current active button in the UI
  47618. */
  47619. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47620. }
  47621. /**
  47622. * Options to create the webXR UI
  47623. */
  47624. export class WebXREnterExitUIOptions {
  47625. /**
  47626. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47627. */
  47628. customButtons?: Array<WebXREnterExitUIButton>;
  47629. /**
  47630. * A reference space type to use when creating the default button.
  47631. * Default is local-floor
  47632. */
  47633. referenceSpaceType?: XRReferenceSpaceType;
  47634. /**
  47635. * Context to enter xr with
  47636. */
  47637. renderTarget?: Nullable<WebXRRenderTarget>;
  47638. /**
  47639. * A session mode to use when creating the default button.
  47640. * Default is immersive-vr
  47641. */
  47642. sessionMode?: XRSessionMode;
  47643. /**
  47644. * A list of optional features to init the session with
  47645. */
  47646. optionalFeatures?: string[];
  47647. }
  47648. /**
  47649. * UI to allow the user to enter/exit XR mode
  47650. */
  47651. export class WebXREnterExitUI implements IDisposable {
  47652. private scene;
  47653. /** version of the options passed to this UI */
  47654. options: WebXREnterExitUIOptions;
  47655. private _activeButton;
  47656. private _buttons;
  47657. private _overlay;
  47658. /**
  47659. * Fired every time the active button is changed.
  47660. *
  47661. * When xr is entered via a button that launches xr that button will be the callback parameter
  47662. *
  47663. * When exiting xr the callback parameter will be null)
  47664. */
  47665. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  47666. /**
  47667. *
  47668. * @param scene babylon scene object to use
  47669. * @param options (read-only) version of the options passed to this UI
  47670. */
  47671. private constructor();
  47672. /**
  47673. * Creates UI to allow the user to enter/exit XR mode
  47674. * @param scene the scene to add the ui to
  47675. * @param helper the xr experience helper to enter/exit xr with
  47676. * @param options options to configure the UI
  47677. * @returns the created ui
  47678. */
  47679. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  47680. /**
  47681. * Disposes of the XR UI component
  47682. */
  47683. dispose(): void;
  47684. private _updateButtons;
  47685. }
  47686. }
  47687. declare module BABYLON {
  47688. /**
  47689. * Class containing static functions to help procedurally build meshes
  47690. */
  47691. export class LinesBuilder {
  47692. /**
  47693. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47694. * * 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
  47695. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47696. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47697. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47698. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47699. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47700. * * 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
  47701. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47704. * @param name defines the name of the new line system
  47705. * @param options defines the options used to create the line system
  47706. * @param scene defines the hosting scene
  47707. * @returns a new line system mesh
  47708. */
  47709. static CreateLineSystem(name: string, options: {
  47710. lines: Vector3[][];
  47711. updatable?: boolean;
  47712. instance?: Nullable<LinesMesh>;
  47713. colors?: Nullable<Color4[][]>;
  47714. useVertexAlpha?: boolean;
  47715. }, scene: Nullable<Scene>): LinesMesh;
  47716. /**
  47717. * Creates a line mesh
  47718. * 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
  47719. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47720. * * The parameter `points` is an array successive Vector3
  47721. * * 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
  47722. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47723. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47724. * * When updating an instance, remember that only point positions can change, not the number of points
  47725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47726. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47727. * @param name defines the name of the new line system
  47728. * @param options defines the options used to create the line system
  47729. * @param scene defines the hosting scene
  47730. * @returns a new line mesh
  47731. */
  47732. static CreateLines(name: string, options: {
  47733. points: Vector3[];
  47734. updatable?: boolean;
  47735. instance?: Nullable<LinesMesh>;
  47736. colors?: Color4[];
  47737. useVertexAlpha?: boolean;
  47738. }, scene?: Nullable<Scene>): LinesMesh;
  47739. /**
  47740. * Creates a dashed line mesh
  47741. * * 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
  47742. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47743. * * The parameter `points` is an array successive Vector3
  47744. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47745. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47746. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47747. * * 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
  47748. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47749. * * When updating an instance, remember that only point positions can change, not the number of points
  47750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47751. * @param name defines the name of the mesh
  47752. * @param options defines the options used to create the mesh
  47753. * @param scene defines the hosting scene
  47754. * @returns the dashed line mesh
  47755. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47756. */
  47757. static CreateDashedLines(name: string, options: {
  47758. points: Vector3[];
  47759. dashSize?: number;
  47760. gapSize?: number;
  47761. dashNb?: number;
  47762. updatable?: boolean;
  47763. instance?: LinesMesh;
  47764. useVertexAlpha?: boolean;
  47765. }, scene?: Nullable<Scene>): LinesMesh;
  47766. }
  47767. }
  47768. declare module BABYLON {
  47769. /**
  47770. * The options container for the teleportation module
  47771. */
  47772. export interface IWebXRTeleportationOptions {
  47773. /**
  47774. * if provided, this scene will be used to render meshes.
  47775. */
  47776. customUtilityLayerScene?: Scene;
  47777. /**
  47778. * Values to configure the default target mesh
  47779. */
  47780. defaultTargetMeshOptions?: {
  47781. /**
  47782. * Fill color of the teleportation area
  47783. */
  47784. teleportationFillColor?: string;
  47785. /**
  47786. * Border color for the teleportation area
  47787. */
  47788. teleportationBorderColor?: string;
  47789. /**
  47790. * Disable the mesh's animation sequence
  47791. */
  47792. disableAnimation?: boolean;
  47793. /**
  47794. * Disable lighting on the material or the ring and arrow
  47795. */
  47796. disableLighting?: boolean;
  47797. /**
  47798. * Override the default material of the torus and arrow
  47799. */
  47800. torusArrowMaterial?: Material;
  47801. };
  47802. /**
  47803. * A list of meshes to use as floor meshes.
  47804. * Meshes can be added and removed after initializing the feature using the
  47805. * addFloorMesh and removeFloorMesh functions
  47806. * If empty, rotation will still work
  47807. */
  47808. floorMeshes?: AbstractMesh[];
  47809. /**
  47810. * use this rendering group id for the meshes (optional)
  47811. */
  47812. renderingGroupId?: number;
  47813. /**
  47814. * Should teleportation move only to snap points
  47815. */
  47816. snapPointsOnly?: boolean;
  47817. /**
  47818. * An array of points to which the teleportation will snap to.
  47819. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  47820. */
  47821. snapPositions?: Vector3[];
  47822. /**
  47823. * How close should the teleportation ray be in order to snap to position.
  47824. * Default to 0.8 units (meters)
  47825. */
  47826. snapToPositionRadius?: number;
  47827. /**
  47828. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  47829. * If you want to support rotation, make sure your mesh has a direction indicator.
  47830. *
  47831. * When left untouched, the default mesh will be initialized.
  47832. */
  47833. teleportationTargetMesh?: AbstractMesh;
  47834. /**
  47835. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  47836. */
  47837. timeToTeleport?: number;
  47838. /**
  47839. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  47840. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  47841. */
  47842. useMainComponentOnly?: boolean;
  47843. /**
  47844. * Should meshes created here be added to a utility layer or the main scene
  47845. */
  47846. useUtilityLayer?: boolean;
  47847. /**
  47848. * Babylon XR Input class for controller
  47849. */
  47850. xrInput: WebXRInput;
  47851. }
  47852. /**
  47853. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  47854. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  47855. * the input of the attached controllers.
  47856. */
  47857. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  47858. private _options;
  47859. private _controllers;
  47860. private _currentTeleportationControllerId;
  47861. private _floorMeshes;
  47862. private _quadraticBezierCurve;
  47863. private _selectionFeature;
  47864. private _snapToPositions;
  47865. private _snappedToPoint;
  47866. private _teleportationRingMaterial?;
  47867. private _tmpRay;
  47868. private _tmpVector;
  47869. /**
  47870. * The module's name
  47871. */
  47872. static readonly Name: string;
  47873. /**
  47874. * The (Babylon) version of this module.
  47875. * This is an integer representing the implementation version.
  47876. * This number does not correspond to the webxr specs version
  47877. */
  47878. static readonly Version: number;
  47879. /**
  47880. * Is movement backwards enabled
  47881. */
  47882. backwardsMovementEnabled: boolean;
  47883. /**
  47884. * Distance to travel when moving backwards
  47885. */
  47886. backwardsTeleportationDistance: number;
  47887. /**
  47888. * The distance from the user to the inspection point in the direction of the controller
  47889. * A higher number will allow the user to move further
  47890. * defaults to 5 (meters, in xr units)
  47891. */
  47892. parabolicCheckRadius: number;
  47893. /**
  47894. * Should the module support parabolic ray on top of direct ray
  47895. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  47896. * Very helpful when moving between floors / different heights
  47897. */
  47898. parabolicRayEnabled: boolean;
  47899. /**
  47900. * How much rotation should be applied when rotating right and left
  47901. */
  47902. rotationAngle: number;
  47903. /**
  47904. * Is rotation enabled when moving forward?
  47905. * Disabling this feature will prevent the user from deciding the direction when teleporting
  47906. */
  47907. rotationEnabled: boolean;
  47908. /**
  47909. * constructs a new anchor system
  47910. * @param _xrSessionManager an instance of WebXRSessionManager
  47911. * @param _options configuration object for this feature
  47912. */
  47913. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  47914. /**
  47915. * Get the snapPointsOnly flag
  47916. */
  47917. get snapPointsOnly(): boolean;
  47918. /**
  47919. * Sets the snapPointsOnly flag
  47920. * @param snapToPoints should teleportation be exclusively to snap points
  47921. */
  47922. set snapPointsOnly(snapToPoints: boolean);
  47923. /**
  47924. * Add a new mesh to the floor meshes array
  47925. * @param mesh the mesh to use as floor mesh
  47926. */
  47927. addFloorMesh(mesh: AbstractMesh): void;
  47928. /**
  47929. * Add a new snap-to point to fix teleportation to this position
  47930. * @param newSnapPoint The new Snap-To point
  47931. */
  47932. addSnapPoint(newSnapPoint: Vector3): void;
  47933. attach(): boolean;
  47934. detach(): boolean;
  47935. dispose(): void;
  47936. /**
  47937. * Remove a mesh from the floor meshes array
  47938. * @param mesh the mesh to remove
  47939. */
  47940. removeFloorMesh(mesh: AbstractMesh): void;
  47941. /**
  47942. * Remove a mesh from the floor meshes array using its name
  47943. * @param name the mesh name to remove
  47944. */
  47945. removeFloorMeshByName(name: string): void;
  47946. /**
  47947. * 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
  47948. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  47949. * @returns was the point found and removed or not
  47950. */
  47951. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  47952. /**
  47953. * This function sets a selection feature that will be disabled when
  47954. * the forward ray is shown and will be reattached when hidden.
  47955. * This is used to remove the selection rays when moving.
  47956. * @param selectionFeature the feature to disable when forward movement is enabled
  47957. */
  47958. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  47959. protected _onXRFrame(_xrFrame: XRFrame): void;
  47960. private _attachController;
  47961. private _createDefaultTargetMesh;
  47962. private _detachController;
  47963. private _findClosestSnapPointWithRadius;
  47964. private _setTargetMeshPosition;
  47965. private _setTargetMeshVisibility;
  47966. private _showParabolicPath;
  47967. private _teleportForward;
  47968. }
  47969. }
  47970. declare module BABYLON {
  47971. /**
  47972. * Options for the default xr helper
  47973. */
  47974. export class WebXRDefaultExperienceOptions {
  47975. /**
  47976. * Enable or disable default UI to enter XR
  47977. */
  47978. disableDefaultUI?: boolean;
  47979. /**
  47980. * Should teleportation not initialize. defaults to false.
  47981. */
  47982. disableTeleportation?: boolean;
  47983. /**
  47984. * Floor meshes that will be used for teleport
  47985. */
  47986. floorMeshes?: Array<AbstractMesh>;
  47987. /**
  47988. * If set to true, the first frame will not be used to reset position
  47989. * The first frame is mainly used when copying transformation from the old camera
  47990. * Mainly used in AR
  47991. */
  47992. ignoreNativeCameraTransformation?: boolean;
  47993. /**
  47994. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  47995. */
  47996. inputOptions?: IWebXRInputOptions;
  47997. /**
  47998. * optional configuration for the output canvas
  47999. */
  48000. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48001. /**
  48002. * optional UI options. This can be used among other to change session mode and reference space type
  48003. */
  48004. uiOptions?: WebXREnterExitUIOptions;
  48005. /**
  48006. * When loading teleportation and pointer select, use stable versions instead of latest.
  48007. */
  48008. useStablePlugins?: boolean;
  48009. /**
  48010. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48011. */
  48012. renderingGroupId?: number;
  48013. /**
  48014. * A list of optional features to init the session with
  48015. * If set to true, all features we support will be added
  48016. */
  48017. optionalFeatures?: boolean | string[];
  48018. }
  48019. /**
  48020. * Default experience which provides a similar setup to the previous webVRExperience
  48021. */
  48022. export class WebXRDefaultExperience {
  48023. /**
  48024. * Base experience
  48025. */
  48026. baseExperience: WebXRExperienceHelper;
  48027. /**
  48028. * Enables ui for entering/exiting xr
  48029. */
  48030. enterExitUI: WebXREnterExitUI;
  48031. /**
  48032. * Input experience extension
  48033. */
  48034. input: WebXRInput;
  48035. /**
  48036. * Enables laser pointer and selection
  48037. */
  48038. pointerSelection: WebXRControllerPointerSelection;
  48039. /**
  48040. * Default target xr should render to
  48041. */
  48042. renderTarget: WebXRRenderTarget;
  48043. /**
  48044. * Enables teleportation
  48045. */
  48046. teleportation: WebXRMotionControllerTeleportation;
  48047. private constructor();
  48048. /**
  48049. * Creates the default xr experience
  48050. * @param scene scene
  48051. * @param options options for basic configuration
  48052. * @returns resulting WebXRDefaultExperience
  48053. */
  48054. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48055. /**
  48056. * DIsposes of the experience helper
  48057. */
  48058. dispose(): void;
  48059. }
  48060. }
  48061. declare module BABYLON {
  48062. /**
  48063. * Options to modify the vr teleportation behavior.
  48064. */
  48065. export interface VRTeleportationOptions {
  48066. /**
  48067. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48068. */
  48069. floorMeshName?: string;
  48070. /**
  48071. * A list of meshes to be used as the teleportation floor. (default: empty)
  48072. */
  48073. floorMeshes?: Mesh[];
  48074. /**
  48075. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48076. */
  48077. teleportationMode?: number;
  48078. /**
  48079. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48080. */
  48081. teleportationTime?: number;
  48082. /**
  48083. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48084. */
  48085. teleportationSpeed?: number;
  48086. /**
  48087. * The easing function used in the animation or null for Linear. (default CircleEase)
  48088. */
  48089. easingFunction?: EasingFunction;
  48090. }
  48091. /**
  48092. * Options to modify the vr experience helper's behavior.
  48093. */
  48094. export interface VRExperienceHelperOptions extends WebVROptions {
  48095. /**
  48096. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48097. */
  48098. createDeviceOrientationCamera?: boolean;
  48099. /**
  48100. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48101. */
  48102. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48103. /**
  48104. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48105. */
  48106. laserToggle?: boolean;
  48107. /**
  48108. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48109. */
  48110. floorMeshes?: Mesh[];
  48111. /**
  48112. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48113. */
  48114. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48115. /**
  48116. * Defines if WebXR should be used instead of WebVR (if available)
  48117. */
  48118. useXR?: boolean;
  48119. }
  48120. /**
  48121. * Event containing information after VR has been entered
  48122. */
  48123. export class OnAfterEnteringVRObservableEvent {
  48124. /**
  48125. * If entering vr was successful
  48126. */
  48127. success: boolean;
  48128. }
  48129. /**
  48130. * Helps to quickly add VR support to an existing scene.
  48131. * See http://doc.babylonjs.com/how_to/webvr_helper
  48132. */
  48133. export class VRExperienceHelper {
  48134. /** Options to modify the vr experience helper's behavior. */
  48135. webVROptions: VRExperienceHelperOptions;
  48136. private _scene;
  48137. private _position;
  48138. private _btnVR;
  48139. private _btnVRDisplayed;
  48140. private _webVRsupported;
  48141. private _webVRready;
  48142. private _webVRrequesting;
  48143. private _webVRpresenting;
  48144. private _hasEnteredVR;
  48145. private _fullscreenVRpresenting;
  48146. private _inputElement;
  48147. private _webVRCamera;
  48148. private _vrDeviceOrientationCamera;
  48149. private _deviceOrientationCamera;
  48150. private _existingCamera;
  48151. private _onKeyDown;
  48152. private _onVrDisplayPresentChange;
  48153. private _onVRDisplayChanged;
  48154. private _onVRRequestPresentStart;
  48155. private _onVRRequestPresentComplete;
  48156. /**
  48157. * 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)
  48158. */
  48159. enableGazeEvenWhenNoPointerLock: boolean;
  48160. /**
  48161. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48162. */
  48163. exitVROnDoubleTap: boolean;
  48164. /**
  48165. * Observable raised right before entering VR.
  48166. */
  48167. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48168. /**
  48169. * Observable raised when entering VR has completed.
  48170. */
  48171. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48172. /**
  48173. * Observable raised when exiting VR.
  48174. */
  48175. onExitingVRObservable: Observable<VRExperienceHelper>;
  48176. /**
  48177. * Observable raised when controller mesh is loaded.
  48178. */
  48179. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48180. /** Return this.onEnteringVRObservable
  48181. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48182. */
  48183. get onEnteringVR(): Observable<VRExperienceHelper>;
  48184. /** Return this.onExitingVRObservable
  48185. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48186. */
  48187. get onExitingVR(): Observable<VRExperienceHelper>;
  48188. /** Return this.onControllerMeshLoadedObservable
  48189. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48190. */
  48191. get onControllerMeshLoaded(): Observable<WebVRController>;
  48192. private _rayLength;
  48193. private _useCustomVRButton;
  48194. private _teleportationRequested;
  48195. private _teleportActive;
  48196. private _floorMeshName;
  48197. private _floorMeshesCollection;
  48198. private _teleportationMode;
  48199. private _teleportationTime;
  48200. private _teleportationSpeed;
  48201. private _teleportationEasing;
  48202. private _rotationAllowed;
  48203. private _teleportBackwardsVector;
  48204. private _teleportationTarget;
  48205. private _isDefaultTeleportationTarget;
  48206. private _postProcessMove;
  48207. private _teleportationFillColor;
  48208. private _teleportationBorderColor;
  48209. private _rotationAngle;
  48210. private _haloCenter;
  48211. private _cameraGazer;
  48212. private _padSensibilityUp;
  48213. private _padSensibilityDown;
  48214. private _leftController;
  48215. private _rightController;
  48216. private _gazeColor;
  48217. private _laserColor;
  48218. private _pickedLaserColor;
  48219. private _pickedGazeColor;
  48220. /**
  48221. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48222. */
  48223. onNewMeshSelected: Observable<AbstractMesh>;
  48224. /**
  48225. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48226. * This observable will provide the mesh and the controller used to select the mesh
  48227. */
  48228. onMeshSelectedWithController: Observable<{
  48229. mesh: AbstractMesh;
  48230. controller: WebVRController;
  48231. }>;
  48232. /**
  48233. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48234. */
  48235. onNewMeshPicked: Observable<PickingInfo>;
  48236. private _circleEase;
  48237. /**
  48238. * Observable raised before camera teleportation
  48239. */
  48240. onBeforeCameraTeleport: Observable<Vector3>;
  48241. /**
  48242. * Observable raised after camera teleportation
  48243. */
  48244. onAfterCameraTeleport: Observable<Vector3>;
  48245. /**
  48246. * Observable raised when current selected mesh gets unselected
  48247. */
  48248. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48249. private _raySelectionPredicate;
  48250. /**
  48251. * To be optionaly changed by user to define custom ray selection
  48252. */
  48253. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48254. /**
  48255. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48256. */
  48257. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48258. /**
  48259. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48260. */
  48261. teleportationEnabled: boolean;
  48262. private _defaultHeight;
  48263. private _teleportationInitialized;
  48264. private _interactionsEnabled;
  48265. private _interactionsRequested;
  48266. private _displayGaze;
  48267. private _displayLaserPointer;
  48268. /**
  48269. * The mesh used to display where the user is going to teleport.
  48270. */
  48271. get teleportationTarget(): Mesh;
  48272. /**
  48273. * Sets the mesh to be used to display where the user is going to teleport.
  48274. */
  48275. set teleportationTarget(value: Mesh);
  48276. /**
  48277. * 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
  48278. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48279. * See http://doc.babylonjs.com/resources/baking_transformations
  48280. */
  48281. get gazeTrackerMesh(): Mesh;
  48282. set gazeTrackerMesh(value: Mesh);
  48283. /**
  48284. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48285. */
  48286. updateGazeTrackerScale: boolean;
  48287. /**
  48288. * If the gaze trackers color should be updated when selecting meshes
  48289. */
  48290. updateGazeTrackerColor: boolean;
  48291. /**
  48292. * If the controller laser color should be updated when selecting meshes
  48293. */
  48294. updateControllerLaserColor: boolean;
  48295. /**
  48296. * The gaze tracking mesh corresponding to the left controller
  48297. */
  48298. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48299. /**
  48300. * The gaze tracking mesh corresponding to the right controller
  48301. */
  48302. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48303. /**
  48304. * If the ray of the gaze should be displayed.
  48305. */
  48306. get displayGaze(): boolean;
  48307. /**
  48308. * Sets if the ray of the gaze should be displayed.
  48309. */
  48310. set displayGaze(value: boolean);
  48311. /**
  48312. * If the ray of the LaserPointer should be displayed.
  48313. */
  48314. get displayLaserPointer(): boolean;
  48315. /**
  48316. * Sets if the ray of the LaserPointer should be displayed.
  48317. */
  48318. set displayLaserPointer(value: boolean);
  48319. /**
  48320. * The deviceOrientationCamera used as the camera when not in VR.
  48321. */
  48322. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48323. /**
  48324. * Based on the current WebVR support, returns the current VR camera used.
  48325. */
  48326. get currentVRCamera(): Nullable<Camera>;
  48327. /**
  48328. * The webVRCamera which is used when in VR.
  48329. */
  48330. get webVRCamera(): WebVRFreeCamera;
  48331. /**
  48332. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48333. */
  48334. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48335. /**
  48336. * The html button that is used to trigger entering into VR.
  48337. */
  48338. get vrButton(): Nullable<HTMLButtonElement>;
  48339. private get _teleportationRequestInitiated();
  48340. /**
  48341. * Defines whether or not Pointer lock should be requested when switching to
  48342. * full screen.
  48343. */
  48344. requestPointerLockOnFullScreen: boolean;
  48345. /**
  48346. * If asking to force XR, this will be populated with the default xr experience
  48347. */
  48348. xr: WebXRDefaultExperience;
  48349. /**
  48350. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48351. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48352. */
  48353. xrTestDone: boolean;
  48354. /**
  48355. * Instantiates a VRExperienceHelper.
  48356. * Helps to quickly add VR support to an existing scene.
  48357. * @param scene The scene the VRExperienceHelper belongs to.
  48358. * @param webVROptions Options to modify the vr experience helper's behavior.
  48359. */
  48360. constructor(scene: Scene,
  48361. /** Options to modify the vr experience helper's behavior. */
  48362. webVROptions?: VRExperienceHelperOptions);
  48363. private completeVRInit;
  48364. private _onDefaultMeshLoaded;
  48365. private _onResize;
  48366. private _onFullscreenChange;
  48367. /**
  48368. * Gets a value indicating if we are currently in VR mode.
  48369. */
  48370. get isInVRMode(): boolean;
  48371. private onVrDisplayPresentChange;
  48372. private onVRDisplayChanged;
  48373. private moveButtonToBottomRight;
  48374. private displayVRButton;
  48375. private updateButtonVisibility;
  48376. private _cachedAngularSensibility;
  48377. /**
  48378. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48379. * Otherwise, will use the fullscreen API.
  48380. */
  48381. enterVR(): void;
  48382. /**
  48383. * Attempt to exit VR, or fullscreen.
  48384. */
  48385. exitVR(): void;
  48386. /**
  48387. * The position of the vr experience helper.
  48388. */
  48389. get position(): Vector3;
  48390. /**
  48391. * Sets the position of the vr experience helper.
  48392. */
  48393. set position(value: Vector3);
  48394. /**
  48395. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48396. */
  48397. enableInteractions(): void;
  48398. private get _noControllerIsActive();
  48399. private beforeRender;
  48400. private _isTeleportationFloor;
  48401. /**
  48402. * Adds a floor mesh to be used for teleportation.
  48403. * @param floorMesh the mesh to be used for teleportation.
  48404. */
  48405. addFloorMesh(floorMesh: Mesh): void;
  48406. /**
  48407. * Removes a floor mesh from being used for teleportation.
  48408. * @param floorMesh the mesh to be removed.
  48409. */
  48410. removeFloorMesh(floorMesh: Mesh): void;
  48411. /**
  48412. * Enables interactions and teleportation using the VR controllers and gaze.
  48413. * @param vrTeleportationOptions options to modify teleportation behavior.
  48414. */
  48415. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48416. private _onNewGamepadConnected;
  48417. private _tryEnableInteractionOnController;
  48418. private _onNewGamepadDisconnected;
  48419. private _enableInteractionOnController;
  48420. private _checkTeleportWithRay;
  48421. private _checkRotate;
  48422. private _checkTeleportBackwards;
  48423. private _enableTeleportationOnController;
  48424. private _createTeleportationCircles;
  48425. private _displayTeleportationTarget;
  48426. private _hideTeleportationTarget;
  48427. private _rotateCamera;
  48428. private _moveTeleportationSelectorTo;
  48429. private _workingVector;
  48430. private _workingQuaternion;
  48431. private _workingMatrix;
  48432. /**
  48433. * Time Constant Teleportation Mode
  48434. */
  48435. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48436. /**
  48437. * Speed Constant Teleportation Mode
  48438. */
  48439. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48440. /**
  48441. * Teleports the users feet to the desired location
  48442. * @param location The location where the user's feet should be placed
  48443. */
  48444. teleportCamera(location: Vector3): void;
  48445. private _convertNormalToDirectionOfRay;
  48446. private _castRayAndSelectObject;
  48447. private _notifySelectedMeshUnselected;
  48448. /**
  48449. * Permanently set new colors for the laser pointer
  48450. * @param color the new laser color
  48451. * @param pickedColor the new laser color when picked mesh detected
  48452. */
  48453. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48454. /**
  48455. * Set lighting enabled / disabled on the laser pointer of both controllers
  48456. * @param enabled should the lighting be enabled on the laser pointer
  48457. */
  48458. setLaserLightingState(enabled?: boolean): void;
  48459. /**
  48460. * Permanently set new colors for the gaze pointer
  48461. * @param color the new gaze color
  48462. * @param pickedColor the new gaze color when picked mesh detected
  48463. */
  48464. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48465. /**
  48466. * Sets the color of the laser ray from the vr controllers.
  48467. * @param color new color for the ray.
  48468. */
  48469. changeLaserColor(color: Color3): void;
  48470. /**
  48471. * Sets the color of the ray from the vr headsets gaze.
  48472. * @param color new color for the ray.
  48473. */
  48474. changeGazeColor(color: Color3): void;
  48475. /**
  48476. * Exits VR and disposes of the vr experience helper
  48477. */
  48478. dispose(): void;
  48479. /**
  48480. * Gets the name of the VRExperienceHelper class
  48481. * @returns "VRExperienceHelper"
  48482. */
  48483. getClassName(): string;
  48484. }
  48485. }
  48486. declare module BABYLON {
  48487. /**
  48488. * Contains an array of blocks representing the octree
  48489. */
  48490. export interface IOctreeContainer<T> {
  48491. /**
  48492. * Blocks within the octree
  48493. */
  48494. blocks: Array<OctreeBlock<T>>;
  48495. }
  48496. /**
  48497. * Class used to store a cell in an octree
  48498. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48499. */
  48500. export class OctreeBlock<T> {
  48501. /**
  48502. * Gets the content of the current block
  48503. */
  48504. entries: T[];
  48505. /**
  48506. * Gets the list of block children
  48507. */
  48508. blocks: Array<OctreeBlock<T>>;
  48509. private _depth;
  48510. private _maxDepth;
  48511. private _capacity;
  48512. private _minPoint;
  48513. private _maxPoint;
  48514. private _boundingVectors;
  48515. private _creationFunc;
  48516. /**
  48517. * Creates a new block
  48518. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  48519. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  48520. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48521. * @param depth defines the current depth of this block in the octree
  48522. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  48523. * @param creationFunc defines a callback to call when an element is added to the block
  48524. */
  48525. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  48526. /**
  48527. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48528. */
  48529. get capacity(): number;
  48530. /**
  48531. * Gets the minimum vector (in world space) of the block's bounding box
  48532. */
  48533. get minPoint(): Vector3;
  48534. /**
  48535. * Gets the maximum vector (in world space) of the block's bounding box
  48536. */
  48537. get maxPoint(): Vector3;
  48538. /**
  48539. * Add a new element to this block
  48540. * @param entry defines the element to add
  48541. */
  48542. addEntry(entry: T): void;
  48543. /**
  48544. * Remove an element from this block
  48545. * @param entry defines the element to remove
  48546. */
  48547. removeEntry(entry: T): void;
  48548. /**
  48549. * Add an array of elements to this block
  48550. * @param entries defines the array of elements to add
  48551. */
  48552. addEntries(entries: T[]): void;
  48553. /**
  48554. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  48555. * @param frustumPlanes defines the frustum planes to test
  48556. * @param selection defines the array to store current content if selection is positive
  48557. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48558. */
  48559. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48560. /**
  48561. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  48562. * @param sphereCenter defines the bounding sphere center
  48563. * @param sphereRadius defines the bounding sphere radius
  48564. * @param selection defines the array to store current content if selection is positive
  48565. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48566. */
  48567. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48568. /**
  48569. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  48570. * @param ray defines the ray to test with
  48571. * @param selection defines the array to store current content if selection is positive
  48572. */
  48573. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  48574. /**
  48575. * Subdivide the content into child blocks (this block will then be empty)
  48576. */
  48577. createInnerBlocks(): void;
  48578. /**
  48579. * @hidden
  48580. */
  48581. 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;
  48582. }
  48583. }
  48584. declare module BABYLON {
  48585. /**
  48586. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  48587. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48588. */
  48589. export class Octree<T> {
  48590. /** 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.) */
  48591. maxDepth: number;
  48592. /**
  48593. * Blocks within the octree containing objects
  48594. */
  48595. blocks: Array<OctreeBlock<T>>;
  48596. /**
  48597. * Content stored in the octree
  48598. */
  48599. dynamicContent: T[];
  48600. private _maxBlockCapacity;
  48601. private _selectionContent;
  48602. private _creationFunc;
  48603. /**
  48604. * Creates a octree
  48605. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48606. * @param creationFunc function to be used to instatiate the octree
  48607. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  48608. * @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.)
  48609. */
  48610. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  48611. /** 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.) */
  48612. maxDepth?: number);
  48613. /**
  48614. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  48615. * @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);
  48616. * @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);
  48617. * @param entries meshes to be added to the octree blocks
  48618. */
  48619. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  48620. /**
  48621. * Adds a mesh to the octree
  48622. * @param entry Mesh to add to the octree
  48623. */
  48624. addMesh(entry: T): void;
  48625. /**
  48626. * Remove an element from the octree
  48627. * @param entry defines the element to remove
  48628. */
  48629. removeMesh(entry: T): void;
  48630. /**
  48631. * Selects an array of meshes within the frustum
  48632. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  48633. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  48634. * @returns array of meshes within the frustum
  48635. */
  48636. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  48637. /**
  48638. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  48639. * @param sphereCenter defines the bounding sphere center
  48640. * @param sphereRadius defines the bounding sphere radius
  48641. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48642. * @returns an array of objects that intersect the sphere
  48643. */
  48644. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  48645. /**
  48646. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  48647. * @param ray defines the ray to test with
  48648. * @returns array of intersected objects
  48649. */
  48650. intersectsRay(ray: Ray): SmartArray<T>;
  48651. /**
  48652. * Adds a mesh into the octree block if it intersects the block
  48653. */
  48654. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  48655. /**
  48656. * Adds a submesh into the octree block if it intersects the block
  48657. */
  48658. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  48659. }
  48660. }
  48661. declare module BABYLON {
  48662. interface Scene {
  48663. /**
  48664. * @hidden
  48665. * Backing Filed
  48666. */
  48667. _selectionOctree: Octree<AbstractMesh>;
  48668. /**
  48669. * Gets the octree used to boost mesh selection (picking)
  48670. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48671. */
  48672. selectionOctree: Octree<AbstractMesh>;
  48673. /**
  48674. * Creates or updates the octree used to boost selection (picking)
  48675. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48676. * @param maxCapacity defines the maximum capacity per leaf
  48677. * @param maxDepth defines the maximum depth of the octree
  48678. * @returns an octree of AbstractMesh
  48679. */
  48680. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  48681. }
  48682. interface AbstractMesh {
  48683. /**
  48684. * @hidden
  48685. * Backing Field
  48686. */
  48687. _submeshesOctree: Octree<SubMesh>;
  48688. /**
  48689. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  48690. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  48691. * @param maxCapacity defines the maximum size of each block (64 by default)
  48692. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  48693. * @returns the new octree
  48694. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  48695. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48696. */
  48697. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  48698. }
  48699. /**
  48700. * Defines the octree scene component responsible to manage any octrees
  48701. * in a given scene.
  48702. */
  48703. export class OctreeSceneComponent {
  48704. /**
  48705. * The component name help to identify the component in the list of scene components.
  48706. */
  48707. readonly name: string;
  48708. /**
  48709. * The scene the component belongs to.
  48710. */
  48711. scene: Scene;
  48712. /**
  48713. * Indicates if the meshes have been checked to make sure they are isEnabled()
  48714. */
  48715. readonly checksIsEnabled: boolean;
  48716. /**
  48717. * Creates a new instance of the component for the given scene
  48718. * @param scene Defines the scene to register the component in
  48719. */
  48720. constructor(scene: Scene);
  48721. /**
  48722. * Registers the component in a given scene
  48723. */
  48724. register(): void;
  48725. /**
  48726. * Return the list of active meshes
  48727. * @returns the list of active meshes
  48728. */
  48729. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48730. /**
  48731. * Return the list of active sub meshes
  48732. * @param mesh The mesh to get the candidates sub meshes from
  48733. * @returns the list of active sub meshes
  48734. */
  48735. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48736. private _tempRay;
  48737. /**
  48738. * Return the list of sub meshes intersecting with a given local ray
  48739. * @param mesh defines the mesh to find the submesh for
  48740. * @param localRay defines the ray in local space
  48741. * @returns the list of intersecting sub meshes
  48742. */
  48743. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  48744. /**
  48745. * Return the list of sub meshes colliding with a collider
  48746. * @param mesh defines the mesh to find the submesh for
  48747. * @param collider defines the collider to evaluate the collision against
  48748. * @returns the list of colliding sub meshes
  48749. */
  48750. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  48751. /**
  48752. * Rebuilds the elements related to this component in case of
  48753. * context lost for instance.
  48754. */
  48755. rebuild(): void;
  48756. /**
  48757. * Disposes the component and the associated ressources.
  48758. */
  48759. dispose(): void;
  48760. }
  48761. }
  48762. declare module BABYLON {
  48763. /**
  48764. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  48765. */
  48766. export class Gizmo implements IDisposable {
  48767. /** The utility layer the gizmo will be added to */
  48768. gizmoLayer: UtilityLayerRenderer;
  48769. /**
  48770. * The root mesh of the gizmo
  48771. */
  48772. _rootMesh: Mesh;
  48773. private _attachedMesh;
  48774. /**
  48775. * Ratio for the scale of the gizmo (Default: 1)
  48776. */
  48777. scaleRatio: number;
  48778. /**
  48779. * If a custom mesh has been set (Default: false)
  48780. */
  48781. protected _customMeshSet: boolean;
  48782. /**
  48783. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  48784. * * When set, interactions will be enabled
  48785. */
  48786. get attachedMesh(): Nullable<AbstractMesh>;
  48787. set attachedMesh(value: Nullable<AbstractMesh>);
  48788. /**
  48789. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48790. * @param mesh The mesh to replace the default mesh of the gizmo
  48791. */
  48792. setCustomMesh(mesh: Mesh): void;
  48793. /**
  48794. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  48795. */
  48796. updateGizmoRotationToMatchAttachedMesh: boolean;
  48797. /**
  48798. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  48799. */
  48800. updateGizmoPositionToMatchAttachedMesh: boolean;
  48801. /**
  48802. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  48803. */
  48804. updateScale: boolean;
  48805. protected _interactionsEnabled: boolean;
  48806. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48807. private _beforeRenderObserver;
  48808. private _tempVector;
  48809. /**
  48810. * Creates a gizmo
  48811. * @param gizmoLayer The utility layer the gizmo will be added to
  48812. */
  48813. constructor(
  48814. /** The utility layer the gizmo will be added to */
  48815. gizmoLayer?: UtilityLayerRenderer);
  48816. /**
  48817. * Updates the gizmo to match the attached mesh's position/rotation
  48818. */
  48819. protected _update(): void;
  48820. /**
  48821. * Disposes of the gizmo
  48822. */
  48823. dispose(): void;
  48824. }
  48825. }
  48826. declare module BABYLON {
  48827. /**
  48828. * Single plane drag gizmo
  48829. */
  48830. export class PlaneDragGizmo extends Gizmo {
  48831. /**
  48832. * Drag behavior responsible for the gizmos dragging interactions
  48833. */
  48834. dragBehavior: PointerDragBehavior;
  48835. private _pointerObserver;
  48836. /**
  48837. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48838. */
  48839. snapDistance: number;
  48840. /**
  48841. * Event that fires each time the gizmo snaps to a new location.
  48842. * * snapDistance is the the change in distance
  48843. */
  48844. onSnapObservable: Observable<{
  48845. snapDistance: number;
  48846. }>;
  48847. private _plane;
  48848. private _coloredMaterial;
  48849. private _hoverMaterial;
  48850. private _isEnabled;
  48851. private _parent;
  48852. /** @hidden */
  48853. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  48854. /** @hidden */
  48855. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48856. /**
  48857. * Creates a PlaneDragGizmo
  48858. * @param gizmoLayer The utility layer the gizmo will be added to
  48859. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  48860. * @param color The color of the gizmo
  48861. */
  48862. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48863. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48864. /**
  48865. * If the gizmo is enabled
  48866. */
  48867. set isEnabled(value: boolean);
  48868. get isEnabled(): boolean;
  48869. /**
  48870. * Disposes of the gizmo
  48871. */
  48872. dispose(): void;
  48873. }
  48874. }
  48875. declare module BABYLON {
  48876. /**
  48877. * Gizmo that enables dragging a mesh along 3 axis
  48878. */
  48879. export class PositionGizmo extends Gizmo {
  48880. /**
  48881. * Internal gizmo used for interactions on the x axis
  48882. */
  48883. xGizmo: AxisDragGizmo;
  48884. /**
  48885. * Internal gizmo used for interactions on the y axis
  48886. */
  48887. yGizmo: AxisDragGizmo;
  48888. /**
  48889. * Internal gizmo used for interactions on the z axis
  48890. */
  48891. zGizmo: AxisDragGizmo;
  48892. /**
  48893. * Internal gizmo used for interactions on the yz plane
  48894. */
  48895. xPlaneGizmo: PlaneDragGizmo;
  48896. /**
  48897. * Internal gizmo used for interactions on the xz plane
  48898. */
  48899. yPlaneGizmo: PlaneDragGizmo;
  48900. /**
  48901. * Internal gizmo used for interactions on the xy plane
  48902. */
  48903. zPlaneGizmo: PlaneDragGizmo;
  48904. /**
  48905. * private variables
  48906. */
  48907. private _meshAttached;
  48908. private _updateGizmoRotationToMatchAttachedMesh;
  48909. private _snapDistance;
  48910. private _scaleRatio;
  48911. /** Fires an event when any of it's sub gizmos are dragged */
  48912. onDragStartObservable: Observable<unknown>;
  48913. /** Fires an event when any of it's sub gizmos are released from dragging */
  48914. onDragEndObservable: Observable<unknown>;
  48915. /**
  48916. * If set to true, planar drag is enabled
  48917. */
  48918. private _planarGizmoEnabled;
  48919. get attachedMesh(): Nullable<AbstractMesh>;
  48920. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48921. /**
  48922. * Creates a PositionGizmo
  48923. * @param gizmoLayer The utility layer the gizmo will be added to
  48924. */
  48925. constructor(gizmoLayer?: UtilityLayerRenderer);
  48926. /**
  48927. * If the planar drag gizmo is enabled
  48928. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  48929. */
  48930. set planarGizmoEnabled(value: boolean);
  48931. get planarGizmoEnabled(): boolean;
  48932. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48933. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48934. /**
  48935. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48936. */
  48937. set snapDistance(value: number);
  48938. get snapDistance(): number;
  48939. /**
  48940. * Ratio for the scale of the gizmo (Default: 1)
  48941. */
  48942. set scaleRatio(value: number);
  48943. get scaleRatio(): number;
  48944. /**
  48945. * Disposes of the gizmo
  48946. */
  48947. dispose(): void;
  48948. /**
  48949. * CustomMeshes are not supported by this gizmo
  48950. * @param mesh The mesh to replace the default mesh of the gizmo
  48951. */
  48952. setCustomMesh(mesh: Mesh): void;
  48953. }
  48954. }
  48955. declare module BABYLON {
  48956. /**
  48957. * Single axis drag gizmo
  48958. */
  48959. export class AxisDragGizmo extends Gizmo {
  48960. /**
  48961. * Drag behavior responsible for the gizmos dragging interactions
  48962. */
  48963. dragBehavior: PointerDragBehavior;
  48964. private _pointerObserver;
  48965. /**
  48966. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48967. */
  48968. snapDistance: number;
  48969. /**
  48970. * Event that fires each time the gizmo snaps to a new location.
  48971. * * snapDistance is the the change in distance
  48972. */
  48973. onSnapObservable: Observable<{
  48974. snapDistance: number;
  48975. }>;
  48976. private _isEnabled;
  48977. private _parent;
  48978. private _arrow;
  48979. private _coloredMaterial;
  48980. private _hoverMaterial;
  48981. /** @hidden */
  48982. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  48983. /** @hidden */
  48984. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48985. /**
  48986. * Creates an AxisDragGizmo
  48987. * @param gizmoLayer The utility layer the gizmo will be added to
  48988. * @param dragAxis The axis which the gizmo will be able to drag on
  48989. * @param color The color of the gizmo
  48990. */
  48991. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48992. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48993. /**
  48994. * If the gizmo is enabled
  48995. */
  48996. set isEnabled(value: boolean);
  48997. get isEnabled(): boolean;
  48998. /**
  48999. * Disposes of the gizmo
  49000. */
  49001. dispose(): void;
  49002. }
  49003. }
  49004. declare module BABYLON.Debug {
  49005. /**
  49006. * The Axes viewer will show 3 axes in a specific point in space
  49007. */
  49008. export class AxesViewer {
  49009. private _xAxis;
  49010. private _yAxis;
  49011. private _zAxis;
  49012. private _scaleLinesFactor;
  49013. private _instanced;
  49014. /**
  49015. * Gets the hosting scene
  49016. */
  49017. scene: Scene;
  49018. /**
  49019. * Gets or sets a number used to scale line length
  49020. */
  49021. scaleLines: number;
  49022. /** Gets the node hierarchy used to render x-axis */
  49023. get xAxis(): TransformNode;
  49024. /** Gets the node hierarchy used to render y-axis */
  49025. get yAxis(): TransformNode;
  49026. /** Gets the node hierarchy used to render z-axis */
  49027. get zAxis(): TransformNode;
  49028. /**
  49029. * Creates a new AxesViewer
  49030. * @param scene defines the hosting scene
  49031. * @param scaleLines defines a number used to scale line length (1 by default)
  49032. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49033. * @param xAxis defines the node hierarchy used to render the x-axis
  49034. * @param yAxis defines the node hierarchy used to render the y-axis
  49035. * @param zAxis defines the node hierarchy used to render the z-axis
  49036. */
  49037. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49038. /**
  49039. * Force the viewer to update
  49040. * @param position defines the position of the viewer
  49041. * @param xaxis defines the x axis of the viewer
  49042. * @param yaxis defines the y axis of the viewer
  49043. * @param zaxis defines the z axis of the viewer
  49044. */
  49045. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49046. /**
  49047. * Creates an instance of this axes viewer.
  49048. * @returns a new axes viewer with instanced meshes
  49049. */
  49050. createInstance(): AxesViewer;
  49051. /** Releases resources */
  49052. dispose(): void;
  49053. private static _SetRenderingGroupId;
  49054. }
  49055. }
  49056. declare module BABYLON.Debug {
  49057. /**
  49058. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49059. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49060. */
  49061. export class BoneAxesViewer extends AxesViewer {
  49062. /**
  49063. * Gets or sets the target mesh where to display the axes viewer
  49064. */
  49065. mesh: Nullable<Mesh>;
  49066. /**
  49067. * Gets or sets the target bone where to display the axes viewer
  49068. */
  49069. bone: Nullable<Bone>;
  49070. /** Gets current position */
  49071. pos: Vector3;
  49072. /** Gets direction of X axis */
  49073. xaxis: Vector3;
  49074. /** Gets direction of Y axis */
  49075. yaxis: Vector3;
  49076. /** Gets direction of Z axis */
  49077. zaxis: Vector3;
  49078. /**
  49079. * Creates a new BoneAxesViewer
  49080. * @param scene defines the hosting scene
  49081. * @param bone defines the target bone
  49082. * @param mesh defines the target mesh
  49083. * @param scaleLines defines a scaling factor for line length (1 by default)
  49084. */
  49085. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49086. /**
  49087. * Force the viewer to update
  49088. */
  49089. update(): void;
  49090. /** Releases resources */
  49091. dispose(): void;
  49092. }
  49093. }
  49094. declare module BABYLON {
  49095. /**
  49096. * Interface used to define scene explorer extensibility option
  49097. */
  49098. export interface IExplorerExtensibilityOption {
  49099. /**
  49100. * Define the option label
  49101. */
  49102. label: string;
  49103. /**
  49104. * Defines the action to execute on click
  49105. */
  49106. action: (entity: any) => void;
  49107. }
  49108. /**
  49109. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49110. */
  49111. export interface IExplorerExtensibilityGroup {
  49112. /**
  49113. * Defines a predicate to test if a given type mut be extended
  49114. */
  49115. predicate: (entity: any) => boolean;
  49116. /**
  49117. * Gets the list of options added to a type
  49118. */
  49119. entries: IExplorerExtensibilityOption[];
  49120. }
  49121. /**
  49122. * Interface used to define the options to use to create the Inspector
  49123. */
  49124. export interface IInspectorOptions {
  49125. /**
  49126. * Display in overlay mode (default: false)
  49127. */
  49128. overlay?: boolean;
  49129. /**
  49130. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49131. */
  49132. globalRoot?: HTMLElement;
  49133. /**
  49134. * Display the Scene explorer
  49135. */
  49136. showExplorer?: boolean;
  49137. /**
  49138. * Display the property inspector
  49139. */
  49140. showInspector?: boolean;
  49141. /**
  49142. * Display in embed mode (both panes on the right)
  49143. */
  49144. embedMode?: boolean;
  49145. /**
  49146. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49147. */
  49148. handleResize?: boolean;
  49149. /**
  49150. * Allow the panes to popup (default: true)
  49151. */
  49152. enablePopup?: boolean;
  49153. /**
  49154. * Allow the panes to be closed by users (default: true)
  49155. */
  49156. enableClose?: boolean;
  49157. /**
  49158. * Optional list of extensibility entries
  49159. */
  49160. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49161. /**
  49162. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49163. */
  49164. inspectorURL?: string;
  49165. /**
  49166. * Optional initial tab (default to DebugLayerTab.Properties)
  49167. */
  49168. initialTab?: DebugLayerTab;
  49169. }
  49170. interface Scene {
  49171. /**
  49172. * @hidden
  49173. * Backing field
  49174. */
  49175. _debugLayer: DebugLayer;
  49176. /**
  49177. * Gets the debug layer (aka Inspector) associated with the scene
  49178. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49179. */
  49180. debugLayer: DebugLayer;
  49181. }
  49182. /**
  49183. * Enum of inspector action tab
  49184. */
  49185. export enum DebugLayerTab {
  49186. /**
  49187. * Properties tag (default)
  49188. */
  49189. Properties = 0,
  49190. /**
  49191. * Debug tab
  49192. */
  49193. Debug = 1,
  49194. /**
  49195. * Statistics tab
  49196. */
  49197. Statistics = 2,
  49198. /**
  49199. * Tools tab
  49200. */
  49201. Tools = 3,
  49202. /**
  49203. * Settings tab
  49204. */
  49205. Settings = 4
  49206. }
  49207. /**
  49208. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49209. * what is happening in your scene
  49210. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49211. */
  49212. export class DebugLayer {
  49213. /**
  49214. * Define the url to get the inspector script from.
  49215. * By default it uses the babylonjs CDN.
  49216. * @ignoreNaming
  49217. */
  49218. static InspectorURL: string;
  49219. private _scene;
  49220. private BJSINSPECTOR;
  49221. private _onPropertyChangedObservable?;
  49222. /**
  49223. * Observable triggered when a property is changed through the inspector.
  49224. */
  49225. get onPropertyChangedObservable(): any;
  49226. /**
  49227. * Instantiates a new debug layer.
  49228. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49229. * what is happening in your scene
  49230. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49231. * @param scene Defines the scene to inspect
  49232. */
  49233. constructor(scene: Scene);
  49234. /** Creates the inspector window. */
  49235. private _createInspector;
  49236. /**
  49237. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49238. * @param entity defines the entity to select
  49239. * @param lineContainerTitle defines the specific block to highlight
  49240. */
  49241. select(entity: any, lineContainerTitle?: string): void;
  49242. /** Get the inspector from bundle or global */
  49243. private _getGlobalInspector;
  49244. /**
  49245. * Get if the inspector is visible or not.
  49246. * @returns true if visible otherwise, false
  49247. */
  49248. isVisible(): boolean;
  49249. /**
  49250. * Hide the inspector and close its window.
  49251. */
  49252. hide(): void;
  49253. /**
  49254. * Update the scene in the inspector
  49255. */
  49256. setAsActiveScene(): void;
  49257. /**
  49258. * Launch the debugLayer.
  49259. * @param config Define the configuration of the inspector
  49260. * @return a promise fulfilled when the debug layer is visible
  49261. */
  49262. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49263. }
  49264. }
  49265. declare module BABYLON {
  49266. /**
  49267. * Class containing static functions to help procedurally build meshes
  49268. */
  49269. export class BoxBuilder {
  49270. /**
  49271. * Creates a box mesh
  49272. * * The parameter `size` sets the size (float) of each box side (default 1)
  49273. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49274. * * 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)
  49275. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49277. * * 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
  49278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49279. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49280. * @param name defines the name of the mesh
  49281. * @param options defines the options used to create the mesh
  49282. * @param scene defines the hosting scene
  49283. * @returns the box mesh
  49284. */
  49285. static CreateBox(name: string, options: {
  49286. size?: number;
  49287. width?: number;
  49288. height?: number;
  49289. depth?: number;
  49290. faceUV?: Vector4[];
  49291. faceColors?: Color4[];
  49292. sideOrientation?: number;
  49293. frontUVs?: Vector4;
  49294. backUVs?: Vector4;
  49295. wrap?: boolean;
  49296. topBaseAt?: number;
  49297. bottomBaseAt?: number;
  49298. updatable?: boolean;
  49299. }, scene?: Nullable<Scene>): Mesh;
  49300. }
  49301. }
  49302. declare module BABYLON.Debug {
  49303. /**
  49304. * Used to show the physics impostor around the specific mesh
  49305. */
  49306. export class PhysicsViewer {
  49307. /** @hidden */
  49308. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49309. /** @hidden */
  49310. protected _meshes: Array<Nullable<AbstractMesh>>;
  49311. /** @hidden */
  49312. protected _scene: Nullable<Scene>;
  49313. /** @hidden */
  49314. protected _numMeshes: number;
  49315. /** @hidden */
  49316. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49317. private _renderFunction;
  49318. private _utilityLayer;
  49319. private _debugBoxMesh;
  49320. private _debugSphereMesh;
  49321. private _debugCylinderMesh;
  49322. private _debugMaterial;
  49323. private _debugMeshMeshes;
  49324. /**
  49325. * Creates a new PhysicsViewer
  49326. * @param scene defines the hosting scene
  49327. */
  49328. constructor(scene: Scene);
  49329. /** @hidden */
  49330. protected _updateDebugMeshes(): void;
  49331. /**
  49332. * Renders a specified physic impostor
  49333. * @param impostor defines the impostor to render
  49334. * @param targetMesh defines the mesh represented by the impostor
  49335. * @returns the new debug mesh used to render the impostor
  49336. */
  49337. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49338. /**
  49339. * Hides a specified physic impostor
  49340. * @param impostor defines the impostor to hide
  49341. */
  49342. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49343. private _getDebugMaterial;
  49344. private _getDebugBoxMesh;
  49345. private _getDebugSphereMesh;
  49346. private _getDebugCylinderMesh;
  49347. private _getDebugMeshMesh;
  49348. private _getDebugMesh;
  49349. /** Releases all resources */
  49350. dispose(): void;
  49351. }
  49352. }
  49353. declare module BABYLON {
  49354. /**
  49355. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49356. * in order to better appreciate the issue one might have.
  49357. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49358. */
  49359. export class RayHelper {
  49360. /**
  49361. * Defines the ray we are currently tryin to visualize.
  49362. */
  49363. ray: Nullable<Ray>;
  49364. private _renderPoints;
  49365. private _renderLine;
  49366. private _renderFunction;
  49367. private _scene;
  49368. private _updateToMeshFunction;
  49369. private _attachedToMesh;
  49370. private _meshSpaceDirection;
  49371. private _meshSpaceOrigin;
  49372. /**
  49373. * Helper function to create a colored helper in a scene in one line.
  49374. * @param ray Defines the ray we are currently tryin to visualize
  49375. * @param scene Defines the scene the ray is used in
  49376. * @param color Defines the color we want to see the ray in
  49377. * @returns The newly created ray helper.
  49378. */
  49379. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49380. /**
  49381. * Instantiate a new ray helper.
  49382. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49383. * in order to better appreciate the issue one might have.
  49384. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49385. * @param ray Defines the ray we are currently tryin to visualize
  49386. */
  49387. constructor(ray: Ray);
  49388. /**
  49389. * Shows the ray we are willing to debug.
  49390. * @param scene Defines the scene the ray needs to be rendered in
  49391. * @param color Defines the color the ray needs to be rendered in
  49392. */
  49393. show(scene: Scene, color?: Color3): void;
  49394. /**
  49395. * Hides the ray we are debugging.
  49396. */
  49397. hide(): void;
  49398. private _render;
  49399. /**
  49400. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49401. * @param mesh Defines the mesh we want the helper attached to
  49402. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49403. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49404. * @param length Defines the length of the ray
  49405. */
  49406. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49407. /**
  49408. * Detach the ray helper from the mesh it has previously been attached to.
  49409. */
  49410. detachFromMesh(): void;
  49411. private _updateToMesh;
  49412. /**
  49413. * Dispose the helper and release its associated resources.
  49414. */
  49415. dispose(): void;
  49416. }
  49417. }
  49418. declare module BABYLON.Debug {
  49419. /**
  49420. * Class used to render a debug view of a given skeleton
  49421. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49422. */
  49423. export class SkeletonViewer {
  49424. /** defines the skeleton to render */
  49425. skeleton: Skeleton;
  49426. /** defines the mesh attached to the skeleton */
  49427. mesh: AbstractMesh;
  49428. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49429. autoUpdateBonesMatrices: boolean;
  49430. /** defines the rendering group id to use with the viewer */
  49431. renderingGroupId: number;
  49432. /** Gets or sets the color used to render the skeleton */
  49433. color: Color3;
  49434. private _scene;
  49435. private _debugLines;
  49436. private _debugMesh;
  49437. private _isEnabled;
  49438. private _renderFunction;
  49439. private _utilityLayer;
  49440. /**
  49441. * Returns the mesh used to render the bones
  49442. */
  49443. get debugMesh(): Nullable<LinesMesh>;
  49444. /**
  49445. * Creates a new SkeletonViewer
  49446. * @param skeleton defines the skeleton to render
  49447. * @param mesh defines the mesh attached to the skeleton
  49448. * @param scene defines the hosting scene
  49449. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49450. * @param renderingGroupId defines the rendering group id to use with the viewer
  49451. */
  49452. constructor(
  49453. /** defines the skeleton to render */
  49454. skeleton: Skeleton,
  49455. /** defines the mesh attached to the skeleton */
  49456. mesh: AbstractMesh, scene: Scene,
  49457. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49458. autoUpdateBonesMatrices?: boolean,
  49459. /** defines the rendering group id to use with the viewer */
  49460. renderingGroupId?: number);
  49461. /** Gets or sets a boolean indicating if the viewer is enabled */
  49462. set isEnabled(value: boolean);
  49463. get isEnabled(): boolean;
  49464. private _getBonePosition;
  49465. private _getLinesForBonesWithLength;
  49466. private _getLinesForBonesNoLength;
  49467. /** Update the viewer to sync with current skeleton state */
  49468. update(): void;
  49469. /** Release associated resources */
  49470. dispose(): void;
  49471. }
  49472. }
  49473. declare module BABYLON {
  49474. /**
  49475. * This class will take all inputs from Keyboard, Pointer, and
  49476. * any Gamepads and provide a polling system that all devices
  49477. * will use. This class assumes that there will only be one
  49478. * pointer device and one keyboard.
  49479. */
  49480. export class DeviceInputSystem implements IDisposable {
  49481. /** POINTER_DEVICE */
  49482. static readonly POINTER_DEVICE: string;
  49483. /** KEYBOARD_DEVICE */
  49484. static readonly KEYBOARD_DEVICE: string;
  49485. /**
  49486. * Observable to be triggered when a device is connected
  49487. */
  49488. onDeviceConnectedObservable: Observable<string>;
  49489. /**
  49490. * Observable to be triggered when a device is disconnected
  49491. */
  49492. onDeviceDisconnectedObservable: Observable<string>;
  49493. private _inputs;
  49494. private _gamepads;
  49495. private _keyboardActive;
  49496. private _pointerActive;
  49497. private _elementToAttachTo;
  49498. private _keyboardDownEvent;
  49499. private _keyboardUpEvent;
  49500. private _pointerMoveEvent;
  49501. private _pointerDownEvent;
  49502. private _pointerUpEvent;
  49503. private _gamepadConnectedEvent;
  49504. private _gamepadDisconnectedEvent;
  49505. private static _MAX_KEYCODES;
  49506. private static _MAX_POINTER_INPUTS;
  49507. /**
  49508. * Default Constructor
  49509. * @param engine - engine to pull input element from
  49510. */
  49511. constructor(engine: Engine);
  49512. /**
  49513. * Checks for current device input value, given an id and input index
  49514. * @param deviceName Id of connected device
  49515. * @param inputIndex Index of device input
  49516. * @returns Current value of input
  49517. */
  49518. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  49519. /**
  49520. * Dispose of all the eventlisteners and clears the observables
  49521. */
  49522. dispose(): void;
  49523. /**
  49524. * Add device and inputs to device map
  49525. * @param deviceName Assigned name of device (may be SN)
  49526. * @param numberOfInputs Number of input entries to create for given device
  49527. */
  49528. private _registerDevice;
  49529. /**
  49530. * Given a specific device name, remove that device from the device map
  49531. * @param deviceName Name of device to be removed
  49532. */
  49533. private _unregisterDevice;
  49534. /**
  49535. * Handle all actions that come from keyboard interaction
  49536. */
  49537. private _handleKeyActions;
  49538. /**
  49539. * Handle all actions that come from pointer interaction
  49540. */
  49541. private _handlePointerActions;
  49542. /**
  49543. * Handle all actions that come from gamepad interaction
  49544. */
  49545. private _handleGamepadActions;
  49546. /**
  49547. * Update all non-event based devices with each frame
  49548. */
  49549. private _updateDevice;
  49550. }
  49551. }
  49552. declare module BABYLON {
  49553. /**
  49554. * Options to create the null engine
  49555. */
  49556. export class NullEngineOptions {
  49557. /**
  49558. * Render width (Default: 512)
  49559. */
  49560. renderWidth: number;
  49561. /**
  49562. * Render height (Default: 256)
  49563. */
  49564. renderHeight: number;
  49565. /**
  49566. * Texture size (Default: 512)
  49567. */
  49568. textureSize: number;
  49569. /**
  49570. * If delta time between frames should be constant
  49571. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49572. */
  49573. deterministicLockstep: boolean;
  49574. /**
  49575. * Maximum about of steps between frames (Default: 4)
  49576. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49577. */
  49578. lockstepMaxSteps: number;
  49579. }
  49580. /**
  49581. * The null engine class provides support for headless version of babylon.js.
  49582. * This can be used in server side scenario or for testing purposes
  49583. */
  49584. export class NullEngine extends Engine {
  49585. private _options;
  49586. /**
  49587. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  49588. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49589. * @returns true if engine is in deterministic lock step mode
  49590. */
  49591. isDeterministicLockStep(): boolean;
  49592. /**
  49593. * Gets the max steps when engine is running in deterministic lock step
  49594. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49595. * @returns the max steps
  49596. */
  49597. getLockstepMaxSteps(): number;
  49598. /**
  49599. * Gets the current hardware scaling level.
  49600. * By default the hardware scaling level is computed from the window device ratio.
  49601. * 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.
  49602. * @returns a number indicating the current hardware scaling level
  49603. */
  49604. getHardwareScalingLevel(): number;
  49605. constructor(options?: NullEngineOptions);
  49606. /**
  49607. * Creates a vertex buffer
  49608. * @param vertices the data for the vertex buffer
  49609. * @returns the new WebGL static buffer
  49610. */
  49611. createVertexBuffer(vertices: FloatArray): DataBuffer;
  49612. /**
  49613. * Creates a new index buffer
  49614. * @param indices defines the content of the index buffer
  49615. * @param updatable defines if the index buffer must be updatable
  49616. * @returns a new webGL buffer
  49617. */
  49618. createIndexBuffer(indices: IndicesArray): DataBuffer;
  49619. /**
  49620. * Clear the current render buffer or the current render target (if any is set up)
  49621. * @param color defines the color to use
  49622. * @param backBuffer defines if the back buffer must be cleared
  49623. * @param depth defines if the depth buffer must be cleared
  49624. * @param stencil defines if the stencil buffer must be cleared
  49625. */
  49626. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49627. /**
  49628. * Gets the current render width
  49629. * @param useScreen defines if screen size must be used (or the current render target if any)
  49630. * @returns a number defining the current render width
  49631. */
  49632. getRenderWidth(useScreen?: boolean): number;
  49633. /**
  49634. * Gets the current render height
  49635. * @param useScreen defines if screen size must be used (or the current render target if any)
  49636. * @returns a number defining the current render height
  49637. */
  49638. getRenderHeight(useScreen?: boolean): number;
  49639. /**
  49640. * Set the WebGL's viewport
  49641. * @param viewport defines the viewport element to be used
  49642. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  49643. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  49644. */
  49645. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  49646. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  49647. /**
  49648. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  49649. * @param pipelineContext defines the pipeline context to use
  49650. * @param uniformsNames defines the list of uniform names
  49651. * @returns an array of webGL uniform locations
  49652. */
  49653. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  49654. /**
  49655. * Gets the lsit of active attributes for a given webGL program
  49656. * @param pipelineContext defines the pipeline context to use
  49657. * @param attributesNames defines the list of attribute names to get
  49658. * @returns an array of indices indicating the offset of each attribute
  49659. */
  49660. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49661. /**
  49662. * Binds an effect to the webGL context
  49663. * @param effect defines the effect to bind
  49664. */
  49665. bindSamplers(effect: Effect): void;
  49666. /**
  49667. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  49668. * @param effect defines the effect to activate
  49669. */
  49670. enableEffect(effect: Effect): void;
  49671. /**
  49672. * Set various states to the webGL context
  49673. * @param culling defines backface culling state
  49674. * @param zOffset defines the value to apply to zOffset (0 by default)
  49675. * @param force defines if states must be applied even if cache is up to date
  49676. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  49677. */
  49678. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49679. /**
  49680. * Set the value of an uniform to an array of int32
  49681. * @param uniform defines the webGL uniform location where to store the value
  49682. * @param array defines the array of int32 to store
  49683. */
  49684. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49685. /**
  49686. * Set the value of an uniform to an array of int32 (stored as vec2)
  49687. * @param uniform defines the webGL uniform location where to store the value
  49688. * @param array defines the array of int32 to store
  49689. */
  49690. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49691. /**
  49692. * Set the value of an uniform to an array of int32 (stored as vec3)
  49693. * @param uniform defines the webGL uniform location where to store the value
  49694. * @param array defines the array of int32 to store
  49695. */
  49696. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49697. /**
  49698. * Set the value of an uniform to an array of int32 (stored as vec4)
  49699. * @param uniform defines the webGL uniform location where to store the value
  49700. * @param array defines the array of int32 to store
  49701. */
  49702. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49703. /**
  49704. * Set the value of an uniform to an array of float32
  49705. * @param uniform defines the webGL uniform location where to store the value
  49706. * @param array defines the array of float32 to store
  49707. */
  49708. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49709. /**
  49710. * Set the value of an uniform to an array of float32 (stored as vec2)
  49711. * @param uniform defines the webGL uniform location where to store the value
  49712. * @param array defines the array of float32 to store
  49713. */
  49714. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49715. /**
  49716. * Set the value of an uniform to an array of float32 (stored as vec3)
  49717. * @param uniform defines the webGL uniform location where to store the value
  49718. * @param array defines the array of float32 to store
  49719. */
  49720. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49721. /**
  49722. * Set the value of an uniform to an array of float32 (stored as vec4)
  49723. * @param uniform defines the webGL uniform location where to store the value
  49724. * @param array defines the array of float32 to store
  49725. */
  49726. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49727. /**
  49728. * Set the value of an uniform to an array of number
  49729. * @param uniform defines the webGL uniform location where to store the value
  49730. * @param array defines the array of number to store
  49731. */
  49732. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49733. /**
  49734. * Set the value of an uniform to an array of number (stored as vec2)
  49735. * @param uniform defines the webGL uniform location where to store the value
  49736. * @param array defines the array of number to store
  49737. */
  49738. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49739. /**
  49740. * Set the value of an uniform to an array of number (stored as vec3)
  49741. * @param uniform defines the webGL uniform location where to store the value
  49742. * @param array defines the array of number to store
  49743. */
  49744. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49745. /**
  49746. * Set the value of an uniform to an array of number (stored as vec4)
  49747. * @param uniform defines the webGL uniform location where to store the value
  49748. * @param array defines the array of number to store
  49749. */
  49750. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49751. /**
  49752. * Set the value of an uniform to an array of float32 (stored as matrices)
  49753. * @param uniform defines the webGL uniform location where to store the value
  49754. * @param matrices defines the array of float32 to store
  49755. */
  49756. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49757. /**
  49758. * Set the value of an uniform to a matrix (3x3)
  49759. * @param uniform defines the webGL uniform location where to store the value
  49760. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  49761. */
  49762. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49763. /**
  49764. * Set the value of an uniform to a matrix (2x2)
  49765. * @param uniform defines the webGL uniform location where to store the value
  49766. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  49767. */
  49768. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49769. /**
  49770. * Set the value of an uniform to a number (float)
  49771. * @param uniform defines the webGL uniform location where to store the value
  49772. * @param value defines the float number to store
  49773. */
  49774. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49775. /**
  49776. * Set the value of an uniform to a vec2
  49777. * @param uniform defines the webGL uniform location where to store the value
  49778. * @param x defines the 1st component of the value
  49779. * @param y defines the 2nd component of the value
  49780. */
  49781. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49782. /**
  49783. * Set the value of an uniform to a vec3
  49784. * @param uniform defines the webGL uniform location where to store the value
  49785. * @param x defines the 1st component of the value
  49786. * @param y defines the 2nd component of the value
  49787. * @param z defines the 3rd component of the value
  49788. */
  49789. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49790. /**
  49791. * Set the value of an uniform to a boolean
  49792. * @param uniform defines the webGL uniform location where to store the value
  49793. * @param bool defines the boolean to store
  49794. */
  49795. setBool(uniform: WebGLUniformLocation, bool: number): void;
  49796. /**
  49797. * Set the value of an uniform to a vec4
  49798. * @param uniform defines the webGL uniform location where to store the value
  49799. * @param x defines the 1st component of the value
  49800. * @param y defines the 2nd component of the value
  49801. * @param z defines the 3rd component of the value
  49802. * @param w defines the 4th component of the value
  49803. */
  49804. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49805. /**
  49806. * Sets the current alpha mode
  49807. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  49808. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49809. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49810. */
  49811. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49812. /**
  49813. * Bind webGl buffers directly to the webGL context
  49814. * @param vertexBuffers defines the vertex buffer to bind
  49815. * @param indexBuffer defines the index buffer to bind
  49816. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  49817. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  49818. * @param effect defines the effect associated with the vertex buffer
  49819. */
  49820. bindBuffers(vertexBuffers: {
  49821. [key: string]: VertexBuffer;
  49822. }, indexBuffer: DataBuffer, effect: Effect): void;
  49823. /**
  49824. * Force the entire cache to be cleared
  49825. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  49826. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  49827. */
  49828. wipeCaches(bruteForce?: boolean): void;
  49829. /**
  49830. * Send a draw order
  49831. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  49832. * @param indexStart defines the starting index
  49833. * @param indexCount defines the number of index to draw
  49834. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49835. */
  49836. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  49837. /**
  49838. * Draw a list of indexed primitives
  49839. * @param fillMode defines the primitive to use
  49840. * @param indexStart defines the starting index
  49841. * @param indexCount defines the number of index to draw
  49842. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49843. */
  49844. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49845. /**
  49846. * Draw a list of unindexed primitives
  49847. * @param fillMode defines the primitive to use
  49848. * @param verticesStart defines the index of first vertex to draw
  49849. * @param verticesCount defines the count of vertices to draw
  49850. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49851. */
  49852. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49853. /** @hidden */
  49854. _createTexture(): WebGLTexture;
  49855. /** @hidden */
  49856. _releaseTexture(texture: InternalTexture): void;
  49857. /**
  49858. * Usually called from Texture.ts.
  49859. * Passed information to create a WebGLTexture
  49860. * @param urlArg defines a value which contains one of the following:
  49861. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49862. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49863. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49864. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49865. * @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)
  49866. * @param scene needed for loading to the correct scene
  49867. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49868. * @param onLoad optional callback to be called upon successful completion
  49869. * @param onError optional callback to be called upon failure
  49870. * @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
  49871. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49872. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49873. * @param forcedExtension defines the extension to use to pick the right loader
  49874. * @param mimeType defines an optional mime type
  49875. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49876. */
  49877. 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;
  49878. /**
  49879. * Creates a new render target texture
  49880. * @param size defines the size of the texture
  49881. * @param options defines the options used to create the texture
  49882. * @returns a new render target texture stored in an InternalTexture
  49883. */
  49884. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  49885. /**
  49886. * Update the sampling mode of a given texture
  49887. * @param samplingMode defines the required sampling mode
  49888. * @param texture defines the texture to update
  49889. */
  49890. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49891. /**
  49892. * Binds the frame buffer to the specified texture.
  49893. * @param texture The texture to render to or null for the default canvas
  49894. * @param faceIndex The face of the texture to render to in case of cube texture
  49895. * @param requiredWidth The width of the target to render to
  49896. * @param requiredHeight The height of the target to render to
  49897. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  49898. * @param lodLevel defines le lod level to bind to the frame buffer
  49899. */
  49900. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49901. /**
  49902. * Unbind the current render target texture from the webGL context
  49903. * @param texture defines the render target texture to unbind
  49904. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49905. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49906. */
  49907. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49908. /**
  49909. * Creates a dynamic vertex buffer
  49910. * @param vertices the data for the dynamic vertex buffer
  49911. * @returns the new WebGL dynamic buffer
  49912. */
  49913. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  49914. /**
  49915. * Update the content of a dynamic texture
  49916. * @param texture defines the texture to update
  49917. * @param canvas defines the canvas containing the source
  49918. * @param invertY defines if data must be stored with Y axis inverted
  49919. * @param premulAlpha defines if alpha is stored as premultiplied
  49920. * @param format defines the format of the data
  49921. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  49922. */
  49923. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  49924. /**
  49925. * Gets a boolean indicating if all created effects are ready
  49926. * @returns true if all effects are ready
  49927. */
  49928. areAllEffectsReady(): boolean;
  49929. /**
  49930. * @hidden
  49931. * Get the current error code of the webGL context
  49932. * @returns the error code
  49933. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  49934. */
  49935. getError(): number;
  49936. /** @hidden */
  49937. _getUnpackAlignement(): number;
  49938. /** @hidden */
  49939. _unpackFlipY(value: boolean): void;
  49940. /**
  49941. * Update a dynamic index buffer
  49942. * @param indexBuffer defines the target index buffer
  49943. * @param indices defines the data to update
  49944. * @param offset defines the offset in the target index buffer where update should start
  49945. */
  49946. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  49947. /**
  49948. * Updates a dynamic vertex buffer.
  49949. * @param vertexBuffer the vertex buffer to update
  49950. * @param vertices the data used to update the vertex buffer
  49951. * @param byteOffset the byte offset of the data (optional)
  49952. * @param byteLength the byte length of the data (optional)
  49953. */
  49954. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  49955. /** @hidden */
  49956. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  49957. /** @hidden */
  49958. _bindTexture(channel: number, texture: InternalTexture): void;
  49959. protected _deleteBuffer(buffer: WebGLBuffer): void;
  49960. /**
  49961. * 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
  49962. */
  49963. releaseEffects(): void;
  49964. displayLoadingUI(): void;
  49965. hideLoadingUI(): void;
  49966. /** @hidden */
  49967. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49968. /** @hidden */
  49969. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49970. /** @hidden */
  49971. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49972. /** @hidden */
  49973. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49974. }
  49975. }
  49976. declare module BABYLON {
  49977. /**
  49978. * @hidden
  49979. **/
  49980. export class _TimeToken {
  49981. _startTimeQuery: Nullable<WebGLQuery>;
  49982. _endTimeQuery: Nullable<WebGLQuery>;
  49983. _timeElapsedQuery: Nullable<WebGLQuery>;
  49984. _timeElapsedQueryEnded: boolean;
  49985. }
  49986. }
  49987. declare module BABYLON {
  49988. /** @hidden */
  49989. export class _OcclusionDataStorage {
  49990. /** @hidden */
  49991. occlusionInternalRetryCounter: number;
  49992. /** @hidden */
  49993. isOcclusionQueryInProgress: boolean;
  49994. /** @hidden */
  49995. isOccluded: boolean;
  49996. /** @hidden */
  49997. occlusionRetryCount: number;
  49998. /** @hidden */
  49999. occlusionType: number;
  50000. /** @hidden */
  50001. occlusionQueryAlgorithmType: number;
  50002. }
  50003. interface Engine {
  50004. /**
  50005. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50006. * @return the new query
  50007. */
  50008. createQuery(): WebGLQuery;
  50009. /**
  50010. * Delete and release a webGL query
  50011. * @param query defines the query to delete
  50012. * @return the current engine
  50013. */
  50014. deleteQuery(query: WebGLQuery): Engine;
  50015. /**
  50016. * Check if a given query has resolved and got its value
  50017. * @param query defines the query to check
  50018. * @returns true if the query got its value
  50019. */
  50020. isQueryResultAvailable(query: WebGLQuery): boolean;
  50021. /**
  50022. * Gets the value of a given query
  50023. * @param query defines the query to check
  50024. * @returns the value of the query
  50025. */
  50026. getQueryResult(query: WebGLQuery): number;
  50027. /**
  50028. * Initiates an occlusion query
  50029. * @param algorithmType defines the algorithm to use
  50030. * @param query defines the query to use
  50031. * @returns the current engine
  50032. * @see http://doc.babylonjs.com/features/occlusionquery
  50033. */
  50034. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50035. /**
  50036. * Ends an occlusion query
  50037. * @see http://doc.babylonjs.com/features/occlusionquery
  50038. * @param algorithmType defines the algorithm to use
  50039. * @returns the current engine
  50040. */
  50041. endOcclusionQuery(algorithmType: number): Engine;
  50042. /**
  50043. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50044. * Please note that only one query can be issued at a time
  50045. * @returns a time token used to track the time span
  50046. */
  50047. startTimeQuery(): Nullable<_TimeToken>;
  50048. /**
  50049. * Ends a time query
  50050. * @param token defines the token used to measure the time span
  50051. * @returns the time spent (in ns)
  50052. */
  50053. endTimeQuery(token: _TimeToken): int;
  50054. /** @hidden */
  50055. _currentNonTimestampToken: Nullable<_TimeToken>;
  50056. /** @hidden */
  50057. _createTimeQuery(): WebGLQuery;
  50058. /** @hidden */
  50059. _deleteTimeQuery(query: WebGLQuery): void;
  50060. /** @hidden */
  50061. _getGlAlgorithmType(algorithmType: number): number;
  50062. /** @hidden */
  50063. _getTimeQueryResult(query: WebGLQuery): any;
  50064. /** @hidden */
  50065. _getTimeQueryAvailability(query: WebGLQuery): any;
  50066. }
  50067. interface AbstractMesh {
  50068. /**
  50069. * Backing filed
  50070. * @hidden
  50071. */
  50072. __occlusionDataStorage: _OcclusionDataStorage;
  50073. /**
  50074. * Access property
  50075. * @hidden
  50076. */
  50077. _occlusionDataStorage: _OcclusionDataStorage;
  50078. /**
  50079. * 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.
  50080. * The default value is -1 which means don't break the query and wait till the result
  50081. * @see http://doc.babylonjs.com/features/occlusionquery
  50082. */
  50083. occlusionRetryCount: number;
  50084. /**
  50085. * 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:
  50086. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50087. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50088. * * 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.
  50089. * @see http://doc.babylonjs.com/features/occlusionquery
  50090. */
  50091. occlusionType: number;
  50092. /**
  50093. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50094. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50095. * * 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.
  50096. * @see http://doc.babylonjs.com/features/occlusionquery
  50097. */
  50098. occlusionQueryAlgorithmType: number;
  50099. /**
  50100. * 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
  50101. * @see http://doc.babylonjs.com/features/occlusionquery
  50102. */
  50103. isOccluded: boolean;
  50104. /**
  50105. * Flag to check the progress status of the query
  50106. * @see http://doc.babylonjs.com/features/occlusionquery
  50107. */
  50108. isOcclusionQueryInProgress: boolean;
  50109. }
  50110. }
  50111. declare module BABYLON {
  50112. /** @hidden */
  50113. export var _forceTransformFeedbackToBundle: boolean;
  50114. interface Engine {
  50115. /**
  50116. * Creates a webGL transform feedback object
  50117. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50118. * @returns the webGL transform feedback object
  50119. */
  50120. createTransformFeedback(): WebGLTransformFeedback;
  50121. /**
  50122. * Delete a webGL transform feedback object
  50123. * @param value defines the webGL transform feedback object to delete
  50124. */
  50125. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50126. /**
  50127. * Bind a webGL transform feedback object to the webgl context
  50128. * @param value defines the webGL transform feedback object to bind
  50129. */
  50130. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50131. /**
  50132. * Begins a transform feedback operation
  50133. * @param usePoints defines if points or triangles must be used
  50134. */
  50135. beginTransformFeedback(usePoints: boolean): void;
  50136. /**
  50137. * Ends a transform feedback operation
  50138. */
  50139. endTransformFeedback(): void;
  50140. /**
  50141. * Specify the varyings to use with transform feedback
  50142. * @param program defines the associated webGL program
  50143. * @param value defines the list of strings representing the varying names
  50144. */
  50145. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50146. /**
  50147. * Bind a webGL buffer for a transform feedback operation
  50148. * @param value defines the webGL buffer to bind
  50149. */
  50150. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50151. }
  50152. }
  50153. declare module BABYLON {
  50154. /**
  50155. * Creation options of the multi render target texture.
  50156. */
  50157. export interface IMultiRenderTargetOptions {
  50158. /**
  50159. * Define if the texture needs to create mip maps after render.
  50160. */
  50161. generateMipMaps?: boolean;
  50162. /**
  50163. * Define the types of all the draw buffers we want to create
  50164. */
  50165. types?: number[];
  50166. /**
  50167. * Define the sampling modes of all the draw buffers we want to create
  50168. */
  50169. samplingModes?: number[];
  50170. /**
  50171. * Define if a depth buffer is required
  50172. */
  50173. generateDepthBuffer?: boolean;
  50174. /**
  50175. * Define if a stencil buffer is required
  50176. */
  50177. generateStencilBuffer?: boolean;
  50178. /**
  50179. * Define if a depth texture is required instead of a depth buffer
  50180. */
  50181. generateDepthTexture?: boolean;
  50182. /**
  50183. * Define the number of desired draw buffers
  50184. */
  50185. textureCount?: number;
  50186. /**
  50187. * Define if aspect ratio should be adapted to the texture or stay the scene one
  50188. */
  50189. doNotChangeAspectRatio?: boolean;
  50190. /**
  50191. * Define the default type of the buffers we are creating
  50192. */
  50193. defaultType?: number;
  50194. }
  50195. /**
  50196. * A multi render target, like a render target provides the ability to render to a texture.
  50197. * Unlike the render target, it can render to several draw buffers in one draw.
  50198. * This is specially interesting in deferred rendering or for any effects requiring more than
  50199. * just one color from a single pass.
  50200. */
  50201. export class MultiRenderTarget extends RenderTargetTexture {
  50202. private _internalTextures;
  50203. private _textures;
  50204. private _multiRenderTargetOptions;
  50205. /**
  50206. * Get if draw buffers are currently supported by the used hardware and browser.
  50207. */
  50208. get isSupported(): boolean;
  50209. /**
  50210. * Get the list of textures generated by the multi render target.
  50211. */
  50212. get textures(): Texture[];
  50213. /**
  50214. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  50215. */
  50216. get depthTexture(): Texture;
  50217. /**
  50218. * Set the wrapping mode on U of all the textures we are rendering to.
  50219. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50220. */
  50221. set wrapU(wrap: number);
  50222. /**
  50223. * Set the wrapping mode on V of all the textures we are rendering to.
  50224. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50225. */
  50226. set wrapV(wrap: number);
  50227. /**
  50228. * Instantiate a new multi render target texture.
  50229. * A multi render target, like a render target provides the ability to render to a texture.
  50230. * Unlike the render target, it can render to several draw buffers in one draw.
  50231. * This is specially interesting in deferred rendering or for any effects requiring more than
  50232. * just one color from a single pass.
  50233. * @param name Define the name of the texture
  50234. * @param size Define the size of the buffers to render to
  50235. * @param count Define the number of target we are rendering into
  50236. * @param scene Define the scene the texture belongs to
  50237. * @param options Define the options used to create the multi render target
  50238. */
  50239. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  50240. /** @hidden */
  50241. _rebuild(): void;
  50242. private _createInternalTextures;
  50243. private _createTextures;
  50244. /**
  50245. * Define the number of samples used if MSAA is enabled.
  50246. */
  50247. get samples(): number;
  50248. set samples(value: number);
  50249. /**
  50250. * Resize all the textures in the multi render target.
  50251. * Be carrefull as it will recreate all the data in the new texture.
  50252. * @param size Define the new size
  50253. */
  50254. resize(size: any): void;
  50255. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  50256. /**
  50257. * Dispose the render targets and their associated resources
  50258. */
  50259. dispose(): void;
  50260. /**
  50261. * Release all the underlying texture used as draw buffers.
  50262. */
  50263. releaseInternalTextures(): void;
  50264. }
  50265. }
  50266. declare module BABYLON {
  50267. interface ThinEngine {
  50268. /**
  50269. * Unbind a list of render target textures from the webGL context
  50270. * This is used only when drawBuffer extension or webGL2 are active
  50271. * @param textures defines the render target textures to unbind
  50272. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50273. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50274. */
  50275. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  50276. /**
  50277. * Create a multi render target texture
  50278. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  50279. * @param size defines the size of the texture
  50280. * @param options defines the creation options
  50281. * @returns the cube texture as an InternalTexture
  50282. */
  50283. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  50284. /**
  50285. * Update the sample count for a given multiple render target texture
  50286. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  50287. * @param textures defines the textures to update
  50288. * @param samples defines the sample count to set
  50289. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  50290. */
  50291. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  50292. }
  50293. }
  50294. declare module BABYLON {
  50295. /**
  50296. * Class used to define an additional view for the engine
  50297. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50298. */
  50299. export class EngineView {
  50300. /** Defines the canvas where to render the view */
  50301. target: HTMLCanvasElement;
  50302. /** Defines an optional camera used to render the view (will use active camera else) */
  50303. camera?: Camera;
  50304. }
  50305. interface Engine {
  50306. /**
  50307. * Gets or sets the HTML element to use for attaching events
  50308. */
  50309. inputElement: Nullable<HTMLElement>;
  50310. /**
  50311. * Gets the current engine view
  50312. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50313. */
  50314. activeView: Nullable<EngineView>;
  50315. /** Gets or sets the list of views */
  50316. views: EngineView[];
  50317. /**
  50318. * Register a new child canvas
  50319. * @param canvas defines the canvas to register
  50320. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  50321. * @returns the associated view
  50322. */
  50323. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  50324. /**
  50325. * Remove a registered child canvas
  50326. * @param canvas defines the canvas to remove
  50327. * @returns the current engine
  50328. */
  50329. unRegisterView(canvas: HTMLCanvasElement): Engine;
  50330. }
  50331. }
  50332. declare module BABYLON {
  50333. interface Engine {
  50334. /** @hidden */
  50335. _excludedCompressedTextures: string[];
  50336. /** @hidden */
  50337. _textureFormatInUse: string;
  50338. /**
  50339. * Gets the list of texture formats supported
  50340. */
  50341. readonly texturesSupported: Array<string>;
  50342. /**
  50343. * Gets the texture format in use
  50344. */
  50345. readonly textureFormatInUse: Nullable<string>;
  50346. /**
  50347. * Set the compressed texture extensions or file names to skip.
  50348. *
  50349. * @param skippedFiles defines the list of those texture files you want to skip
  50350. * Example: [".dds", ".env", "myfile.png"]
  50351. */
  50352. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  50353. /**
  50354. * Set the compressed texture format to use, based on the formats you have, and the formats
  50355. * supported by the hardware / browser.
  50356. *
  50357. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  50358. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  50359. * to API arguments needed to compressed textures. This puts the burden on the container
  50360. * generator to house the arcane code for determining these for current & future formats.
  50361. *
  50362. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50363. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50364. *
  50365. * Note: The result of this call is not taken into account when a texture is base64.
  50366. *
  50367. * @param formatsAvailable defines the list of those format families you have created
  50368. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  50369. *
  50370. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  50371. * @returns The extension selected.
  50372. */
  50373. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  50374. }
  50375. }
  50376. declare module BABYLON {
  50377. /**
  50378. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  50379. */
  50380. export interface CubeMapInfo {
  50381. /**
  50382. * The pixel array for the front face.
  50383. * This is stored in format, left to right, up to down format.
  50384. */
  50385. front: Nullable<ArrayBufferView>;
  50386. /**
  50387. * The pixel array for the back face.
  50388. * This is stored in format, left to right, up to down format.
  50389. */
  50390. back: Nullable<ArrayBufferView>;
  50391. /**
  50392. * The pixel array for the left face.
  50393. * This is stored in format, left to right, up to down format.
  50394. */
  50395. left: Nullable<ArrayBufferView>;
  50396. /**
  50397. * The pixel array for the right face.
  50398. * This is stored in format, left to right, up to down format.
  50399. */
  50400. right: Nullable<ArrayBufferView>;
  50401. /**
  50402. * The pixel array for the up face.
  50403. * This is stored in format, left to right, up to down format.
  50404. */
  50405. up: Nullable<ArrayBufferView>;
  50406. /**
  50407. * The pixel array for the down face.
  50408. * This is stored in format, left to right, up to down format.
  50409. */
  50410. down: Nullable<ArrayBufferView>;
  50411. /**
  50412. * The size of the cubemap stored.
  50413. *
  50414. * Each faces will be size * size pixels.
  50415. */
  50416. size: number;
  50417. /**
  50418. * The format of the texture.
  50419. *
  50420. * RGBA, RGB.
  50421. */
  50422. format: number;
  50423. /**
  50424. * The type of the texture data.
  50425. *
  50426. * UNSIGNED_INT, FLOAT.
  50427. */
  50428. type: number;
  50429. /**
  50430. * Specifies whether the texture is in gamma space.
  50431. */
  50432. gammaSpace: boolean;
  50433. }
  50434. /**
  50435. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  50436. */
  50437. export class PanoramaToCubeMapTools {
  50438. private static FACE_LEFT;
  50439. private static FACE_RIGHT;
  50440. private static FACE_FRONT;
  50441. private static FACE_BACK;
  50442. private static FACE_DOWN;
  50443. private static FACE_UP;
  50444. /**
  50445. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50446. *
  50447. * @param float32Array The source data.
  50448. * @param inputWidth The width of the input panorama.
  50449. * @param inputHeight The height of the input panorama.
  50450. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50451. * @return The cubemap data
  50452. */
  50453. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50454. private static CreateCubemapTexture;
  50455. private static CalcProjectionSpherical;
  50456. }
  50457. }
  50458. declare module BABYLON {
  50459. /**
  50460. * Helper class dealing with the extraction of spherical polynomial dataArray
  50461. * from a cube map.
  50462. */
  50463. export class CubeMapToSphericalPolynomialTools {
  50464. private static FileFaces;
  50465. /**
  50466. * Converts a texture to the according Spherical Polynomial data.
  50467. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50468. *
  50469. * @param texture The texture to extract the information from.
  50470. * @return The Spherical Polynomial data.
  50471. */
  50472. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  50473. /**
  50474. * Converts a cubemap to the according Spherical Polynomial data.
  50475. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50476. *
  50477. * @param cubeInfo The Cube map to extract the information from.
  50478. * @return The Spherical Polynomial data.
  50479. */
  50480. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  50481. }
  50482. }
  50483. declare module BABYLON {
  50484. interface BaseTexture {
  50485. /**
  50486. * Get the polynomial representation of the texture data.
  50487. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  50488. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  50489. */
  50490. sphericalPolynomial: Nullable<SphericalPolynomial>;
  50491. }
  50492. }
  50493. declare module BABYLON {
  50494. /** @hidden */
  50495. export var rgbdEncodePixelShader: {
  50496. name: string;
  50497. shader: string;
  50498. };
  50499. }
  50500. declare module BABYLON {
  50501. /** @hidden */
  50502. export var rgbdDecodePixelShader: {
  50503. name: string;
  50504. shader: string;
  50505. };
  50506. }
  50507. declare module BABYLON {
  50508. /**
  50509. * Raw texture data and descriptor sufficient for WebGL texture upload
  50510. */
  50511. export interface EnvironmentTextureInfo {
  50512. /**
  50513. * Version of the environment map
  50514. */
  50515. version: number;
  50516. /**
  50517. * Width of image
  50518. */
  50519. width: number;
  50520. /**
  50521. * Irradiance information stored in the file.
  50522. */
  50523. irradiance: any;
  50524. /**
  50525. * Specular information stored in the file.
  50526. */
  50527. specular: any;
  50528. }
  50529. /**
  50530. * Defines One Image in the file. It requires only the position in the file
  50531. * as well as the length.
  50532. */
  50533. interface BufferImageData {
  50534. /**
  50535. * Length of the image data.
  50536. */
  50537. length: number;
  50538. /**
  50539. * Position of the data from the null terminator delimiting the end of the JSON.
  50540. */
  50541. position: number;
  50542. }
  50543. /**
  50544. * Defines the specular data enclosed in the file.
  50545. * This corresponds to the version 1 of the data.
  50546. */
  50547. export interface EnvironmentTextureSpecularInfoV1 {
  50548. /**
  50549. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  50550. */
  50551. specularDataPosition?: number;
  50552. /**
  50553. * This contains all the images data needed to reconstruct the cubemap.
  50554. */
  50555. mipmaps: Array<BufferImageData>;
  50556. /**
  50557. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  50558. */
  50559. lodGenerationScale: number;
  50560. }
  50561. /**
  50562. * Sets of helpers addressing the serialization and deserialization of environment texture
  50563. * stored in a BabylonJS env file.
  50564. * Those files are usually stored as .env files.
  50565. */
  50566. export class EnvironmentTextureTools {
  50567. /**
  50568. * Magic number identifying the env file.
  50569. */
  50570. private static _MagicBytes;
  50571. /**
  50572. * Gets the environment info from an env file.
  50573. * @param data The array buffer containing the .env bytes.
  50574. * @returns the environment file info (the json header) if successfully parsed.
  50575. */
  50576. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  50577. /**
  50578. * Creates an environment texture from a loaded cube texture.
  50579. * @param texture defines the cube texture to convert in env file
  50580. * @return a promise containing the environment data if succesfull.
  50581. */
  50582. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  50583. /**
  50584. * Creates a JSON representation of the spherical data.
  50585. * @param texture defines the texture containing the polynomials
  50586. * @return the JSON representation of the spherical info
  50587. */
  50588. private static _CreateEnvTextureIrradiance;
  50589. /**
  50590. * Creates the ArrayBufferViews used for initializing environment texture image data.
  50591. * @param data the image data
  50592. * @param info parameters that determine what views will be created for accessing the underlying buffer
  50593. * @return the views described by info providing access to the underlying buffer
  50594. */
  50595. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  50596. /**
  50597. * Uploads the texture info contained in the env file to the GPU.
  50598. * @param texture defines the internal texture to upload to
  50599. * @param data defines the data to load
  50600. * @param info defines the texture info retrieved through the GetEnvInfo method
  50601. * @returns a promise
  50602. */
  50603. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  50604. private static _OnImageReadyAsync;
  50605. /**
  50606. * Uploads the levels of image data to the GPU.
  50607. * @param texture defines the internal texture to upload to
  50608. * @param imageData defines the array buffer views of image data [mipmap][face]
  50609. * @returns a promise
  50610. */
  50611. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  50612. /**
  50613. * Uploads spherical polynomials information to the texture.
  50614. * @param texture defines the texture we are trying to upload the information to
  50615. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  50616. */
  50617. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  50618. /** @hidden */
  50619. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50620. }
  50621. }
  50622. declare module BABYLON {
  50623. /** @hidden */
  50624. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  50625. private _genericAttributeLocation;
  50626. private _varyingLocationCount;
  50627. private _varyingLocationMap;
  50628. private _replacements;
  50629. private _textureCount;
  50630. private _uniforms;
  50631. lineProcessor(line: string): string;
  50632. attributeProcessor(attribute: string): string;
  50633. varyingProcessor(varying: string, isFragment: boolean): string;
  50634. uniformProcessor(uniform: string): string;
  50635. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  50636. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  50637. }
  50638. }
  50639. declare module BABYLON {
  50640. /**
  50641. * Container for accessors for natively-stored mesh data buffers.
  50642. */
  50643. class NativeDataBuffer extends DataBuffer {
  50644. /**
  50645. * Accessor value used to identify/retrieve a natively-stored index buffer.
  50646. */
  50647. nativeIndexBuffer?: any;
  50648. /**
  50649. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  50650. */
  50651. nativeVertexBuffer?: any;
  50652. }
  50653. /** @hidden */
  50654. class NativeTexture extends InternalTexture {
  50655. getInternalTexture(): InternalTexture;
  50656. getViewCount(): number;
  50657. }
  50658. /** @hidden */
  50659. export class NativeEngine extends Engine {
  50660. private readonly _native;
  50661. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  50662. private readonly INVALID_HANDLE;
  50663. getHardwareScalingLevel(): number;
  50664. constructor();
  50665. dispose(): void;
  50666. /**
  50667. * Can be used to override the current requestAnimationFrame requester.
  50668. * @hidden
  50669. */
  50670. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  50671. /**
  50672. * Override default engine behavior.
  50673. * @param color
  50674. * @param backBuffer
  50675. * @param depth
  50676. * @param stencil
  50677. */
  50678. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  50679. /**
  50680. * Gets host document
  50681. * @returns the host document object
  50682. */
  50683. getHostDocument(): Nullable<Document>;
  50684. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50685. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  50686. createVertexBuffer(data: DataArray): NativeDataBuffer;
  50687. recordVertexArrayObject(vertexBuffers: {
  50688. [key: string]: VertexBuffer;
  50689. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  50690. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  50691. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  50692. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50693. /**
  50694. * Draw a list of indexed primitives
  50695. * @param fillMode defines the primitive to use
  50696. * @param indexStart defines the starting index
  50697. * @param indexCount defines the number of index to draw
  50698. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50699. */
  50700. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50701. /**
  50702. * Draw a list of unindexed primitives
  50703. * @param fillMode defines the primitive to use
  50704. * @param verticesStart defines the index of first vertex to draw
  50705. * @param verticesCount defines the count of vertices to draw
  50706. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50707. */
  50708. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50709. createPipelineContext(): IPipelineContext;
  50710. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  50711. /** @hidden */
  50712. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  50713. /** @hidden */
  50714. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  50715. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  50716. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  50717. protected _setProgram(program: WebGLProgram): void;
  50718. _releaseEffect(effect: Effect): void;
  50719. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  50720. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  50721. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  50722. bindSamplers(effect: Effect): void;
  50723. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  50724. getRenderWidth(useScreen?: boolean): number;
  50725. getRenderHeight(useScreen?: boolean): number;
  50726. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  50727. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50728. /**
  50729. * Set the z offset to apply to current rendering
  50730. * @param value defines the offset to apply
  50731. */
  50732. setZOffset(value: number): void;
  50733. /**
  50734. * Gets the current value of the zOffset
  50735. * @returns the current zOffset state
  50736. */
  50737. getZOffset(): number;
  50738. /**
  50739. * Enable or disable depth buffering
  50740. * @param enable defines the state to set
  50741. */
  50742. setDepthBuffer(enable: boolean): void;
  50743. /**
  50744. * Gets a boolean indicating if depth writing is enabled
  50745. * @returns the current depth writing state
  50746. */
  50747. getDepthWrite(): boolean;
  50748. /**
  50749. * Enable or disable depth writing
  50750. * @param enable defines the state to set
  50751. */
  50752. setDepthWrite(enable: boolean): void;
  50753. /**
  50754. * Enable or disable color writing
  50755. * @param enable defines the state to set
  50756. */
  50757. setColorWrite(enable: boolean): void;
  50758. /**
  50759. * Gets a boolean indicating if color writing is enabled
  50760. * @returns the current color writing state
  50761. */
  50762. getColorWrite(): boolean;
  50763. /**
  50764. * Sets alpha constants used by some alpha blending modes
  50765. * @param r defines the red component
  50766. * @param g defines the green component
  50767. * @param b defines the blue component
  50768. * @param a defines the alpha component
  50769. */
  50770. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  50771. /**
  50772. * Sets the current alpha mode
  50773. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  50774. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50775. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50776. */
  50777. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50778. /**
  50779. * Gets the current alpha mode
  50780. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50781. * @returns the current alpha mode
  50782. */
  50783. getAlphaMode(): number;
  50784. setInt(uniform: WebGLUniformLocation, int: number): void;
  50785. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50786. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50787. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50788. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50789. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50790. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50791. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50792. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50793. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50794. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50795. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50796. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50797. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50798. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50799. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50800. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50801. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50802. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50803. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50804. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  50805. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  50806. wipeCaches(bruteForce?: boolean): void;
  50807. _createTexture(): WebGLTexture;
  50808. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  50809. /**
  50810. * Usually called from Texture.ts.
  50811. * Passed information to create a WebGLTexture
  50812. * @param url defines a value which contains one of the following:
  50813. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50814. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50815. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50816. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50817. * @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)
  50818. * @param scene needed for loading to the correct scene
  50819. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50820. * @param onLoad optional callback to be called upon successful completion
  50821. * @param onError optional callback to be called upon failure
  50822. * @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
  50823. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50824. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50825. * @param forcedExtension defines the extension to use to pick the right loader
  50826. * @param mimeType defines an optional mime type
  50827. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50828. */
  50829. 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;
  50830. /**
  50831. * Creates a cube texture
  50832. * @param rootUrl defines the url where the files to load is located
  50833. * @param scene defines the current scene
  50834. * @param files defines the list of files to load (1 per face)
  50835. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  50836. * @param onLoad defines an optional callback raised when the texture is loaded
  50837. * @param onError defines an optional callback raised if there is an issue to load the texture
  50838. * @param format defines the format of the data
  50839. * @param forcedExtension defines the extension to use to pick the right loader
  50840. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  50841. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50842. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50843. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  50844. * @returns the cube texture as an InternalTexture
  50845. */
  50846. 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;
  50847. private _getSamplingFilter;
  50848. private static _GetNativeTextureFormat;
  50849. createRenderTargetTexture(size: number | {
  50850. width: number;
  50851. height: number;
  50852. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  50853. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50854. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50855. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50856. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  50857. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  50858. /**
  50859. * Updates a dynamic vertex buffer.
  50860. * @param vertexBuffer the vertex buffer to update
  50861. * @param data the data used to update the vertex buffer
  50862. * @param byteOffset the byte offset of the data (optional)
  50863. * @param byteLength the byte length of the data (optional)
  50864. */
  50865. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  50866. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  50867. private _updateAnisotropicLevel;
  50868. private _getAddressMode;
  50869. /** @hidden */
  50870. _bindTexture(channel: number, texture: InternalTexture): void;
  50871. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  50872. releaseEffects(): void;
  50873. /** @hidden */
  50874. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50875. /** @hidden */
  50876. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50877. /** @hidden */
  50878. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50879. /** @hidden */
  50880. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50881. }
  50882. }
  50883. declare module BABYLON {
  50884. /**
  50885. * Gather the list of clipboard event types as constants.
  50886. */
  50887. export class ClipboardEventTypes {
  50888. /**
  50889. * The clipboard event is fired when a copy command is active (pressed).
  50890. */
  50891. static readonly COPY: number;
  50892. /**
  50893. * The clipboard event is fired when a cut command is active (pressed).
  50894. */
  50895. static readonly CUT: number;
  50896. /**
  50897. * The clipboard event is fired when a paste command is active (pressed).
  50898. */
  50899. static readonly PASTE: number;
  50900. }
  50901. /**
  50902. * This class is used to store clipboard related info for the onClipboardObservable event.
  50903. */
  50904. export class ClipboardInfo {
  50905. /**
  50906. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50907. */
  50908. type: number;
  50909. /**
  50910. * Defines the related dom event
  50911. */
  50912. event: ClipboardEvent;
  50913. /**
  50914. *Creates an instance of ClipboardInfo.
  50915. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  50916. * @param event Defines the related dom event
  50917. */
  50918. constructor(
  50919. /**
  50920. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50921. */
  50922. type: number,
  50923. /**
  50924. * Defines the related dom event
  50925. */
  50926. event: ClipboardEvent);
  50927. /**
  50928. * Get the clipboard event's type from the keycode.
  50929. * @param keyCode Defines the keyCode for the current keyboard event.
  50930. * @return {number}
  50931. */
  50932. static GetTypeFromCharacter(keyCode: number): number;
  50933. }
  50934. }
  50935. declare module BABYLON {
  50936. /**
  50937. * Google Daydream controller
  50938. */
  50939. export class DaydreamController extends WebVRController {
  50940. /**
  50941. * Base Url for the controller model.
  50942. */
  50943. static MODEL_BASE_URL: string;
  50944. /**
  50945. * File name for the controller model.
  50946. */
  50947. static MODEL_FILENAME: string;
  50948. /**
  50949. * Gamepad Id prefix used to identify Daydream Controller.
  50950. */
  50951. static readonly GAMEPAD_ID_PREFIX: string;
  50952. /**
  50953. * Creates a new DaydreamController from a gamepad
  50954. * @param vrGamepad the gamepad that the controller should be created from
  50955. */
  50956. constructor(vrGamepad: any);
  50957. /**
  50958. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50959. * @param scene scene in which to add meshes
  50960. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50961. */
  50962. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50963. /**
  50964. * Called once for each button that changed state since the last frame
  50965. * @param buttonIdx Which button index changed
  50966. * @param state New state of the button
  50967. * @param changes Which properties on the state changed since last frame
  50968. */
  50969. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50970. }
  50971. }
  50972. declare module BABYLON {
  50973. /**
  50974. * Gear VR Controller
  50975. */
  50976. export class GearVRController extends WebVRController {
  50977. /**
  50978. * Base Url for the controller model.
  50979. */
  50980. static MODEL_BASE_URL: string;
  50981. /**
  50982. * File name for the controller model.
  50983. */
  50984. static MODEL_FILENAME: string;
  50985. /**
  50986. * Gamepad Id prefix used to identify this controller.
  50987. */
  50988. static readonly GAMEPAD_ID_PREFIX: string;
  50989. private readonly _buttonIndexToObservableNameMap;
  50990. /**
  50991. * Creates a new GearVRController from a gamepad
  50992. * @param vrGamepad the gamepad that the controller should be created from
  50993. */
  50994. constructor(vrGamepad: any);
  50995. /**
  50996. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50997. * @param scene scene in which to add meshes
  50998. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50999. */
  51000. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51001. /**
  51002. * Called once for each button that changed state since the last frame
  51003. * @param buttonIdx Which button index changed
  51004. * @param state New state of the button
  51005. * @param changes Which properties on the state changed since last frame
  51006. */
  51007. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51008. }
  51009. }
  51010. declare module BABYLON {
  51011. /**
  51012. * Generic Controller
  51013. */
  51014. export class GenericController extends WebVRController {
  51015. /**
  51016. * Base Url for the controller model.
  51017. */
  51018. static readonly MODEL_BASE_URL: string;
  51019. /**
  51020. * File name for the controller model.
  51021. */
  51022. static readonly MODEL_FILENAME: string;
  51023. /**
  51024. * Creates a new GenericController from a gamepad
  51025. * @param vrGamepad the gamepad that the controller should be created from
  51026. */
  51027. constructor(vrGamepad: any);
  51028. /**
  51029. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51030. * @param scene scene in which to add meshes
  51031. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51032. */
  51033. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51034. /**
  51035. * Called once for each button that changed state since the last frame
  51036. * @param buttonIdx Which button index changed
  51037. * @param state New state of the button
  51038. * @param changes Which properties on the state changed since last frame
  51039. */
  51040. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51041. }
  51042. }
  51043. declare module BABYLON {
  51044. /**
  51045. * Oculus Touch Controller
  51046. */
  51047. export class OculusTouchController extends WebVRController {
  51048. /**
  51049. * Base Url for the controller model.
  51050. */
  51051. static MODEL_BASE_URL: string;
  51052. /**
  51053. * File name for the left controller model.
  51054. */
  51055. static MODEL_LEFT_FILENAME: string;
  51056. /**
  51057. * File name for the right controller model.
  51058. */
  51059. static MODEL_RIGHT_FILENAME: string;
  51060. /**
  51061. * Base Url for the Quest controller model.
  51062. */
  51063. static QUEST_MODEL_BASE_URL: string;
  51064. /**
  51065. * @hidden
  51066. * If the controllers are running on a device that needs the updated Quest controller models
  51067. */
  51068. static _IsQuest: boolean;
  51069. /**
  51070. * Fired when the secondary trigger on this controller is modified
  51071. */
  51072. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51073. /**
  51074. * Fired when the thumb rest on this controller is modified
  51075. */
  51076. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51077. /**
  51078. * Creates a new OculusTouchController from a gamepad
  51079. * @param vrGamepad the gamepad that the controller should be created from
  51080. */
  51081. constructor(vrGamepad: any);
  51082. /**
  51083. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51084. * @param scene scene in which to add meshes
  51085. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51086. */
  51087. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51088. /**
  51089. * Fired when the A button on this controller is modified
  51090. */
  51091. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51092. /**
  51093. * Fired when the B button on this controller is modified
  51094. */
  51095. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51096. /**
  51097. * Fired when the X button on this controller is modified
  51098. */
  51099. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51100. /**
  51101. * Fired when the Y button on this controller is modified
  51102. */
  51103. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51104. /**
  51105. * Called once for each button that changed state since the last frame
  51106. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51107. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51108. * 2) secondary trigger (same)
  51109. * 3) A (right) X (left), touch, pressed = value
  51110. * 4) B / Y
  51111. * 5) thumb rest
  51112. * @param buttonIdx Which button index changed
  51113. * @param state New state of the button
  51114. * @param changes Which properties on the state changed since last frame
  51115. */
  51116. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51117. }
  51118. }
  51119. declare module BABYLON {
  51120. /**
  51121. * Vive Controller
  51122. */
  51123. export class ViveController extends WebVRController {
  51124. /**
  51125. * Base Url for the controller model.
  51126. */
  51127. static MODEL_BASE_URL: string;
  51128. /**
  51129. * File name for the controller model.
  51130. */
  51131. static MODEL_FILENAME: string;
  51132. /**
  51133. * Creates a new ViveController from a gamepad
  51134. * @param vrGamepad the gamepad that the controller should be created from
  51135. */
  51136. constructor(vrGamepad: any);
  51137. /**
  51138. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51139. * @param scene scene in which to add meshes
  51140. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51141. */
  51142. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51143. /**
  51144. * Fired when the left button on this controller is modified
  51145. */
  51146. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51147. /**
  51148. * Fired when the right button on this controller is modified
  51149. */
  51150. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51151. /**
  51152. * Fired when the menu button on this controller is modified
  51153. */
  51154. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51155. /**
  51156. * Called once for each button that changed state since the last frame
  51157. * Vive mapping:
  51158. * 0: touchpad
  51159. * 1: trigger
  51160. * 2: left AND right buttons
  51161. * 3: menu button
  51162. * @param buttonIdx Which button index changed
  51163. * @param state New state of the button
  51164. * @param changes Which properties on the state changed since last frame
  51165. */
  51166. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51167. }
  51168. }
  51169. declare module BABYLON {
  51170. /**
  51171. * Defines the WindowsMotionController object that the state of the windows motion controller
  51172. */
  51173. export class WindowsMotionController extends WebVRController {
  51174. /**
  51175. * The base url used to load the left and right controller models
  51176. */
  51177. static MODEL_BASE_URL: string;
  51178. /**
  51179. * The name of the left controller model file
  51180. */
  51181. static MODEL_LEFT_FILENAME: string;
  51182. /**
  51183. * The name of the right controller model file
  51184. */
  51185. static MODEL_RIGHT_FILENAME: string;
  51186. /**
  51187. * The controller name prefix for this controller type
  51188. */
  51189. static readonly GAMEPAD_ID_PREFIX: string;
  51190. /**
  51191. * The controller id pattern for this controller type
  51192. */
  51193. private static readonly GAMEPAD_ID_PATTERN;
  51194. private _loadedMeshInfo;
  51195. protected readonly _mapping: {
  51196. buttons: string[];
  51197. buttonMeshNames: {
  51198. trigger: string;
  51199. menu: string;
  51200. grip: string;
  51201. thumbstick: string;
  51202. trackpad: string;
  51203. };
  51204. buttonObservableNames: {
  51205. trigger: string;
  51206. menu: string;
  51207. grip: string;
  51208. thumbstick: string;
  51209. trackpad: string;
  51210. };
  51211. axisMeshNames: string[];
  51212. pointingPoseMeshName: string;
  51213. };
  51214. /**
  51215. * Fired when the trackpad on this controller is clicked
  51216. */
  51217. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51218. /**
  51219. * Fired when the trackpad on this controller is modified
  51220. */
  51221. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51222. /**
  51223. * The current x and y values of this controller's trackpad
  51224. */
  51225. trackpad: StickValues;
  51226. /**
  51227. * Creates a new WindowsMotionController from a gamepad
  51228. * @param vrGamepad the gamepad that the controller should be created from
  51229. */
  51230. constructor(vrGamepad: any);
  51231. /**
  51232. * Fired when the trigger on this controller is modified
  51233. */
  51234. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51235. /**
  51236. * Fired when the menu button on this controller is modified
  51237. */
  51238. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51239. /**
  51240. * Fired when the grip button on this controller is modified
  51241. */
  51242. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51243. /**
  51244. * Fired when the thumbstick button on this controller is modified
  51245. */
  51246. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51247. /**
  51248. * Fired when the touchpad button on this controller is modified
  51249. */
  51250. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51251. /**
  51252. * Fired when the touchpad values on this controller are modified
  51253. */
  51254. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  51255. protected _updateTrackpad(): void;
  51256. /**
  51257. * Called once per frame by the engine.
  51258. */
  51259. update(): void;
  51260. /**
  51261. * Called once for each button that changed state since the last frame
  51262. * @param buttonIdx Which button index changed
  51263. * @param state New state of the button
  51264. * @param changes Which properties on the state changed since last frame
  51265. */
  51266. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51267. /**
  51268. * Moves the buttons on the controller mesh based on their current state
  51269. * @param buttonName the name of the button to move
  51270. * @param buttonValue the value of the button which determines the buttons new position
  51271. */
  51272. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  51273. /**
  51274. * Moves the axis on the controller mesh based on its current state
  51275. * @param axis the index of the axis
  51276. * @param axisValue the value of the axis which determines the meshes new position
  51277. * @hidden
  51278. */
  51279. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  51280. /**
  51281. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51282. * @param scene scene in which to add meshes
  51283. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51284. */
  51285. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  51286. /**
  51287. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  51288. * can be transformed by button presses and axes values, based on this._mapping.
  51289. *
  51290. * @param scene scene in which the meshes exist
  51291. * @param meshes list of meshes that make up the controller model to process
  51292. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  51293. */
  51294. private processModel;
  51295. private createMeshInfo;
  51296. /**
  51297. * Gets the ray of the controller in the direction the controller is pointing
  51298. * @param length the length the resulting ray should be
  51299. * @returns a ray in the direction the controller is pointing
  51300. */
  51301. getForwardRay(length?: number): Ray;
  51302. /**
  51303. * Disposes of the controller
  51304. */
  51305. dispose(): void;
  51306. }
  51307. /**
  51308. * This class represents a new windows motion controller in XR.
  51309. */
  51310. export class XRWindowsMotionController extends WindowsMotionController {
  51311. /**
  51312. * Changing the original WIndowsMotionController mapping to fir the new mapping
  51313. */
  51314. protected readonly _mapping: {
  51315. buttons: string[];
  51316. buttonMeshNames: {
  51317. trigger: string;
  51318. menu: string;
  51319. grip: string;
  51320. thumbstick: string;
  51321. trackpad: string;
  51322. };
  51323. buttonObservableNames: {
  51324. trigger: string;
  51325. menu: string;
  51326. grip: string;
  51327. thumbstick: string;
  51328. trackpad: string;
  51329. };
  51330. axisMeshNames: string[];
  51331. pointingPoseMeshName: string;
  51332. };
  51333. /**
  51334. * Construct a new XR-Based windows motion controller
  51335. *
  51336. * @param gamepadInfo the gamepad object from the browser
  51337. */
  51338. constructor(gamepadInfo: any);
  51339. /**
  51340. * holds the thumbstick values (X,Y)
  51341. */
  51342. thumbstickValues: StickValues;
  51343. /**
  51344. * Fired when the thumbstick on this controller is clicked
  51345. */
  51346. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  51347. /**
  51348. * Fired when the thumbstick on this controller is modified
  51349. */
  51350. onThumbstickValuesChangedObservable: Observable<StickValues>;
  51351. /**
  51352. * Fired when the touchpad button on this controller is modified
  51353. */
  51354. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51355. /**
  51356. * Fired when the touchpad values on this controller are modified
  51357. */
  51358. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51359. /**
  51360. * Fired when the thumbstick button on this controller is modified
  51361. * here to prevent breaking changes
  51362. */
  51363. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51364. /**
  51365. * updating the thumbstick(!) and not the trackpad.
  51366. * This is named this way due to the difference between WebVR and XR and to avoid
  51367. * changing the parent class.
  51368. */
  51369. protected _updateTrackpad(): void;
  51370. /**
  51371. * Disposes the class with joy
  51372. */
  51373. dispose(): void;
  51374. }
  51375. }
  51376. declare module BABYLON {
  51377. /**
  51378. * Class containing static functions to help procedurally build meshes
  51379. */
  51380. export class PolyhedronBuilder {
  51381. /**
  51382. * Creates a polyhedron mesh
  51383. * * 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
  51384. * * The parameter `size` (positive float, default 1) sets the polygon size
  51385. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51386. * * 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`
  51387. * * 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
  51388. * * 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)`)
  51389. * * 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
  51390. * * 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
  51391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51392. * * 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
  51393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51394. * @param name defines the name of the mesh
  51395. * @param options defines the options used to create the mesh
  51396. * @param scene defines the hosting scene
  51397. * @returns the polyhedron mesh
  51398. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51399. */
  51400. static CreatePolyhedron(name: string, options: {
  51401. type?: number;
  51402. size?: number;
  51403. sizeX?: number;
  51404. sizeY?: number;
  51405. sizeZ?: number;
  51406. custom?: any;
  51407. faceUV?: Vector4[];
  51408. faceColors?: Color4[];
  51409. flat?: boolean;
  51410. updatable?: boolean;
  51411. sideOrientation?: number;
  51412. frontUVs?: Vector4;
  51413. backUVs?: Vector4;
  51414. }, scene?: Nullable<Scene>): Mesh;
  51415. }
  51416. }
  51417. declare module BABYLON {
  51418. /**
  51419. * Gizmo that enables scaling a mesh along 3 axis
  51420. */
  51421. export class ScaleGizmo extends Gizmo {
  51422. /**
  51423. * Internal gizmo used for interactions on the x axis
  51424. */
  51425. xGizmo: AxisScaleGizmo;
  51426. /**
  51427. * Internal gizmo used for interactions on the y axis
  51428. */
  51429. yGizmo: AxisScaleGizmo;
  51430. /**
  51431. * Internal gizmo used for interactions on the z axis
  51432. */
  51433. zGizmo: AxisScaleGizmo;
  51434. /**
  51435. * Internal gizmo used to scale all axis equally
  51436. */
  51437. uniformScaleGizmo: AxisScaleGizmo;
  51438. private _meshAttached;
  51439. private _updateGizmoRotationToMatchAttachedMesh;
  51440. private _snapDistance;
  51441. private _scaleRatio;
  51442. private _uniformScalingMesh;
  51443. private _octahedron;
  51444. private _sensitivity;
  51445. /** Fires an event when any of it's sub gizmos are dragged */
  51446. onDragStartObservable: Observable<unknown>;
  51447. /** Fires an event when any of it's sub gizmos are released from dragging */
  51448. onDragEndObservable: Observable<unknown>;
  51449. get attachedMesh(): Nullable<AbstractMesh>;
  51450. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51451. /**
  51452. * Creates a ScaleGizmo
  51453. * @param gizmoLayer The utility layer the gizmo will be added to
  51454. */
  51455. constructor(gizmoLayer?: UtilityLayerRenderer);
  51456. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51457. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51458. /**
  51459. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51460. */
  51461. set snapDistance(value: number);
  51462. get snapDistance(): number;
  51463. /**
  51464. * Ratio for the scale of the gizmo (Default: 1)
  51465. */
  51466. set scaleRatio(value: number);
  51467. get scaleRatio(): number;
  51468. /**
  51469. * Sensitivity factor for dragging (Default: 1)
  51470. */
  51471. set sensitivity(value: number);
  51472. get sensitivity(): number;
  51473. /**
  51474. * Disposes of the gizmo
  51475. */
  51476. dispose(): void;
  51477. }
  51478. }
  51479. declare module BABYLON {
  51480. /**
  51481. * Single axis scale gizmo
  51482. */
  51483. export class AxisScaleGizmo extends Gizmo {
  51484. /**
  51485. * Drag behavior responsible for the gizmos dragging interactions
  51486. */
  51487. dragBehavior: PointerDragBehavior;
  51488. private _pointerObserver;
  51489. /**
  51490. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51491. */
  51492. snapDistance: number;
  51493. /**
  51494. * Event that fires each time the gizmo snaps to a new location.
  51495. * * snapDistance is the the change in distance
  51496. */
  51497. onSnapObservable: Observable<{
  51498. snapDistance: number;
  51499. }>;
  51500. /**
  51501. * If the scaling operation should be done on all axis (default: false)
  51502. */
  51503. uniformScaling: boolean;
  51504. /**
  51505. * Custom sensitivity value for the drag strength
  51506. */
  51507. sensitivity: number;
  51508. private _isEnabled;
  51509. private _parent;
  51510. private _arrow;
  51511. private _coloredMaterial;
  51512. private _hoverMaterial;
  51513. /**
  51514. * Creates an AxisScaleGizmo
  51515. * @param gizmoLayer The utility layer the gizmo will be added to
  51516. * @param dragAxis The axis which the gizmo will be able to scale on
  51517. * @param color The color of the gizmo
  51518. */
  51519. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  51520. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51521. /**
  51522. * If the gizmo is enabled
  51523. */
  51524. set isEnabled(value: boolean);
  51525. get isEnabled(): boolean;
  51526. /**
  51527. * Disposes of the gizmo
  51528. */
  51529. dispose(): void;
  51530. /**
  51531. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51532. * @param mesh The mesh to replace the default mesh of the gizmo
  51533. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  51534. */
  51535. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  51536. }
  51537. }
  51538. declare module BABYLON {
  51539. /**
  51540. * Bounding box gizmo
  51541. */
  51542. export class BoundingBoxGizmo extends Gizmo {
  51543. private _lineBoundingBox;
  51544. private _rotateSpheresParent;
  51545. private _scaleBoxesParent;
  51546. private _boundingDimensions;
  51547. private _renderObserver;
  51548. private _pointerObserver;
  51549. private _scaleDragSpeed;
  51550. private _tmpQuaternion;
  51551. private _tmpVector;
  51552. private _tmpRotationMatrix;
  51553. /**
  51554. * 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)
  51555. */
  51556. ignoreChildren: boolean;
  51557. /**
  51558. * 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)
  51559. */
  51560. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  51561. /**
  51562. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  51563. */
  51564. rotationSphereSize: number;
  51565. /**
  51566. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  51567. */
  51568. scaleBoxSize: number;
  51569. /**
  51570. * 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)
  51571. */
  51572. fixedDragMeshScreenSize: boolean;
  51573. /**
  51574. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  51575. */
  51576. fixedDragMeshScreenSizeDistanceFactor: number;
  51577. /**
  51578. * Fired when a rotation sphere or scale box is dragged
  51579. */
  51580. onDragStartObservable: Observable<{}>;
  51581. /**
  51582. * Fired when a scale box is dragged
  51583. */
  51584. onScaleBoxDragObservable: Observable<{}>;
  51585. /**
  51586. * Fired when a scale box drag is ended
  51587. */
  51588. onScaleBoxDragEndObservable: Observable<{}>;
  51589. /**
  51590. * Fired when a rotation sphere is dragged
  51591. */
  51592. onRotationSphereDragObservable: Observable<{}>;
  51593. /**
  51594. * Fired when a rotation sphere drag is ended
  51595. */
  51596. onRotationSphereDragEndObservable: Observable<{}>;
  51597. /**
  51598. * 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)
  51599. */
  51600. scalePivot: Nullable<Vector3>;
  51601. /**
  51602. * Mesh used as a pivot to rotate the attached mesh
  51603. */
  51604. private _anchorMesh;
  51605. private _existingMeshScale;
  51606. private _dragMesh;
  51607. private pointerDragBehavior;
  51608. private coloredMaterial;
  51609. private hoverColoredMaterial;
  51610. /**
  51611. * Sets the color of the bounding box gizmo
  51612. * @param color the color to set
  51613. */
  51614. setColor(color: Color3): void;
  51615. /**
  51616. * Creates an BoundingBoxGizmo
  51617. * @param gizmoLayer The utility layer the gizmo will be added to
  51618. * @param color The color of the gizmo
  51619. */
  51620. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  51621. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51622. private _selectNode;
  51623. /**
  51624. * Updates the bounding box information for the Gizmo
  51625. */
  51626. updateBoundingBox(): void;
  51627. private _updateRotationSpheres;
  51628. private _updateScaleBoxes;
  51629. /**
  51630. * Enables rotation on the specified axis and disables rotation on the others
  51631. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  51632. */
  51633. setEnabledRotationAxis(axis: string): void;
  51634. /**
  51635. * Enables/disables scaling
  51636. * @param enable if scaling should be enabled
  51637. * @param homogeneousScaling defines if scaling should only be homogeneous
  51638. */
  51639. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  51640. private _updateDummy;
  51641. /**
  51642. * Enables a pointer drag behavior on the bounding box of the gizmo
  51643. */
  51644. enableDragBehavior(): void;
  51645. /**
  51646. * Disposes of the gizmo
  51647. */
  51648. dispose(): void;
  51649. /**
  51650. * 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)
  51651. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  51652. * @returns the bounding box mesh with the passed in mesh as a child
  51653. */
  51654. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  51655. /**
  51656. * CustomMeshes are not supported by this gizmo
  51657. * @param mesh The mesh to replace the default mesh of the gizmo
  51658. */
  51659. setCustomMesh(mesh: Mesh): void;
  51660. }
  51661. }
  51662. declare module BABYLON {
  51663. /**
  51664. * Single plane rotation gizmo
  51665. */
  51666. export class PlaneRotationGizmo extends Gizmo {
  51667. /**
  51668. * Drag behavior responsible for the gizmos dragging interactions
  51669. */
  51670. dragBehavior: PointerDragBehavior;
  51671. private _pointerObserver;
  51672. /**
  51673. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  51674. */
  51675. snapDistance: number;
  51676. /**
  51677. * Event that fires each time the gizmo snaps to a new location.
  51678. * * snapDistance is the the change in distance
  51679. */
  51680. onSnapObservable: Observable<{
  51681. snapDistance: number;
  51682. }>;
  51683. private _isEnabled;
  51684. private _parent;
  51685. /**
  51686. * Creates a PlaneRotationGizmo
  51687. * @param gizmoLayer The utility layer the gizmo will be added to
  51688. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  51689. * @param color The color of the gizmo
  51690. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51691. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51692. */
  51693. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  51694. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51695. /**
  51696. * If the gizmo is enabled
  51697. */
  51698. set isEnabled(value: boolean);
  51699. get isEnabled(): boolean;
  51700. /**
  51701. * Disposes of the gizmo
  51702. */
  51703. dispose(): void;
  51704. }
  51705. }
  51706. declare module BABYLON {
  51707. /**
  51708. * Gizmo that enables rotating a mesh along 3 axis
  51709. */
  51710. export class RotationGizmo extends Gizmo {
  51711. /**
  51712. * Internal gizmo used for interactions on the x axis
  51713. */
  51714. xGizmo: PlaneRotationGizmo;
  51715. /**
  51716. * Internal gizmo used for interactions on the y axis
  51717. */
  51718. yGizmo: PlaneRotationGizmo;
  51719. /**
  51720. * Internal gizmo used for interactions on the z axis
  51721. */
  51722. zGizmo: PlaneRotationGizmo;
  51723. /** Fires an event when any of it's sub gizmos are dragged */
  51724. onDragStartObservable: Observable<unknown>;
  51725. /** Fires an event when any of it's sub gizmos are released from dragging */
  51726. onDragEndObservable: Observable<unknown>;
  51727. private _meshAttached;
  51728. get attachedMesh(): Nullable<AbstractMesh>;
  51729. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51730. /**
  51731. * Creates a RotationGizmo
  51732. * @param gizmoLayer The utility layer the gizmo will be added to
  51733. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51734. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51735. */
  51736. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  51737. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51738. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51739. /**
  51740. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51741. */
  51742. set snapDistance(value: number);
  51743. get snapDistance(): number;
  51744. /**
  51745. * Ratio for the scale of the gizmo (Default: 1)
  51746. */
  51747. set scaleRatio(value: number);
  51748. get scaleRatio(): number;
  51749. /**
  51750. * Disposes of the gizmo
  51751. */
  51752. dispose(): void;
  51753. /**
  51754. * CustomMeshes are not supported by this gizmo
  51755. * @param mesh The mesh to replace the default mesh of the gizmo
  51756. */
  51757. setCustomMesh(mesh: Mesh): void;
  51758. }
  51759. }
  51760. declare module BABYLON {
  51761. /**
  51762. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  51763. */
  51764. export class GizmoManager implements IDisposable {
  51765. private scene;
  51766. /**
  51767. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  51768. */
  51769. gizmos: {
  51770. positionGizmo: Nullable<PositionGizmo>;
  51771. rotationGizmo: Nullable<RotationGizmo>;
  51772. scaleGizmo: Nullable<ScaleGizmo>;
  51773. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  51774. };
  51775. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  51776. clearGizmoOnEmptyPointerEvent: boolean;
  51777. /** Fires an event when the manager is attached to a mesh */
  51778. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  51779. private _gizmosEnabled;
  51780. private _pointerObserver;
  51781. private _attachedMesh;
  51782. private _boundingBoxColor;
  51783. private _defaultUtilityLayer;
  51784. private _defaultKeepDepthUtilityLayer;
  51785. /**
  51786. * When bounding box gizmo is enabled, this can be used to track drag/end events
  51787. */
  51788. boundingBoxDragBehavior: SixDofDragBehavior;
  51789. /**
  51790. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  51791. */
  51792. attachableMeshes: Nullable<Array<AbstractMesh>>;
  51793. /**
  51794. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  51795. */
  51796. usePointerToAttachGizmos: boolean;
  51797. /**
  51798. * Utility layer that the bounding box gizmo belongs to
  51799. */
  51800. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  51801. /**
  51802. * Utility layer that all gizmos besides bounding box belong to
  51803. */
  51804. get utilityLayer(): UtilityLayerRenderer;
  51805. /**
  51806. * Instatiates a gizmo manager
  51807. * @param scene the scene to overlay the gizmos on top of
  51808. */
  51809. constructor(scene: Scene);
  51810. /**
  51811. * Attaches a set of gizmos to the specified mesh
  51812. * @param mesh The mesh the gizmo's should be attached to
  51813. */
  51814. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51815. /**
  51816. * If the position gizmo is enabled
  51817. */
  51818. set positionGizmoEnabled(value: boolean);
  51819. get positionGizmoEnabled(): boolean;
  51820. /**
  51821. * If the rotation gizmo is enabled
  51822. */
  51823. set rotationGizmoEnabled(value: boolean);
  51824. get rotationGizmoEnabled(): boolean;
  51825. /**
  51826. * If the scale gizmo is enabled
  51827. */
  51828. set scaleGizmoEnabled(value: boolean);
  51829. get scaleGizmoEnabled(): boolean;
  51830. /**
  51831. * If the boundingBox gizmo is enabled
  51832. */
  51833. set boundingBoxGizmoEnabled(value: boolean);
  51834. get boundingBoxGizmoEnabled(): boolean;
  51835. /**
  51836. * Disposes of the gizmo manager
  51837. */
  51838. dispose(): void;
  51839. }
  51840. }
  51841. declare module BABYLON {
  51842. /**
  51843. * A directional light is defined by a direction (what a surprise!).
  51844. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  51845. * 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.
  51846. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51847. */
  51848. export class DirectionalLight extends ShadowLight {
  51849. private _shadowFrustumSize;
  51850. /**
  51851. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  51852. */
  51853. get shadowFrustumSize(): number;
  51854. /**
  51855. * Specifies a fix frustum size for the shadow generation.
  51856. */
  51857. set shadowFrustumSize(value: number);
  51858. private _shadowOrthoScale;
  51859. /**
  51860. * Gets the shadow projection scale against the optimal computed one.
  51861. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51862. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51863. */
  51864. get shadowOrthoScale(): number;
  51865. /**
  51866. * Sets the shadow projection scale against the optimal computed one.
  51867. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51868. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51869. */
  51870. set shadowOrthoScale(value: number);
  51871. /**
  51872. * Automatically compute the projection matrix to best fit (including all the casters)
  51873. * on each frame.
  51874. */
  51875. autoUpdateExtends: boolean;
  51876. /**
  51877. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  51878. * on each frame. autoUpdateExtends must be set to true for this to work
  51879. */
  51880. autoCalcShadowZBounds: boolean;
  51881. private _orthoLeft;
  51882. private _orthoRight;
  51883. private _orthoTop;
  51884. private _orthoBottom;
  51885. /**
  51886. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  51887. * The directional light is emitted from everywhere in the given direction.
  51888. * It can cast shadows.
  51889. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51890. * @param name The friendly name of the light
  51891. * @param direction The direction of the light
  51892. * @param scene The scene the light belongs to
  51893. */
  51894. constructor(name: string, direction: Vector3, scene: Scene);
  51895. /**
  51896. * Returns the string "DirectionalLight".
  51897. * @return The class name
  51898. */
  51899. getClassName(): string;
  51900. /**
  51901. * Returns the integer 1.
  51902. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51903. */
  51904. getTypeID(): number;
  51905. /**
  51906. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  51907. * Returns the DirectionalLight Shadow projection matrix.
  51908. */
  51909. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51910. /**
  51911. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  51912. * Returns the DirectionalLight Shadow projection matrix.
  51913. */
  51914. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  51915. /**
  51916. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  51917. * Returns the DirectionalLight Shadow projection matrix.
  51918. */
  51919. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51920. protected _buildUniformLayout(): void;
  51921. /**
  51922. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  51923. * @param effect The effect to update
  51924. * @param lightIndex The index of the light in the effect to update
  51925. * @returns The directional light
  51926. */
  51927. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  51928. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  51929. /**
  51930. * Gets the minZ used for shadow according to both the scene and the light.
  51931. *
  51932. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51933. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51934. * @param activeCamera The camera we are returning the min for
  51935. * @returns the depth min z
  51936. */
  51937. getDepthMinZ(activeCamera: Camera): number;
  51938. /**
  51939. * Gets the maxZ used for shadow according to both the scene and the light.
  51940. *
  51941. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51942. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51943. * @param activeCamera The camera we are returning the max for
  51944. * @returns the depth max z
  51945. */
  51946. getDepthMaxZ(activeCamera: Camera): number;
  51947. /**
  51948. * Prepares the list of defines specific to the light type.
  51949. * @param defines the list of defines
  51950. * @param lightIndex defines the index of the light for the effect
  51951. */
  51952. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51953. }
  51954. }
  51955. declare module BABYLON {
  51956. /**
  51957. * Class containing static functions to help procedurally build meshes
  51958. */
  51959. export class HemisphereBuilder {
  51960. /**
  51961. * Creates a hemisphere mesh
  51962. * @param name defines the name of the mesh
  51963. * @param options defines the options used to create the mesh
  51964. * @param scene defines the hosting scene
  51965. * @returns the hemisphere mesh
  51966. */
  51967. static CreateHemisphere(name: string, options: {
  51968. segments?: number;
  51969. diameter?: number;
  51970. sideOrientation?: number;
  51971. }, scene: any): Mesh;
  51972. }
  51973. }
  51974. declare module BABYLON {
  51975. /**
  51976. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51977. * These values define a cone of light starting from the position, emitting toward the direction.
  51978. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51979. * and the exponent defines the speed of the decay of the light with distance (reach).
  51980. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51981. */
  51982. export class SpotLight extends ShadowLight {
  51983. private _angle;
  51984. private _innerAngle;
  51985. private _cosHalfAngle;
  51986. private _lightAngleScale;
  51987. private _lightAngleOffset;
  51988. /**
  51989. * Gets the cone angle of the spot light in Radians.
  51990. */
  51991. get angle(): number;
  51992. /**
  51993. * Sets the cone angle of the spot light in Radians.
  51994. */
  51995. set angle(value: number);
  51996. /**
  51997. * Only used in gltf falloff mode, this defines the angle where
  51998. * the directional falloff will start before cutting at angle which could be seen
  51999. * as outer angle.
  52000. */
  52001. get innerAngle(): number;
  52002. /**
  52003. * Only used in gltf falloff mode, this defines the angle where
  52004. * the directional falloff will start before cutting at angle which could be seen
  52005. * as outer angle.
  52006. */
  52007. set innerAngle(value: number);
  52008. private _shadowAngleScale;
  52009. /**
  52010. * Allows scaling the angle of the light for shadow generation only.
  52011. */
  52012. get shadowAngleScale(): number;
  52013. /**
  52014. * Allows scaling the angle of the light for shadow generation only.
  52015. */
  52016. set shadowAngleScale(value: number);
  52017. /**
  52018. * The light decay speed with the distance from the emission spot.
  52019. */
  52020. exponent: number;
  52021. private _projectionTextureMatrix;
  52022. /**
  52023. * Allows reading the projecton texture
  52024. */
  52025. get projectionTextureMatrix(): Matrix;
  52026. protected _projectionTextureLightNear: number;
  52027. /**
  52028. * Gets the near clip of the Spotlight for texture projection.
  52029. */
  52030. get projectionTextureLightNear(): number;
  52031. /**
  52032. * Sets the near clip of the Spotlight for texture projection.
  52033. */
  52034. set projectionTextureLightNear(value: number);
  52035. protected _projectionTextureLightFar: number;
  52036. /**
  52037. * Gets the far clip of the Spotlight for texture projection.
  52038. */
  52039. get projectionTextureLightFar(): number;
  52040. /**
  52041. * Sets the far clip of the Spotlight for texture projection.
  52042. */
  52043. set projectionTextureLightFar(value: number);
  52044. protected _projectionTextureUpDirection: Vector3;
  52045. /**
  52046. * Gets the Up vector of the Spotlight for texture projection.
  52047. */
  52048. get projectionTextureUpDirection(): Vector3;
  52049. /**
  52050. * Sets the Up vector of the Spotlight for texture projection.
  52051. */
  52052. set projectionTextureUpDirection(value: Vector3);
  52053. private _projectionTexture;
  52054. /**
  52055. * Gets the projection texture of the light.
  52056. */
  52057. get projectionTexture(): Nullable<BaseTexture>;
  52058. /**
  52059. * Sets the projection texture of the light.
  52060. */
  52061. set projectionTexture(value: Nullable<BaseTexture>);
  52062. private _projectionTextureViewLightDirty;
  52063. private _projectionTextureProjectionLightDirty;
  52064. private _projectionTextureDirty;
  52065. private _projectionTextureViewTargetVector;
  52066. private _projectionTextureViewLightMatrix;
  52067. private _projectionTextureProjectionLightMatrix;
  52068. private _projectionTextureScalingMatrix;
  52069. /**
  52070. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52071. * It can cast shadows.
  52072. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52073. * @param name The light friendly name
  52074. * @param position The position of the spot light in the scene
  52075. * @param direction The direction of the light in the scene
  52076. * @param angle The cone angle of the light in Radians
  52077. * @param exponent The light decay speed with the distance from the emission spot
  52078. * @param scene The scene the lights belongs to
  52079. */
  52080. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52081. /**
  52082. * Returns the string "SpotLight".
  52083. * @returns the class name
  52084. */
  52085. getClassName(): string;
  52086. /**
  52087. * Returns the integer 2.
  52088. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52089. */
  52090. getTypeID(): number;
  52091. /**
  52092. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52093. */
  52094. protected _setDirection(value: Vector3): void;
  52095. /**
  52096. * Overrides the position setter to recompute the projection texture view light Matrix.
  52097. */
  52098. protected _setPosition(value: Vector3): void;
  52099. /**
  52100. * 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.
  52101. * Returns the SpotLight.
  52102. */
  52103. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52104. protected _computeProjectionTextureViewLightMatrix(): void;
  52105. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52106. /**
  52107. * Main function for light texture projection matrix computing.
  52108. */
  52109. protected _computeProjectionTextureMatrix(): void;
  52110. protected _buildUniformLayout(): void;
  52111. private _computeAngleValues;
  52112. /**
  52113. * Sets the passed Effect "effect" with the Light textures.
  52114. * @param effect The effect to update
  52115. * @param lightIndex The index of the light in the effect to update
  52116. * @returns The light
  52117. */
  52118. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52119. /**
  52120. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52121. * @param effect The effect to update
  52122. * @param lightIndex The index of the light in the effect to update
  52123. * @returns The spot light
  52124. */
  52125. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52126. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52127. /**
  52128. * Disposes the light and the associated resources.
  52129. */
  52130. dispose(): void;
  52131. /**
  52132. * Prepares the list of defines specific to the light type.
  52133. * @param defines the list of defines
  52134. * @param lightIndex defines the index of the light for the effect
  52135. */
  52136. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52137. }
  52138. }
  52139. declare module BABYLON {
  52140. /**
  52141. * Gizmo that enables viewing a light
  52142. */
  52143. export class LightGizmo extends Gizmo {
  52144. private _lightMesh;
  52145. private _material;
  52146. private _cachedPosition;
  52147. private _cachedForward;
  52148. private _attachedMeshParent;
  52149. /**
  52150. * Creates a LightGizmo
  52151. * @param gizmoLayer The utility layer the gizmo will be added to
  52152. */
  52153. constructor(gizmoLayer?: UtilityLayerRenderer);
  52154. private _light;
  52155. /**
  52156. * The light that the gizmo is attached to
  52157. */
  52158. set light(light: Nullable<Light>);
  52159. get light(): Nullable<Light>;
  52160. /**
  52161. * Gets the material used to render the light gizmo
  52162. */
  52163. get material(): StandardMaterial;
  52164. /**
  52165. * @hidden
  52166. * Updates the gizmo to match the attached mesh's position/rotation
  52167. */
  52168. protected _update(): void;
  52169. private static _Scale;
  52170. /**
  52171. * Creates the lines for a light mesh
  52172. */
  52173. private static _CreateLightLines;
  52174. /**
  52175. * Disposes of the light gizmo
  52176. */
  52177. dispose(): void;
  52178. private static _CreateHemisphericLightMesh;
  52179. private static _CreatePointLightMesh;
  52180. private static _CreateSpotLightMesh;
  52181. private static _CreateDirectionalLightMesh;
  52182. }
  52183. }
  52184. declare module BABYLON {
  52185. /** @hidden */
  52186. export var backgroundFragmentDeclaration: {
  52187. name: string;
  52188. shader: string;
  52189. };
  52190. }
  52191. declare module BABYLON {
  52192. /** @hidden */
  52193. export var backgroundUboDeclaration: {
  52194. name: string;
  52195. shader: string;
  52196. };
  52197. }
  52198. declare module BABYLON {
  52199. /** @hidden */
  52200. export var backgroundPixelShader: {
  52201. name: string;
  52202. shader: string;
  52203. };
  52204. }
  52205. declare module BABYLON {
  52206. /** @hidden */
  52207. export var backgroundVertexDeclaration: {
  52208. name: string;
  52209. shader: string;
  52210. };
  52211. }
  52212. declare module BABYLON {
  52213. /** @hidden */
  52214. export var backgroundVertexShader: {
  52215. name: string;
  52216. shader: string;
  52217. };
  52218. }
  52219. declare module BABYLON {
  52220. /**
  52221. * Background material used to create an efficient environement around your scene.
  52222. */
  52223. export class BackgroundMaterial extends PushMaterial {
  52224. /**
  52225. * Standard reflectance value at parallel view angle.
  52226. */
  52227. static StandardReflectance0: number;
  52228. /**
  52229. * Standard reflectance value at grazing angle.
  52230. */
  52231. static StandardReflectance90: number;
  52232. protected _primaryColor: Color3;
  52233. /**
  52234. * Key light Color (multiply against the environement texture)
  52235. */
  52236. primaryColor: Color3;
  52237. protected __perceptualColor: Nullable<Color3>;
  52238. /**
  52239. * Experimental Internal Use Only.
  52240. *
  52241. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  52242. * This acts as a helper to set the primary color to a more "human friendly" value.
  52243. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  52244. * output color as close as possible from the chosen value.
  52245. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  52246. * part of lighting setup.)
  52247. */
  52248. get _perceptualColor(): Nullable<Color3>;
  52249. set _perceptualColor(value: Nullable<Color3>);
  52250. protected _primaryColorShadowLevel: float;
  52251. /**
  52252. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  52253. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  52254. */
  52255. get primaryColorShadowLevel(): float;
  52256. set primaryColorShadowLevel(value: float);
  52257. protected _primaryColorHighlightLevel: float;
  52258. /**
  52259. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  52260. * The primary color is used at the level chosen to define what the white area would look.
  52261. */
  52262. get primaryColorHighlightLevel(): float;
  52263. set primaryColorHighlightLevel(value: float);
  52264. protected _reflectionTexture: Nullable<BaseTexture>;
  52265. /**
  52266. * Reflection Texture used in the material.
  52267. * Should be author in a specific way for the best result (refer to the documentation).
  52268. */
  52269. reflectionTexture: Nullable<BaseTexture>;
  52270. protected _reflectionBlur: float;
  52271. /**
  52272. * Reflection Texture level of blur.
  52273. *
  52274. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  52275. * texture twice.
  52276. */
  52277. reflectionBlur: float;
  52278. protected _diffuseTexture: Nullable<BaseTexture>;
  52279. /**
  52280. * Diffuse Texture used in the material.
  52281. * Should be author in a specific way for the best result (refer to the documentation).
  52282. */
  52283. diffuseTexture: Nullable<BaseTexture>;
  52284. protected _shadowLights: Nullable<IShadowLight[]>;
  52285. /**
  52286. * Specify the list of lights casting shadow on the material.
  52287. * All scene shadow lights will be included if null.
  52288. */
  52289. shadowLights: Nullable<IShadowLight[]>;
  52290. protected _shadowLevel: float;
  52291. /**
  52292. * Helps adjusting the shadow to a softer level if required.
  52293. * 0 means black shadows and 1 means no shadows.
  52294. */
  52295. shadowLevel: float;
  52296. protected _sceneCenter: Vector3;
  52297. /**
  52298. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52299. * It is usually zero but might be interesting to modify according to your setup.
  52300. */
  52301. sceneCenter: Vector3;
  52302. protected _opacityFresnel: boolean;
  52303. /**
  52304. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52305. * This helps ensuring a nice transition when the camera goes under the ground.
  52306. */
  52307. opacityFresnel: boolean;
  52308. protected _reflectionFresnel: boolean;
  52309. /**
  52310. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  52311. * This helps adding a mirror texture on the ground.
  52312. */
  52313. reflectionFresnel: boolean;
  52314. protected _reflectionFalloffDistance: number;
  52315. /**
  52316. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  52317. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  52318. */
  52319. reflectionFalloffDistance: number;
  52320. protected _reflectionAmount: number;
  52321. /**
  52322. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  52323. */
  52324. reflectionAmount: number;
  52325. protected _reflectionReflectance0: number;
  52326. /**
  52327. * This specifies the weight of the reflection at grazing angle.
  52328. */
  52329. reflectionReflectance0: number;
  52330. protected _reflectionReflectance90: number;
  52331. /**
  52332. * This specifies the weight of the reflection at a perpendicular point of view.
  52333. */
  52334. reflectionReflectance90: number;
  52335. /**
  52336. * Sets the reflection reflectance fresnel values according to the default standard
  52337. * empirically know to work well :-)
  52338. */
  52339. set reflectionStandardFresnelWeight(value: number);
  52340. protected _useRGBColor: boolean;
  52341. /**
  52342. * Helps to directly use the maps channels instead of their level.
  52343. */
  52344. useRGBColor: boolean;
  52345. protected _enableNoise: boolean;
  52346. /**
  52347. * This helps reducing the banding effect that could occur on the background.
  52348. */
  52349. enableNoise: boolean;
  52350. /**
  52351. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52352. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  52353. * Recommended to be keep at 1.0 except for special cases.
  52354. */
  52355. get fovMultiplier(): number;
  52356. set fovMultiplier(value: number);
  52357. private _fovMultiplier;
  52358. /**
  52359. * Enable the FOV adjustment feature controlled by fovMultiplier.
  52360. */
  52361. useEquirectangularFOV: boolean;
  52362. private _maxSimultaneousLights;
  52363. /**
  52364. * Number of Simultaneous lights allowed on the material.
  52365. */
  52366. maxSimultaneousLights: int;
  52367. /**
  52368. * Default configuration related to image processing available in the Background Material.
  52369. */
  52370. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52371. /**
  52372. * Keep track of the image processing observer to allow dispose and replace.
  52373. */
  52374. private _imageProcessingObserver;
  52375. /**
  52376. * Attaches a new image processing configuration to the PBR Material.
  52377. * @param configuration (if null the scene configuration will be use)
  52378. */
  52379. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52380. /**
  52381. * Gets the image processing configuration used either in this material.
  52382. */
  52383. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  52384. /**
  52385. * Sets the Default image processing configuration used either in the this material.
  52386. *
  52387. * If sets to null, the scene one is in use.
  52388. */
  52389. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  52390. /**
  52391. * Gets wether the color curves effect is enabled.
  52392. */
  52393. get cameraColorCurvesEnabled(): boolean;
  52394. /**
  52395. * Sets wether the color curves effect is enabled.
  52396. */
  52397. set cameraColorCurvesEnabled(value: boolean);
  52398. /**
  52399. * Gets wether the color grading effect is enabled.
  52400. */
  52401. get cameraColorGradingEnabled(): boolean;
  52402. /**
  52403. * Gets wether the color grading effect is enabled.
  52404. */
  52405. set cameraColorGradingEnabled(value: boolean);
  52406. /**
  52407. * Gets wether tonemapping is enabled or not.
  52408. */
  52409. get cameraToneMappingEnabled(): boolean;
  52410. /**
  52411. * Sets wether tonemapping is enabled or not
  52412. */
  52413. set cameraToneMappingEnabled(value: boolean);
  52414. /**
  52415. * The camera exposure used on this material.
  52416. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52417. * This corresponds to a photographic exposure.
  52418. */
  52419. get cameraExposure(): float;
  52420. /**
  52421. * The camera exposure used on this material.
  52422. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52423. * This corresponds to a photographic exposure.
  52424. */
  52425. set cameraExposure(value: float);
  52426. /**
  52427. * Gets The camera contrast used on this material.
  52428. */
  52429. get cameraContrast(): float;
  52430. /**
  52431. * Sets The camera contrast used on this material.
  52432. */
  52433. set cameraContrast(value: float);
  52434. /**
  52435. * Gets the Color Grading 2D Lookup Texture.
  52436. */
  52437. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52438. /**
  52439. * Sets the Color Grading 2D Lookup Texture.
  52440. */
  52441. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52442. /**
  52443. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52444. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52445. * 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;
  52446. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52447. */
  52448. get cameraColorCurves(): Nullable<ColorCurves>;
  52449. /**
  52450. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52451. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52452. * 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;
  52453. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52454. */
  52455. set cameraColorCurves(value: Nullable<ColorCurves>);
  52456. /**
  52457. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  52458. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  52459. */
  52460. switchToBGR: boolean;
  52461. private _renderTargets;
  52462. private _reflectionControls;
  52463. private _white;
  52464. private _primaryShadowColor;
  52465. private _primaryHighlightColor;
  52466. /**
  52467. * Instantiates a Background Material in the given scene
  52468. * @param name The friendly name of the material
  52469. * @param scene The scene to add the material to
  52470. */
  52471. constructor(name: string, scene: Scene);
  52472. /**
  52473. * Gets a boolean indicating that current material needs to register RTT
  52474. */
  52475. get hasRenderTargetTextures(): boolean;
  52476. /**
  52477. * The entire material has been created in order to prevent overdraw.
  52478. * @returns false
  52479. */
  52480. needAlphaTesting(): boolean;
  52481. /**
  52482. * The entire material has been created in order to prevent overdraw.
  52483. * @returns true if blending is enable
  52484. */
  52485. needAlphaBlending(): boolean;
  52486. /**
  52487. * Checks wether the material is ready to be rendered for a given mesh.
  52488. * @param mesh The mesh to render
  52489. * @param subMesh The submesh to check against
  52490. * @param useInstances Specify wether or not the material is used with instances
  52491. * @returns true if all the dependencies are ready (Textures, Effects...)
  52492. */
  52493. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52494. /**
  52495. * Compute the primary color according to the chosen perceptual color.
  52496. */
  52497. private _computePrimaryColorFromPerceptualColor;
  52498. /**
  52499. * Compute the highlights and shadow colors according to their chosen levels.
  52500. */
  52501. private _computePrimaryColors;
  52502. /**
  52503. * Build the uniform buffer used in the material.
  52504. */
  52505. buildUniformLayout(): void;
  52506. /**
  52507. * Unbind the material.
  52508. */
  52509. unbind(): void;
  52510. /**
  52511. * Bind only the world matrix to the material.
  52512. * @param world The world matrix to bind.
  52513. */
  52514. bindOnlyWorldMatrix(world: Matrix): void;
  52515. /**
  52516. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52517. * @param world The world matrix to bind.
  52518. * @param subMesh The submesh to bind for.
  52519. */
  52520. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52521. /**
  52522. * Checks to see if a texture is used in the material.
  52523. * @param texture - Base texture to use.
  52524. * @returns - Boolean specifying if a texture is used in the material.
  52525. */
  52526. hasTexture(texture: BaseTexture): boolean;
  52527. /**
  52528. * Dispose the material.
  52529. * @param forceDisposeEffect Force disposal of the associated effect.
  52530. * @param forceDisposeTextures Force disposal of the associated textures.
  52531. */
  52532. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52533. /**
  52534. * Clones the material.
  52535. * @param name The cloned name.
  52536. * @returns The cloned material.
  52537. */
  52538. clone(name: string): BackgroundMaterial;
  52539. /**
  52540. * Serializes the current material to its JSON representation.
  52541. * @returns The JSON representation.
  52542. */
  52543. serialize(): any;
  52544. /**
  52545. * Gets the class name of the material
  52546. * @returns "BackgroundMaterial"
  52547. */
  52548. getClassName(): string;
  52549. /**
  52550. * Parse a JSON input to create back a background material.
  52551. * @param source The JSON data to parse
  52552. * @param scene The scene to create the parsed material in
  52553. * @param rootUrl The root url of the assets the material depends upon
  52554. * @returns the instantiated BackgroundMaterial.
  52555. */
  52556. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  52557. }
  52558. }
  52559. declare module BABYLON {
  52560. /**
  52561. * Represents the different options available during the creation of
  52562. * a Environment helper.
  52563. *
  52564. * This can control the default ground, skybox and image processing setup of your scene.
  52565. */
  52566. export interface IEnvironmentHelperOptions {
  52567. /**
  52568. * Specifies whether or not to create a ground.
  52569. * True by default.
  52570. */
  52571. createGround: boolean;
  52572. /**
  52573. * Specifies the ground size.
  52574. * 15 by default.
  52575. */
  52576. groundSize: number;
  52577. /**
  52578. * The texture used on the ground for the main color.
  52579. * Comes from the BabylonJS CDN by default.
  52580. *
  52581. * Remarks: Can be either a texture or a url.
  52582. */
  52583. groundTexture: string | BaseTexture;
  52584. /**
  52585. * The color mixed in the ground texture by default.
  52586. * BabylonJS clearColor by default.
  52587. */
  52588. groundColor: Color3;
  52589. /**
  52590. * Specifies the ground opacity.
  52591. * 1 by default.
  52592. */
  52593. groundOpacity: number;
  52594. /**
  52595. * Enables the ground to receive shadows.
  52596. * True by default.
  52597. */
  52598. enableGroundShadow: boolean;
  52599. /**
  52600. * Helps preventing the shadow to be fully black on the ground.
  52601. * 0.5 by default.
  52602. */
  52603. groundShadowLevel: number;
  52604. /**
  52605. * Creates a mirror texture attach to the ground.
  52606. * false by default.
  52607. */
  52608. enableGroundMirror: boolean;
  52609. /**
  52610. * Specifies the ground mirror size ratio.
  52611. * 0.3 by default as the default kernel is 64.
  52612. */
  52613. groundMirrorSizeRatio: number;
  52614. /**
  52615. * Specifies the ground mirror blur kernel size.
  52616. * 64 by default.
  52617. */
  52618. groundMirrorBlurKernel: number;
  52619. /**
  52620. * Specifies the ground mirror visibility amount.
  52621. * 1 by default
  52622. */
  52623. groundMirrorAmount: number;
  52624. /**
  52625. * Specifies the ground mirror reflectance weight.
  52626. * This uses the standard weight of the background material to setup the fresnel effect
  52627. * of the mirror.
  52628. * 1 by default.
  52629. */
  52630. groundMirrorFresnelWeight: number;
  52631. /**
  52632. * Specifies the ground mirror Falloff distance.
  52633. * This can helps reducing the size of the reflection.
  52634. * 0 by Default.
  52635. */
  52636. groundMirrorFallOffDistance: number;
  52637. /**
  52638. * Specifies the ground mirror texture type.
  52639. * Unsigned Int by Default.
  52640. */
  52641. groundMirrorTextureType: number;
  52642. /**
  52643. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  52644. * the shown objects.
  52645. */
  52646. groundYBias: number;
  52647. /**
  52648. * Specifies whether or not to create a skybox.
  52649. * True by default.
  52650. */
  52651. createSkybox: boolean;
  52652. /**
  52653. * Specifies the skybox size.
  52654. * 20 by default.
  52655. */
  52656. skyboxSize: number;
  52657. /**
  52658. * The texture used on the skybox for the main color.
  52659. * Comes from the BabylonJS CDN by default.
  52660. *
  52661. * Remarks: Can be either a texture or a url.
  52662. */
  52663. skyboxTexture: string | BaseTexture;
  52664. /**
  52665. * The color mixed in the skybox texture by default.
  52666. * BabylonJS clearColor by default.
  52667. */
  52668. skyboxColor: Color3;
  52669. /**
  52670. * The background rotation around the Y axis of the scene.
  52671. * This helps aligning the key lights of your scene with the background.
  52672. * 0 by default.
  52673. */
  52674. backgroundYRotation: number;
  52675. /**
  52676. * Compute automatically the size of the elements to best fit with the scene.
  52677. */
  52678. sizeAuto: boolean;
  52679. /**
  52680. * Default position of the rootMesh if autoSize is not true.
  52681. */
  52682. rootPosition: Vector3;
  52683. /**
  52684. * Sets up the image processing in the scene.
  52685. * true by default.
  52686. */
  52687. setupImageProcessing: boolean;
  52688. /**
  52689. * The texture used as your environment texture in the scene.
  52690. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  52691. *
  52692. * Remarks: Can be either a texture or a url.
  52693. */
  52694. environmentTexture: string | BaseTexture;
  52695. /**
  52696. * The value of the exposure to apply to the scene.
  52697. * 0.6 by default if setupImageProcessing is true.
  52698. */
  52699. cameraExposure: number;
  52700. /**
  52701. * The value of the contrast to apply to the scene.
  52702. * 1.6 by default if setupImageProcessing is true.
  52703. */
  52704. cameraContrast: number;
  52705. /**
  52706. * Specifies whether or not tonemapping should be enabled in the scene.
  52707. * true by default if setupImageProcessing is true.
  52708. */
  52709. toneMappingEnabled: boolean;
  52710. }
  52711. /**
  52712. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  52713. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  52714. * It also helps with the default setup of your imageProcessing configuration.
  52715. */
  52716. export class EnvironmentHelper {
  52717. /**
  52718. * Default ground texture URL.
  52719. */
  52720. private static _groundTextureCDNUrl;
  52721. /**
  52722. * Default skybox texture URL.
  52723. */
  52724. private static _skyboxTextureCDNUrl;
  52725. /**
  52726. * Default environment texture URL.
  52727. */
  52728. private static _environmentTextureCDNUrl;
  52729. /**
  52730. * Creates the default options for the helper.
  52731. */
  52732. private static _getDefaultOptions;
  52733. private _rootMesh;
  52734. /**
  52735. * Gets the root mesh created by the helper.
  52736. */
  52737. get rootMesh(): Mesh;
  52738. private _skybox;
  52739. /**
  52740. * Gets the skybox created by the helper.
  52741. */
  52742. get skybox(): Nullable<Mesh>;
  52743. private _skyboxTexture;
  52744. /**
  52745. * Gets the skybox texture created by the helper.
  52746. */
  52747. get skyboxTexture(): Nullable<BaseTexture>;
  52748. private _skyboxMaterial;
  52749. /**
  52750. * Gets the skybox material created by the helper.
  52751. */
  52752. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  52753. private _ground;
  52754. /**
  52755. * Gets the ground mesh created by the helper.
  52756. */
  52757. get ground(): Nullable<Mesh>;
  52758. private _groundTexture;
  52759. /**
  52760. * Gets the ground texture created by the helper.
  52761. */
  52762. get groundTexture(): Nullable<BaseTexture>;
  52763. private _groundMirror;
  52764. /**
  52765. * Gets the ground mirror created by the helper.
  52766. */
  52767. get groundMirror(): Nullable<MirrorTexture>;
  52768. /**
  52769. * Gets the ground mirror render list to helps pushing the meshes
  52770. * you wish in the ground reflection.
  52771. */
  52772. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  52773. private _groundMaterial;
  52774. /**
  52775. * Gets the ground material created by the helper.
  52776. */
  52777. get groundMaterial(): Nullable<BackgroundMaterial>;
  52778. /**
  52779. * Stores the creation options.
  52780. */
  52781. private readonly _scene;
  52782. private _options;
  52783. /**
  52784. * This observable will be notified with any error during the creation of the environment,
  52785. * mainly texture creation errors.
  52786. */
  52787. onErrorObservable: Observable<{
  52788. message?: string;
  52789. exception?: any;
  52790. }>;
  52791. /**
  52792. * constructor
  52793. * @param options Defines the options we want to customize the helper
  52794. * @param scene The scene to add the material to
  52795. */
  52796. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  52797. /**
  52798. * Updates the background according to the new options
  52799. * @param options
  52800. */
  52801. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  52802. /**
  52803. * Sets the primary color of all the available elements.
  52804. * @param color the main color to affect to the ground and the background
  52805. */
  52806. setMainColor(color: Color3): void;
  52807. /**
  52808. * Setup the image processing according to the specified options.
  52809. */
  52810. private _setupImageProcessing;
  52811. /**
  52812. * Setup the environment texture according to the specified options.
  52813. */
  52814. private _setupEnvironmentTexture;
  52815. /**
  52816. * Setup the background according to the specified options.
  52817. */
  52818. private _setupBackground;
  52819. /**
  52820. * Get the scene sizes according to the setup.
  52821. */
  52822. private _getSceneSize;
  52823. /**
  52824. * Setup the ground according to the specified options.
  52825. */
  52826. private _setupGround;
  52827. /**
  52828. * Setup the ground material according to the specified options.
  52829. */
  52830. private _setupGroundMaterial;
  52831. /**
  52832. * Setup the ground diffuse texture according to the specified options.
  52833. */
  52834. private _setupGroundDiffuseTexture;
  52835. /**
  52836. * Setup the ground mirror texture according to the specified options.
  52837. */
  52838. private _setupGroundMirrorTexture;
  52839. /**
  52840. * Setup the ground to receive the mirror texture.
  52841. */
  52842. private _setupMirrorInGroundMaterial;
  52843. /**
  52844. * Setup the skybox according to the specified options.
  52845. */
  52846. private _setupSkybox;
  52847. /**
  52848. * Setup the skybox material according to the specified options.
  52849. */
  52850. private _setupSkyboxMaterial;
  52851. /**
  52852. * Setup the skybox reflection texture according to the specified options.
  52853. */
  52854. private _setupSkyboxReflectionTexture;
  52855. private _errorHandler;
  52856. /**
  52857. * Dispose all the elements created by the Helper.
  52858. */
  52859. dispose(): void;
  52860. }
  52861. }
  52862. declare module BABYLON {
  52863. /**
  52864. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52865. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52866. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52867. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52868. */
  52869. export class PhotoDome extends TransformNode {
  52870. /**
  52871. * Define the image as a Monoscopic panoramic 360 image.
  52872. */
  52873. static readonly MODE_MONOSCOPIC: number;
  52874. /**
  52875. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52876. */
  52877. static readonly MODE_TOPBOTTOM: number;
  52878. /**
  52879. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52880. */
  52881. static readonly MODE_SIDEBYSIDE: number;
  52882. private _useDirectMapping;
  52883. /**
  52884. * The texture being displayed on the sphere
  52885. */
  52886. protected _photoTexture: Texture;
  52887. /**
  52888. * Gets or sets the texture being displayed on the sphere
  52889. */
  52890. get photoTexture(): Texture;
  52891. set photoTexture(value: Texture);
  52892. /**
  52893. * Observable raised when an error occured while loading the 360 image
  52894. */
  52895. onLoadErrorObservable: Observable<string>;
  52896. /**
  52897. * The skybox material
  52898. */
  52899. protected _material: BackgroundMaterial;
  52900. /**
  52901. * The surface used for the skybox
  52902. */
  52903. protected _mesh: Mesh;
  52904. /**
  52905. * Gets the mesh used for the skybox.
  52906. */
  52907. get mesh(): Mesh;
  52908. /**
  52909. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52910. * Also see the options.resolution property.
  52911. */
  52912. get fovMultiplier(): number;
  52913. set fovMultiplier(value: number);
  52914. private _imageMode;
  52915. /**
  52916. * Gets or set the current video mode for the video. It can be:
  52917. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52918. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52919. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52920. */
  52921. get imageMode(): number;
  52922. set imageMode(value: number);
  52923. /**
  52924. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52925. * @param name Element's name, child elements will append suffixes for their own names.
  52926. * @param urlsOfPhoto defines the url of the photo to display
  52927. * @param options defines an object containing optional or exposed sub element properties
  52928. * @param onError defines a callback called when an error occured while loading the texture
  52929. */
  52930. constructor(name: string, urlOfPhoto: string, options: {
  52931. resolution?: number;
  52932. size?: number;
  52933. useDirectMapping?: boolean;
  52934. faceForward?: boolean;
  52935. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52936. private _onBeforeCameraRenderObserver;
  52937. private _changeImageMode;
  52938. /**
  52939. * Releases resources associated with this node.
  52940. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52941. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52942. */
  52943. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52944. }
  52945. }
  52946. declare module BABYLON {
  52947. /**
  52948. * Class used to host RGBD texture specific utilities
  52949. */
  52950. export class RGBDTextureTools {
  52951. /**
  52952. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52953. * @param texture the texture to expand.
  52954. */
  52955. static ExpandRGBDTexture(texture: Texture): void;
  52956. }
  52957. }
  52958. declare module BABYLON {
  52959. /**
  52960. * Class used to host texture specific utilities
  52961. */
  52962. export class BRDFTextureTools {
  52963. /**
  52964. * Prevents texture cache collision
  52965. */
  52966. private static _instanceNumber;
  52967. /**
  52968. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52969. * @param scene defines the hosting scene
  52970. * @returns the environment BRDF texture
  52971. */
  52972. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52973. private static _environmentBRDFBase64Texture;
  52974. }
  52975. }
  52976. declare module BABYLON {
  52977. /**
  52978. * @hidden
  52979. */
  52980. export interface IMaterialClearCoatDefines {
  52981. CLEARCOAT: boolean;
  52982. CLEARCOAT_DEFAULTIOR: boolean;
  52983. CLEARCOAT_TEXTURE: boolean;
  52984. CLEARCOAT_TEXTUREDIRECTUV: number;
  52985. CLEARCOAT_BUMP: boolean;
  52986. CLEARCOAT_BUMPDIRECTUV: number;
  52987. CLEARCOAT_TINT: boolean;
  52988. CLEARCOAT_TINT_TEXTURE: boolean;
  52989. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52990. /** @hidden */
  52991. _areTexturesDirty: boolean;
  52992. }
  52993. /**
  52994. * Define the code related to the clear coat parameters of the pbr material.
  52995. */
  52996. export class PBRClearCoatConfiguration {
  52997. /**
  52998. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52999. * The default fits with a polyurethane material.
  53000. */
  53001. private static readonly _DefaultIndexOfRefraction;
  53002. private _isEnabled;
  53003. /**
  53004. * Defines if the clear coat is enabled in the material.
  53005. */
  53006. isEnabled: boolean;
  53007. /**
  53008. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53009. */
  53010. intensity: number;
  53011. /**
  53012. * Defines the clear coat layer roughness.
  53013. */
  53014. roughness: number;
  53015. private _indexOfRefraction;
  53016. /**
  53017. * Defines the index of refraction of the clear coat.
  53018. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53019. * The default fits with a polyurethane material.
  53020. * Changing the default value is more performance intensive.
  53021. */
  53022. indexOfRefraction: number;
  53023. private _texture;
  53024. /**
  53025. * Stores the clear coat values in a texture.
  53026. */
  53027. texture: Nullable<BaseTexture>;
  53028. private _bumpTexture;
  53029. /**
  53030. * Define the clear coat specific bump texture.
  53031. */
  53032. bumpTexture: Nullable<BaseTexture>;
  53033. private _isTintEnabled;
  53034. /**
  53035. * Defines if the clear coat tint is enabled in the material.
  53036. */
  53037. isTintEnabled: boolean;
  53038. /**
  53039. * Defines the clear coat tint of the material.
  53040. * This is only use if tint is enabled
  53041. */
  53042. tintColor: Color3;
  53043. /**
  53044. * Defines the distance at which the tint color should be found in the
  53045. * clear coat media.
  53046. * This is only use if tint is enabled
  53047. */
  53048. tintColorAtDistance: number;
  53049. /**
  53050. * Defines the clear coat layer thickness.
  53051. * This is only use if tint is enabled
  53052. */
  53053. tintThickness: number;
  53054. private _tintTexture;
  53055. /**
  53056. * Stores the clear tint values in a texture.
  53057. * rgb is tint
  53058. * a is a thickness factor
  53059. */
  53060. tintTexture: Nullable<BaseTexture>;
  53061. /** @hidden */
  53062. private _internalMarkAllSubMeshesAsTexturesDirty;
  53063. /** @hidden */
  53064. _markAllSubMeshesAsTexturesDirty(): void;
  53065. /**
  53066. * Instantiate a new istance of clear coat configuration.
  53067. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53068. */
  53069. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53070. /**
  53071. * Gets wehter the submesh is ready to be used or not.
  53072. * @param defines the list of "defines" to update.
  53073. * @param scene defines the scene the material belongs to.
  53074. * @param engine defines the engine the material belongs to.
  53075. * @param disableBumpMap defines wether the material disables bump or not.
  53076. * @returns - boolean indicating that the submesh is ready or not.
  53077. */
  53078. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53079. /**
  53080. * Checks to see if a texture is used in the material.
  53081. * @param defines the list of "defines" to update.
  53082. * @param scene defines the scene to the material belongs to.
  53083. */
  53084. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53085. /**
  53086. * Binds the material data.
  53087. * @param uniformBuffer defines the Uniform buffer to fill in.
  53088. * @param scene defines the scene the material belongs to.
  53089. * @param engine defines the engine the material belongs to.
  53090. * @param disableBumpMap defines wether the material disables bump or not.
  53091. * @param isFrozen defines wether the material is frozen or not.
  53092. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53093. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53094. */
  53095. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53096. /**
  53097. * Checks to see if a texture is used in the material.
  53098. * @param texture - Base texture to use.
  53099. * @returns - Boolean specifying if a texture is used in the material.
  53100. */
  53101. hasTexture(texture: BaseTexture): boolean;
  53102. /**
  53103. * Returns an array of the actively used textures.
  53104. * @param activeTextures Array of BaseTextures
  53105. */
  53106. getActiveTextures(activeTextures: BaseTexture[]): void;
  53107. /**
  53108. * Returns the animatable textures.
  53109. * @param animatables Array of animatable textures.
  53110. */
  53111. getAnimatables(animatables: IAnimatable[]): void;
  53112. /**
  53113. * Disposes the resources of the material.
  53114. * @param forceDisposeTextures - Forces the disposal of all textures.
  53115. */
  53116. dispose(forceDisposeTextures?: boolean): void;
  53117. /**
  53118. * Get the current class name of the texture useful for serialization or dynamic coding.
  53119. * @returns "PBRClearCoatConfiguration"
  53120. */
  53121. getClassName(): string;
  53122. /**
  53123. * Add fallbacks to the effect fallbacks list.
  53124. * @param defines defines the Base texture to use.
  53125. * @param fallbacks defines the current fallback list.
  53126. * @param currentRank defines the current fallback rank.
  53127. * @returns the new fallback rank.
  53128. */
  53129. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53130. /**
  53131. * Add the required uniforms to the current list.
  53132. * @param uniforms defines the current uniform list.
  53133. */
  53134. static AddUniforms(uniforms: string[]): void;
  53135. /**
  53136. * Add the required samplers to the current list.
  53137. * @param samplers defines the current sampler list.
  53138. */
  53139. static AddSamplers(samplers: string[]): void;
  53140. /**
  53141. * Add the required uniforms to the current buffer.
  53142. * @param uniformBuffer defines the current uniform buffer.
  53143. */
  53144. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53145. /**
  53146. * Makes a duplicate of the current configuration into another one.
  53147. * @param clearCoatConfiguration define the config where to copy the info
  53148. */
  53149. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  53150. /**
  53151. * Serializes this clear coat configuration.
  53152. * @returns - An object with the serialized config.
  53153. */
  53154. serialize(): any;
  53155. /**
  53156. * Parses a anisotropy Configuration from a serialized object.
  53157. * @param source - Serialized object.
  53158. * @param scene Defines the scene we are parsing for
  53159. * @param rootUrl Defines the rootUrl to load from
  53160. */
  53161. parse(source: any, scene: Scene, rootUrl: string): void;
  53162. }
  53163. }
  53164. declare module BABYLON {
  53165. /**
  53166. * @hidden
  53167. */
  53168. export interface IMaterialAnisotropicDefines {
  53169. ANISOTROPIC: boolean;
  53170. ANISOTROPIC_TEXTURE: boolean;
  53171. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53172. MAINUV1: boolean;
  53173. _areTexturesDirty: boolean;
  53174. _needUVs: boolean;
  53175. }
  53176. /**
  53177. * Define the code related to the anisotropic parameters of the pbr material.
  53178. */
  53179. export class PBRAnisotropicConfiguration {
  53180. private _isEnabled;
  53181. /**
  53182. * Defines if the anisotropy is enabled in the material.
  53183. */
  53184. isEnabled: boolean;
  53185. /**
  53186. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  53187. */
  53188. intensity: number;
  53189. /**
  53190. * Defines if the effect is along the tangents, bitangents or in between.
  53191. * By default, the effect is "strectching" the highlights along the tangents.
  53192. */
  53193. direction: Vector2;
  53194. private _texture;
  53195. /**
  53196. * Stores the anisotropy values in a texture.
  53197. * rg is direction (like normal from -1 to 1)
  53198. * b is a intensity
  53199. */
  53200. texture: Nullable<BaseTexture>;
  53201. /** @hidden */
  53202. private _internalMarkAllSubMeshesAsTexturesDirty;
  53203. /** @hidden */
  53204. _markAllSubMeshesAsTexturesDirty(): void;
  53205. /**
  53206. * Instantiate a new istance of anisotropy configuration.
  53207. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53208. */
  53209. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53210. /**
  53211. * Specifies that the submesh is ready to be used.
  53212. * @param defines the list of "defines" to update.
  53213. * @param scene defines the scene the material belongs to.
  53214. * @returns - boolean indicating that the submesh is ready or not.
  53215. */
  53216. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  53217. /**
  53218. * Checks to see if a texture is used in the material.
  53219. * @param defines the list of "defines" to update.
  53220. * @param mesh the mesh we are preparing the defines for.
  53221. * @param scene defines the scene the material belongs to.
  53222. */
  53223. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  53224. /**
  53225. * Binds the material data.
  53226. * @param uniformBuffer defines the Uniform buffer to fill in.
  53227. * @param scene defines the scene the material belongs to.
  53228. * @param isFrozen defines wether the material is frozen or not.
  53229. */
  53230. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53231. /**
  53232. * Checks to see if a texture is used in the material.
  53233. * @param texture - Base texture to use.
  53234. * @returns - Boolean specifying if a texture is used in the material.
  53235. */
  53236. hasTexture(texture: BaseTexture): boolean;
  53237. /**
  53238. * Returns an array of the actively used textures.
  53239. * @param activeTextures Array of BaseTextures
  53240. */
  53241. getActiveTextures(activeTextures: BaseTexture[]): void;
  53242. /**
  53243. * Returns the animatable textures.
  53244. * @param animatables Array of animatable textures.
  53245. */
  53246. getAnimatables(animatables: IAnimatable[]): void;
  53247. /**
  53248. * Disposes the resources of the material.
  53249. * @param forceDisposeTextures - Forces the disposal of all textures.
  53250. */
  53251. dispose(forceDisposeTextures?: boolean): void;
  53252. /**
  53253. * Get the current class name of the texture useful for serialization or dynamic coding.
  53254. * @returns "PBRAnisotropicConfiguration"
  53255. */
  53256. getClassName(): string;
  53257. /**
  53258. * Add fallbacks to the effect fallbacks list.
  53259. * @param defines defines the Base texture to use.
  53260. * @param fallbacks defines the current fallback list.
  53261. * @param currentRank defines the current fallback rank.
  53262. * @returns the new fallback rank.
  53263. */
  53264. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53265. /**
  53266. * Add the required uniforms to the current list.
  53267. * @param uniforms defines the current uniform list.
  53268. */
  53269. static AddUniforms(uniforms: string[]): void;
  53270. /**
  53271. * Add the required uniforms to the current buffer.
  53272. * @param uniformBuffer defines the current uniform buffer.
  53273. */
  53274. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53275. /**
  53276. * Add the required samplers to the current list.
  53277. * @param samplers defines the current sampler list.
  53278. */
  53279. static AddSamplers(samplers: string[]): void;
  53280. /**
  53281. * Makes a duplicate of the current configuration into another one.
  53282. * @param anisotropicConfiguration define the config where to copy the info
  53283. */
  53284. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53285. /**
  53286. * Serializes this anisotropy configuration.
  53287. * @returns - An object with the serialized config.
  53288. */
  53289. serialize(): any;
  53290. /**
  53291. * Parses a anisotropy Configuration from a serialized object.
  53292. * @param source - Serialized object.
  53293. * @param scene Defines the scene we are parsing for
  53294. * @param rootUrl Defines the rootUrl to load from
  53295. */
  53296. parse(source: any, scene: Scene, rootUrl: string): void;
  53297. }
  53298. }
  53299. declare module BABYLON {
  53300. /**
  53301. * @hidden
  53302. */
  53303. export interface IMaterialBRDFDefines {
  53304. BRDF_V_HEIGHT_CORRELATED: boolean;
  53305. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53306. SPHERICAL_HARMONICS: boolean;
  53307. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53308. /** @hidden */
  53309. _areMiscDirty: boolean;
  53310. }
  53311. /**
  53312. * Define the code related to the BRDF parameters of the pbr material.
  53313. */
  53314. export class PBRBRDFConfiguration {
  53315. /**
  53316. * Default value used for the energy conservation.
  53317. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53318. */
  53319. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  53320. /**
  53321. * Default value used for the Smith Visibility Height Correlated mode.
  53322. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53323. */
  53324. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  53325. /**
  53326. * Default value used for the IBL diffuse part.
  53327. * This can help switching back to the polynomials mode globally which is a tiny bit
  53328. * less GPU intensive at the drawback of a lower quality.
  53329. */
  53330. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  53331. /**
  53332. * Default value used for activating energy conservation for the specular workflow.
  53333. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53334. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53335. */
  53336. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  53337. private _useEnergyConservation;
  53338. /**
  53339. * Defines if the material uses energy conservation.
  53340. */
  53341. useEnergyConservation: boolean;
  53342. private _useSmithVisibilityHeightCorrelated;
  53343. /**
  53344. * LEGACY Mode set to false
  53345. * Defines if the material uses height smith correlated visibility term.
  53346. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  53347. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53348. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53349. * Not relying on height correlated will also disable energy conservation.
  53350. */
  53351. useSmithVisibilityHeightCorrelated: boolean;
  53352. private _useSphericalHarmonics;
  53353. /**
  53354. * LEGACY Mode set to false
  53355. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53356. * diffuse part of the IBL.
  53357. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53358. * to the ground truth.
  53359. */
  53360. useSphericalHarmonics: boolean;
  53361. private _useSpecularGlossinessInputEnergyConservation;
  53362. /**
  53363. * Defines if the material uses energy conservation, when the specular workflow is active.
  53364. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53365. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53366. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  53367. */
  53368. useSpecularGlossinessInputEnergyConservation: boolean;
  53369. /** @hidden */
  53370. private _internalMarkAllSubMeshesAsMiscDirty;
  53371. /** @hidden */
  53372. _markAllSubMeshesAsMiscDirty(): void;
  53373. /**
  53374. * Instantiate a new istance of clear coat configuration.
  53375. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53376. */
  53377. constructor(markAllSubMeshesAsMiscDirty: () => void);
  53378. /**
  53379. * Checks to see if a texture is used in the material.
  53380. * @param defines the list of "defines" to update.
  53381. */
  53382. prepareDefines(defines: IMaterialBRDFDefines): void;
  53383. /**
  53384. * Get the current class name of the texture useful for serialization or dynamic coding.
  53385. * @returns "PBRClearCoatConfiguration"
  53386. */
  53387. getClassName(): string;
  53388. /**
  53389. * Makes a duplicate of the current configuration into another one.
  53390. * @param brdfConfiguration define the config where to copy the info
  53391. */
  53392. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  53393. /**
  53394. * Serializes this BRDF configuration.
  53395. * @returns - An object with the serialized config.
  53396. */
  53397. serialize(): any;
  53398. /**
  53399. * Parses a anisotropy Configuration from a serialized object.
  53400. * @param source - Serialized object.
  53401. * @param scene Defines the scene we are parsing for
  53402. * @param rootUrl Defines the rootUrl to load from
  53403. */
  53404. parse(source: any, scene: Scene, rootUrl: string): void;
  53405. }
  53406. }
  53407. declare module BABYLON {
  53408. /**
  53409. * @hidden
  53410. */
  53411. export interface IMaterialSheenDefines {
  53412. SHEEN: boolean;
  53413. SHEEN_TEXTURE: boolean;
  53414. SHEEN_TEXTUREDIRECTUV: number;
  53415. SHEEN_LINKWITHALBEDO: boolean;
  53416. SHEEN_ROUGHNESS: boolean;
  53417. SHEEN_ALBEDOSCALING: boolean;
  53418. /** @hidden */
  53419. _areTexturesDirty: boolean;
  53420. }
  53421. /**
  53422. * Define the code related to the Sheen parameters of the pbr material.
  53423. */
  53424. export class PBRSheenConfiguration {
  53425. private _isEnabled;
  53426. /**
  53427. * Defines if the material uses sheen.
  53428. */
  53429. isEnabled: boolean;
  53430. private _linkSheenWithAlbedo;
  53431. /**
  53432. * Defines if the sheen is linked to the sheen color.
  53433. */
  53434. linkSheenWithAlbedo: boolean;
  53435. /**
  53436. * Defines the sheen intensity.
  53437. */
  53438. intensity: number;
  53439. /**
  53440. * Defines the sheen color.
  53441. */
  53442. color: Color3;
  53443. private _texture;
  53444. /**
  53445. * Stores the sheen tint values in a texture.
  53446. * rgb is tint
  53447. * a is a intensity
  53448. */
  53449. texture: Nullable<BaseTexture>;
  53450. private _roughness;
  53451. /**
  53452. * Defines the sheen roughness.
  53453. * It is not taken into account if linkSheenWithAlbedo is true.
  53454. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  53455. */
  53456. roughness: Nullable<number>;
  53457. private _albedoScaling;
  53458. /**
  53459. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  53460. * It allows the strength of the sheen effect to not depend on the base color of the material,
  53461. * making it easier to setup and tweak the effect
  53462. */
  53463. albedoScaling: boolean;
  53464. /** @hidden */
  53465. private _internalMarkAllSubMeshesAsTexturesDirty;
  53466. /** @hidden */
  53467. _markAllSubMeshesAsTexturesDirty(): void;
  53468. /**
  53469. * Instantiate a new istance of clear coat configuration.
  53470. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53471. */
  53472. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53473. /**
  53474. * Specifies that the submesh is ready to be used.
  53475. * @param defines the list of "defines" to update.
  53476. * @param scene defines the scene the material belongs to.
  53477. * @returns - boolean indicating that the submesh is ready or not.
  53478. */
  53479. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  53480. /**
  53481. * Checks to see if a texture is used in the material.
  53482. * @param defines the list of "defines" to update.
  53483. * @param scene defines the scene the material belongs to.
  53484. */
  53485. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  53486. /**
  53487. * Binds the material data.
  53488. * @param uniformBuffer defines the Uniform buffer to fill in.
  53489. * @param scene defines the scene the material belongs to.
  53490. * @param isFrozen defines wether the material is frozen or not.
  53491. */
  53492. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53493. /**
  53494. * Checks to see if a texture is used in the material.
  53495. * @param texture - Base texture to use.
  53496. * @returns - Boolean specifying if a texture is used in the material.
  53497. */
  53498. hasTexture(texture: BaseTexture): boolean;
  53499. /**
  53500. * Returns an array of the actively used textures.
  53501. * @param activeTextures Array of BaseTextures
  53502. */
  53503. getActiveTextures(activeTextures: BaseTexture[]): void;
  53504. /**
  53505. * Returns the animatable textures.
  53506. * @param animatables Array of animatable textures.
  53507. */
  53508. getAnimatables(animatables: IAnimatable[]): void;
  53509. /**
  53510. * Disposes the resources of the material.
  53511. * @param forceDisposeTextures - Forces the disposal of all textures.
  53512. */
  53513. dispose(forceDisposeTextures?: boolean): void;
  53514. /**
  53515. * Get the current class name of the texture useful for serialization or dynamic coding.
  53516. * @returns "PBRSheenConfiguration"
  53517. */
  53518. getClassName(): string;
  53519. /**
  53520. * Add fallbacks to the effect fallbacks list.
  53521. * @param defines defines the Base texture to use.
  53522. * @param fallbacks defines the current fallback list.
  53523. * @param currentRank defines the current fallback rank.
  53524. * @returns the new fallback rank.
  53525. */
  53526. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53527. /**
  53528. * Add the required uniforms to the current list.
  53529. * @param uniforms defines the current uniform list.
  53530. */
  53531. static AddUniforms(uniforms: string[]): void;
  53532. /**
  53533. * Add the required uniforms to the current buffer.
  53534. * @param uniformBuffer defines the current uniform buffer.
  53535. */
  53536. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53537. /**
  53538. * Add the required samplers to the current list.
  53539. * @param samplers defines the current sampler list.
  53540. */
  53541. static AddSamplers(samplers: string[]): void;
  53542. /**
  53543. * Makes a duplicate of the current configuration into another one.
  53544. * @param sheenConfiguration define the config where to copy the info
  53545. */
  53546. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53547. /**
  53548. * Serializes this BRDF configuration.
  53549. * @returns - An object with the serialized config.
  53550. */
  53551. serialize(): any;
  53552. /**
  53553. * Parses a anisotropy Configuration from a serialized object.
  53554. * @param source - Serialized object.
  53555. * @param scene Defines the scene we are parsing for
  53556. * @param rootUrl Defines the rootUrl to load from
  53557. */
  53558. parse(source: any, scene: Scene, rootUrl: string): void;
  53559. }
  53560. }
  53561. declare module BABYLON {
  53562. /**
  53563. * @hidden
  53564. */
  53565. export interface IMaterialSubSurfaceDefines {
  53566. SUBSURFACE: boolean;
  53567. SS_REFRACTION: boolean;
  53568. SS_TRANSLUCENCY: boolean;
  53569. SS_SCATERRING: boolean;
  53570. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53571. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53572. SS_REFRACTIONMAP_3D: boolean;
  53573. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53574. SS_LODINREFRACTIONALPHA: boolean;
  53575. SS_GAMMAREFRACTION: boolean;
  53576. SS_RGBDREFRACTION: boolean;
  53577. SS_LINEARSPECULARREFRACTION: boolean;
  53578. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53579. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53580. /** @hidden */
  53581. _areTexturesDirty: boolean;
  53582. }
  53583. /**
  53584. * Define the code related to the sub surface parameters of the pbr material.
  53585. */
  53586. export class PBRSubSurfaceConfiguration {
  53587. private _isRefractionEnabled;
  53588. /**
  53589. * Defines if the refraction is enabled in the material.
  53590. */
  53591. isRefractionEnabled: boolean;
  53592. private _isTranslucencyEnabled;
  53593. /**
  53594. * Defines if the translucency is enabled in the material.
  53595. */
  53596. isTranslucencyEnabled: boolean;
  53597. private _isScatteringEnabled;
  53598. /**
  53599. * Defines the refraction intensity of the material.
  53600. * The refraction when enabled replaces the Diffuse part of the material.
  53601. * The intensity helps transitionning between diffuse and refraction.
  53602. */
  53603. refractionIntensity: number;
  53604. /**
  53605. * Defines the translucency intensity of the material.
  53606. * When translucency has been enabled, this defines how much of the "translucency"
  53607. * is addded to the diffuse part of the material.
  53608. */
  53609. translucencyIntensity: number;
  53610. /**
  53611. * Defines the scattering intensity of the material.
  53612. * When scattering has been enabled, this defines how much of the "scattered light"
  53613. * is addded to the diffuse part of the material.
  53614. */
  53615. scatteringIntensity: number;
  53616. private _thicknessTexture;
  53617. /**
  53618. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  53619. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  53620. * 0 would mean minimumThickness
  53621. * 1 would mean maximumThickness
  53622. * The other channels might be use as a mask to vary the different effects intensity.
  53623. */
  53624. thicknessTexture: Nullable<BaseTexture>;
  53625. private _refractionTexture;
  53626. /**
  53627. * Defines the texture to use for refraction.
  53628. */
  53629. refractionTexture: Nullable<BaseTexture>;
  53630. private _indexOfRefraction;
  53631. /**
  53632. * Index of refraction of the material base layer.
  53633. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  53634. *
  53635. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  53636. *
  53637. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  53638. */
  53639. indexOfRefraction: number;
  53640. private _invertRefractionY;
  53641. /**
  53642. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53643. */
  53644. invertRefractionY: boolean;
  53645. private _linkRefractionWithTransparency;
  53646. /**
  53647. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53648. * Materials half opaque for instance using refraction could benefit from this control.
  53649. */
  53650. linkRefractionWithTransparency: boolean;
  53651. /**
  53652. * Defines the minimum thickness stored in the thickness map.
  53653. * If no thickness map is defined, this value will be used to simulate thickness.
  53654. */
  53655. minimumThickness: number;
  53656. /**
  53657. * Defines the maximum thickness stored in the thickness map.
  53658. */
  53659. maximumThickness: number;
  53660. /**
  53661. * Defines the volume tint of the material.
  53662. * This is used for both translucency and scattering.
  53663. */
  53664. tintColor: Color3;
  53665. /**
  53666. * Defines the distance at which the tint color should be found in the media.
  53667. * This is used for refraction only.
  53668. */
  53669. tintColorAtDistance: number;
  53670. /**
  53671. * Defines how far each channel transmit through the media.
  53672. * It is defined as a color to simplify it selection.
  53673. */
  53674. diffusionDistance: Color3;
  53675. private _useMaskFromThicknessTexture;
  53676. /**
  53677. * Stores the intensity of the different subsurface effects in the thickness texture.
  53678. * * the green channel is the translucency intensity.
  53679. * * the blue channel is the scattering intensity.
  53680. * * the alpha channel is the refraction intensity.
  53681. */
  53682. useMaskFromThicknessTexture: boolean;
  53683. /** @hidden */
  53684. private _internalMarkAllSubMeshesAsTexturesDirty;
  53685. /** @hidden */
  53686. _markAllSubMeshesAsTexturesDirty(): void;
  53687. /**
  53688. * Instantiate a new istance of sub surface configuration.
  53689. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53690. */
  53691. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53692. /**
  53693. * Gets wehter the submesh is ready to be used or not.
  53694. * @param defines the list of "defines" to update.
  53695. * @param scene defines the scene the material belongs to.
  53696. * @returns - boolean indicating that the submesh is ready or not.
  53697. */
  53698. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  53699. /**
  53700. * Checks to see if a texture is used in the material.
  53701. * @param defines the list of "defines" to update.
  53702. * @param scene defines the scene to the material belongs to.
  53703. */
  53704. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  53705. /**
  53706. * Binds the material data.
  53707. * @param uniformBuffer defines the Uniform buffer to fill in.
  53708. * @param scene defines the scene the material belongs to.
  53709. * @param engine defines the engine the material belongs to.
  53710. * @param isFrozen defines wether the material is frozen or not.
  53711. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  53712. */
  53713. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  53714. /**
  53715. * Unbinds the material from the mesh.
  53716. * @param activeEffect defines the effect that should be unbound from.
  53717. * @returns true if unbound, otherwise false
  53718. */
  53719. unbind(activeEffect: Effect): boolean;
  53720. /**
  53721. * Returns the texture used for refraction or null if none is used.
  53722. * @param scene defines the scene the material belongs to.
  53723. * @returns - Refraction texture if present. If no refraction texture and refraction
  53724. * is linked with transparency, returns environment texture. Otherwise, returns null.
  53725. */
  53726. private _getRefractionTexture;
  53727. /**
  53728. * Returns true if alpha blending should be disabled.
  53729. */
  53730. get disableAlphaBlending(): boolean;
  53731. /**
  53732. * Fills the list of render target textures.
  53733. * @param renderTargets the list of render targets to update
  53734. */
  53735. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  53736. /**
  53737. * Checks to see if a texture is used in the material.
  53738. * @param texture - Base texture to use.
  53739. * @returns - Boolean specifying if a texture is used in the material.
  53740. */
  53741. hasTexture(texture: BaseTexture): boolean;
  53742. /**
  53743. * Gets a boolean indicating that current material needs to register RTT
  53744. * @returns true if this uses a render target otherwise false.
  53745. */
  53746. hasRenderTargetTextures(): boolean;
  53747. /**
  53748. * Returns an array of the actively used textures.
  53749. * @param activeTextures Array of BaseTextures
  53750. */
  53751. getActiveTextures(activeTextures: BaseTexture[]): void;
  53752. /**
  53753. * Returns the animatable textures.
  53754. * @param animatables Array of animatable textures.
  53755. */
  53756. getAnimatables(animatables: IAnimatable[]): void;
  53757. /**
  53758. * Disposes the resources of the material.
  53759. * @param forceDisposeTextures - Forces the disposal of all textures.
  53760. */
  53761. dispose(forceDisposeTextures?: boolean): void;
  53762. /**
  53763. * Get the current class name of the texture useful for serialization or dynamic coding.
  53764. * @returns "PBRSubSurfaceConfiguration"
  53765. */
  53766. getClassName(): string;
  53767. /**
  53768. * Add fallbacks to the effect fallbacks list.
  53769. * @param defines defines the Base texture to use.
  53770. * @param fallbacks defines the current fallback list.
  53771. * @param currentRank defines the current fallback rank.
  53772. * @returns the new fallback rank.
  53773. */
  53774. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53775. /**
  53776. * Add the required uniforms to the current list.
  53777. * @param uniforms defines the current uniform list.
  53778. */
  53779. static AddUniforms(uniforms: string[]): void;
  53780. /**
  53781. * Add the required samplers to the current list.
  53782. * @param samplers defines the current sampler list.
  53783. */
  53784. static AddSamplers(samplers: string[]): void;
  53785. /**
  53786. * Add the required uniforms to the current buffer.
  53787. * @param uniformBuffer defines the current uniform buffer.
  53788. */
  53789. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53790. /**
  53791. * Makes a duplicate of the current configuration into another one.
  53792. * @param configuration define the config where to copy the info
  53793. */
  53794. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  53795. /**
  53796. * Serializes this Sub Surface configuration.
  53797. * @returns - An object with the serialized config.
  53798. */
  53799. serialize(): any;
  53800. /**
  53801. * Parses a anisotropy Configuration from a serialized object.
  53802. * @param source - Serialized object.
  53803. * @param scene Defines the scene we are parsing for
  53804. * @param rootUrl Defines the rootUrl to load from
  53805. */
  53806. parse(source: any, scene: Scene, rootUrl: string): void;
  53807. }
  53808. }
  53809. declare module BABYLON {
  53810. /** @hidden */
  53811. export var pbrFragmentDeclaration: {
  53812. name: string;
  53813. shader: string;
  53814. };
  53815. }
  53816. declare module BABYLON {
  53817. /** @hidden */
  53818. export var pbrUboDeclaration: {
  53819. name: string;
  53820. shader: string;
  53821. };
  53822. }
  53823. declare module BABYLON {
  53824. /** @hidden */
  53825. export var pbrFragmentExtraDeclaration: {
  53826. name: string;
  53827. shader: string;
  53828. };
  53829. }
  53830. declare module BABYLON {
  53831. /** @hidden */
  53832. export var pbrFragmentSamplersDeclaration: {
  53833. name: string;
  53834. shader: string;
  53835. };
  53836. }
  53837. declare module BABYLON {
  53838. /** @hidden */
  53839. export var importanceSampling: {
  53840. name: string;
  53841. shader: string;
  53842. };
  53843. }
  53844. declare module BABYLON {
  53845. /** @hidden */
  53846. export var pbrHelperFunctions: {
  53847. name: string;
  53848. shader: string;
  53849. };
  53850. }
  53851. declare module BABYLON {
  53852. /** @hidden */
  53853. export var harmonicsFunctions: {
  53854. name: string;
  53855. shader: string;
  53856. };
  53857. }
  53858. declare module BABYLON {
  53859. /** @hidden */
  53860. export var pbrDirectLightingSetupFunctions: {
  53861. name: string;
  53862. shader: string;
  53863. };
  53864. }
  53865. declare module BABYLON {
  53866. /** @hidden */
  53867. export var pbrDirectLightingFalloffFunctions: {
  53868. name: string;
  53869. shader: string;
  53870. };
  53871. }
  53872. declare module BABYLON {
  53873. /** @hidden */
  53874. export var pbrBRDFFunctions: {
  53875. name: string;
  53876. shader: string;
  53877. };
  53878. }
  53879. declare module BABYLON {
  53880. /** @hidden */
  53881. export var hdrFilteringFunctions: {
  53882. name: string;
  53883. shader: string;
  53884. };
  53885. }
  53886. declare module BABYLON {
  53887. /** @hidden */
  53888. export var pbrDirectLightingFunctions: {
  53889. name: string;
  53890. shader: string;
  53891. };
  53892. }
  53893. declare module BABYLON {
  53894. /** @hidden */
  53895. export var pbrIBLFunctions: {
  53896. name: string;
  53897. shader: string;
  53898. };
  53899. }
  53900. declare module BABYLON {
  53901. /** @hidden */
  53902. export var pbrBlockAlbedoOpacity: {
  53903. name: string;
  53904. shader: string;
  53905. };
  53906. }
  53907. declare module BABYLON {
  53908. /** @hidden */
  53909. export var pbrBlockReflectivity: {
  53910. name: string;
  53911. shader: string;
  53912. };
  53913. }
  53914. declare module BABYLON {
  53915. /** @hidden */
  53916. export var pbrBlockAmbientOcclusion: {
  53917. name: string;
  53918. shader: string;
  53919. };
  53920. }
  53921. declare module BABYLON {
  53922. /** @hidden */
  53923. export var pbrBlockAlphaFresnel: {
  53924. name: string;
  53925. shader: string;
  53926. };
  53927. }
  53928. declare module BABYLON {
  53929. /** @hidden */
  53930. export var pbrBlockAnisotropic: {
  53931. name: string;
  53932. shader: string;
  53933. };
  53934. }
  53935. declare module BABYLON {
  53936. /** @hidden */
  53937. export var pbrBlockReflection: {
  53938. name: string;
  53939. shader: string;
  53940. };
  53941. }
  53942. declare module BABYLON {
  53943. /** @hidden */
  53944. export var pbrBlockSheen: {
  53945. name: string;
  53946. shader: string;
  53947. };
  53948. }
  53949. declare module BABYLON {
  53950. /** @hidden */
  53951. export var pbrBlockClearcoat: {
  53952. name: string;
  53953. shader: string;
  53954. };
  53955. }
  53956. declare module BABYLON {
  53957. /** @hidden */
  53958. export var pbrBlockSubSurface: {
  53959. name: string;
  53960. shader: string;
  53961. };
  53962. }
  53963. declare module BABYLON {
  53964. /** @hidden */
  53965. export var pbrBlockNormalGeometric: {
  53966. name: string;
  53967. shader: string;
  53968. };
  53969. }
  53970. declare module BABYLON {
  53971. /** @hidden */
  53972. export var pbrBlockNormalFinal: {
  53973. name: string;
  53974. shader: string;
  53975. };
  53976. }
  53977. declare module BABYLON {
  53978. /** @hidden */
  53979. export var pbrBlockGeometryInfo: {
  53980. name: string;
  53981. shader: string;
  53982. };
  53983. }
  53984. declare module BABYLON {
  53985. /** @hidden */
  53986. export var pbrBlockReflectance0: {
  53987. name: string;
  53988. shader: string;
  53989. };
  53990. }
  53991. declare module BABYLON {
  53992. /** @hidden */
  53993. export var pbrBlockReflectance: {
  53994. name: string;
  53995. shader: string;
  53996. };
  53997. }
  53998. declare module BABYLON {
  53999. /** @hidden */
  54000. export var pbrBlockDirectLighting: {
  54001. name: string;
  54002. shader: string;
  54003. };
  54004. }
  54005. declare module BABYLON {
  54006. /** @hidden */
  54007. export var pbrBlockFinalLitComponents: {
  54008. name: string;
  54009. shader: string;
  54010. };
  54011. }
  54012. declare module BABYLON {
  54013. /** @hidden */
  54014. export var pbrBlockFinalUnlitComponents: {
  54015. name: string;
  54016. shader: string;
  54017. };
  54018. }
  54019. declare module BABYLON {
  54020. /** @hidden */
  54021. export var pbrBlockFinalColorComposition: {
  54022. name: string;
  54023. shader: string;
  54024. };
  54025. }
  54026. declare module BABYLON {
  54027. /** @hidden */
  54028. export var pbrBlockImageProcessing: {
  54029. name: string;
  54030. shader: string;
  54031. };
  54032. }
  54033. declare module BABYLON {
  54034. /** @hidden */
  54035. export var pbrDebug: {
  54036. name: string;
  54037. shader: string;
  54038. };
  54039. }
  54040. declare module BABYLON {
  54041. /** @hidden */
  54042. export var pbrPixelShader: {
  54043. name: string;
  54044. shader: string;
  54045. };
  54046. }
  54047. declare module BABYLON {
  54048. /** @hidden */
  54049. export var pbrVertexDeclaration: {
  54050. name: string;
  54051. shader: string;
  54052. };
  54053. }
  54054. declare module BABYLON {
  54055. /** @hidden */
  54056. export var pbrVertexShader: {
  54057. name: string;
  54058. shader: string;
  54059. };
  54060. }
  54061. declare module BABYLON {
  54062. /**
  54063. * Manages the defines for the PBR Material.
  54064. * @hidden
  54065. */
  54066. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  54067. PBR: boolean;
  54068. NUM_SAMPLES: string;
  54069. REALTIME_FILTERING: boolean;
  54070. MAINUV1: boolean;
  54071. MAINUV2: boolean;
  54072. UV1: boolean;
  54073. UV2: boolean;
  54074. ALBEDO: boolean;
  54075. GAMMAALBEDO: boolean;
  54076. ALBEDODIRECTUV: number;
  54077. VERTEXCOLOR: boolean;
  54078. AMBIENT: boolean;
  54079. AMBIENTDIRECTUV: number;
  54080. AMBIENTINGRAYSCALE: boolean;
  54081. OPACITY: boolean;
  54082. VERTEXALPHA: boolean;
  54083. OPACITYDIRECTUV: number;
  54084. OPACITYRGB: boolean;
  54085. ALPHATEST: boolean;
  54086. DEPTHPREPASS: boolean;
  54087. ALPHABLEND: boolean;
  54088. ALPHAFROMALBEDO: boolean;
  54089. ALPHATESTVALUE: string;
  54090. SPECULAROVERALPHA: boolean;
  54091. RADIANCEOVERALPHA: boolean;
  54092. ALPHAFRESNEL: boolean;
  54093. LINEARALPHAFRESNEL: boolean;
  54094. PREMULTIPLYALPHA: boolean;
  54095. EMISSIVE: boolean;
  54096. EMISSIVEDIRECTUV: number;
  54097. REFLECTIVITY: boolean;
  54098. REFLECTIVITYDIRECTUV: number;
  54099. SPECULARTERM: boolean;
  54100. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54101. MICROSURFACEAUTOMATIC: boolean;
  54102. LODBASEDMICROSFURACE: boolean;
  54103. MICROSURFACEMAP: boolean;
  54104. MICROSURFACEMAPDIRECTUV: number;
  54105. METALLICWORKFLOW: boolean;
  54106. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54107. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54108. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54109. AOSTOREINMETALMAPRED: boolean;
  54110. METALLIC_REFLECTANCE: boolean;
  54111. METALLIC_REFLECTANCEDIRECTUV: number;
  54112. ENVIRONMENTBRDF: boolean;
  54113. ENVIRONMENTBRDF_RGBD: boolean;
  54114. NORMAL: boolean;
  54115. TANGENT: boolean;
  54116. BUMP: boolean;
  54117. BUMPDIRECTUV: number;
  54118. OBJECTSPACE_NORMALMAP: boolean;
  54119. PARALLAX: boolean;
  54120. PARALLAXOCCLUSION: boolean;
  54121. NORMALXYSCALE: boolean;
  54122. LIGHTMAP: boolean;
  54123. LIGHTMAPDIRECTUV: number;
  54124. USELIGHTMAPASSHADOWMAP: boolean;
  54125. GAMMALIGHTMAP: boolean;
  54126. RGBDLIGHTMAP: boolean;
  54127. REFLECTION: boolean;
  54128. REFLECTIONMAP_3D: boolean;
  54129. REFLECTIONMAP_SPHERICAL: boolean;
  54130. REFLECTIONMAP_PLANAR: boolean;
  54131. REFLECTIONMAP_CUBIC: boolean;
  54132. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  54133. REFLECTIONMAP_PROJECTION: boolean;
  54134. REFLECTIONMAP_SKYBOX: boolean;
  54135. REFLECTIONMAP_EXPLICIT: boolean;
  54136. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  54137. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  54138. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  54139. INVERTCUBICMAP: boolean;
  54140. USESPHERICALFROMREFLECTIONMAP: boolean;
  54141. USEIRRADIANCEMAP: boolean;
  54142. SPHERICAL_HARMONICS: boolean;
  54143. USESPHERICALINVERTEX: boolean;
  54144. REFLECTIONMAP_OPPOSITEZ: boolean;
  54145. LODINREFLECTIONALPHA: boolean;
  54146. GAMMAREFLECTION: boolean;
  54147. RGBDREFLECTION: boolean;
  54148. LINEARSPECULARREFLECTION: boolean;
  54149. RADIANCEOCCLUSION: boolean;
  54150. HORIZONOCCLUSION: boolean;
  54151. INSTANCES: boolean;
  54152. NUM_BONE_INFLUENCERS: number;
  54153. BonesPerMesh: number;
  54154. BONETEXTURE: boolean;
  54155. NONUNIFORMSCALING: boolean;
  54156. MORPHTARGETS: boolean;
  54157. MORPHTARGETS_NORMAL: boolean;
  54158. MORPHTARGETS_TANGENT: boolean;
  54159. MORPHTARGETS_UV: boolean;
  54160. NUM_MORPH_INFLUENCERS: number;
  54161. IMAGEPROCESSING: boolean;
  54162. VIGNETTE: boolean;
  54163. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54164. VIGNETTEBLENDMODEOPAQUE: boolean;
  54165. TONEMAPPING: boolean;
  54166. TONEMAPPING_ACES: boolean;
  54167. CONTRAST: boolean;
  54168. COLORCURVES: boolean;
  54169. COLORGRADING: boolean;
  54170. COLORGRADING3D: boolean;
  54171. SAMPLER3DGREENDEPTH: boolean;
  54172. SAMPLER3DBGRMAP: boolean;
  54173. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54174. EXPOSURE: boolean;
  54175. MULTIVIEW: boolean;
  54176. USEPHYSICALLIGHTFALLOFF: boolean;
  54177. USEGLTFLIGHTFALLOFF: boolean;
  54178. TWOSIDEDLIGHTING: boolean;
  54179. SHADOWFLOAT: boolean;
  54180. CLIPPLANE: boolean;
  54181. CLIPPLANE2: boolean;
  54182. CLIPPLANE3: boolean;
  54183. CLIPPLANE4: boolean;
  54184. CLIPPLANE5: boolean;
  54185. CLIPPLANE6: boolean;
  54186. POINTSIZE: boolean;
  54187. FOG: boolean;
  54188. LOGARITHMICDEPTH: boolean;
  54189. FORCENORMALFORWARD: boolean;
  54190. SPECULARAA: boolean;
  54191. CLEARCOAT: boolean;
  54192. CLEARCOAT_DEFAULTIOR: boolean;
  54193. CLEARCOAT_TEXTURE: boolean;
  54194. CLEARCOAT_TEXTUREDIRECTUV: number;
  54195. CLEARCOAT_BUMP: boolean;
  54196. CLEARCOAT_BUMPDIRECTUV: number;
  54197. CLEARCOAT_TINT: boolean;
  54198. CLEARCOAT_TINT_TEXTURE: boolean;
  54199. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54200. ANISOTROPIC: boolean;
  54201. ANISOTROPIC_TEXTURE: boolean;
  54202. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54203. BRDF_V_HEIGHT_CORRELATED: boolean;
  54204. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54205. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54206. SHEEN: boolean;
  54207. SHEEN_TEXTURE: boolean;
  54208. SHEEN_TEXTUREDIRECTUV: number;
  54209. SHEEN_LINKWITHALBEDO: boolean;
  54210. SHEEN_ROUGHNESS: boolean;
  54211. SHEEN_ALBEDOSCALING: boolean;
  54212. SUBSURFACE: boolean;
  54213. SS_REFRACTION: boolean;
  54214. SS_TRANSLUCENCY: boolean;
  54215. SS_SCATERRING: boolean;
  54216. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54217. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54218. SS_REFRACTIONMAP_3D: boolean;
  54219. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54220. SS_LODINREFRACTIONALPHA: boolean;
  54221. SS_GAMMAREFRACTION: boolean;
  54222. SS_RGBDREFRACTION: boolean;
  54223. SS_LINEARSPECULARREFRACTION: boolean;
  54224. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54225. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54226. UNLIT: boolean;
  54227. DEBUGMODE: number;
  54228. /**
  54229. * Initializes the PBR Material defines.
  54230. */
  54231. constructor();
  54232. /**
  54233. * Resets the PBR Material defines.
  54234. */
  54235. reset(): void;
  54236. }
  54237. /**
  54238. * The Physically based material base class of BJS.
  54239. *
  54240. * This offers the main features of a standard PBR material.
  54241. * For more information, please refer to the documentation :
  54242. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54243. */
  54244. export abstract class PBRBaseMaterial extends PushMaterial {
  54245. /**
  54246. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54247. */
  54248. static readonly PBRMATERIAL_OPAQUE: number;
  54249. /**
  54250. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54251. */
  54252. static readonly PBRMATERIAL_ALPHATEST: number;
  54253. /**
  54254. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54255. */
  54256. static readonly PBRMATERIAL_ALPHABLEND: number;
  54257. /**
  54258. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54259. * They are also discarded below the alpha cutoff threshold to improve performances.
  54260. */
  54261. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54262. /**
  54263. * Defines the default value of how much AO map is occluding the analytical lights
  54264. * (point spot...).
  54265. */
  54266. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54267. /**
  54268. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54269. */
  54270. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54271. /**
  54272. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54273. * to enhance interoperability with other engines.
  54274. */
  54275. static readonly LIGHTFALLOFF_GLTF: number;
  54276. /**
  54277. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54278. * to enhance interoperability with other materials.
  54279. */
  54280. static readonly LIGHTFALLOFF_STANDARD: number;
  54281. /**
  54282. * Intensity of the direct lights e.g. the four lights available in your scene.
  54283. * This impacts both the direct diffuse and specular highlights.
  54284. */
  54285. protected _directIntensity: number;
  54286. /**
  54287. * Intensity of the emissive part of the material.
  54288. * This helps controlling the emissive effect without modifying the emissive color.
  54289. */
  54290. protected _emissiveIntensity: number;
  54291. /**
  54292. * Intensity of the environment e.g. how much the environment will light the object
  54293. * either through harmonics for rough material or through the refelction for shiny ones.
  54294. */
  54295. protected _environmentIntensity: number;
  54296. /**
  54297. * This is a special control allowing the reduction of the specular highlights coming from the
  54298. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54299. */
  54300. protected _specularIntensity: number;
  54301. /**
  54302. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  54303. */
  54304. private _lightingInfos;
  54305. /**
  54306. * Debug Control allowing disabling the bump map on this material.
  54307. */
  54308. protected _disableBumpMap: boolean;
  54309. /**
  54310. * AKA Diffuse Texture in standard nomenclature.
  54311. */
  54312. protected _albedoTexture: Nullable<BaseTexture>;
  54313. /**
  54314. * AKA Occlusion Texture in other nomenclature.
  54315. */
  54316. protected _ambientTexture: Nullable<BaseTexture>;
  54317. /**
  54318. * AKA Occlusion Texture Intensity in other nomenclature.
  54319. */
  54320. protected _ambientTextureStrength: number;
  54321. /**
  54322. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54323. * 1 means it completely occludes it
  54324. * 0 mean it has no impact
  54325. */
  54326. protected _ambientTextureImpactOnAnalyticalLights: number;
  54327. /**
  54328. * Stores the alpha values in a texture.
  54329. */
  54330. protected _opacityTexture: Nullable<BaseTexture>;
  54331. /**
  54332. * Stores the reflection values in a texture.
  54333. */
  54334. protected _reflectionTexture: Nullable<BaseTexture>;
  54335. /**
  54336. * Stores the emissive values in a texture.
  54337. */
  54338. protected _emissiveTexture: Nullable<BaseTexture>;
  54339. /**
  54340. * AKA Specular texture in other nomenclature.
  54341. */
  54342. protected _reflectivityTexture: Nullable<BaseTexture>;
  54343. /**
  54344. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54345. */
  54346. protected _metallicTexture: Nullable<BaseTexture>;
  54347. /**
  54348. * Specifies the metallic scalar of the metallic/roughness workflow.
  54349. * Can also be used to scale the metalness values of the metallic texture.
  54350. */
  54351. protected _metallic: Nullable<number>;
  54352. /**
  54353. * Specifies the roughness scalar of the metallic/roughness workflow.
  54354. * Can also be used to scale the roughness values of the metallic texture.
  54355. */
  54356. protected _roughness: Nullable<number>;
  54357. /**
  54358. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  54359. * By default the indexOfrefraction is used to compute F0;
  54360. *
  54361. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  54362. *
  54363. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  54364. * F90 = metallicReflectanceColor;
  54365. */
  54366. protected _metallicF0Factor: number;
  54367. /**
  54368. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  54369. * By default the F90 is always 1;
  54370. *
  54371. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  54372. *
  54373. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  54374. * F90 = metallicReflectanceColor;
  54375. */
  54376. protected _metallicReflectanceColor: Color3;
  54377. /**
  54378. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  54379. * This is multiply against the scalar values defined in the material.
  54380. */
  54381. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  54382. /**
  54383. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54384. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54385. */
  54386. protected _microSurfaceTexture: Nullable<BaseTexture>;
  54387. /**
  54388. * Stores surface normal data used to displace a mesh in a texture.
  54389. */
  54390. protected _bumpTexture: Nullable<BaseTexture>;
  54391. /**
  54392. * Stores the pre-calculated light information of a mesh in a texture.
  54393. */
  54394. protected _lightmapTexture: Nullable<BaseTexture>;
  54395. /**
  54396. * The color of a material in ambient lighting.
  54397. */
  54398. protected _ambientColor: Color3;
  54399. /**
  54400. * AKA Diffuse Color in other nomenclature.
  54401. */
  54402. protected _albedoColor: Color3;
  54403. /**
  54404. * AKA Specular Color in other nomenclature.
  54405. */
  54406. protected _reflectivityColor: Color3;
  54407. /**
  54408. * The color applied when light is reflected from a material.
  54409. */
  54410. protected _reflectionColor: Color3;
  54411. /**
  54412. * The color applied when light is emitted from a material.
  54413. */
  54414. protected _emissiveColor: Color3;
  54415. /**
  54416. * AKA Glossiness in other nomenclature.
  54417. */
  54418. protected _microSurface: number;
  54419. /**
  54420. * Specifies that the material will use the light map as a show map.
  54421. */
  54422. protected _useLightmapAsShadowmap: boolean;
  54423. /**
  54424. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54425. * makes the reflect vector face the model (under horizon).
  54426. */
  54427. protected _useHorizonOcclusion: boolean;
  54428. /**
  54429. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54430. * too much the area relying on ambient texture to define their ambient occlusion.
  54431. */
  54432. protected _useRadianceOcclusion: boolean;
  54433. /**
  54434. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54435. */
  54436. protected _useAlphaFromAlbedoTexture: boolean;
  54437. /**
  54438. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  54439. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54440. */
  54441. protected _useSpecularOverAlpha: boolean;
  54442. /**
  54443. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54444. */
  54445. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54446. /**
  54447. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54448. */
  54449. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  54450. /**
  54451. * Specifies if the metallic texture contains the roughness information in its green channel.
  54452. */
  54453. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54454. /**
  54455. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54456. */
  54457. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54458. /**
  54459. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54460. */
  54461. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54462. /**
  54463. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54464. */
  54465. protected _useAmbientInGrayScale: boolean;
  54466. /**
  54467. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54468. * The material will try to infer what glossiness each pixel should be.
  54469. */
  54470. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54471. /**
  54472. * Defines the falloff type used in this material.
  54473. * It by default is Physical.
  54474. */
  54475. protected _lightFalloff: number;
  54476. /**
  54477. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54478. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54479. */
  54480. protected _useRadianceOverAlpha: boolean;
  54481. /**
  54482. * Allows using an object space normal map (instead of tangent space).
  54483. */
  54484. protected _useObjectSpaceNormalMap: boolean;
  54485. /**
  54486. * Allows using the bump map in parallax mode.
  54487. */
  54488. protected _useParallax: boolean;
  54489. /**
  54490. * Allows using the bump map in parallax occlusion mode.
  54491. */
  54492. protected _useParallaxOcclusion: boolean;
  54493. /**
  54494. * Controls the scale bias of the parallax mode.
  54495. */
  54496. protected _parallaxScaleBias: number;
  54497. /**
  54498. * If sets to true, disables all the lights affecting the material.
  54499. */
  54500. protected _disableLighting: boolean;
  54501. /**
  54502. * Number of Simultaneous lights allowed on the material.
  54503. */
  54504. protected _maxSimultaneousLights: number;
  54505. /**
  54506. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54507. */
  54508. protected _invertNormalMapX: boolean;
  54509. /**
  54510. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54511. */
  54512. protected _invertNormalMapY: boolean;
  54513. /**
  54514. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54515. */
  54516. protected _twoSidedLighting: boolean;
  54517. /**
  54518. * Defines the alpha limits in alpha test mode.
  54519. */
  54520. protected _alphaCutOff: number;
  54521. /**
  54522. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54523. */
  54524. protected _forceAlphaTest: boolean;
  54525. /**
  54526. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54527. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54528. */
  54529. protected _useAlphaFresnel: boolean;
  54530. /**
  54531. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54532. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54533. */
  54534. protected _useLinearAlphaFresnel: boolean;
  54535. /**
  54536. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54537. * from cos thetav and roughness:
  54538. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54539. */
  54540. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54541. /**
  54542. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54543. */
  54544. protected _forceIrradianceInFragment: boolean;
  54545. /**
  54546. * Force normal to face away from face.
  54547. */
  54548. protected _forceNormalForward: boolean;
  54549. /**
  54550. * Enables specular anti aliasing in the PBR shader.
  54551. * It will both interacts on the Geometry for analytical and IBL lighting.
  54552. * It also prefilter the roughness map based on the bump values.
  54553. */
  54554. protected _enableSpecularAntiAliasing: boolean;
  54555. /**
  54556. * Default configuration related to image processing available in the PBR Material.
  54557. */
  54558. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54559. /**
  54560. * Keep track of the image processing observer to allow dispose and replace.
  54561. */
  54562. private _imageProcessingObserver;
  54563. /**
  54564. * Attaches a new image processing configuration to the PBR Material.
  54565. * @param configuration
  54566. */
  54567. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54568. /**
  54569. * Stores the available render targets.
  54570. */
  54571. private _renderTargets;
  54572. /**
  54573. * Sets the global ambient color for the material used in lighting calculations.
  54574. */
  54575. private _globalAmbientColor;
  54576. /**
  54577. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  54578. */
  54579. private _useLogarithmicDepth;
  54580. /**
  54581. * If set to true, no lighting calculations will be applied.
  54582. */
  54583. private _unlit;
  54584. private _debugMode;
  54585. /**
  54586. * @hidden
  54587. * This is reserved for the inspector.
  54588. * Defines the material debug mode.
  54589. * It helps seeing only some components of the material while troubleshooting.
  54590. */
  54591. debugMode: number;
  54592. /**
  54593. * @hidden
  54594. * This is reserved for the inspector.
  54595. * Specify from where on screen the debug mode should start.
  54596. * The value goes from -1 (full screen) to 1 (not visible)
  54597. * It helps with side by side comparison against the final render
  54598. * This defaults to -1
  54599. */
  54600. private debugLimit;
  54601. /**
  54602. * @hidden
  54603. * This is reserved for the inspector.
  54604. * As the default viewing range might not be enough (if the ambient is really small for instance)
  54605. * You can use the factor to better multiply the final value.
  54606. */
  54607. private debugFactor;
  54608. /**
  54609. * Defines the clear coat layer parameters for the material.
  54610. */
  54611. readonly clearCoat: PBRClearCoatConfiguration;
  54612. /**
  54613. * Defines the anisotropic parameters for the material.
  54614. */
  54615. readonly anisotropy: PBRAnisotropicConfiguration;
  54616. /**
  54617. * Defines the BRDF parameters for the material.
  54618. */
  54619. readonly brdf: PBRBRDFConfiguration;
  54620. /**
  54621. * Defines the Sheen parameters for the material.
  54622. */
  54623. readonly sheen: PBRSheenConfiguration;
  54624. /**
  54625. * Defines the SubSurface parameters for the material.
  54626. */
  54627. readonly subSurface: PBRSubSurfaceConfiguration;
  54628. protected _rebuildInParallel: boolean;
  54629. /**
  54630. * Instantiates a new PBRMaterial instance.
  54631. *
  54632. * @param name The material name
  54633. * @param scene The scene the material will be use in.
  54634. */
  54635. constructor(name: string, scene: Scene);
  54636. /**
  54637. * Gets a boolean indicating that current material needs to register RTT
  54638. */
  54639. get hasRenderTargetTextures(): boolean;
  54640. /**
  54641. * Gets the name of the material class.
  54642. */
  54643. getClassName(): string;
  54644. /**
  54645. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54646. */
  54647. get useLogarithmicDepth(): boolean;
  54648. /**
  54649. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54650. */
  54651. set useLogarithmicDepth(value: boolean);
  54652. /**
  54653. * Returns true if alpha blending should be disabled.
  54654. */
  54655. protected get _disableAlphaBlending(): boolean;
  54656. /**
  54657. * Specifies whether or not this material should be rendered in alpha blend mode.
  54658. */
  54659. needAlphaBlending(): boolean;
  54660. /**
  54661. * Specifies whether or not this material should be rendered in alpha test mode.
  54662. */
  54663. needAlphaTesting(): boolean;
  54664. /**
  54665. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  54666. */
  54667. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  54668. /**
  54669. * Gets the texture used for the alpha test.
  54670. */
  54671. getAlphaTestTexture(): Nullable<BaseTexture>;
  54672. /**
  54673. * Specifies that the submesh is ready to be used.
  54674. * @param mesh - BJS mesh.
  54675. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  54676. * @param useInstances - Specifies that instances should be used.
  54677. * @returns - boolean indicating that the submesh is ready or not.
  54678. */
  54679. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54680. /**
  54681. * Specifies if the material uses metallic roughness workflow.
  54682. * @returns boolean specifiying if the material uses metallic roughness workflow.
  54683. */
  54684. isMetallicWorkflow(): boolean;
  54685. private _prepareEffect;
  54686. private _prepareDefines;
  54687. /**
  54688. * Force shader compilation
  54689. */
  54690. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  54691. /**
  54692. * Initializes the uniform buffer layout for the shader.
  54693. */
  54694. buildUniformLayout(): void;
  54695. /**
  54696. * Unbinds the material from the mesh
  54697. */
  54698. unbind(): void;
  54699. /**
  54700. * Binds the submesh data.
  54701. * @param world - The world matrix.
  54702. * @param mesh - The BJS mesh.
  54703. * @param subMesh - A submesh of the BJS mesh.
  54704. */
  54705. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54706. /**
  54707. * Returns the animatable textures.
  54708. * @returns - Array of animatable textures.
  54709. */
  54710. getAnimatables(): IAnimatable[];
  54711. /**
  54712. * Returns the texture used for reflections.
  54713. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  54714. */
  54715. private _getReflectionTexture;
  54716. /**
  54717. * Returns an array of the actively used textures.
  54718. * @returns - Array of BaseTextures
  54719. */
  54720. getActiveTextures(): BaseTexture[];
  54721. /**
  54722. * Checks to see if a texture is used in the material.
  54723. * @param texture - Base texture to use.
  54724. * @returns - Boolean specifying if a texture is used in the material.
  54725. */
  54726. hasTexture(texture: BaseTexture): boolean;
  54727. /**
  54728. * Disposes the resources of the material.
  54729. * @param forceDisposeEffect - Forces the disposal of effects.
  54730. * @param forceDisposeTextures - Forces the disposal of all textures.
  54731. */
  54732. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54733. }
  54734. }
  54735. declare module BABYLON {
  54736. /**
  54737. * The Physically based material of BJS.
  54738. *
  54739. * This offers the main features of a standard PBR material.
  54740. * For more information, please refer to the documentation :
  54741. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54742. */
  54743. export class PBRMaterial extends PBRBaseMaterial {
  54744. /**
  54745. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54746. */
  54747. static readonly PBRMATERIAL_OPAQUE: number;
  54748. /**
  54749. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54750. */
  54751. static readonly PBRMATERIAL_ALPHATEST: number;
  54752. /**
  54753. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54754. */
  54755. static readonly PBRMATERIAL_ALPHABLEND: number;
  54756. /**
  54757. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54758. * They are also discarded below the alpha cutoff threshold to improve performances.
  54759. */
  54760. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54761. /**
  54762. * Defines the default value of how much AO map is occluding the analytical lights
  54763. * (point spot...).
  54764. */
  54765. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54766. /**
  54767. * Intensity of the direct lights e.g. the four lights available in your scene.
  54768. * This impacts both the direct diffuse and specular highlights.
  54769. */
  54770. directIntensity: number;
  54771. /**
  54772. * Intensity of the emissive part of the material.
  54773. * This helps controlling the emissive effect without modifying the emissive color.
  54774. */
  54775. emissiveIntensity: number;
  54776. /**
  54777. * Intensity of the environment e.g. how much the environment will light the object
  54778. * either through harmonics for rough material or through the refelction for shiny ones.
  54779. */
  54780. environmentIntensity: number;
  54781. /**
  54782. * This is a special control allowing the reduction of the specular highlights coming from the
  54783. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54784. */
  54785. specularIntensity: number;
  54786. /**
  54787. * Debug Control allowing disabling the bump map on this material.
  54788. */
  54789. disableBumpMap: boolean;
  54790. /**
  54791. * AKA Diffuse Texture in standard nomenclature.
  54792. */
  54793. albedoTexture: BaseTexture;
  54794. /**
  54795. * AKA Occlusion Texture in other nomenclature.
  54796. */
  54797. ambientTexture: BaseTexture;
  54798. /**
  54799. * AKA Occlusion Texture Intensity in other nomenclature.
  54800. */
  54801. ambientTextureStrength: number;
  54802. /**
  54803. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54804. * 1 means it completely occludes it
  54805. * 0 mean it has no impact
  54806. */
  54807. ambientTextureImpactOnAnalyticalLights: number;
  54808. /**
  54809. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  54810. */
  54811. opacityTexture: BaseTexture;
  54812. /**
  54813. * Stores the reflection values in a texture.
  54814. */
  54815. reflectionTexture: Nullable<BaseTexture>;
  54816. /**
  54817. * Stores the emissive values in a texture.
  54818. */
  54819. emissiveTexture: BaseTexture;
  54820. /**
  54821. * AKA Specular texture in other nomenclature.
  54822. */
  54823. reflectivityTexture: BaseTexture;
  54824. /**
  54825. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54826. */
  54827. metallicTexture: BaseTexture;
  54828. /**
  54829. * Specifies the metallic scalar of the metallic/roughness workflow.
  54830. * Can also be used to scale the metalness values of the metallic texture.
  54831. */
  54832. metallic: Nullable<number>;
  54833. /**
  54834. * Specifies the roughness scalar of the metallic/roughness workflow.
  54835. * Can also be used to scale the roughness values of the metallic texture.
  54836. */
  54837. roughness: Nullable<number>;
  54838. /**
  54839. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  54840. * By default the indexOfrefraction is used to compute F0;
  54841. *
  54842. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  54843. *
  54844. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  54845. * F90 = metallicReflectanceColor;
  54846. */
  54847. metallicF0Factor: number;
  54848. /**
  54849. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  54850. * By default the F90 is always 1;
  54851. *
  54852. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  54853. *
  54854. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  54855. * F90 = metallicReflectanceColor;
  54856. */
  54857. metallicReflectanceColor: Color3;
  54858. /**
  54859. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  54860. * This is multiply against the scalar values defined in the material.
  54861. */
  54862. metallicReflectanceTexture: Nullable<BaseTexture>;
  54863. /**
  54864. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54865. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54866. */
  54867. microSurfaceTexture: BaseTexture;
  54868. /**
  54869. * Stores surface normal data used to displace a mesh in a texture.
  54870. */
  54871. bumpTexture: BaseTexture;
  54872. /**
  54873. * Stores the pre-calculated light information of a mesh in a texture.
  54874. */
  54875. lightmapTexture: BaseTexture;
  54876. /**
  54877. * Stores the refracted light information in a texture.
  54878. */
  54879. get refractionTexture(): Nullable<BaseTexture>;
  54880. set refractionTexture(value: Nullable<BaseTexture>);
  54881. /**
  54882. * The color of a material in ambient lighting.
  54883. */
  54884. ambientColor: Color3;
  54885. /**
  54886. * AKA Diffuse Color in other nomenclature.
  54887. */
  54888. albedoColor: Color3;
  54889. /**
  54890. * AKA Specular Color in other nomenclature.
  54891. */
  54892. reflectivityColor: Color3;
  54893. /**
  54894. * The color reflected from the material.
  54895. */
  54896. reflectionColor: Color3;
  54897. /**
  54898. * The color emitted from the material.
  54899. */
  54900. emissiveColor: Color3;
  54901. /**
  54902. * AKA Glossiness in other nomenclature.
  54903. */
  54904. microSurface: number;
  54905. /**
  54906. * Index of refraction of the material base layer.
  54907. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54908. *
  54909. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54910. *
  54911. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54912. */
  54913. get indexOfRefraction(): number;
  54914. set indexOfRefraction(value: number);
  54915. /**
  54916. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54917. */
  54918. get invertRefractionY(): boolean;
  54919. set invertRefractionY(value: boolean);
  54920. /**
  54921. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54922. * Materials half opaque for instance using refraction could benefit from this control.
  54923. */
  54924. get linkRefractionWithTransparency(): boolean;
  54925. set linkRefractionWithTransparency(value: boolean);
  54926. /**
  54927. * If true, the light map contains occlusion information instead of lighting info.
  54928. */
  54929. useLightmapAsShadowmap: boolean;
  54930. /**
  54931. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54932. */
  54933. useAlphaFromAlbedoTexture: boolean;
  54934. /**
  54935. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54936. */
  54937. forceAlphaTest: boolean;
  54938. /**
  54939. * Defines the alpha limits in alpha test mode.
  54940. */
  54941. alphaCutOff: number;
  54942. /**
  54943. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54944. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54945. */
  54946. useSpecularOverAlpha: boolean;
  54947. /**
  54948. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54949. */
  54950. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54951. /**
  54952. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54953. */
  54954. useRoughnessFromMetallicTextureAlpha: boolean;
  54955. /**
  54956. * Specifies if the metallic texture contains the roughness information in its green channel.
  54957. */
  54958. useRoughnessFromMetallicTextureGreen: boolean;
  54959. /**
  54960. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54961. */
  54962. useMetallnessFromMetallicTextureBlue: boolean;
  54963. /**
  54964. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54965. */
  54966. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54967. /**
  54968. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54969. */
  54970. useAmbientInGrayScale: boolean;
  54971. /**
  54972. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54973. * The material will try to infer what glossiness each pixel should be.
  54974. */
  54975. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54976. /**
  54977. * BJS is using an harcoded light falloff based on a manually sets up range.
  54978. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54979. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54980. */
  54981. get usePhysicalLightFalloff(): boolean;
  54982. /**
  54983. * BJS is using an harcoded light falloff based on a manually sets up range.
  54984. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54985. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54986. */
  54987. set usePhysicalLightFalloff(value: boolean);
  54988. /**
  54989. * In order to support the falloff compatibility with gltf, a special mode has been added
  54990. * to reproduce the gltf light falloff.
  54991. */
  54992. get useGLTFLightFalloff(): boolean;
  54993. /**
  54994. * In order to support the falloff compatibility with gltf, a special mode has been added
  54995. * to reproduce the gltf light falloff.
  54996. */
  54997. set useGLTFLightFalloff(value: boolean);
  54998. /**
  54999. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55000. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55001. */
  55002. useRadianceOverAlpha: boolean;
  55003. /**
  55004. * Allows using an object space normal map (instead of tangent space).
  55005. */
  55006. useObjectSpaceNormalMap: boolean;
  55007. /**
  55008. * Allows using the bump map in parallax mode.
  55009. */
  55010. useParallax: boolean;
  55011. /**
  55012. * Allows using the bump map in parallax occlusion mode.
  55013. */
  55014. useParallaxOcclusion: boolean;
  55015. /**
  55016. * Controls the scale bias of the parallax mode.
  55017. */
  55018. parallaxScaleBias: number;
  55019. /**
  55020. * If sets to true, disables all the lights affecting the material.
  55021. */
  55022. disableLighting: boolean;
  55023. /**
  55024. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55025. */
  55026. forceIrradianceInFragment: boolean;
  55027. /**
  55028. * Number of Simultaneous lights allowed on the material.
  55029. */
  55030. maxSimultaneousLights: number;
  55031. /**
  55032. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55033. */
  55034. invertNormalMapX: boolean;
  55035. /**
  55036. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55037. */
  55038. invertNormalMapY: boolean;
  55039. /**
  55040. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55041. */
  55042. twoSidedLighting: boolean;
  55043. /**
  55044. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55045. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55046. */
  55047. useAlphaFresnel: boolean;
  55048. /**
  55049. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55050. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55051. */
  55052. useLinearAlphaFresnel: boolean;
  55053. /**
  55054. * Let user defines the brdf lookup texture used for IBL.
  55055. * A default 8bit version is embedded but you could point at :
  55056. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55057. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55058. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55059. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55060. */
  55061. environmentBRDFTexture: Nullable<BaseTexture>;
  55062. /**
  55063. * Force normal to face away from face.
  55064. */
  55065. forceNormalForward: boolean;
  55066. /**
  55067. * Enables specular anti aliasing in the PBR shader.
  55068. * It will both interacts on the Geometry for analytical and IBL lighting.
  55069. * It also prefilter the roughness map based on the bump values.
  55070. */
  55071. enableSpecularAntiAliasing: boolean;
  55072. /**
  55073. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55074. * makes the reflect vector face the model (under horizon).
  55075. */
  55076. useHorizonOcclusion: boolean;
  55077. /**
  55078. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55079. * too much the area relying on ambient texture to define their ambient occlusion.
  55080. */
  55081. useRadianceOcclusion: boolean;
  55082. /**
  55083. * If set to true, no lighting calculations will be applied.
  55084. */
  55085. unlit: boolean;
  55086. /**
  55087. * Gets the image processing configuration used either in this material.
  55088. */
  55089. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55090. /**
  55091. * Sets the Default image processing configuration used either in the this material.
  55092. *
  55093. * If sets to null, the scene one is in use.
  55094. */
  55095. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55096. /**
  55097. * Gets wether the color curves effect is enabled.
  55098. */
  55099. get cameraColorCurvesEnabled(): boolean;
  55100. /**
  55101. * Sets wether the color curves effect is enabled.
  55102. */
  55103. set cameraColorCurvesEnabled(value: boolean);
  55104. /**
  55105. * Gets wether the color grading effect is enabled.
  55106. */
  55107. get cameraColorGradingEnabled(): boolean;
  55108. /**
  55109. * Gets wether the color grading effect is enabled.
  55110. */
  55111. set cameraColorGradingEnabled(value: boolean);
  55112. /**
  55113. * Gets wether tonemapping is enabled or not.
  55114. */
  55115. get cameraToneMappingEnabled(): boolean;
  55116. /**
  55117. * Sets wether tonemapping is enabled or not
  55118. */
  55119. set cameraToneMappingEnabled(value: boolean);
  55120. /**
  55121. * The camera exposure used on this material.
  55122. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55123. * This corresponds to a photographic exposure.
  55124. */
  55125. get cameraExposure(): number;
  55126. /**
  55127. * The camera exposure used on this material.
  55128. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55129. * This corresponds to a photographic exposure.
  55130. */
  55131. set cameraExposure(value: number);
  55132. /**
  55133. * Gets The camera contrast used on this material.
  55134. */
  55135. get cameraContrast(): number;
  55136. /**
  55137. * Sets The camera contrast used on this material.
  55138. */
  55139. set cameraContrast(value: number);
  55140. /**
  55141. * Gets the Color Grading 2D Lookup Texture.
  55142. */
  55143. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55144. /**
  55145. * Sets the Color Grading 2D Lookup Texture.
  55146. */
  55147. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55148. /**
  55149. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55150. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55151. * 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;
  55152. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55153. */
  55154. get cameraColorCurves(): Nullable<ColorCurves>;
  55155. /**
  55156. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55157. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55158. * 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;
  55159. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55160. */
  55161. set cameraColorCurves(value: Nullable<ColorCurves>);
  55162. /**
  55163. * Instantiates a new PBRMaterial instance.
  55164. *
  55165. * @param name The material name
  55166. * @param scene The scene the material will be use in.
  55167. */
  55168. constructor(name: string, scene: Scene);
  55169. /**
  55170. * Returns the name of this material class.
  55171. */
  55172. getClassName(): string;
  55173. /**
  55174. * Makes a duplicate of the current material.
  55175. * @param name - name to use for the new material.
  55176. */
  55177. clone(name: string): PBRMaterial;
  55178. /**
  55179. * Serializes this PBR Material.
  55180. * @returns - An object with the serialized material.
  55181. */
  55182. serialize(): any;
  55183. /**
  55184. * Parses a PBR Material from a serialized object.
  55185. * @param source - Serialized object.
  55186. * @param scene - BJS scene instance.
  55187. * @param rootUrl - url for the scene object
  55188. * @returns - PBRMaterial
  55189. */
  55190. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55191. }
  55192. }
  55193. declare module BABYLON {
  55194. /**
  55195. * Direct draw surface info
  55196. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55197. */
  55198. export interface DDSInfo {
  55199. /**
  55200. * Width of the texture
  55201. */
  55202. width: number;
  55203. /**
  55204. * Width of the texture
  55205. */
  55206. height: number;
  55207. /**
  55208. * Number of Mipmaps for the texture
  55209. * @see https://en.wikipedia.org/wiki/Mipmap
  55210. */
  55211. mipmapCount: number;
  55212. /**
  55213. * If the textures format is a known fourCC format
  55214. * @see https://www.fourcc.org/
  55215. */
  55216. isFourCC: boolean;
  55217. /**
  55218. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55219. */
  55220. isRGB: boolean;
  55221. /**
  55222. * If the texture is a lumincance format
  55223. */
  55224. isLuminance: boolean;
  55225. /**
  55226. * If this is a cube texture
  55227. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55228. */
  55229. isCube: boolean;
  55230. /**
  55231. * If the texture is a compressed format eg. FOURCC_DXT1
  55232. */
  55233. isCompressed: boolean;
  55234. /**
  55235. * The dxgiFormat of the texture
  55236. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55237. */
  55238. dxgiFormat: number;
  55239. /**
  55240. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55241. */
  55242. textureType: number;
  55243. /**
  55244. * Sphericle polynomial created for the dds texture
  55245. */
  55246. sphericalPolynomial?: SphericalPolynomial;
  55247. }
  55248. /**
  55249. * Class used to provide DDS decompression tools
  55250. */
  55251. export class DDSTools {
  55252. /**
  55253. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55254. */
  55255. static StoreLODInAlphaChannel: boolean;
  55256. /**
  55257. * Gets DDS information from an array buffer
  55258. * @param data defines the array buffer view to read data from
  55259. * @returns the DDS information
  55260. */
  55261. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55262. private static _FloatView;
  55263. private static _Int32View;
  55264. private static _ToHalfFloat;
  55265. private static _FromHalfFloat;
  55266. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55267. private static _GetHalfFloatRGBAArrayBuffer;
  55268. private static _GetFloatRGBAArrayBuffer;
  55269. private static _GetFloatAsUIntRGBAArrayBuffer;
  55270. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55271. private static _GetRGBAArrayBuffer;
  55272. private static _ExtractLongWordOrder;
  55273. private static _GetRGBArrayBuffer;
  55274. private static _GetLuminanceArrayBuffer;
  55275. /**
  55276. * Uploads DDS Levels to a Babylon Texture
  55277. * @hidden
  55278. */
  55279. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55280. }
  55281. interface ThinEngine {
  55282. /**
  55283. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  55284. * @param rootUrl defines the url where the file to load is located
  55285. * @param scene defines the current scene
  55286. * @param lodScale defines scale to apply to the mip map selection
  55287. * @param lodOffset defines offset to apply to the mip map selection
  55288. * @param onLoad defines an optional callback raised when the texture is loaded
  55289. * @param onError defines an optional callback raised if there is an issue to load the texture
  55290. * @param format defines the format of the data
  55291. * @param forcedExtension defines the extension to use to pick the right loader
  55292. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  55293. * @returns the cube texture as an InternalTexture
  55294. */
  55295. 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;
  55296. }
  55297. }
  55298. declare module BABYLON {
  55299. /**
  55300. * Implementation of the DDS Texture Loader.
  55301. * @hidden
  55302. */
  55303. export class _DDSTextureLoader implements IInternalTextureLoader {
  55304. /**
  55305. * Defines wether the loader supports cascade loading the different faces.
  55306. */
  55307. readonly supportCascades: boolean;
  55308. /**
  55309. * This returns if the loader support the current file information.
  55310. * @param extension defines the file extension of the file being loaded
  55311. * @returns true if the loader can load the specified file
  55312. */
  55313. canLoad(extension: string): boolean;
  55314. /**
  55315. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55316. * @param data contains the texture data
  55317. * @param texture defines the BabylonJS internal texture
  55318. * @param createPolynomials will be true if polynomials have been requested
  55319. * @param onLoad defines the callback to trigger once the texture is ready
  55320. * @param onError defines the callback to trigger in case of error
  55321. */
  55322. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55323. /**
  55324. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55325. * @param data contains the texture data
  55326. * @param texture defines the BabylonJS internal texture
  55327. * @param callback defines the method to call once ready to upload
  55328. */
  55329. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55330. }
  55331. }
  55332. declare module BABYLON {
  55333. /**
  55334. * Implementation of the ENV Texture Loader.
  55335. * @hidden
  55336. */
  55337. export class _ENVTextureLoader implements IInternalTextureLoader {
  55338. /**
  55339. * Defines wether the loader supports cascade loading the different faces.
  55340. */
  55341. readonly supportCascades: boolean;
  55342. /**
  55343. * This returns if the loader support the current file information.
  55344. * @param extension defines the file extension of the file being loaded
  55345. * @returns true if the loader can load the specified file
  55346. */
  55347. canLoad(extension: string): boolean;
  55348. /**
  55349. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55350. * @param data contains the texture data
  55351. * @param texture defines the BabylonJS internal texture
  55352. * @param createPolynomials will be true if polynomials have been requested
  55353. * @param onLoad defines the callback to trigger once the texture is ready
  55354. * @param onError defines the callback to trigger in case of error
  55355. */
  55356. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55357. /**
  55358. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55359. * @param data contains the texture data
  55360. * @param texture defines the BabylonJS internal texture
  55361. * @param callback defines the method to call once ready to upload
  55362. */
  55363. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55364. }
  55365. }
  55366. declare module BABYLON {
  55367. /**
  55368. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55369. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55370. */
  55371. export class KhronosTextureContainer {
  55372. /** contents of the KTX container file */
  55373. data: ArrayBufferView;
  55374. private static HEADER_LEN;
  55375. private static COMPRESSED_2D;
  55376. private static COMPRESSED_3D;
  55377. private static TEX_2D;
  55378. private static TEX_3D;
  55379. /**
  55380. * Gets the openGL type
  55381. */
  55382. glType: number;
  55383. /**
  55384. * Gets the openGL type size
  55385. */
  55386. glTypeSize: number;
  55387. /**
  55388. * Gets the openGL format
  55389. */
  55390. glFormat: number;
  55391. /**
  55392. * Gets the openGL internal format
  55393. */
  55394. glInternalFormat: number;
  55395. /**
  55396. * Gets the base internal format
  55397. */
  55398. glBaseInternalFormat: number;
  55399. /**
  55400. * Gets image width in pixel
  55401. */
  55402. pixelWidth: number;
  55403. /**
  55404. * Gets image height in pixel
  55405. */
  55406. pixelHeight: number;
  55407. /**
  55408. * Gets image depth in pixels
  55409. */
  55410. pixelDepth: number;
  55411. /**
  55412. * Gets the number of array elements
  55413. */
  55414. numberOfArrayElements: number;
  55415. /**
  55416. * Gets the number of faces
  55417. */
  55418. numberOfFaces: number;
  55419. /**
  55420. * Gets the number of mipmap levels
  55421. */
  55422. numberOfMipmapLevels: number;
  55423. /**
  55424. * Gets the bytes of key value data
  55425. */
  55426. bytesOfKeyValueData: number;
  55427. /**
  55428. * Gets the load type
  55429. */
  55430. loadType: number;
  55431. /**
  55432. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  55433. */
  55434. isInvalid: boolean;
  55435. /**
  55436. * Creates a new KhronosTextureContainer
  55437. * @param data contents of the KTX container file
  55438. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  55439. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  55440. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  55441. */
  55442. constructor(
  55443. /** contents of the KTX container file */
  55444. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55445. /**
  55446. * Uploads KTX content to a Babylon Texture.
  55447. * It is assumed that the texture has already been created & is currently bound
  55448. * @hidden
  55449. */
  55450. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55451. private _upload2DCompressedLevels;
  55452. /**
  55453. * Checks if the given data starts with a KTX file identifier.
  55454. * @param data the data to check
  55455. * @returns true if the data is a KTX file or false otherwise
  55456. */
  55457. static IsValid(data: ArrayBufferView): boolean;
  55458. }
  55459. }
  55460. declare module BABYLON {
  55461. /**
  55462. * Class for loading KTX2 files
  55463. * !!! Experimental Extension Subject to Changes !!!
  55464. * @hidden
  55465. */
  55466. export class KhronosTextureContainer2 {
  55467. private static _ModulePromise;
  55468. private static _TranscodeFormat;
  55469. constructor(engine: ThinEngine);
  55470. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55471. private _determineTranscodeFormat;
  55472. /**
  55473. * Checks if the given data starts with a KTX2 file identifier.
  55474. * @param data the data to check
  55475. * @returns true if the data is a KTX2 file or false otherwise
  55476. */
  55477. static IsValid(data: ArrayBufferView): boolean;
  55478. }
  55479. }
  55480. declare module BABYLON {
  55481. /**
  55482. * Implementation of the KTX Texture Loader.
  55483. * @hidden
  55484. */
  55485. export class _KTXTextureLoader implements IInternalTextureLoader {
  55486. /**
  55487. * Defines wether the loader supports cascade loading the different faces.
  55488. */
  55489. readonly supportCascades: boolean;
  55490. /**
  55491. * This returns if the loader support the current file information.
  55492. * @param extension defines the file extension of the file being loaded
  55493. * @returns true if the loader can load the specified file
  55494. */
  55495. canLoad(extension: string): boolean;
  55496. /**
  55497. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55498. * @param data contains the texture data
  55499. * @param texture defines the BabylonJS internal texture
  55500. * @param createPolynomials will be true if polynomials have been requested
  55501. * @param onLoad defines the callback to trigger once the texture is ready
  55502. * @param onError defines the callback to trigger in case of error
  55503. */
  55504. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55505. /**
  55506. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55507. * @param data contains the texture data
  55508. * @param texture defines the BabylonJS internal texture
  55509. * @param callback defines the method to call once ready to upload
  55510. */
  55511. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55512. }
  55513. }
  55514. declare module BABYLON {
  55515. /** @hidden */
  55516. export var _forceSceneHelpersToBundle: boolean;
  55517. interface Scene {
  55518. /**
  55519. * Creates a default light for the scene.
  55520. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55521. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55522. */
  55523. createDefaultLight(replace?: boolean): void;
  55524. /**
  55525. * Creates a default camera for the scene.
  55526. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55527. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55528. * @param replace has default false, when true replaces the active camera in the scene
  55529. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55530. */
  55531. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55532. /**
  55533. * Creates a default camera and a default light.
  55534. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55535. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55536. * @param replace has the default false, when true replaces the active camera/light in the scene
  55537. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55538. */
  55539. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55540. /**
  55541. * Creates a new sky box
  55542. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55543. * @param environmentTexture defines the texture to use as environment texture
  55544. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55545. * @param scale defines the overall scale of the skybox
  55546. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55547. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55548. * @returns a new mesh holding the sky box
  55549. */
  55550. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55551. /**
  55552. * Creates a new environment
  55553. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55554. * @param options defines the options you can use to configure the environment
  55555. * @returns the new EnvironmentHelper
  55556. */
  55557. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55558. /**
  55559. * Creates a new VREXperienceHelper
  55560. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55561. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55562. * @returns a new VREXperienceHelper
  55563. */
  55564. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55565. /**
  55566. * Creates a new WebXRDefaultExperience
  55567. * @see http://doc.babylonjs.com/how_to/webxr
  55568. * @param options experience options
  55569. * @returns a promise for a new WebXRDefaultExperience
  55570. */
  55571. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55572. }
  55573. }
  55574. declare module BABYLON {
  55575. /**
  55576. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  55577. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  55578. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  55579. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55580. */
  55581. export class VideoDome extends TransformNode {
  55582. /**
  55583. * Define the video source as a Monoscopic panoramic 360 video.
  55584. */
  55585. static readonly MODE_MONOSCOPIC: number;
  55586. /**
  55587. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55588. */
  55589. static readonly MODE_TOPBOTTOM: number;
  55590. /**
  55591. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55592. */
  55593. static readonly MODE_SIDEBYSIDE: number;
  55594. private _halfDome;
  55595. private _useDirectMapping;
  55596. /**
  55597. * The video texture being displayed on the sphere
  55598. */
  55599. protected _videoTexture: VideoTexture;
  55600. /**
  55601. * Gets the video texture being displayed on the sphere
  55602. */
  55603. get videoTexture(): VideoTexture;
  55604. /**
  55605. * The skybox material
  55606. */
  55607. protected _material: BackgroundMaterial;
  55608. /**
  55609. * The surface used for the skybox
  55610. */
  55611. protected _mesh: Mesh;
  55612. /**
  55613. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  55614. */
  55615. private _halfDomeMask;
  55616. /**
  55617. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55618. * Also see the options.resolution property.
  55619. */
  55620. get fovMultiplier(): number;
  55621. set fovMultiplier(value: number);
  55622. private _videoMode;
  55623. /**
  55624. * Gets or set the current video mode for the video. It can be:
  55625. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  55626. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55627. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55628. */
  55629. get videoMode(): number;
  55630. set videoMode(value: number);
  55631. /**
  55632. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  55633. *
  55634. */
  55635. get halfDome(): boolean;
  55636. /**
  55637. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55638. */
  55639. set halfDome(enabled: boolean);
  55640. /**
  55641. * Oberserver used in Stereoscopic VR Mode.
  55642. */
  55643. private _onBeforeCameraRenderObserver;
  55644. /**
  55645. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  55646. * @param name Element's name, child elements will append suffixes for their own names.
  55647. * @param urlsOrVideo defines the url(s) or the video element to use
  55648. * @param options An object containing optional or exposed sub element properties
  55649. */
  55650. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  55651. resolution?: number;
  55652. clickToPlay?: boolean;
  55653. autoPlay?: boolean;
  55654. loop?: boolean;
  55655. size?: number;
  55656. poster?: string;
  55657. faceForward?: boolean;
  55658. useDirectMapping?: boolean;
  55659. halfDomeMode?: boolean;
  55660. }, scene: Scene);
  55661. private _changeVideoMode;
  55662. /**
  55663. * Releases resources associated with this node.
  55664. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55665. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55666. */
  55667. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55668. }
  55669. }
  55670. declare module BABYLON {
  55671. /**
  55672. * This class can be used to get instrumentation data from a Babylon engine
  55673. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55674. */
  55675. export class EngineInstrumentation implements IDisposable {
  55676. /**
  55677. * Define the instrumented engine.
  55678. */
  55679. engine: Engine;
  55680. private _captureGPUFrameTime;
  55681. private _gpuFrameTimeToken;
  55682. private _gpuFrameTime;
  55683. private _captureShaderCompilationTime;
  55684. private _shaderCompilationTime;
  55685. private _onBeginFrameObserver;
  55686. private _onEndFrameObserver;
  55687. private _onBeforeShaderCompilationObserver;
  55688. private _onAfterShaderCompilationObserver;
  55689. /**
  55690. * Gets the perf counter used for GPU frame time
  55691. */
  55692. get gpuFrameTimeCounter(): PerfCounter;
  55693. /**
  55694. * Gets the GPU frame time capture status
  55695. */
  55696. get captureGPUFrameTime(): boolean;
  55697. /**
  55698. * Enable or disable the GPU frame time capture
  55699. */
  55700. set captureGPUFrameTime(value: boolean);
  55701. /**
  55702. * Gets the perf counter used for shader compilation time
  55703. */
  55704. get shaderCompilationTimeCounter(): PerfCounter;
  55705. /**
  55706. * Gets the shader compilation time capture status
  55707. */
  55708. get captureShaderCompilationTime(): boolean;
  55709. /**
  55710. * Enable or disable the shader compilation time capture
  55711. */
  55712. set captureShaderCompilationTime(value: boolean);
  55713. /**
  55714. * Instantiates a new engine instrumentation.
  55715. * This class can be used to get instrumentation data from a Babylon engine
  55716. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55717. * @param engine Defines the engine to instrument
  55718. */
  55719. constructor(
  55720. /**
  55721. * Define the instrumented engine.
  55722. */
  55723. engine: Engine);
  55724. /**
  55725. * Dispose and release associated resources.
  55726. */
  55727. dispose(): void;
  55728. }
  55729. }
  55730. declare module BABYLON {
  55731. /**
  55732. * This class can be used to get instrumentation data from a Babylon engine
  55733. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55734. */
  55735. export class SceneInstrumentation implements IDisposable {
  55736. /**
  55737. * Defines the scene to instrument
  55738. */
  55739. scene: Scene;
  55740. private _captureActiveMeshesEvaluationTime;
  55741. private _activeMeshesEvaluationTime;
  55742. private _captureRenderTargetsRenderTime;
  55743. private _renderTargetsRenderTime;
  55744. private _captureFrameTime;
  55745. private _frameTime;
  55746. private _captureRenderTime;
  55747. private _renderTime;
  55748. private _captureInterFrameTime;
  55749. private _interFrameTime;
  55750. private _captureParticlesRenderTime;
  55751. private _particlesRenderTime;
  55752. private _captureSpritesRenderTime;
  55753. private _spritesRenderTime;
  55754. private _capturePhysicsTime;
  55755. private _physicsTime;
  55756. private _captureAnimationsTime;
  55757. private _animationsTime;
  55758. private _captureCameraRenderTime;
  55759. private _cameraRenderTime;
  55760. private _onBeforeActiveMeshesEvaluationObserver;
  55761. private _onAfterActiveMeshesEvaluationObserver;
  55762. private _onBeforeRenderTargetsRenderObserver;
  55763. private _onAfterRenderTargetsRenderObserver;
  55764. private _onAfterRenderObserver;
  55765. private _onBeforeDrawPhaseObserver;
  55766. private _onAfterDrawPhaseObserver;
  55767. private _onBeforeAnimationsObserver;
  55768. private _onBeforeParticlesRenderingObserver;
  55769. private _onAfterParticlesRenderingObserver;
  55770. private _onBeforeSpritesRenderingObserver;
  55771. private _onAfterSpritesRenderingObserver;
  55772. private _onBeforePhysicsObserver;
  55773. private _onAfterPhysicsObserver;
  55774. private _onAfterAnimationsObserver;
  55775. private _onBeforeCameraRenderObserver;
  55776. private _onAfterCameraRenderObserver;
  55777. /**
  55778. * Gets the perf counter used for active meshes evaluation time
  55779. */
  55780. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  55781. /**
  55782. * Gets the active meshes evaluation time capture status
  55783. */
  55784. get captureActiveMeshesEvaluationTime(): boolean;
  55785. /**
  55786. * Enable or disable the active meshes evaluation time capture
  55787. */
  55788. set captureActiveMeshesEvaluationTime(value: boolean);
  55789. /**
  55790. * Gets the perf counter used for render targets render time
  55791. */
  55792. get renderTargetsRenderTimeCounter(): PerfCounter;
  55793. /**
  55794. * Gets the render targets render time capture status
  55795. */
  55796. get captureRenderTargetsRenderTime(): boolean;
  55797. /**
  55798. * Enable or disable the render targets render time capture
  55799. */
  55800. set captureRenderTargetsRenderTime(value: boolean);
  55801. /**
  55802. * Gets the perf counter used for particles render time
  55803. */
  55804. get particlesRenderTimeCounter(): PerfCounter;
  55805. /**
  55806. * Gets the particles render time capture status
  55807. */
  55808. get captureParticlesRenderTime(): boolean;
  55809. /**
  55810. * Enable or disable the particles render time capture
  55811. */
  55812. set captureParticlesRenderTime(value: boolean);
  55813. /**
  55814. * Gets the perf counter used for sprites render time
  55815. */
  55816. get spritesRenderTimeCounter(): PerfCounter;
  55817. /**
  55818. * Gets the sprites render time capture status
  55819. */
  55820. get captureSpritesRenderTime(): boolean;
  55821. /**
  55822. * Enable or disable the sprites render time capture
  55823. */
  55824. set captureSpritesRenderTime(value: boolean);
  55825. /**
  55826. * Gets the perf counter used for physics time
  55827. */
  55828. get physicsTimeCounter(): PerfCounter;
  55829. /**
  55830. * Gets the physics time capture status
  55831. */
  55832. get capturePhysicsTime(): boolean;
  55833. /**
  55834. * Enable or disable the physics time capture
  55835. */
  55836. set capturePhysicsTime(value: boolean);
  55837. /**
  55838. * Gets the perf counter used for animations time
  55839. */
  55840. get animationsTimeCounter(): PerfCounter;
  55841. /**
  55842. * Gets the animations time capture status
  55843. */
  55844. get captureAnimationsTime(): boolean;
  55845. /**
  55846. * Enable or disable the animations time capture
  55847. */
  55848. set captureAnimationsTime(value: boolean);
  55849. /**
  55850. * Gets the perf counter used for frame time capture
  55851. */
  55852. get frameTimeCounter(): PerfCounter;
  55853. /**
  55854. * Gets the frame time capture status
  55855. */
  55856. get captureFrameTime(): boolean;
  55857. /**
  55858. * Enable or disable the frame time capture
  55859. */
  55860. set captureFrameTime(value: boolean);
  55861. /**
  55862. * Gets the perf counter used for inter-frames time capture
  55863. */
  55864. get interFrameTimeCounter(): PerfCounter;
  55865. /**
  55866. * Gets the inter-frames time capture status
  55867. */
  55868. get captureInterFrameTime(): boolean;
  55869. /**
  55870. * Enable or disable the inter-frames time capture
  55871. */
  55872. set captureInterFrameTime(value: boolean);
  55873. /**
  55874. * Gets the perf counter used for render time capture
  55875. */
  55876. get renderTimeCounter(): PerfCounter;
  55877. /**
  55878. * Gets the render time capture status
  55879. */
  55880. get captureRenderTime(): boolean;
  55881. /**
  55882. * Enable or disable the render time capture
  55883. */
  55884. set captureRenderTime(value: boolean);
  55885. /**
  55886. * Gets the perf counter used for camera render time capture
  55887. */
  55888. get cameraRenderTimeCounter(): PerfCounter;
  55889. /**
  55890. * Gets the camera render time capture status
  55891. */
  55892. get captureCameraRenderTime(): boolean;
  55893. /**
  55894. * Enable or disable the camera render time capture
  55895. */
  55896. set captureCameraRenderTime(value: boolean);
  55897. /**
  55898. * Gets the perf counter used for draw calls
  55899. */
  55900. get drawCallsCounter(): PerfCounter;
  55901. /**
  55902. * Instantiates a new scene instrumentation.
  55903. * This class can be used to get instrumentation data from a Babylon engine
  55904. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55905. * @param scene Defines the scene to instrument
  55906. */
  55907. constructor(
  55908. /**
  55909. * Defines the scene to instrument
  55910. */
  55911. scene: Scene);
  55912. /**
  55913. * Dispose and release associated resources.
  55914. */
  55915. dispose(): void;
  55916. }
  55917. }
  55918. declare module BABYLON {
  55919. /** @hidden */
  55920. export var glowMapGenerationPixelShader: {
  55921. name: string;
  55922. shader: string;
  55923. };
  55924. }
  55925. declare module BABYLON {
  55926. /** @hidden */
  55927. export var glowMapGenerationVertexShader: {
  55928. name: string;
  55929. shader: string;
  55930. };
  55931. }
  55932. declare module BABYLON {
  55933. /**
  55934. * Effect layer options. This helps customizing the behaviour
  55935. * of the effect layer.
  55936. */
  55937. export interface IEffectLayerOptions {
  55938. /**
  55939. * Multiplication factor apply to the canvas size to compute the render target size
  55940. * used to generated the objects (the smaller the faster).
  55941. */
  55942. mainTextureRatio: number;
  55943. /**
  55944. * Enforces a fixed size texture to ensure effect stability across devices.
  55945. */
  55946. mainTextureFixedSize?: number;
  55947. /**
  55948. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55949. */
  55950. alphaBlendingMode: number;
  55951. /**
  55952. * The camera attached to the layer.
  55953. */
  55954. camera: Nullable<Camera>;
  55955. /**
  55956. * The rendering group to draw the layer in.
  55957. */
  55958. renderingGroupId: number;
  55959. }
  55960. /**
  55961. * The effect layer Helps adding post process effect blended with the main pass.
  55962. *
  55963. * This can be for instance use to generate glow or higlight effects on the scene.
  55964. *
  55965. * The effect layer class can not be used directly and is intented to inherited from to be
  55966. * customized per effects.
  55967. */
  55968. export abstract class EffectLayer {
  55969. private _vertexBuffers;
  55970. private _indexBuffer;
  55971. private _cachedDefines;
  55972. private _effectLayerMapGenerationEffect;
  55973. private _effectLayerOptions;
  55974. private _mergeEffect;
  55975. protected _scene: Scene;
  55976. protected _engine: Engine;
  55977. protected _maxSize: number;
  55978. protected _mainTextureDesiredSize: ISize;
  55979. protected _mainTexture: RenderTargetTexture;
  55980. protected _shouldRender: boolean;
  55981. protected _postProcesses: PostProcess[];
  55982. protected _textures: BaseTexture[];
  55983. protected _emissiveTextureAndColor: {
  55984. texture: Nullable<BaseTexture>;
  55985. color: Color4;
  55986. };
  55987. /**
  55988. * The name of the layer
  55989. */
  55990. name: string;
  55991. /**
  55992. * The clear color of the texture used to generate the glow map.
  55993. */
  55994. neutralColor: Color4;
  55995. /**
  55996. * Specifies whether the highlight layer is enabled or not.
  55997. */
  55998. isEnabled: boolean;
  55999. /**
  56000. * Gets the camera attached to the layer.
  56001. */
  56002. get camera(): Nullable<Camera>;
  56003. /**
  56004. * Gets the rendering group id the layer should render in.
  56005. */
  56006. get renderingGroupId(): number;
  56007. set renderingGroupId(renderingGroupId: number);
  56008. /**
  56009. * An event triggered when the effect layer has been disposed.
  56010. */
  56011. onDisposeObservable: Observable<EffectLayer>;
  56012. /**
  56013. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56014. */
  56015. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56016. /**
  56017. * An event triggered when the generated texture is being merged in the scene.
  56018. */
  56019. onBeforeComposeObservable: Observable<EffectLayer>;
  56020. /**
  56021. * An event triggered when the mesh is rendered into the effect render target.
  56022. */
  56023. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56024. /**
  56025. * An event triggered after the mesh has been rendered into the effect render target.
  56026. */
  56027. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56028. /**
  56029. * An event triggered when the generated texture has been merged in the scene.
  56030. */
  56031. onAfterComposeObservable: Observable<EffectLayer>;
  56032. /**
  56033. * An event triggered when the efffect layer changes its size.
  56034. */
  56035. onSizeChangedObservable: Observable<EffectLayer>;
  56036. /** @hidden */
  56037. static _SceneComponentInitialization: (scene: Scene) => void;
  56038. /**
  56039. * Instantiates a new effect Layer and references it in the scene.
  56040. * @param name The name of the layer
  56041. * @param scene The scene to use the layer in
  56042. */
  56043. constructor(
  56044. /** The Friendly of the effect in the scene */
  56045. name: string, scene: Scene);
  56046. /**
  56047. * Get the effect name of the layer.
  56048. * @return The effect name
  56049. */
  56050. abstract getEffectName(): string;
  56051. /**
  56052. * Checks for the readiness of the element composing the layer.
  56053. * @param subMesh the mesh to check for
  56054. * @param useInstances specify whether or not to use instances to render the mesh
  56055. * @return true if ready otherwise, false
  56056. */
  56057. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56058. /**
  56059. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56060. * @returns true if the effect requires stencil during the main canvas render pass.
  56061. */
  56062. abstract needStencil(): boolean;
  56063. /**
  56064. * Create the merge effect. This is the shader use to blit the information back
  56065. * to the main canvas at the end of the scene rendering.
  56066. * @returns The effect containing the shader used to merge the effect on the main canvas
  56067. */
  56068. protected abstract _createMergeEffect(): Effect;
  56069. /**
  56070. * Creates the render target textures and post processes used in the effect layer.
  56071. */
  56072. protected abstract _createTextureAndPostProcesses(): void;
  56073. /**
  56074. * Implementation specific of rendering the generating effect on the main canvas.
  56075. * @param effect The effect used to render through
  56076. */
  56077. protected abstract _internalRender(effect: Effect): void;
  56078. /**
  56079. * Sets the required values for both the emissive texture and and the main color.
  56080. */
  56081. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56082. /**
  56083. * Free any resources and references associated to a mesh.
  56084. * Internal use
  56085. * @param mesh The mesh to free.
  56086. */
  56087. abstract _disposeMesh(mesh: Mesh): void;
  56088. /**
  56089. * Serializes this layer (Glow or Highlight for example)
  56090. * @returns a serialized layer object
  56091. */
  56092. abstract serialize?(): any;
  56093. /**
  56094. * Initializes the effect layer with the required options.
  56095. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56096. */
  56097. protected _init(options: Partial<IEffectLayerOptions>): void;
  56098. /**
  56099. * Generates the index buffer of the full screen quad blending to the main canvas.
  56100. */
  56101. private _generateIndexBuffer;
  56102. /**
  56103. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56104. */
  56105. private _generateVertexBuffer;
  56106. /**
  56107. * Sets the main texture desired size which is the closest power of two
  56108. * of the engine canvas size.
  56109. */
  56110. private _setMainTextureSize;
  56111. /**
  56112. * Creates the main texture for the effect layer.
  56113. */
  56114. protected _createMainTexture(): void;
  56115. /**
  56116. * Adds specific effects defines.
  56117. * @param defines The defines to add specifics to.
  56118. */
  56119. protected _addCustomEffectDefines(defines: string[]): void;
  56120. /**
  56121. * Checks for the readiness of the element composing the layer.
  56122. * @param subMesh the mesh to check for
  56123. * @param useInstances specify whether or not to use instances to render the mesh
  56124. * @param emissiveTexture the associated emissive texture used to generate the glow
  56125. * @return true if ready otherwise, false
  56126. */
  56127. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56128. /**
  56129. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56130. */
  56131. render(): void;
  56132. /**
  56133. * Determine if a given mesh will be used in the current effect.
  56134. * @param mesh mesh to test
  56135. * @returns true if the mesh will be used
  56136. */
  56137. hasMesh(mesh: AbstractMesh): boolean;
  56138. /**
  56139. * Returns true if the layer contains information to display, otherwise false.
  56140. * @returns true if the glow layer should be rendered
  56141. */
  56142. shouldRender(): boolean;
  56143. /**
  56144. * Returns true if the mesh should render, otherwise false.
  56145. * @param mesh The mesh to render
  56146. * @returns true if it should render otherwise false
  56147. */
  56148. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56149. /**
  56150. * Returns true if the mesh can be rendered, otherwise false.
  56151. * @param mesh The mesh to render
  56152. * @param material The material used on the mesh
  56153. * @returns true if it can be rendered otherwise false
  56154. */
  56155. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56156. /**
  56157. * Returns true if the mesh should render, otherwise false.
  56158. * @param mesh The mesh to render
  56159. * @returns true if it should render otherwise false
  56160. */
  56161. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56162. /**
  56163. * Renders the submesh passed in parameter to the generation map.
  56164. */
  56165. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56166. /**
  56167. * Defines whether the current material of the mesh should be use to render the effect.
  56168. * @param mesh defines the current mesh to render
  56169. */
  56170. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56171. /**
  56172. * Rebuild the required buffers.
  56173. * @hidden Internal use only.
  56174. */
  56175. _rebuild(): void;
  56176. /**
  56177. * Dispose only the render target textures and post process.
  56178. */
  56179. private _disposeTextureAndPostProcesses;
  56180. /**
  56181. * Dispose the highlight layer and free resources.
  56182. */
  56183. dispose(): void;
  56184. /**
  56185. * Gets the class name of the effect layer
  56186. * @returns the string with the class name of the effect layer
  56187. */
  56188. getClassName(): string;
  56189. /**
  56190. * Creates an effect layer from parsed effect layer data
  56191. * @param parsedEffectLayer defines effect layer data
  56192. * @param scene defines the current scene
  56193. * @param rootUrl defines the root URL containing the effect layer information
  56194. * @returns a parsed effect Layer
  56195. */
  56196. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56197. }
  56198. }
  56199. declare module BABYLON {
  56200. interface AbstractScene {
  56201. /**
  56202. * The list of effect layers (highlights/glow) added to the scene
  56203. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56204. * @see http://doc.babylonjs.com/how_to/glow_layer
  56205. */
  56206. effectLayers: Array<EffectLayer>;
  56207. /**
  56208. * Removes the given effect layer from this scene.
  56209. * @param toRemove defines the effect layer to remove
  56210. * @returns the index of the removed effect layer
  56211. */
  56212. removeEffectLayer(toRemove: EffectLayer): number;
  56213. /**
  56214. * Adds the given effect layer to this scene
  56215. * @param newEffectLayer defines the effect layer to add
  56216. */
  56217. addEffectLayer(newEffectLayer: EffectLayer): void;
  56218. }
  56219. /**
  56220. * Defines the layer scene component responsible to manage any effect layers
  56221. * in a given scene.
  56222. */
  56223. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56224. /**
  56225. * The component name helpfull to identify the component in the list of scene components.
  56226. */
  56227. readonly name: string;
  56228. /**
  56229. * The scene the component belongs to.
  56230. */
  56231. scene: Scene;
  56232. private _engine;
  56233. private _renderEffects;
  56234. private _needStencil;
  56235. private _previousStencilState;
  56236. /**
  56237. * Creates a new instance of the component for the given scene
  56238. * @param scene Defines the scene to register the component in
  56239. */
  56240. constructor(scene: Scene);
  56241. /**
  56242. * Registers the component in a given scene
  56243. */
  56244. register(): void;
  56245. /**
  56246. * Rebuilds the elements related to this component in case of
  56247. * context lost for instance.
  56248. */
  56249. rebuild(): void;
  56250. /**
  56251. * Serializes the component data to the specified json object
  56252. * @param serializationObject The object to serialize to
  56253. */
  56254. serialize(serializationObject: any): void;
  56255. /**
  56256. * Adds all the elements from the container to the scene
  56257. * @param container the container holding the elements
  56258. */
  56259. addFromContainer(container: AbstractScene): void;
  56260. /**
  56261. * Removes all the elements in the container from the scene
  56262. * @param container contains the elements to remove
  56263. * @param dispose if the removed element should be disposed (default: false)
  56264. */
  56265. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56266. /**
  56267. * Disposes the component and the associated ressources.
  56268. */
  56269. dispose(): void;
  56270. private _isReadyForMesh;
  56271. private _renderMainTexture;
  56272. private _setStencil;
  56273. private _setStencilBack;
  56274. private _draw;
  56275. private _drawCamera;
  56276. private _drawRenderingGroup;
  56277. }
  56278. }
  56279. declare module BABYLON {
  56280. /** @hidden */
  56281. export var glowMapMergePixelShader: {
  56282. name: string;
  56283. shader: string;
  56284. };
  56285. }
  56286. declare module BABYLON {
  56287. /** @hidden */
  56288. export var glowMapMergeVertexShader: {
  56289. name: string;
  56290. shader: string;
  56291. };
  56292. }
  56293. declare module BABYLON {
  56294. interface AbstractScene {
  56295. /**
  56296. * Return a the first highlight layer of the scene with a given name.
  56297. * @param name The name of the highlight layer to look for.
  56298. * @return The highlight layer if found otherwise null.
  56299. */
  56300. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  56301. }
  56302. /**
  56303. * Glow layer options. This helps customizing the behaviour
  56304. * of the glow layer.
  56305. */
  56306. export interface IGlowLayerOptions {
  56307. /**
  56308. * Multiplication factor apply to the canvas size to compute the render target size
  56309. * used to generated the glowing objects (the smaller the faster).
  56310. */
  56311. mainTextureRatio: number;
  56312. /**
  56313. * Enforces a fixed size texture to ensure resize independant blur.
  56314. */
  56315. mainTextureFixedSize?: number;
  56316. /**
  56317. * How big is the kernel of the blur texture.
  56318. */
  56319. blurKernelSize: number;
  56320. /**
  56321. * The camera attached to the layer.
  56322. */
  56323. camera: Nullable<Camera>;
  56324. /**
  56325. * Enable MSAA by chosing the number of samples.
  56326. */
  56327. mainTextureSamples?: number;
  56328. /**
  56329. * The rendering group to draw the layer in.
  56330. */
  56331. renderingGroupId: number;
  56332. }
  56333. /**
  56334. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  56335. *
  56336. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  56337. *
  56338. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  56339. */
  56340. export class GlowLayer extends EffectLayer {
  56341. /**
  56342. * Effect Name of the layer.
  56343. */
  56344. static readonly EffectName: string;
  56345. /**
  56346. * The default blur kernel size used for the glow.
  56347. */
  56348. static DefaultBlurKernelSize: number;
  56349. /**
  56350. * The default texture size ratio used for the glow.
  56351. */
  56352. static DefaultTextureRatio: number;
  56353. /**
  56354. * Sets the kernel size of the blur.
  56355. */
  56356. set blurKernelSize(value: number);
  56357. /**
  56358. * Gets the kernel size of the blur.
  56359. */
  56360. get blurKernelSize(): number;
  56361. /**
  56362. * Sets the glow intensity.
  56363. */
  56364. set intensity(value: number);
  56365. /**
  56366. * Gets the glow intensity.
  56367. */
  56368. get intensity(): number;
  56369. private _options;
  56370. private _intensity;
  56371. private _horizontalBlurPostprocess1;
  56372. private _verticalBlurPostprocess1;
  56373. private _horizontalBlurPostprocess2;
  56374. private _verticalBlurPostprocess2;
  56375. private _blurTexture1;
  56376. private _blurTexture2;
  56377. private _postProcesses1;
  56378. private _postProcesses2;
  56379. private _includedOnlyMeshes;
  56380. private _excludedMeshes;
  56381. private _meshesUsingTheirOwnMaterials;
  56382. /**
  56383. * Callback used to let the user override the color selection on a per mesh basis
  56384. */
  56385. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56386. /**
  56387. * Callback used to let the user override the texture selection on a per mesh basis
  56388. */
  56389. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56390. /**
  56391. * Instantiates a new glow Layer and references it to the scene.
  56392. * @param name The name of the layer
  56393. * @param scene The scene to use the layer in
  56394. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56395. */
  56396. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56397. /**
  56398. * Get the effect name of the layer.
  56399. * @return The effect name
  56400. */
  56401. getEffectName(): string;
  56402. /**
  56403. * Create the merge effect. This is the shader use to blit the information back
  56404. * to the main canvas at the end of the scene rendering.
  56405. */
  56406. protected _createMergeEffect(): Effect;
  56407. /**
  56408. * Creates the render target textures and post processes used in the glow layer.
  56409. */
  56410. protected _createTextureAndPostProcesses(): void;
  56411. /**
  56412. * Checks for the readiness of the element composing the layer.
  56413. * @param subMesh the mesh to check for
  56414. * @param useInstances specify wether or not to use instances to render the mesh
  56415. * @param emissiveTexture the associated emissive texture used to generate the glow
  56416. * @return true if ready otherwise, false
  56417. */
  56418. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56419. /**
  56420. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56421. */
  56422. needStencil(): boolean;
  56423. /**
  56424. * Returns true if the mesh can be rendered, otherwise false.
  56425. * @param mesh The mesh to render
  56426. * @param material The material used on the mesh
  56427. * @returns true if it can be rendered otherwise false
  56428. */
  56429. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56430. /**
  56431. * Implementation specific of rendering the generating effect on the main canvas.
  56432. * @param effect The effect used to render through
  56433. */
  56434. protected _internalRender(effect: Effect): void;
  56435. /**
  56436. * Sets the required values for both the emissive texture and and the main color.
  56437. */
  56438. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56439. /**
  56440. * Returns true if the mesh should render, otherwise false.
  56441. * @param mesh The mesh to render
  56442. * @returns true if it should render otherwise false
  56443. */
  56444. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56445. /**
  56446. * Adds specific effects defines.
  56447. * @param defines The defines to add specifics to.
  56448. */
  56449. protected _addCustomEffectDefines(defines: string[]): void;
  56450. /**
  56451. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56452. * @param mesh The mesh to exclude from the glow layer
  56453. */
  56454. addExcludedMesh(mesh: Mesh): void;
  56455. /**
  56456. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56457. * @param mesh The mesh to remove
  56458. */
  56459. removeExcludedMesh(mesh: Mesh): void;
  56460. /**
  56461. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56462. * @param mesh The mesh to include in the glow layer
  56463. */
  56464. addIncludedOnlyMesh(mesh: Mesh): void;
  56465. /**
  56466. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56467. * @param mesh The mesh to remove
  56468. */
  56469. removeIncludedOnlyMesh(mesh: Mesh): void;
  56470. /**
  56471. * Determine if a given mesh will be used in the glow layer
  56472. * @param mesh The mesh to test
  56473. * @returns true if the mesh will be highlighted by the current glow layer
  56474. */
  56475. hasMesh(mesh: AbstractMesh): boolean;
  56476. /**
  56477. * Defines whether the current material of the mesh should be use to render the effect.
  56478. * @param mesh defines the current mesh to render
  56479. */
  56480. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56481. /**
  56482. * Add a mesh to be rendered through its own material and not with emissive only.
  56483. * @param mesh The mesh for which we need to use its material
  56484. */
  56485. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56486. /**
  56487. * Remove a mesh from being rendered through its own material and not with emissive only.
  56488. * @param mesh The mesh for which we need to not use its material
  56489. */
  56490. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56491. /**
  56492. * Free any resources and references associated to a mesh.
  56493. * Internal use
  56494. * @param mesh The mesh to free.
  56495. * @hidden
  56496. */
  56497. _disposeMesh(mesh: Mesh): void;
  56498. /**
  56499. * Gets the class name of the effect layer
  56500. * @returns the string with the class name of the effect layer
  56501. */
  56502. getClassName(): string;
  56503. /**
  56504. * Serializes this glow layer
  56505. * @returns a serialized glow layer object
  56506. */
  56507. serialize(): any;
  56508. /**
  56509. * Creates a Glow Layer from parsed glow layer data
  56510. * @param parsedGlowLayer defines glow layer data
  56511. * @param scene defines the current scene
  56512. * @param rootUrl defines the root URL containing the glow layer information
  56513. * @returns a parsed Glow Layer
  56514. */
  56515. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56516. }
  56517. }
  56518. declare module BABYLON {
  56519. /** @hidden */
  56520. export var glowBlurPostProcessPixelShader: {
  56521. name: string;
  56522. shader: string;
  56523. };
  56524. }
  56525. declare module BABYLON {
  56526. interface AbstractScene {
  56527. /**
  56528. * Return a the first highlight layer of the scene with a given name.
  56529. * @param name The name of the highlight layer to look for.
  56530. * @return The highlight layer if found otherwise null.
  56531. */
  56532. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56533. }
  56534. /**
  56535. * Highlight layer options. This helps customizing the behaviour
  56536. * of the highlight layer.
  56537. */
  56538. export interface IHighlightLayerOptions {
  56539. /**
  56540. * Multiplication factor apply to the canvas size to compute the render target size
  56541. * used to generated the glowing objects (the smaller the faster).
  56542. */
  56543. mainTextureRatio: number;
  56544. /**
  56545. * Enforces a fixed size texture to ensure resize independant blur.
  56546. */
  56547. mainTextureFixedSize?: number;
  56548. /**
  56549. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56550. * of the picture to blur (the smaller the faster).
  56551. */
  56552. blurTextureSizeRatio: number;
  56553. /**
  56554. * How big in texel of the blur texture is the vertical blur.
  56555. */
  56556. blurVerticalSize: number;
  56557. /**
  56558. * How big in texel of the blur texture is the horizontal blur.
  56559. */
  56560. blurHorizontalSize: number;
  56561. /**
  56562. * Alpha blending mode used to apply the blur. Default is combine.
  56563. */
  56564. alphaBlendingMode: number;
  56565. /**
  56566. * The camera attached to the layer.
  56567. */
  56568. camera: Nullable<Camera>;
  56569. /**
  56570. * Should we display highlight as a solid stroke?
  56571. */
  56572. isStroke?: boolean;
  56573. /**
  56574. * The rendering group to draw the layer in.
  56575. */
  56576. renderingGroupId: number;
  56577. }
  56578. /**
  56579. * The highlight layer Helps adding a glow effect around a mesh.
  56580. *
  56581. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  56582. * glowy meshes to your scene.
  56583. *
  56584. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  56585. */
  56586. export class HighlightLayer extends EffectLayer {
  56587. name: string;
  56588. /**
  56589. * Effect Name of the highlight layer.
  56590. */
  56591. static readonly EffectName: string;
  56592. /**
  56593. * The neutral color used during the preparation of the glow effect.
  56594. * This is black by default as the blend operation is a blend operation.
  56595. */
  56596. static NeutralColor: Color4;
  56597. /**
  56598. * Stencil value used for glowing meshes.
  56599. */
  56600. static GlowingMeshStencilReference: number;
  56601. /**
  56602. * Stencil value used for the other meshes in the scene.
  56603. */
  56604. static NormalMeshStencilReference: number;
  56605. /**
  56606. * Specifies whether or not the inner glow is ACTIVE in the layer.
  56607. */
  56608. innerGlow: boolean;
  56609. /**
  56610. * Specifies whether or not the outer glow is ACTIVE in the layer.
  56611. */
  56612. outerGlow: boolean;
  56613. /**
  56614. * Specifies the horizontal size of the blur.
  56615. */
  56616. set blurHorizontalSize(value: number);
  56617. /**
  56618. * Specifies the vertical size of the blur.
  56619. */
  56620. set blurVerticalSize(value: number);
  56621. /**
  56622. * Gets the horizontal size of the blur.
  56623. */
  56624. get blurHorizontalSize(): number;
  56625. /**
  56626. * Gets the vertical size of the blur.
  56627. */
  56628. get blurVerticalSize(): number;
  56629. /**
  56630. * An event triggered when the highlight layer is being blurred.
  56631. */
  56632. onBeforeBlurObservable: Observable<HighlightLayer>;
  56633. /**
  56634. * An event triggered when the highlight layer has been blurred.
  56635. */
  56636. onAfterBlurObservable: Observable<HighlightLayer>;
  56637. private _instanceGlowingMeshStencilReference;
  56638. private _options;
  56639. private _downSamplePostprocess;
  56640. private _horizontalBlurPostprocess;
  56641. private _verticalBlurPostprocess;
  56642. private _blurTexture;
  56643. private _meshes;
  56644. private _excludedMeshes;
  56645. /**
  56646. * Instantiates a new highlight Layer and references it to the scene..
  56647. * @param name The name of the layer
  56648. * @param scene The scene to use the layer in
  56649. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  56650. */
  56651. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  56652. /**
  56653. * Get the effect name of the layer.
  56654. * @return The effect name
  56655. */
  56656. getEffectName(): string;
  56657. /**
  56658. * Create the merge effect. This is the shader use to blit the information back
  56659. * to the main canvas at the end of the scene rendering.
  56660. */
  56661. protected _createMergeEffect(): Effect;
  56662. /**
  56663. * Creates the render target textures and post processes used in the highlight layer.
  56664. */
  56665. protected _createTextureAndPostProcesses(): void;
  56666. /**
  56667. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  56668. */
  56669. needStencil(): boolean;
  56670. /**
  56671. * Checks for the readiness of the element composing the layer.
  56672. * @param subMesh the mesh to check for
  56673. * @param useInstances specify wether or not to use instances to render the mesh
  56674. * @param emissiveTexture the associated emissive texture used to generate the glow
  56675. * @return true if ready otherwise, false
  56676. */
  56677. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56678. /**
  56679. * Implementation specific of rendering the generating effect on the main canvas.
  56680. * @param effect The effect used to render through
  56681. */
  56682. protected _internalRender(effect: Effect): void;
  56683. /**
  56684. * Returns true if the layer contains information to display, otherwise false.
  56685. */
  56686. shouldRender(): boolean;
  56687. /**
  56688. * Returns true if the mesh should render, otherwise false.
  56689. * @param mesh The mesh to render
  56690. * @returns true if it should render otherwise false
  56691. */
  56692. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56693. /**
  56694. * Adds specific effects defines.
  56695. * @param defines The defines to add specifics to.
  56696. */
  56697. protected _addCustomEffectDefines(defines: string[]): void;
  56698. /**
  56699. * Sets the required values for both the emissive texture and and the main color.
  56700. */
  56701. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56702. /**
  56703. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  56704. * @param mesh The mesh to exclude from the highlight layer
  56705. */
  56706. addExcludedMesh(mesh: Mesh): void;
  56707. /**
  56708. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  56709. * @param mesh The mesh to highlight
  56710. */
  56711. removeExcludedMesh(mesh: Mesh): void;
  56712. /**
  56713. * Determine if a given mesh will be highlighted by the current HighlightLayer
  56714. * @param mesh mesh to test
  56715. * @returns true if the mesh will be highlighted by the current HighlightLayer
  56716. */
  56717. hasMesh(mesh: AbstractMesh): boolean;
  56718. /**
  56719. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  56720. * @param mesh The mesh to highlight
  56721. * @param color The color of the highlight
  56722. * @param glowEmissiveOnly Extract the glow from the emissive texture
  56723. */
  56724. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  56725. /**
  56726. * Remove a mesh from the highlight layer in order to make it stop glowing.
  56727. * @param mesh The mesh to highlight
  56728. */
  56729. removeMesh(mesh: Mesh): void;
  56730. /**
  56731. * Remove all the meshes currently referenced in the highlight layer
  56732. */
  56733. removeAllMeshes(): void;
  56734. /**
  56735. * Force the stencil to the normal expected value for none glowing parts
  56736. */
  56737. private _defaultStencilReference;
  56738. /**
  56739. * Free any resources and references associated to a mesh.
  56740. * Internal use
  56741. * @param mesh The mesh to free.
  56742. * @hidden
  56743. */
  56744. _disposeMesh(mesh: Mesh): void;
  56745. /**
  56746. * Dispose the highlight layer and free resources.
  56747. */
  56748. dispose(): void;
  56749. /**
  56750. * Gets the class name of the effect layer
  56751. * @returns the string with the class name of the effect layer
  56752. */
  56753. getClassName(): string;
  56754. /**
  56755. * Serializes this Highlight layer
  56756. * @returns a serialized Highlight layer object
  56757. */
  56758. serialize(): any;
  56759. /**
  56760. * Creates a Highlight layer from parsed Highlight layer data
  56761. * @param parsedHightlightLayer defines the Highlight layer data
  56762. * @param scene defines the current scene
  56763. * @param rootUrl defines the root URL containing the Highlight layer information
  56764. * @returns a parsed Highlight layer
  56765. */
  56766. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  56767. }
  56768. }
  56769. declare module BABYLON {
  56770. interface AbstractScene {
  56771. /**
  56772. * The list of layers (background and foreground) of the scene
  56773. */
  56774. layers: Array<Layer>;
  56775. }
  56776. /**
  56777. * Defines the layer scene component responsible to manage any layers
  56778. * in a given scene.
  56779. */
  56780. export class LayerSceneComponent implements ISceneComponent {
  56781. /**
  56782. * The component name helpfull to identify the component in the list of scene components.
  56783. */
  56784. readonly name: string;
  56785. /**
  56786. * The scene the component belongs to.
  56787. */
  56788. scene: Scene;
  56789. private _engine;
  56790. /**
  56791. * Creates a new instance of the component for the given scene
  56792. * @param scene Defines the scene to register the component in
  56793. */
  56794. constructor(scene: Scene);
  56795. /**
  56796. * Registers the component in a given scene
  56797. */
  56798. register(): void;
  56799. /**
  56800. * Rebuilds the elements related to this component in case of
  56801. * context lost for instance.
  56802. */
  56803. rebuild(): void;
  56804. /**
  56805. * Disposes the component and the associated ressources.
  56806. */
  56807. dispose(): void;
  56808. private _draw;
  56809. private _drawCameraPredicate;
  56810. private _drawCameraBackground;
  56811. private _drawCameraForeground;
  56812. private _drawRenderTargetPredicate;
  56813. private _drawRenderTargetBackground;
  56814. private _drawRenderTargetForeground;
  56815. /**
  56816. * Adds all the elements from the container to the scene
  56817. * @param container the container holding the elements
  56818. */
  56819. addFromContainer(container: AbstractScene): void;
  56820. /**
  56821. * Removes all the elements in the container from the scene
  56822. * @param container contains the elements to remove
  56823. * @param dispose if the removed element should be disposed (default: false)
  56824. */
  56825. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56826. }
  56827. }
  56828. declare module BABYLON {
  56829. /** @hidden */
  56830. export var layerPixelShader: {
  56831. name: string;
  56832. shader: string;
  56833. };
  56834. }
  56835. declare module BABYLON {
  56836. /** @hidden */
  56837. export var layerVertexShader: {
  56838. name: string;
  56839. shader: string;
  56840. };
  56841. }
  56842. declare module BABYLON {
  56843. /**
  56844. * This represents a full screen 2d layer.
  56845. * This can be useful to display a picture in the background of your scene for instance.
  56846. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56847. */
  56848. export class Layer {
  56849. /**
  56850. * Define the name of the layer.
  56851. */
  56852. name: string;
  56853. /**
  56854. * Define the texture the layer should display.
  56855. */
  56856. texture: Nullable<Texture>;
  56857. /**
  56858. * Is the layer in background or foreground.
  56859. */
  56860. isBackground: boolean;
  56861. /**
  56862. * Define the color of the layer (instead of texture).
  56863. */
  56864. color: Color4;
  56865. /**
  56866. * Define the scale of the layer in order to zoom in out of the texture.
  56867. */
  56868. scale: Vector2;
  56869. /**
  56870. * Define an offset for the layer in order to shift the texture.
  56871. */
  56872. offset: Vector2;
  56873. /**
  56874. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56875. */
  56876. alphaBlendingMode: number;
  56877. /**
  56878. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56879. * Alpha test will not mix with the background color in case of transparency.
  56880. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56881. */
  56882. alphaTest: boolean;
  56883. /**
  56884. * Define a mask to restrict the layer to only some of the scene cameras.
  56885. */
  56886. layerMask: number;
  56887. /**
  56888. * Define the list of render target the layer is visible into.
  56889. */
  56890. renderTargetTextures: RenderTargetTexture[];
  56891. /**
  56892. * Define if the layer is only used in renderTarget or if it also
  56893. * renders in the main frame buffer of the canvas.
  56894. */
  56895. renderOnlyInRenderTargetTextures: boolean;
  56896. private _scene;
  56897. private _vertexBuffers;
  56898. private _indexBuffer;
  56899. private _effect;
  56900. private _previousDefines;
  56901. /**
  56902. * An event triggered when the layer is disposed.
  56903. */
  56904. onDisposeObservable: Observable<Layer>;
  56905. private _onDisposeObserver;
  56906. /**
  56907. * Back compatibility with callback before the onDisposeObservable existed.
  56908. * The set callback will be triggered when the layer has been disposed.
  56909. */
  56910. set onDispose(callback: () => void);
  56911. /**
  56912. * An event triggered before rendering the scene
  56913. */
  56914. onBeforeRenderObservable: Observable<Layer>;
  56915. private _onBeforeRenderObserver;
  56916. /**
  56917. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56918. * The set callback will be triggered just before rendering the layer.
  56919. */
  56920. set onBeforeRender(callback: () => void);
  56921. /**
  56922. * An event triggered after rendering the scene
  56923. */
  56924. onAfterRenderObservable: Observable<Layer>;
  56925. private _onAfterRenderObserver;
  56926. /**
  56927. * Back compatibility with callback before the onAfterRenderObservable existed.
  56928. * The set callback will be triggered just after rendering the layer.
  56929. */
  56930. set onAfterRender(callback: () => void);
  56931. /**
  56932. * Instantiates a new layer.
  56933. * This represents a full screen 2d layer.
  56934. * This can be useful to display a picture in the background of your scene for instance.
  56935. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56936. * @param name Define the name of the layer in the scene
  56937. * @param imgUrl Define the url of the texture to display in the layer
  56938. * @param scene Define the scene the layer belongs to
  56939. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56940. * @param color Defines a color for the layer
  56941. */
  56942. constructor(
  56943. /**
  56944. * Define the name of the layer.
  56945. */
  56946. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56947. private _createIndexBuffer;
  56948. /** @hidden */
  56949. _rebuild(): void;
  56950. /**
  56951. * Renders the layer in the scene.
  56952. */
  56953. render(): void;
  56954. /**
  56955. * Disposes and releases the associated ressources.
  56956. */
  56957. dispose(): void;
  56958. }
  56959. }
  56960. declare module BABYLON {
  56961. /** @hidden */
  56962. export var lensFlarePixelShader: {
  56963. name: string;
  56964. shader: string;
  56965. };
  56966. }
  56967. declare module BABYLON {
  56968. /** @hidden */
  56969. export var lensFlareVertexShader: {
  56970. name: string;
  56971. shader: string;
  56972. };
  56973. }
  56974. declare module BABYLON {
  56975. /**
  56976. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56977. * It is usually composed of several `lensFlare`.
  56978. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56979. */
  56980. export class LensFlareSystem {
  56981. /**
  56982. * Define the name of the lens flare system
  56983. */
  56984. name: string;
  56985. /**
  56986. * List of lens flares used in this system.
  56987. */
  56988. lensFlares: LensFlare[];
  56989. /**
  56990. * Define a limit from the border the lens flare can be visible.
  56991. */
  56992. borderLimit: number;
  56993. /**
  56994. * Define a viewport border we do not want to see the lens flare in.
  56995. */
  56996. viewportBorder: number;
  56997. /**
  56998. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56999. */
  57000. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57001. /**
  57002. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57003. */
  57004. layerMask: number;
  57005. /**
  57006. * Define the id of the lens flare system in the scene.
  57007. * (equal to name by default)
  57008. */
  57009. id: string;
  57010. private _scene;
  57011. private _emitter;
  57012. private _vertexBuffers;
  57013. private _indexBuffer;
  57014. private _effect;
  57015. private _positionX;
  57016. private _positionY;
  57017. private _isEnabled;
  57018. /** @hidden */
  57019. static _SceneComponentInitialization: (scene: Scene) => void;
  57020. /**
  57021. * Instantiates a lens flare system.
  57022. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57023. * It is usually composed of several `lensFlare`.
  57024. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57025. * @param name Define the name of the lens flare system in the scene
  57026. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57027. * @param scene Define the scene the lens flare system belongs to
  57028. */
  57029. constructor(
  57030. /**
  57031. * Define the name of the lens flare system
  57032. */
  57033. name: string, emitter: any, scene: Scene);
  57034. /**
  57035. * Define if the lens flare system is enabled.
  57036. */
  57037. get isEnabled(): boolean;
  57038. set isEnabled(value: boolean);
  57039. /**
  57040. * Get the scene the effects belongs to.
  57041. * @returns the scene holding the lens flare system
  57042. */
  57043. getScene(): Scene;
  57044. /**
  57045. * Get the emitter of the lens flare system.
  57046. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57047. * @returns the emitter of the lens flare system
  57048. */
  57049. getEmitter(): any;
  57050. /**
  57051. * Set the emitter of the lens flare system.
  57052. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57053. * @param newEmitter Define the new emitter of the system
  57054. */
  57055. setEmitter(newEmitter: any): void;
  57056. /**
  57057. * Get the lens flare system emitter position.
  57058. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57059. * @returns the position
  57060. */
  57061. getEmitterPosition(): Vector3;
  57062. /**
  57063. * @hidden
  57064. */
  57065. computeEffectivePosition(globalViewport: Viewport): boolean;
  57066. /** @hidden */
  57067. _isVisible(): boolean;
  57068. /**
  57069. * @hidden
  57070. */
  57071. render(): boolean;
  57072. /**
  57073. * Dispose and release the lens flare with its associated resources.
  57074. */
  57075. dispose(): void;
  57076. /**
  57077. * Parse a lens flare system from a JSON repressentation
  57078. * @param parsedLensFlareSystem Define the JSON to parse
  57079. * @param scene Define the scene the parsed system should be instantiated in
  57080. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57081. * @returns the parsed system
  57082. */
  57083. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57084. /**
  57085. * Serialize the current Lens Flare System into a JSON representation.
  57086. * @returns the serialized JSON
  57087. */
  57088. serialize(): any;
  57089. }
  57090. }
  57091. declare module BABYLON {
  57092. /**
  57093. * This represents one of the lens effect in a `lensFlareSystem`.
  57094. * It controls one of the indiviual texture used in the effect.
  57095. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57096. */
  57097. export class LensFlare {
  57098. /**
  57099. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57100. */
  57101. size: number;
  57102. /**
  57103. * 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.
  57104. */
  57105. position: number;
  57106. /**
  57107. * Define the lens color.
  57108. */
  57109. color: Color3;
  57110. /**
  57111. * Define the lens texture.
  57112. */
  57113. texture: Nullable<Texture>;
  57114. /**
  57115. * Define the alpha mode to render this particular lens.
  57116. */
  57117. alphaMode: number;
  57118. private _system;
  57119. /**
  57120. * Creates a new Lens Flare.
  57121. * This represents one of the lens effect in a `lensFlareSystem`.
  57122. * It controls one of the indiviual texture used in the effect.
  57123. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57124. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57125. * @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.
  57126. * @param color Define the lens color
  57127. * @param imgUrl Define the lens texture url
  57128. * @param system Define the `lensFlareSystem` this flare is part of
  57129. * @returns The newly created Lens Flare
  57130. */
  57131. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57132. /**
  57133. * Instantiates a new Lens Flare.
  57134. * This represents one of the lens effect in a `lensFlareSystem`.
  57135. * It controls one of the indiviual texture used in the effect.
  57136. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57137. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57138. * @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.
  57139. * @param color Define the lens color
  57140. * @param imgUrl Define the lens texture url
  57141. * @param system Define the `lensFlareSystem` this flare is part of
  57142. */
  57143. constructor(
  57144. /**
  57145. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57146. */
  57147. size: number,
  57148. /**
  57149. * 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.
  57150. */
  57151. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57152. /**
  57153. * Dispose and release the lens flare with its associated resources.
  57154. */
  57155. dispose(): void;
  57156. }
  57157. }
  57158. declare module BABYLON {
  57159. interface AbstractScene {
  57160. /**
  57161. * The list of lens flare system added to the scene
  57162. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57163. */
  57164. lensFlareSystems: Array<LensFlareSystem>;
  57165. /**
  57166. * Removes the given lens flare system from this scene.
  57167. * @param toRemove The lens flare system to remove
  57168. * @returns The index of the removed lens flare system
  57169. */
  57170. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57171. /**
  57172. * Adds the given lens flare system to this scene
  57173. * @param newLensFlareSystem The lens flare system to add
  57174. */
  57175. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57176. /**
  57177. * Gets a lens flare system using its name
  57178. * @param name defines the name to look for
  57179. * @returns the lens flare system or null if not found
  57180. */
  57181. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57182. /**
  57183. * Gets a lens flare system using its id
  57184. * @param id defines the id to look for
  57185. * @returns the lens flare system or null if not found
  57186. */
  57187. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57188. }
  57189. /**
  57190. * Defines the lens flare scene component responsible to manage any lens flares
  57191. * in a given scene.
  57192. */
  57193. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57194. /**
  57195. * The component name helpfull to identify the component in the list of scene components.
  57196. */
  57197. readonly name: string;
  57198. /**
  57199. * The scene the component belongs to.
  57200. */
  57201. scene: Scene;
  57202. /**
  57203. * Creates a new instance of the component for the given scene
  57204. * @param scene Defines the scene to register the component in
  57205. */
  57206. constructor(scene: Scene);
  57207. /**
  57208. * Registers the component in a given scene
  57209. */
  57210. register(): void;
  57211. /**
  57212. * Rebuilds the elements related to this component in case of
  57213. * context lost for instance.
  57214. */
  57215. rebuild(): void;
  57216. /**
  57217. * Adds all the elements from the container to the scene
  57218. * @param container the container holding the elements
  57219. */
  57220. addFromContainer(container: AbstractScene): void;
  57221. /**
  57222. * Removes all the elements in the container from the scene
  57223. * @param container contains the elements to remove
  57224. * @param dispose if the removed element should be disposed (default: false)
  57225. */
  57226. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57227. /**
  57228. * Serializes the component data to the specified json object
  57229. * @param serializationObject The object to serialize to
  57230. */
  57231. serialize(serializationObject: any): void;
  57232. /**
  57233. * Disposes the component and the associated ressources.
  57234. */
  57235. dispose(): void;
  57236. private _draw;
  57237. }
  57238. }
  57239. declare module BABYLON {
  57240. /** @hidden */
  57241. export var depthPixelShader: {
  57242. name: string;
  57243. shader: string;
  57244. };
  57245. }
  57246. declare module BABYLON {
  57247. /** @hidden */
  57248. export var depthVertexShader: {
  57249. name: string;
  57250. shader: string;
  57251. };
  57252. }
  57253. declare module BABYLON {
  57254. /**
  57255. * This represents a depth renderer in Babylon.
  57256. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57257. */
  57258. export class DepthRenderer {
  57259. private _scene;
  57260. private _depthMap;
  57261. private _effect;
  57262. private readonly _storeNonLinearDepth;
  57263. private readonly _clearColor;
  57264. /** Get if the depth renderer is using packed depth or not */
  57265. readonly isPacked: boolean;
  57266. private _cachedDefines;
  57267. private _camera;
  57268. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57269. enabled: boolean;
  57270. /**
  57271. * Specifiess that the depth renderer will only be used within
  57272. * the camera it is created for.
  57273. * This can help forcing its rendering during the camera processing.
  57274. */
  57275. useOnlyInActiveCamera: boolean;
  57276. /** @hidden */
  57277. static _SceneComponentInitialization: (scene: Scene) => void;
  57278. /**
  57279. * Instantiates a depth renderer
  57280. * @param scene The scene the renderer belongs to
  57281. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57282. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57283. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57284. */
  57285. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57286. /**
  57287. * Creates the depth rendering effect and checks if the effect is ready.
  57288. * @param subMesh The submesh to be used to render the depth map of
  57289. * @param useInstances If multiple world instances should be used
  57290. * @returns if the depth renderer is ready to render the depth map
  57291. */
  57292. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57293. /**
  57294. * Gets the texture which the depth map will be written to.
  57295. * @returns The depth map texture
  57296. */
  57297. getDepthMap(): RenderTargetTexture;
  57298. /**
  57299. * Disposes of the depth renderer.
  57300. */
  57301. dispose(): void;
  57302. }
  57303. }
  57304. declare module BABYLON {
  57305. /** @hidden */
  57306. export var minmaxReduxPixelShader: {
  57307. name: string;
  57308. shader: string;
  57309. };
  57310. }
  57311. declare module BABYLON {
  57312. /**
  57313. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57314. * and maximum values from all values of the texture.
  57315. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57316. * The source values are read from the red channel of the texture.
  57317. */
  57318. export class MinMaxReducer {
  57319. /**
  57320. * Observable triggered when the computation has been performed
  57321. */
  57322. onAfterReductionPerformed: Observable<{
  57323. min: number;
  57324. max: number;
  57325. }>;
  57326. protected _camera: Camera;
  57327. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57328. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57329. protected _postProcessManager: PostProcessManager;
  57330. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57331. protected _forceFullscreenViewport: boolean;
  57332. /**
  57333. * Creates a min/max reducer
  57334. * @param camera The camera to use for the post processes
  57335. */
  57336. constructor(camera: Camera);
  57337. /**
  57338. * Gets the texture used to read the values from.
  57339. */
  57340. get sourceTexture(): Nullable<RenderTargetTexture>;
  57341. /**
  57342. * Sets the source texture to read the values from.
  57343. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57344. * because in such textures '1' value must not be taken into account to compute the maximum
  57345. * as this value is used to clear the texture.
  57346. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57347. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57348. * @param depthRedux Indicates if the texture is a depth texture or not
  57349. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57350. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57351. */
  57352. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57353. /**
  57354. * Defines the refresh rate of the computation.
  57355. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57356. */
  57357. get refreshRate(): number;
  57358. set refreshRate(value: number);
  57359. protected _activated: boolean;
  57360. /**
  57361. * Gets the activation status of the reducer
  57362. */
  57363. get activated(): boolean;
  57364. /**
  57365. * Activates the reduction computation.
  57366. * When activated, the observers registered in onAfterReductionPerformed are
  57367. * called after the compuation is performed
  57368. */
  57369. activate(): void;
  57370. /**
  57371. * Deactivates the reduction computation.
  57372. */
  57373. deactivate(): void;
  57374. /**
  57375. * Disposes the min/max reducer
  57376. * @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.
  57377. */
  57378. dispose(disposeAll?: boolean): void;
  57379. }
  57380. }
  57381. declare module BABYLON {
  57382. /**
  57383. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57384. */
  57385. export class DepthReducer extends MinMaxReducer {
  57386. private _depthRenderer;
  57387. private _depthRendererId;
  57388. /**
  57389. * Gets the depth renderer used for the computation.
  57390. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57391. */
  57392. get depthRenderer(): Nullable<DepthRenderer>;
  57393. /**
  57394. * Creates a depth reducer
  57395. * @param camera The camera used to render the depth texture
  57396. */
  57397. constructor(camera: Camera);
  57398. /**
  57399. * Sets the depth renderer to use to generate the depth map
  57400. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57401. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57402. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57403. */
  57404. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57405. /** @hidden */
  57406. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57407. /**
  57408. * Activates the reduction computation.
  57409. * When activated, the observers registered in onAfterReductionPerformed are
  57410. * called after the compuation is performed
  57411. */
  57412. activate(): void;
  57413. /**
  57414. * Deactivates the reduction computation.
  57415. */
  57416. deactivate(): void;
  57417. /**
  57418. * Disposes the depth reducer
  57419. * @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.
  57420. */
  57421. dispose(disposeAll?: boolean): void;
  57422. }
  57423. }
  57424. declare module BABYLON {
  57425. /**
  57426. * A CSM implementation allowing casting shadows on large scenes.
  57427. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57428. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57429. */
  57430. export class CascadedShadowGenerator extends ShadowGenerator {
  57431. private static readonly frustumCornersNDCSpace;
  57432. /**
  57433. * Name of the CSM class
  57434. */
  57435. static CLASSNAME: string;
  57436. /**
  57437. * Defines the default number of cascades used by the CSM.
  57438. */
  57439. static readonly DEFAULT_CASCADES_COUNT: number;
  57440. /**
  57441. * Defines the minimum number of cascades used by the CSM.
  57442. */
  57443. static readonly MIN_CASCADES_COUNT: number;
  57444. /**
  57445. * Defines the maximum number of cascades used by the CSM.
  57446. */
  57447. static readonly MAX_CASCADES_COUNT: number;
  57448. protected _validateFilter(filter: number): number;
  57449. /**
  57450. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57451. */
  57452. penumbraDarkness: number;
  57453. private _numCascades;
  57454. /**
  57455. * Gets or set the number of cascades used by the CSM.
  57456. */
  57457. get numCascades(): number;
  57458. set numCascades(value: number);
  57459. /**
  57460. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57461. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  57462. */
  57463. stabilizeCascades: boolean;
  57464. private _freezeShadowCastersBoundingInfo;
  57465. private _freezeShadowCastersBoundingInfoObservable;
  57466. /**
  57467. * Enables or disables the shadow casters bounding info computation.
  57468. * If your shadow casters don't move, you can disable this feature.
  57469. * If it is enabled, the bounding box computation is done every frame.
  57470. */
  57471. get freezeShadowCastersBoundingInfo(): boolean;
  57472. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57473. private _scbiMin;
  57474. private _scbiMax;
  57475. protected _computeShadowCastersBoundingInfo(): void;
  57476. protected _shadowCastersBoundingInfo: BoundingInfo;
  57477. /**
  57478. * Gets or sets the shadow casters bounding info.
  57479. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57480. * so that the system won't overwrite the bounds you provide
  57481. */
  57482. get shadowCastersBoundingInfo(): BoundingInfo;
  57483. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57484. protected _breaksAreDirty: boolean;
  57485. protected _minDistance: number;
  57486. protected _maxDistance: number;
  57487. /**
  57488. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57489. *
  57490. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57491. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57492. * @param min minimal distance for the breaks (default to 0.)
  57493. * @param max maximal distance for the breaks (default to 1.)
  57494. */
  57495. setMinMaxDistance(min: number, max: number): void;
  57496. /** Gets the minimal distance used in the cascade break computation */
  57497. get minDistance(): number;
  57498. /** Gets the maximal distance used in the cascade break computation */
  57499. get maxDistance(): number;
  57500. /**
  57501. * Gets the class name of that object
  57502. * @returns "CascadedShadowGenerator"
  57503. */
  57504. getClassName(): string;
  57505. private _cascadeMinExtents;
  57506. private _cascadeMaxExtents;
  57507. /**
  57508. * Gets a cascade minimum extents
  57509. * @param cascadeIndex index of the cascade
  57510. * @returns the minimum cascade extents
  57511. */
  57512. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57513. /**
  57514. * Gets a cascade maximum extents
  57515. * @param cascadeIndex index of the cascade
  57516. * @returns the maximum cascade extents
  57517. */
  57518. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57519. private _cascades;
  57520. private _currentLayer;
  57521. private _viewSpaceFrustumsZ;
  57522. private _viewMatrices;
  57523. private _projectionMatrices;
  57524. private _transformMatrices;
  57525. private _transformMatricesAsArray;
  57526. private _frustumLengths;
  57527. private _lightSizeUVCorrection;
  57528. private _depthCorrection;
  57529. private _frustumCornersWorldSpace;
  57530. private _frustumCenter;
  57531. private _shadowCameraPos;
  57532. private _shadowMaxZ;
  57533. /**
  57534. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57535. * It defaults to camera.maxZ
  57536. */
  57537. get shadowMaxZ(): number;
  57538. /**
  57539. * Sets the shadow max z distance.
  57540. */
  57541. set shadowMaxZ(value: number);
  57542. protected _debug: boolean;
  57543. /**
  57544. * Gets or sets the debug flag.
  57545. * When enabled, the cascades are materialized by different colors on the screen.
  57546. */
  57547. get debug(): boolean;
  57548. set debug(dbg: boolean);
  57549. private _depthClamp;
  57550. /**
  57551. * Gets or sets the depth clamping value.
  57552. *
  57553. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57554. * to account for the shadow casters far away.
  57555. *
  57556. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57557. */
  57558. get depthClamp(): boolean;
  57559. set depthClamp(value: boolean);
  57560. private _cascadeBlendPercentage;
  57561. /**
  57562. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57563. * It defaults to 0.1 (10% blending).
  57564. */
  57565. get cascadeBlendPercentage(): number;
  57566. set cascadeBlendPercentage(value: number);
  57567. private _lambda;
  57568. /**
  57569. * Gets or set the lambda parameter.
  57570. * This parameter is used to split the camera frustum and create the cascades.
  57571. * 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.
  57572. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57573. */
  57574. get lambda(): number;
  57575. set lambda(value: number);
  57576. /**
  57577. * Gets the view matrix corresponding to a given cascade
  57578. * @param cascadeNum cascade to retrieve the view matrix from
  57579. * @returns the cascade view matrix
  57580. */
  57581. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57582. /**
  57583. * Gets the projection matrix corresponding to a given cascade
  57584. * @param cascadeNum cascade to retrieve the projection matrix from
  57585. * @returns the cascade projection matrix
  57586. */
  57587. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57588. /**
  57589. * Gets the transformation matrix corresponding to a given cascade
  57590. * @param cascadeNum cascade to retrieve the transformation matrix from
  57591. * @returns the cascade transformation matrix
  57592. */
  57593. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  57594. private _depthRenderer;
  57595. /**
  57596. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57597. *
  57598. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57599. *
  57600. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57601. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57602. * @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
  57603. */
  57604. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57605. private _depthReducer;
  57606. private _autoCalcDepthBounds;
  57607. /**
  57608. * Gets or sets the autoCalcDepthBounds property.
  57609. *
  57610. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57611. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57612. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57613. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57614. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57615. */
  57616. get autoCalcDepthBounds(): boolean;
  57617. set autoCalcDepthBounds(value: boolean);
  57618. /**
  57619. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57620. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57621. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57622. * for setting the refresh rate on the renderer yourself!
  57623. */
  57624. get autoCalcDepthBoundsRefreshRate(): number;
  57625. set autoCalcDepthBoundsRefreshRate(value: number);
  57626. /**
  57627. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57628. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  57629. * you change the camera near/far planes!
  57630. */
  57631. splitFrustum(): void;
  57632. private _splitFrustum;
  57633. private _computeMatrices;
  57634. private _computeFrustumInWorldSpace;
  57635. private _computeCascadeFrustum;
  57636. /**
  57637. * Support test.
  57638. */
  57639. static get IsSupported(): boolean;
  57640. /** @hidden */
  57641. static _SceneComponentInitialization: (scene: Scene) => void;
  57642. /**
  57643. * Creates a Cascaded Shadow Generator object.
  57644. * A ShadowGenerator is the required tool to use the shadows.
  57645. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57646. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57647. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57648. * @param light The directional light object generating the shadows.
  57649. * @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.
  57650. */
  57651. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57652. protected _initializeGenerator(): void;
  57653. protected _createTargetRenderTexture(): void;
  57654. protected _initializeShadowMap(): void;
  57655. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  57656. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  57657. /**
  57658. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57659. * @param defines Defines of the material we want to update
  57660. * @param lightIndex Index of the light in the enabled light list of the material
  57661. */
  57662. prepareDefines(defines: any, lightIndex: number): void;
  57663. /**
  57664. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57665. * defined in the generator but impacting the effect).
  57666. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57667. * @param effect The effect we are binfing the information for
  57668. */
  57669. bindShadowLight(lightIndex: string, effect: Effect): void;
  57670. /**
  57671. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57672. * (eq to view projection * shadow projection matrices)
  57673. * @returns The transform matrix used to create the shadow map
  57674. */
  57675. getTransformMatrix(): Matrix;
  57676. /**
  57677. * Disposes the ShadowGenerator.
  57678. * Returns nothing.
  57679. */
  57680. dispose(): void;
  57681. /**
  57682. * Serializes the shadow generator setup to a json object.
  57683. * @returns The serialized JSON object
  57684. */
  57685. serialize(): any;
  57686. /**
  57687. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57688. * @param parsedShadowGenerator The JSON object to parse
  57689. * @param scene The scene to create the shadow map for
  57690. * @returns The parsed shadow generator
  57691. */
  57692. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  57693. }
  57694. }
  57695. declare module BABYLON {
  57696. /**
  57697. * Defines the shadow generator component responsible to manage any shadow generators
  57698. * in a given scene.
  57699. */
  57700. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57701. /**
  57702. * The component name helpfull to identify the component in the list of scene components.
  57703. */
  57704. readonly name: string;
  57705. /**
  57706. * The scene the component belongs to.
  57707. */
  57708. scene: Scene;
  57709. /**
  57710. * Creates a new instance of the component for the given scene
  57711. * @param scene Defines the scene to register the component in
  57712. */
  57713. constructor(scene: Scene);
  57714. /**
  57715. * Registers the component in a given scene
  57716. */
  57717. register(): void;
  57718. /**
  57719. * Rebuilds the elements related to this component in case of
  57720. * context lost for instance.
  57721. */
  57722. rebuild(): void;
  57723. /**
  57724. * Serializes the component data to the specified json object
  57725. * @param serializationObject The object to serialize to
  57726. */
  57727. serialize(serializationObject: any): void;
  57728. /**
  57729. * Adds all the elements from the container to the scene
  57730. * @param container the container holding the elements
  57731. */
  57732. addFromContainer(container: AbstractScene): void;
  57733. /**
  57734. * Removes all the elements in the container from the scene
  57735. * @param container contains the elements to remove
  57736. * @param dispose if the removed element should be disposed (default: false)
  57737. */
  57738. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57739. /**
  57740. * Rebuilds the elements related to this component in case of
  57741. * context lost for instance.
  57742. */
  57743. dispose(): void;
  57744. private _gatherRenderTargets;
  57745. }
  57746. }
  57747. declare module BABYLON {
  57748. /**
  57749. * A point light is a light defined by an unique point in world space.
  57750. * The light is emitted in every direction from this point.
  57751. * A good example of a point light is a standard light bulb.
  57752. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57753. */
  57754. export class PointLight extends ShadowLight {
  57755. private _shadowAngle;
  57756. /**
  57757. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57758. * This specifies what angle the shadow will use to be created.
  57759. *
  57760. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57761. */
  57762. get shadowAngle(): number;
  57763. /**
  57764. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57765. * This specifies what angle the shadow will use to be created.
  57766. *
  57767. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57768. */
  57769. set shadowAngle(value: number);
  57770. /**
  57771. * Gets the direction if it has been set.
  57772. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57773. */
  57774. get direction(): Vector3;
  57775. /**
  57776. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57777. */
  57778. set direction(value: Vector3);
  57779. /**
  57780. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57781. * A PointLight emits the light in every direction.
  57782. * It can cast shadows.
  57783. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57784. * ```javascript
  57785. * var pointLight = new PointLight("pl", camera.position, scene);
  57786. * ```
  57787. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57788. * @param name The light friendly name
  57789. * @param position The position of the point light in the scene
  57790. * @param scene The scene the lights belongs to
  57791. */
  57792. constructor(name: string, position: Vector3, scene: Scene);
  57793. /**
  57794. * Returns the string "PointLight"
  57795. * @returns the class name
  57796. */
  57797. getClassName(): string;
  57798. /**
  57799. * Returns the integer 0.
  57800. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57801. */
  57802. getTypeID(): number;
  57803. /**
  57804. * Specifies wether or not the shadowmap should be a cube texture.
  57805. * @returns true if the shadowmap needs to be a cube texture.
  57806. */
  57807. needCube(): boolean;
  57808. /**
  57809. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57810. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57811. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57812. */
  57813. getShadowDirection(faceIndex?: number): Vector3;
  57814. /**
  57815. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57816. * - fov = PI / 2
  57817. * - aspect ratio : 1.0
  57818. * - z-near and far equal to the active camera minZ and maxZ.
  57819. * Returns the PointLight.
  57820. */
  57821. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57822. protected _buildUniformLayout(): void;
  57823. /**
  57824. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57825. * @param effect The effect to update
  57826. * @param lightIndex The index of the light in the effect to update
  57827. * @returns The point light
  57828. */
  57829. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57830. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57831. /**
  57832. * Prepares the list of defines specific to the light type.
  57833. * @param defines the list of defines
  57834. * @param lightIndex defines the index of the light for the effect
  57835. */
  57836. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57837. }
  57838. }
  57839. declare module BABYLON {
  57840. /**
  57841. * Header information of HDR texture files.
  57842. */
  57843. export interface HDRInfo {
  57844. /**
  57845. * The height of the texture in pixels.
  57846. */
  57847. height: number;
  57848. /**
  57849. * The width of the texture in pixels.
  57850. */
  57851. width: number;
  57852. /**
  57853. * The index of the beginning of the data in the binary file.
  57854. */
  57855. dataPosition: number;
  57856. }
  57857. /**
  57858. * This groups tools to convert HDR texture to native colors array.
  57859. */
  57860. export class HDRTools {
  57861. private static Ldexp;
  57862. private static Rgbe2float;
  57863. private static readStringLine;
  57864. /**
  57865. * Reads header information from an RGBE texture stored in a native array.
  57866. * More information on this format are available here:
  57867. * https://en.wikipedia.org/wiki/RGBE_image_format
  57868. *
  57869. * @param uint8array The binary file stored in native array.
  57870. * @return The header information.
  57871. */
  57872. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57873. /**
  57874. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57875. * This RGBE texture needs to store the information as a panorama.
  57876. *
  57877. * More information on this format are available here:
  57878. * https://en.wikipedia.org/wiki/RGBE_image_format
  57879. *
  57880. * @param buffer The binary file stored in an array buffer.
  57881. * @param size The expected size of the extracted cubemap.
  57882. * @return The Cube Map information.
  57883. */
  57884. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57885. /**
  57886. * Returns the pixels data extracted from an RGBE texture.
  57887. * This pixels will be stored left to right up to down in the R G B order in one array.
  57888. *
  57889. * More information on this format are available here:
  57890. * https://en.wikipedia.org/wiki/RGBE_image_format
  57891. *
  57892. * @param uint8array The binary file stored in an array buffer.
  57893. * @param hdrInfo The header information of the file.
  57894. * @return The pixels data in RGB right to left up to down order.
  57895. */
  57896. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57897. private static RGBE_ReadPixels_RLE;
  57898. }
  57899. }
  57900. declare module BABYLON {
  57901. /**
  57902. * Effect Render Options
  57903. */
  57904. export interface IEffectRendererOptions {
  57905. /**
  57906. * Defines the vertices positions.
  57907. */
  57908. positions?: number[];
  57909. /**
  57910. * Defines the indices.
  57911. */
  57912. indices?: number[];
  57913. }
  57914. /**
  57915. * Helper class to render one or more effects.
  57916. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  57917. */
  57918. export class EffectRenderer {
  57919. private engine;
  57920. private static _DefaultOptions;
  57921. private _vertexBuffers;
  57922. private _indexBuffer;
  57923. private _fullscreenViewport;
  57924. /**
  57925. * Creates an effect renderer
  57926. * @param engine the engine to use for rendering
  57927. * @param options defines the options of the effect renderer
  57928. */
  57929. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  57930. /**
  57931. * Sets the current viewport in normalized coordinates 0-1
  57932. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57933. */
  57934. setViewport(viewport?: Viewport): void;
  57935. /**
  57936. * Binds the embedded attributes buffer to the effect.
  57937. * @param effect Defines the effect to bind the attributes for
  57938. */
  57939. bindBuffers(effect: Effect): void;
  57940. /**
  57941. * Sets the current effect wrapper to use during draw.
  57942. * The effect needs to be ready before calling this api.
  57943. * This also sets the default full screen position attribute.
  57944. * @param effectWrapper Defines the effect to draw with
  57945. */
  57946. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57947. /**
  57948. * Restores engine states
  57949. */
  57950. restoreStates(): void;
  57951. /**
  57952. * Draws a full screen quad.
  57953. */
  57954. draw(): void;
  57955. private isRenderTargetTexture;
  57956. /**
  57957. * renders one or more effects to a specified texture
  57958. * @param effectWrapper the effect to renderer
  57959. * @param outputTexture texture to draw to, if null it will render to the screen.
  57960. */
  57961. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  57962. /**
  57963. * Disposes of the effect renderer
  57964. */
  57965. dispose(): void;
  57966. }
  57967. /**
  57968. * Options to create an EffectWrapper
  57969. */
  57970. interface EffectWrapperCreationOptions {
  57971. /**
  57972. * Engine to use to create the effect
  57973. */
  57974. engine: ThinEngine;
  57975. /**
  57976. * Fragment shader for the effect
  57977. */
  57978. fragmentShader: string;
  57979. /**
  57980. * Use the shader store instead of direct source code
  57981. */
  57982. useShaderStore?: boolean;
  57983. /**
  57984. * Vertex shader for the effect
  57985. */
  57986. vertexShader?: string;
  57987. /**
  57988. * Attributes to use in the shader
  57989. */
  57990. attributeNames?: Array<string>;
  57991. /**
  57992. * Uniforms to use in the shader
  57993. */
  57994. uniformNames?: Array<string>;
  57995. /**
  57996. * Texture sampler names to use in the shader
  57997. */
  57998. samplerNames?: Array<string>;
  57999. /**
  58000. * Defines to use in the shader
  58001. */
  58002. defines?: Array<string>;
  58003. /**
  58004. * Callback when effect is compiled
  58005. */
  58006. onCompiled?: Nullable<(effect: Effect) => void>;
  58007. /**
  58008. * The friendly name of the effect displayed in Spector.
  58009. */
  58010. name?: string;
  58011. }
  58012. /**
  58013. * Wraps an effect to be used for rendering
  58014. */
  58015. export class EffectWrapper {
  58016. /**
  58017. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58018. */
  58019. onApplyObservable: Observable<{}>;
  58020. /**
  58021. * The underlying effect
  58022. */
  58023. effect: Effect;
  58024. /**
  58025. * Creates an effect to be renderer
  58026. * @param creationOptions options to create the effect
  58027. */
  58028. constructor(creationOptions: EffectWrapperCreationOptions);
  58029. /**
  58030. * Disposes of the effect wrapper
  58031. */
  58032. dispose(): void;
  58033. }
  58034. }
  58035. declare module BABYLON {
  58036. /** @hidden */
  58037. export var hdrFilteringVertexShader: {
  58038. name: string;
  58039. shader: string;
  58040. };
  58041. }
  58042. declare module BABYLON {
  58043. /** @hidden */
  58044. export var hdrFilteringPixelShader: {
  58045. name: string;
  58046. shader: string;
  58047. };
  58048. }
  58049. declare module BABYLON {
  58050. /**
  58051. * Options for texture filtering
  58052. */
  58053. interface IHDRFilteringOptions {
  58054. /**
  58055. * Scales pixel intensity for the input HDR map.
  58056. */
  58057. hdrScale?: number;
  58058. /**
  58059. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58060. */
  58061. quality?: number;
  58062. }
  58063. /**
  58064. * Filters HDR maps to get correct renderings of PBR reflections
  58065. */
  58066. export class HDRFiltering {
  58067. private _engine;
  58068. private _effectRenderer;
  58069. private _effectWrapper;
  58070. private _lodGenerationOffset;
  58071. private _lodGenerationScale;
  58072. /**
  58073. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58074. * you care about baking speed.
  58075. */
  58076. quality: number;
  58077. /**
  58078. * Scales pixel intensity for the input HDR map.
  58079. */
  58080. hdrScale: number;
  58081. /**
  58082. * Instantiates HDR filter for reflection maps
  58083. *
  58084. * @param engine Thin engine
  58085. * @param options Options
  58086. */
  58087. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58088. private _createRenderTarget;
  58089. private _prefilterInternal;
  58090. private _createEffect;
  58091. /**
  58092. * Get a value indicating if the filter is ready to be used
  58093. * @param texture Texture to filter
  58094. * @returns true if the filter is ready
  58095. */
  58096. isReady(texture: BaseTexture): boolean;
  58097. /**
  58098. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58099. * Prefiltering will be invoked at the end of next rendering pass.
  58100. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58101. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58102. * @param texture Texture to filter
  58103. * @param onFinished Callback when filtering is done
  58104. * @return Promise called when prefiltering is done
  58105. */
  58106. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown>;
  58107. }
  58108. }
  58109. declare module BABYLON {
  58110. /**
  58111. * This represents a texture coming from an HDR input.
  58112. *
  58113. * The only supported format is currently panorama picture stored in RGBE format.
  58114. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58115. */
  58116. export class HDRCubeTexture extends BaseTexture {
  58117. private static _facesMapping;
  58118. private _generateHarmonics;
  58119. private _noMipmap;
  58120. private _prefilterOnLoad;
  58121. private _textureMatrix;
  58122. private _size;
  58123. private _onLoad;
  58124. private _onError;
  58125. /**
  58126. * The texture URL.
  58127. */
  58128. url: string;
  58129. /**
  58130. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58131. */
  58132. coordinatesMode: number;
  58133. protected _isBlocking: boolean;
  58134. /**
  58135. * Sets wether or not the texture is blocking during loading.
  58136. */
  58137. set isBlocking(value: boolean);
  58138. /**
  58139. * Gets wether or not the texture is blocking during loading.
  58140. */
  58141. get isBlocking(): boolean;
  58142. protected _rotationY: number;
  58143. /**
  58144. * Sets texture matrix rotation angle around Y axis in radians.
  58145. */
  58146. set rotationY(value: number);
  58147. /**
  58148. * Gets texture matrix rotation angle around Y axis radians.
  58149. */
  58150. get rotationY(): number;
  58151. /**
  58152. * Gets or sets the center of the bounding box associated with the cube texture
  58153. * It must define where the camera used to render the texture was set
  58154. */
  58155. boundingBoxPosition: Vector3;
  58156. private _boundingBoxSize;
  58157. /**
  58158. * Gets or sets the size of the bounding box associated with the cube texture
  58159. * When defined, the cubemap will switch to local mode
  58160. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58161. * @example https://www.babylonjs-playground.com/#RNASML
  58162. */
  58163. set boundingBoxSize(value: Vector3);
  58164. get boundingBoxSize(): Vector3;
  58165. /**
  58166. * Instantiates an HDRTexture from the following parameters.
  58167. *
  58168. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58169. * @param sceneOrEngine The scene or engine the texture will be used in
  58170. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58171. * @param noMipmap Forces to not generate the mipmap if true
  58172. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58173. * @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)
  58174. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  58175. */
  58176. 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>);
  58177. /**
  58178. * Get the current class name of the texture useful for serialization or dynamic coding.
  58179. * @returns "HDRCubeTexture"
  58180. */
  58181. getClassName(): string;
  58182. /**
  58183. * Occurs when the file is raw .hdr file.
  58184. */
  58185. private loadTexture;
  58186. clone(): HDRCubeTexture;
  58187. delayLoad(): void;
  58188. /**
  58189. * Get the texture reflection matrix used to rotate/transform the reflection.
  58190. * @returns the reflection matrix
  58191. */
  58192. getReflectionTextureMatrix(): Matrix;
  58193. /**
  58194. * Set the texture reflection matrix used to rotate/transform the reflection.
  58195. * @param value Define the reflection matrix to set
  58196. */
  58197. setReflectionTextureMatrix(value: Matrix): void;
  58198. /**
  58199. * Parses a JSON representation of an HDR Texture in order to create the texture
  58200. * @param parsedTexture Define the JSON representation
  58201. * @param scene Define the scene the texture should be created in
  58202. * @param rootUrl Define the root url in case we need to load relative dependencies
  58203. * @returns the newly created texture after parsing
  58204. */
  58205. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58206. serialize(): any;
  58207. }
  58208. }
  58209. declare module BABYLON {
  58210. /**
  58211. * Class used to control physics engine
  58212. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58213. */
  58214. export class PhysicsEngine implements IPhysicsEngine {
  58215. private _physicsPlugin;
  58216. /**
  58217. * Global value used to control the smallest number supported by the simulation
  58218. */
  58219. static Epsilon: number;
  58220. private _impostors;
  58221. private _joints;
  58222. private _subTimeStep;
  58223. /**
  58224. * Gets the gravity vector used by the simulation
  58225. */
  58226. gravity: Vector3;
  58227. /**
  58228. * Factory used to create the default physics plugin.
  58229. * @returns The default physics plugin
  58230. */
  58231. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58232. /**
  58233. * Creates a new Physics Engine
  58234. * @param gravity defines the gravity vector used by the simulation
  58235. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58236. */
  58237. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58238. /**
  58239. * Sets the gravity vector used by the simulation
  58240. * @param gravity defines the gravity vector to use
  58241. */
  58242. setGravity(gravity: Vector3): void;
  58243. /**
  58244. * Set the time step of the physics engine.
  58245. * Default is 1/60.
  58246. * To slow it down, enter 1/600 for example.
  58247. * To speed it up, 1/30
  58248. * @param newTimeStep defines the new timestep to apply to this world.
  58249. */
  58250. setTimeStep(newTimeStep?: number): void;
  58251. /**
  58252. * Get the time step of the physics engine.
  58253. * @returns the current time step
  58254. */
  58255. getTimeStep(): number;
  58256. /**
  58257. * Set the sub time step of the physics engine.
  58258. * Default is 0 meaning there is no sub steps
  58259. * To increase physics resolution precision, set a small value (like 1 ms)
  58260. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58261. */
  58262. setSubTimeStep(subTimeStep?: number): void;
  58263. /**
  58264. * Get the sub time step of the physics engine.
  58265. * @returns the current sub time step
  58266. */
  58267. getSubTimeStep(): number;
  58268. /**
  58269. * Release all resources
  58270. */
  58271. dispose(): void;
  58272. /**
  58273. * Gets the name of the current physics plugin
  58274. * @returns the name of the plugin
  58275. */
  58276. getPhysicsPluginName(): string;
  58277. /**
  58278. * Adding a new impostor for the impostor tracking.
  58279. * This will be done by the impostor itself.
  58280. * @param impostor the impostor to add
  58281. */
  58282. addImpostor(impostor: PhysicsImpostor): void;
  58283. /**
  58284. * Remove an impostor from the engine.
  58285. * This impostor and its mesh will not longer be updated by the physics engine.
  58286. * @param impostor the impostor to remove
  58287. */
  58288. removeImpostor(impostor: PhysicsImpostor): void;
  58289. /**
  58290. * Add a joint to the physics engine
  58291. * @param mainImpostor defines the main impostor to which the joint is added.
  58292. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  58293. * @param joint defines the joint that will connect both impostors.
  58294. */
  58295. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58296. /**
  58297. * Removes a joint from the simulation
  58298. * @param mainImpostor defines the impostor used with the joint
  58299. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  58300. * @param joint defines the joint to remove
  58301. */
  58302. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58303. /**
  58304. * Called by the scene. No need to call it.
  58305. * @param delta defines the timespam between frames
  58306. */
  58307. _step(delta: number): void;
  58308. /**
  58309. * Gets the current plugin used to run the simulation
  58310. * @returns current plugin
  58311. */
  58312. getPhysicsPlugin(): IPhysicsEnginePlugin;
  58313. /**
  58314. * Gets the list of physic impostors
  58315. * @returns an array of PhysicsImpostor
  58316. */
  58317. getImpostors(): Array<PhysicsImpostor>;
  58318. /**
  58319. * Gets the impostor for a physics enabled object
  58320. * @param object defines the object impersonated by the impostor
  58321. * @returns the PhysicsImpostor or null if not found
  58322. */
  58323. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  58324. /**
  58325. * Gets the impostor for a physics body object
  58326. * @param body defines physics body used by the impostor
  58327. * @returns the PhysicsImpostor or null if not found
  58328. */
  58329. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  58330. /**
  58331. * Does a raycast in the physics world
  58332. * @param from when should the ray start?
  58333. * @param to when should the ray end?
  58334. * @returns PhysicsRaycastResult
  58335. */
  58336. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58337. }
  58338. }
  58339. declare module BABYLON {
  58340. /** @hidden */
  58341. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  58342. private _useDeltaForWorldStep;
  58343. world: any;
  58344. name: string;
  58345. private _physicsMaterials;
  58346. private _fixedTimeStep;
  58347. private _cannonRaycastResult;
  58348. private _raycastResult;
  58349. private _physicsBodysToRemoveAfterStep;
  58350. BJSCANNON: any;
  58351. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  58352. setGravity(gravity: Vector3): void;
  58353. setTimeStep(timeStep: number): void;
  58354. getTimeStep(): number;
  58355. executeStep(delta: number): void;
  58356. private _removeMarkedPhysicsBodiesFromWorld;
  58357. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58358. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58359. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58360. private _processChildMeshes;
  58361. removePhysicsBody(impostor: PhysicsImpostor): void;
  58362. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58363. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58364. private _addMaterial;
  58365. private _checkWithEpsilon;
  58366. private _createShape;
  58367. private _createHeightmap;
  58368. private _minus90X;
  58369. private _plus90X;
  58370. private _tmpPosition;
  58371. private _tmpDeltaPosition;
  58372. private _tmpUnityRotation;
  58373. private _updatePhysicsBodyTransformation;
  58374. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58375. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58376. isSupported(): boolean;
  58377. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58378. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58379. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58380. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58381. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58382. getBodyMass(impostor: PhysicsImpostor): number;
  58383. getBodyFriction(impostor: PhysicsImpostor): number;
  58384. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58385. getBodyRestitution(impostor: PhysicsImpostor): number;
  58386. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58387. sleepBody(impostor: PhysicsImpostor): void;
  58388. wakeUpBody(impostor: PhysicsImpostor): void;
  58389. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  58390. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58391. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58392. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58393. getRadius(impostor: PhysicsImpostor): number;
  58394. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58395. dispose(): void;
  58396. private _extendNamespace;
  58397. /**
  58398. * Does a raycast in the physics world
  58399. * @param from when should the ray start?
  58400. * @param to when should the ray end?
  58401. * @returns PhysicsRaycastResult
  58402. */
  58403. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58404. }
  58405. }
  58406. declare module BABYLON {
  58407. /** @hidden */
  58408. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  58409. private _useDeltaForWorldStep;
  58410. world: any;
  58411. name: string;
  58412. BJSOIMO: any;
  58413. private _raycastResult;
  58414. private _fixedTimeStep;
  58415. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  58416. setGravity(gravity: Vector3): void;
  58417. setTimeStep(timeStep: number): void;
  58418. getTimeStep(): number;
  58419. private _tmpImpostorsArray;
  58420. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58421. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58422. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58423. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58424. private _tmpPositionVector;
  58425. removePhysicsBody(impostor: PhysicsImpostor): void;
  58426. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58427. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58428. isSupported(): boolean;
  58429. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58430. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58431. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58432. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58433. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58434. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58435. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58436. getBodyMass(impostor: PhysicsImpostor): number;
  58437. getBodyFriction(impostor: PhysicsImpostor): number;
  58438. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58439. getBodyRestitution(impostor: PhysicsImpostor): number;
  58440. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58441. sleepBody(impostor: PhysicsImpostor): void;
  58442. wakeUpBody(impostor: PhysicsImpostor): void;
  58443. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58444. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58445. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58446. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58447. getRadius(impostor: PhysicsImpostor): number;
  58448. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58449. dispose(): void;
  58450. /**
  58451. * Does a raycast in the physics world
  58452. * @param from when should the ray start?
  58453. * @param to when should the ray end?
  58454. * @returns PhysicsRaycastResult
  58455. */
  58456. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58457. }
  58458. }
  58459. declare module BABYLON {
  58460. /**
  58461. * Class containing static functions to help procedurally build meshes
  58462. */
  58463. export class RibbonBuilder {
  58464. /**
  58465. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58466. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58467. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58468. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58469. * * 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
  58470. * * 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
  58471. * * 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
  58472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58473. * * 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
  58474. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58475. * * 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
  58476. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58477. * * 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
  58478. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58480. * @param name defines the name of the mesh
  58481. * @param options defines the options used to create the mesh
  58482. * @param scene defines the hosting scene
  58483. * @returns the ribbon mesh
  58484. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58485. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58486. */
  58487. static CreateRibbon(name: string, options: {
  58488. pathArray: Vector3[][];
  58489. closeArray?: boolean;
  58490. closePath?: boolean;
  58491. offset?: number;
  58492. updatable?: boolean;
  58493. sideOrientation?: number;
  58494. frontUVs?: Vector4;
  58495. backUVs?: Vector4;
  58496. instance?: Mesh;
  58497. invertUV?: boolean;
  58498. uvs?: Vector2[];
  58499. colors?: Color4[];
  58500. }, scene?: Nullable<Scene>): Mesh;
  58501. }
  58502. }
  58503. declare module BABYLON {
  58504. /**
  58505. * Class containing static functions to help procedurally build meshes
  58506. */
  58507. export class ShapeBuilder {
  58508. /**
  58509. * 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.
  58510. * * 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.
  58511. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58512. * * 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.
  58513. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58514. * * 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
  58515. * * 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
  58516. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58518. * * 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
  58519. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58521. * @param name defines the name of the mesh
  58522. * @param options defines the options used to create the mesh
  58523. * @param scene defines the hosting scene
  58524. * @returns the extruded shape mesh
  58525. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58526. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58527. */
  58528. static ExtrudeShape(name: string, options: {
  58529. shape: Vector3[];
  58530. path: Vector3[];
  58531. scale?: number;
  58532. rotation?: number;
  58533. cap?: number;
  58534. updatable?: boolean;
  58535. sideOrientation?: number;
  58536. frontUVs?: Vector4;
  58537. backUVs?: Vector4;
  58538. instance?: Mesh;
  58539. invertUV?: boolean;
  58540. }, scene?: Nullable<Scene>): Mesh;
  58541. /**
  58542. * Creates an custom extruded shape mesh.
  58543. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58544. * * 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.
  58545. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58546. * * 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
  58547. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58548. * * 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
  58549. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58550. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58551. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58552. * * 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
  58553. * * 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
  58554. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58556. * * 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
  58557. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58559. * @param name defines the name of the mesh
  58560. * @param options defines the options used to create the mesh
  58561. * @param scene defines the hosting scene
  58562. * @returns the custom extruded shape mesh
  58563. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58564. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58565. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58566. */
  58567. static ExtrudeShapeCustom(name: string, options: {
  58568. shape: Vector3[];
  58569. path: Vector3[];
  58570. scaleFunction?: any;
  58571. rotationFunction?: any;
  58572. ribbonCloseArray?: boolean;
  58573. ribbonClosePath?: boolean;
  58574. cap?: number;
  58575. updatable?: boolean;
  58576. sideOrientation?: number;
  58577. frontUVs?: Vector4;
  58578. backUVs?: Vector4;
  58579. instance?: Mesh;
  58580. invertUV?: boolean;
  58581. }, scene?: Nullable<Scene>): Mesh;
  58582. private static _ExtrudeShapeGeneric;
  58583. }
  58584. }
  58585. declare module BABYLON {
  58586. /**
  58587. * AmmoJS Physics plugin
  58588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  58589. * @see https://github.com/kripken/ammo.js/
  58590. */
  58591. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  58592. private _useDeltaForWorldStep;
  58593. /**
  58594. * Reference to the Ammo library
  58595. */
  58596. bjsAMMO: any;
  58597. /**
  58598. * Created ammoJS world which physics bodies are added to
  58599. */
  58600. world: any;
  58601. /**
  58602. * Name of the plugin
  58603. */
  58604. name: string;
  58605. private _timeStep;
  58606. private _fixedTimeStep;
  58607. private _maxSteps;
  58608. private _tmpQuaternion;
  58609. private _tmpAmmoTransform;
  58610. private _tmpAmmoQuaternion;
  58611. private _tmpAmmoConcreteContactResultCallback;
  58612. private _collisionConfiguration;
  58613. private _dispatcher;
  58614. private _overlappingPairCache;
  58615. private _solver;
  58616. private _softBodySolver;
  58617. private _tmpAmmoVectorA;
  58618. private _tmpAmmoVectorB;
  58619. private _tmpAmmoVectorC;
  58620. private _tmpAmmoVectorD;
  58621. private _tmpContactCallbackResult;
  58622. private _tmpAmmoVectorRCA;
  58623. private _tmpAmmoVectorRCB;
  58624. private _raycastResult;
  58625. private static readonly DISABLE_COLLISION_FLAG;
  58626. private static readonly KINEMATIC_FLAG;
  58627. private static readonly DISABLE_DEACTIVATION_FLAG;
  58628. /**
  58629. * Initializes the ammoJS plugin
  58630. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  58631. * @param ammoInjection can be used to inject your own ammo reference
  58632. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  58633. */
  58634. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  58635. /**
  58636. * Sets the gravity of the physics world (m/(s^2))
  58637. * @param gravity Gravity to set
  58638. */
  58639. setGravity(gravity: Vector3): void;
  58640. /**
  58641. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  58642. * @param timeStep timestep to use in seconds
  58643. */
  58644. setTimeStep(timeStep: number): void;
  58645. /**
  58646. * 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)
  58647. * @param fixedTimeStep fixedTimeStep to use in seconds
  58648. */
  58649. setFixedTimeStep(fixedTimeStep: number): void;
  58650. /**
  58651. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  58652. * @param maxSteps the maximum number of steps by the physics engine per frame
  58653. */
  58654. setMaxSteps(maxSteps: number): void;
  58655. /**
  58656. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  58657. * @returns the current timestep in seconds
  58658. */
  58659. getTimeStep(): number;
  58660. /**
  58661. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  58662. */
  58663. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  58664. private _isImpostorInContact;
  58665. private _isImpostorPairInContact;
  58666. private _stepSimulation;
  58667. /**
  58668. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  58669. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  58670. * After the step the babylon meshes are set to the position of the physics imposters
  58671. * @param delta amount of time to step forward
  58672. * @param impostors array of imposters to update before/after the step
  58673. */
  58674. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58675. /**
  58676. * Update babylon mesh to match physics world object
  58677. * @param impostor imposter to match
  58678. */
  58679. private _afterSoftStep;
  58680. /**
  58681. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58682. * @param impostor imposter to match
  58683. */
  58684. private _ropeStep;
  58685. /**
  58686. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58687. * @param impostor imposter to match
  58688. */
  58689. private _softbodyOrClothStep;
  58690. private _tmpMatrix;
  58691. /**
  58692. * Applies an impulse on the imposter
  58693. * @param impostor imposter to apply impulse to
  58694. * @param force amount of force to be applied to the imposter
  58695. * @param contactPoint the location to apply the impulse on the imposter
  58696. */
  58697. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58698. /**
  58699. * Applies a force on the imposter
  58700. * @param impostor imposter to apply force
  58701. * @param force amount of force to be applied to the imposter
  58702. * @param contactPoint the location to apply the force on the imposter
  58703. */
  58704. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58705. /**
  58706. * Creates a physics body using the plugin
  58707. * @param impostor the imposter to create the physics body on
  58708. */
  58709. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58710. /**
  58711. * Removes the physics body from the imposter and disposes of the body's memory
  58712. * @param impostor imposter to remove the physics body from
  58713. */
  58714. removePhysicsBody(impostor: PhysicsImpostor): void;
  58715. /**
  58716. * Generates a joint
  58717. * @param impostorJoint the imposter joint to create the joint with
  58718. */
  58719. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58720. /**
  58721. * Removes a joint
  58722. * @param impostorJoint the imposter joint to remove the joint from
  58723. */
  58724. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58725. private _addMeshVerts;
  58726. /**
  58727. * Initialise the soft body vertices to match its object's (mesh) vertices
  58728. * Softbody vertices (nodes) are in world space and to match this
  58729. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  58730. * @param impostor to create the softbody for
  58731. */
  58732. private _softVertexData;
  58733. /**
  58734. * Create an impostor's soft body
  58735. * @param impostor to create the softbody for
  58736. */
  58737. private _createSoftbody;
  58738. /**
  58739. * Create cloth for an impostor
  58740. * @param impostor to create the softbody for
  58741. */
  58742. private _createCloth;
  58743. /**
  58744. * Create rope for an impostor
  58745. * @param impostor to create the softbody for
  58746. */
  58747. private _createRope;
  58748. /**
  58749. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  58750. * @param impostor to create the custom physics shape for
  58751. */
  58752. private _createCustom;
  58753. private _addHullVerts;
  58754. private _createShape;
  58755. /**
  58756. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  58757. * @param impostor imposter containing the physics body and babylon object
  58758. */
  58759. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58760. /**
  58761. * Sets the babylon object's position/rotation from the physics body's position/rotation
  58762. * @param impostor imposter containing the physics body and babylon object
  58763. * @param newPosition new position
  58764. * @param newRotation new rotation
  58765. */
  58766. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58767. /**
  58768. * If this plugin is supported
  58769. * @returns true if its supported
  58770. */
  58771. isSupported(): boolean;
  58772. /**
  58773. * Sets the linear velocity of the physics body
  58774. * @param impostor imposter to set the velocity on
  58775. * @param velocity velocity to set
  58776. */
  58777. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58778. /**
  58779. * Sets the angular velocity of the physics body
  58780. * @param impostor imposter to set the velocity on
  58781. * @param velocity velocity to set
  58782. */
  58783. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58784. /**
  58785. * gets the linear velocity
  58786. * @param impostor imposter to get linear velocity from
  58787. * @returns linear velocity
  58788. */
  58789. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58790. /**
  58791. * gets the angular velocity
  58792. * @param impostor imposter to get angular velocity from
  58793. * @returns angular velocity
  58794. */
  58795. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58796. /**
  58797. * Sets the mass of physics body
  58798. * @param impostor imposter to set the mass on
  58799. * @param mass mass to set
  58800. */
  58801. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58802. /**
  58803. * Gets the mass of the physics body
  58804. * @param impostor imposter to get the mass from
  58805. * @returns mass
  58806. */
  58807. getBodyMass(impostor: PhysicsImpostor): number;
  58808. /**
  58809. * Gets friction of the impostor
  58810. * @param impostor impostor to get friction from
  58811. * @returns friction value
  58812. */
  58813. getBodyFriction(impostor: PhysicsImpostor): number;
  58814. /**
  58815. * Sets friction of the impostor
  58816. * @param impostor impostor to set friction on
  58817. * @param friction friction value
  58818. */
  58819. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58820. /**
  58821. * Gets restitution of the impostor
  58822. * @param impostor impostor to get restitution from
  58823. * @returns restitution value
  58824. */
  58825. getBodyRestitution(impostor: PhysicsImpostor): number;
  58826. /**
  58827. * Sets resitution of the impostor
  58828. * @param impostor impostor to set resitution on
  58829. * @param restitution resitution value
  58830. */
  58831. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58832. /**
  58833. * Gets pressure inside the impostor
  58834. * @param impostor impostor to get pressure from
  58835. * @returns pressure value
  58836. */
  58837. getBodyPressure(impostor: PhysicsImpostor): number;
  58838. /**
  58839. * Sets pressure inside a soft body impostor
  58840. * Cloth and rope must remain 0 pressure
  58841. * @param impostor impostor to set pressure on
  58842. * @param pressure pressure value
  58843. */
  58844. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58845. /**
  58846. * Gets stiffness of the impostor
  58847. * @param impostor impostor to get stiffness from
  58848. * @returns pressure value
  58849. */
  58850. getBodyStiffness(impostor: PhysicsImpostor): number;
  58851. /**
  58852. * Sets stiffness of the impostor
  58853. * @param impostor impostor to set stiffness on
  58854. * @param stiffness stiffness value from 0 to 1
  58855. */
  58856. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58857. /**
  58858. * Gets velocityIterations of the impostor
  58859. * @param impostor impostor to get velocity iterations from
  58860. * @returns velocityIterations value
  58861. */
  58862. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58863. /**
  58864. * Sets velocityIterations of the impostor
  58865. * @param impostor impostor to set velocity iterations on
  58866. * @param velocityIterations velocityIterations value
  58867. */
  58868. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58869. /**
  58870. * Gets positionIterations of the impostor
  58871. * @param impostor impostor to get position iterations from
  58872. * @returns positionIterations value
  58873. */
  58874. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58875. /**
  58876. * Sets positionIterations of the impostor
  58877. * @param impostor impostor to set position on
  58878. * @param positionIterations positionIterations value
  58879. */
  58880. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58881. /**
  58882. * Append an anchor to a cloth object
  58883. * @param impostor is the cloth impostor to add anchor to
  58884. * @param otherImpostor is the rigid impostor to anchor to
  58885. * @param width ratio across width from 0 to 1
  58886. * @param height ratio up height from 0 to 1
  58887. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58888. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58889. */
  58890. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58891. /**
  58892. * Append an hook to a rope object
  58893. * @param impostor is the rope impostor to add hook to
  58894. * @param otherImpostor is the rigid impostor to hook to
  58895. * @param length ratio along the rope from 0 to 1
  58896. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58897. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58898. */
  58899. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58900. /**
  58901. * Sleeps the physics body and stops it from being active
  58902. * @param impostor impostor to sleep
  58903. */
  58904. sleepBody(impostor: PhysicsImpostor): void;
  58905. /**
  58906. * Activates the physics body
  58907. * @param impostor impostor to activate
  58908. */
  58909. wakeUpBody(impostor: PhysicsImpostor): void;
  58910. /**
  58911. * Updates the distance parameters of the joint
  58912. * @param joint joint to update
  58913. * @param maxDistance maximum distance of the joint
  58914. * @param minDistance minimum distance of the joint
  58915. */
  58916. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58917. /**
  58918. * Sets a motor on the joint
  58919. * @param joint joint to set motor on
  58920. * @param speed speed of the motor
  58921. * @param maxForce maximum force of the motor
  58922. * @param motorIndex index of the motor
  58923. */
  58924. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58925. /**
  58926. * Sets the motors limit
  58927. * @param joint joint to set limit on
  58928. * @param upperLimit upper limit
  58929. * @param lowerLimit lower limit
  58930. */
  58931. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58932. /**
  58933. * Syncs the position and rotation of a mesh with the impostor
  58934. * @param mesh mesh to sync
  58935. * @param impostor impostor to update the mesh with
  58936. */
  58937. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58938. /**
  58939. * Gets the radius of the impostor
  58940. * @param impostor impostor to get radius from
  58941. * @returns the radius
  58942. */
  58943. getRadius(impostor: PhysicsImpostor): number;
  58944. /**
  58945. * Gets the box size of the impostor
  58946. * @param impostor impostor to get box size from
  58947. * @param result the resulting box size
  58948. */
  58949. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58950. /**
  58951. * Disposes of the impostor
  58952. */
  58953. dispose(): void;
  58954. /**
  58955. * Does a raycast in the physics world
  58956. * @param from when should the ray start?
  58957. * @param to when should the ray end?
  58958. * @returns PhysicsRaycastResult
  58959. */
  58960. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58961. }
  58962. }
  58963. declare module BABYLON {
  58964. interface AbstractScene {
  58965. /**
  58966. * The list of reflection probes added to the scene
  58967. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58968. */
  58969. reflectionProbes: Array<ReflectionProbe>;
  58970. /**
  58971. * Removes the given reflection probe from this scene.
  58972. * @param toRemove The reflection probe to remove
  58973. * @returns The index of the removed reflection probe
  58974. */
  58975. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58976. /**
  58977. * Adds the given reflection probe to this scene.
  58978. * @param newReflectionProbe The reflection probe to add
  58979. */
  58980. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58981. }
  58982. /**
  58983. * Class used to generate realtime reflection / refraction cube textures
  58984. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58985. */
  58986. export class ReflectionProbe {
  58987. /** defines the name of the probe */
  58988. name: string;
  58989. private _scene;
  58990. private _renderTargetTexture;
  58991. private _projectionMatrix;
  58992. private _viewMatrix;
  58993. private _target;
  58994. private _add;
  58995. private _attachedMesh;
  58996. private _invertYAxis;
  58997. /** Gets or sets probe position (center of the cube map) */
  58998. position: Vector3;
  58999. /**
  59000. * Creates a new reflection probe
  59001. * @param name defines the name of the probe
  59002. * @param size defines the texture resolution (for each face)
  59003. * @param scene defines the hosting scene
  59004. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59005. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59006. */
  59007. constructor(
  59008. /** defines the name of the probe */
  59009. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59010. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59011. get samples(): number;
  59012. set samples(value: number);
  59013. /** Gets or sets the refresh rate to use (on every frame by default) */
  59014. get refreshRate(): number;
  59015. set refreshRate(value: number);
  59016. /**
  59017. * Gets the hosting scene
  59018. * @returns a Scene
  59019. */
  59020. getScene(): Scene;
  59021. /** Gets the internal CubeTexture used to render to */
  59022. get cubeTexture(): RenderTargetTexture;
  59023. /** Gets the list of meshes to render */
  59024. get renderList(): Nullable<AbstractMesh[]>;
  59025. /**
  59026. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59027. * @param mesh defines the mesh to attach to
  59028. */
  59029. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59030. /**
  59031. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59032. * @param renderingGroupId The rendering group id corresponding to its index
  59033. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59034. */
  59035. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59036. /**
  59037. * Clean all associated resources
  59038. */
  59039. dispose(): void;
  59040. /**
  59041. * Converts the reflection probe information to a readable string for debug purpose.
  59042. * @param fullDetails Supports for multiple levels of logging within scene loading
  59043. * @returns the human readable reflection probe info
  59044. */
  59045. toString(fullDetails?: boolean): string;
  59046. /**
  59047. * Get the class name of the relfection probe.
  59048. * @returns "ReflectionProbe"
  59049. */
  59050. getClassName(): string;
  59051. /**
  59052. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59053. * @returns The JSON representation of the texture
  59054. */
  59055. serialize(): any;
  59056. /**
  59057. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59058. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59059. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59060. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59061. * @returns The parsed reflection probe if successful
  59062. */
  59063. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59064. }
  59065. }
  59066. declare module BABYLON {
  59067. /** @hidden */
  59068. export var _BabylonLoaderRegistered: boolean;
  59069. /**
  59070. * Helps setting up some configuration for the babylon file loader.
  59071. */
  59072. export class BabylonFileLoaderConfiguration {
  59073. /**
  59074. * The loader does not allow injecting custom physix engine into the plugins.
  59075. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59076. * So you could set this variable to your engine import to make it work.
  59077. */
  59078. static LoaderInjectedPhysicsEngine: any;
  59079. }
  59080. }
  59081. declare module BABYLON {
  59082. /**
  59083. * The Physically based simple base material of BJS.
  59084. *
  59085. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59086. * It is used as the base class for both the specGloss and metalRough conventions.
  59087. */
  59088. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59089. /**
  59090. * Number of Simultaneous lights allowed on the material.
  59091. */
  59092. maxSimultaneousLights: number;
  59093. /**
  59094. * If sets to true, disables all the lights affecting the material.
  59095. */
  59096. disableLighting: boolean;
  59097. /**
  59098. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59099. */
  59100. environmentTexture: BaseTexture;
  59101. /**
  59102. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59103. */
  59104. invertNormalMapX: boolean;
  59105. /**
  59106. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59107. */
  59108. invertNormalMapY: boolean;
  59109. /**
  59110. * Normal map used in the model.
  59111. */
  59112. normalTexture: BaseTexture;
  59113. /**
  59114. * Emissivie color used to self-illuminate the model.
  59115. */
  59116. emissiveColor: Color3;
  59117. /**
  59118. * Emissivie texture used to self-illuminate the model.
  59119. */
  59120. emissiveTexture: BaseTexture;
  59121. /**
  59122. * Occlusion Channel Strenght.
  59123. */
  59124. occlusionStrength: number;
  59125. /**
  59126. * Occlusion Texture of the material (adding extra occlusion effects).
  59127. */
  59128. occlusionTexture: BaseTexture;
  59129. /**
  59130. * Defines the alpha limits in alpha test mode.
  59131. */
  59132. alphaCutOff: number;
  59133. /**
  59134. * Gets the current double sided mode.
  59135. */
  59136. get doubleSided(): boolean;
  59137. /**
  59138. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59139. */
  59140. set doubleSided(value: boolean);
  59141. /**
  59142. * Stores the pre-calculated light information of a mesh in a texture.
  59143. */
  59144. lightmapTexture: BaseTexture;
  59145. /**
  59146. * If true, the light map contains occlusion information instead of lighting info.
  59147. */
  59148. useLightmapAsShadowmap: boolean;
  59149. /**
  59150. * Instantiates a new PBRMaterial instance.
  59151. *
  59152. * @param name The material name
  59153. * @param scene The scene the material will be use in.
  59154. */
  59155. constructor(name: string, scene: Scene);
  59156. getClassName(): string;
  59157. }
  59158. }
  59159. declare module BABYLON {
  59160. /**
  59161. * The PBR material of BJS following the metal roughness convention.
  59162. *
  59163. * This fits to the PBR convention in the GLTF definition:
  59164. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59165. */
  59166. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59167. /**
  59168. * The base color has two different interpretations depending on the value of metalness.
  59169. * When the material is a metal, the base color is the specific measured reflectance value
  59170. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59171. * of the material.
  59172. */
  59173. baseColor: Color3;
  59174. /**
  59175. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59176. * well as opacity information in the alpha channel.
  59177. */
  59178. baseTexture: BaseTexture;
  59179. /**
  59180. * Specifies the metallic scalar value of the material.
  59181. * Can also be used to scale the metalness values of the metallic texture.
  59182. */
  59183. metallic: number;
  59184. /**
  59185. * Specifies the roughness scalar value of the material.
  59186. * Can also be used to scale the roughness values of the metallic texture.
  59187. */
  59188. roughness: number;
  59189. /**
  59190. * Texture containing both the metallic value in the B channel and the
  59191. * roughness value in the G channel to keep better precision.
  59192. */
  59193. metallicRoughnessTexture: BaseTexture;
  59194. /**
  59195. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59196. *
  59197. * @param name The material name
  59198. * @param scene The scene the material will be use in.
  59199. */
  59200. constructor(name: string, scene: Scene);
  59201. /**
  59202. * Return the currrent class name of the material.
  59203. */
  59204. getClassName(): string;
  59205. /**
  59206. * Makes a duplicate of the current material.
  59207. * @param name - name to use for the new material.
  59208. */
  59209. clone(name: string): PBRMetallicRoughnessMaterial;
  59210. /**
  59211. * Serialize the material to a parsable JSON object.
  59212. */
  59213. serialize(): any;
  59214. /**
  59215. * Parses a JSON object correponding to the serialize function.
  59216. */
  59217. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59218. }
  59219. }
  59220. declare module BABYLON {
  59221. /**
  59222. * The PBR material of BJS following the specular glossiness convention.
  59223. *
  59224. * This fits to the PBR convention in the GLTF definition:
  59225. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59226. */
  59227. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59228. /**
  59229. * Specifies the diffuse color of the material.
  59230. */
  59231. diffuseColor: Color3;
  59232. /**
  59233. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59234. * channel.
  59235. */
  59236. diffuseTexture: BaseTexture;
  59237. /**
  59238. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59239. */
  59240. specularColor: Color3;
  59241. /**
  59242. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59243. */
  59244. glossiness: number;
  59245. /**
  59246. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59247. */
  59248. specularGlossinessTexture: BaseTexture;
  59249. /**
  59250. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59251. *
  59252. * @param name The material name
  59253. * @param scene The scene the material will be use in.
  59254. */
  59255. constructor(name: string, scene: Scene);
  59256. /**
  59257. * Return the currrent class name of the material.
  59258. */
  59259. getClassName(): string;
  59260. /**
  59261. * Makes a duplicate of the current material.
  59262. * @param name - name to use for the new material.
  59263. */
  59264. clone(name: string): PBRSpecularGlossinessMaterial;
  59265. /**
  59266. * Serialize the material to a parsable JSON object.
  59267. */
  59268. serialize(): any;
  59269. /**
  59270. * Parses a JSON object correponding to the serialize function.
  59271. */
  59272. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59273. }
  59274. }
  59275. declare module BABYLON {
  59276. /**
  59277. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59278. * It can help converting any input color in a desired output one. This can then be used to create effects
  59279. * from sepia, black and white to sixties or futuristic rendering...
  59280. *
  59281. * The only supported format is currently 3dl.
  59282. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59283. */
  59284. export class ColorGradingTexture extends BaseTexture {
  59285. /**
  59286. * The texture URL.
  59287. */
  59288. url: string;
  59289. /**
  59290. * Empty line regex stored for GC.
  59291. */
  59292. private static _noneEmptyLineRegex;
  59293. private _textureMatrix;
  59294. private _onLoad;
  59295. /**
  59296. * Instantiates a ColorGradingTexture from the following parameters.
  59297. *
  59298. * @param url The location of the color gradind data (currently only supporting 3dl)
  59299. * @param sceneOrEngine The scene or engine the texture will be used in
  59300. * @param onLoad defines a callback triggered when the texture has been loaded
  59301. */
  59302. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  59303. /**
  59304. * Fires the onload event from the constructor if requested.
  59305. */
  59306. private _triggerOnLoad;
  59307. /**
  59308. * Returns the texture matrix used in most of the material.
  59309. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59310. */
  59311. getTextureMatrix(): Matrix;
  59312. /**
  59313. * Occurs when the file being loaded is a .3dl LUT file.
  59314. */
  59315. private load3dlTexture;
  59316. /**
  59317. * Starts the loading process of the texture.
  59318. */
  59319. private loadTexture;
  59320. /**
  59321. * Clones the color gradind texture.
  59322. */
  59323. clone(): ColorGradingTexture;
  59324. /**
  59325. * Called during delayed load for textures.
  59326. */
  59327. delayLoad(): void;
  59328. /**
  59329. * Parses a color grading texture serialized by Babylon.
  59330. * @param parsedTexture The texture information being parsedTexture
  59331. * @param scene The scene to load the texture in
  59332. * @param rootUrl The root url of the data assets to load
  59333. * @return A color gradind texture
  59334. */
  59335. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  59336. /**
  59337. * Serializes the LUT texture to json format.
  59338. */
  59339. serialize(): any;
  59340. }
  59341. }
  59342. declare module BABYLON {
  59343. /**
  59344. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59345. */
  59346. export class EquiRectangularCubeTexture extends BaseTexture {
  59347. /** The six faces of the cube. */
  59348. private static _FacesMapping;
  59349. private _noMipmap;
  59350. private _onLoad;
  59351. private _onError;
  59352. /** The size of the cubemap. */
  59353. private _size;
  59354. /** The buffer of the image. */
  59355. private _buffer;
  59356. /** The width of the input image. */
  59357. private _width;
  59358. /** The height of the input image. */
  59359. private _height;
  59360. /** The URL to the image. */
  59361. url: string;
  59362. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59363. coordinatesMode: number;
  59364. /**
  59365. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59366. * @param url The location of the image
  59367. * @param scene The scene the texture will be used in
  59368. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59369. * @param noMipmap Forces to not generate the mipmap if true
  59370. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59371. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59372. * @param onLoad — defines a callback called when texture is loaded
  59373. * @param onError — defines a callback called if there is an error
  59374. */
  59375. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59376. /**
  59377. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59378. */
  59379. private loadImage;
  59380. /**
  59381. * Convert the image buffer into a cubemap and create a CubeTexture.
  59382. */
  59383. private loadTexture;
  59384. /**
  59385. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59386. * @param buffer The ArrayBuffer that should be converted.
  59387. * @returns The buffer as Float32Array.
  59388. */
  59389. private getFloat32ArrayFromArrayBuffer;
  59390. /**
  59391. * Get the current class name of the texture useful for serialization or dynamic coding.
  59392. * @returns "EquiRectangularCubeTexture"
  59393. */
  59394. getClassName(): string;
  59395. /**
  59396. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59397. * @returns A clone of the current EquiRectangularCubeTexture.
  59398. */
  59399. clone(): EquiRectangularCubeTexture;
  59400. }
  59401. }
  59402. declare module BABYLON {
  59403. /**
  59404. * Defines the options related to the creation of an HtmlElementTexture
  59405. */
  59406. export interface IHtmlElementTextureOptions {
  59407. /**
  59408. * Defines wether mip maps should be created or not.
  59409. */
  59410. generateMipMaps?: boolean;
  59411. /**
  59412. * Defines the sampling mode of the texture.
  59413. */
  59414. samplingMode?: number;
  59415. /**
  59416. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59417. */
  59418. engine: Nullable<ThinEngine>;
  59419. /**
  59420. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59421. */
  59422. scene: Nullable<Scene>;
  59423. }
  59424. /**
  59425. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59426. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59427. * is automatically managed.
  59428. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59429. * in your application.
  59430. *
  59431. * As the update is not automatic, you need to call them manually.
  59432. */
  59433. export class HtmlElementTexture extends BaseTexture {
  59434. /**
  59435. * The texture URL.
  59436. */
  59437. element: HTMLVideoElement | HTMLCanvasElement;
  59438. private static readonly DefaultOptions;
  59439. private _textureMatrix;
  59440. private _isVideo;
  59441. private _generateMipMaps;
  59442. private _samplingMode;
  59443. /**
  59444. * Instantiates a HtmlElementTexture from the following parameters.
  59445. *
  59446. * @param name Defines the name of the texture
  59447. * @param element Defines the video or canvas the texture is filled with
  59448. * @param options Defines the other none mandatory texture creation options
  59449. */
  59450. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59451. private _createInternalTexture;
  59452. /**
  59453. * Returns the texture matrix used in most of the material.
  59454. */
  59455. getTextureMatrix(): Matrix;
  59456. /**
  59457. * Updates the content of the texture.
  59458. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59459. */
  59460. update(invertY?: Nullable<boolean>): void;
  59461. }
  59462. }
  59463. declare module BABYLON {
  59464. /**
  59465. * Based on jsTGALoader - Javascript loader for TGA file
  59466. * By Vincent Thibault
  59467. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59468. */
  59469. export class TGATools {
  59470. private static _TYPE_INDEXED;
  59471. private static _TYPE_RGB;
  59472. private static _TYPE_GREY;
  59473. private static _TYPE_RLE_INDEXED;
  59474. private static _TYPE_RLE_RGB;
  59475. private static _TYPE_RLE_GREY;
  59476. private static _ORIGIN_MASK;
  59477. private static _ORIGIN_SHIFT;
  59478. private static _ORIGIN_BL;
  59479. private static _ORIGIN_BR;
  59480. private static _ORIGIN_UL;
  59481. private static _ORIGIN_UR;
  59482. /**
  59483. * Gets the header of a TGA file
  59484. * @param data defines the TGA data
  59485. * @returns the header
  59486. */
  59487. static GetTGAHeader(data: Uint8Array): any;
  59488. /**
  59489. * Uploads TGA content to a Babylon Texture
  59490. * @hidden
  59491. */
  59492. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59493. /** @hidden */
  59494. 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;
  59495. /** @hidden */
  59496. 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;
  59497. /** @hidden */
  59498. 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;
  59499. /** @hidden */
  59500. 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;
  59501. /** @hidden */
  59502. 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;
  59503. /** @hidden */
  59504. 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;
  59505. }
  59506. }
  59507. declare module BABYLON {
  59508. /**
  59509. * Implementation of the TGA Texture Loader.
  59510. * @hidden
  59511. */
  59512. export class _TGATextureLoader implements IInternalTextureLoader {
  59513. /**
  59514. * Defines wether the loader supports cascade loading the different faces.
  59515. */
  59516. readonly supportCascades: boolean;
  59517. /**
  59518. * This returns if the loader support the current file information.
  59519. * @param extension defines the file extension of the file being loaded
  59520. * @returns true if the loader can load the specified file
  59521. */
  59522. canLoad(extension: string): boolean;
  59523. /**
  59524. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59525. * @param data contains the texture data
  59526. * @param texture defines the BabylonJS internal texture
  59527. * @param createPolynomials will be true if polynomials have been requested
  59528. * @param onLoad defines the callback to trigger once the texture is ready
  59529. * @param onError defines the callback to trigger in case of error
  59530. */
  59531. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59532. /**
  59533. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59534. * @param data contains the texture data
  59535. * @param texture defines the BabylonJS internal texture
  59536. * @param callback defines the method to call once ready to upload
  59537. */
  59538. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59539. }
  59540. }
  59541. declare module BABYLON {
  59542. /**
  59543. * Info about the .basis files
  59544. */
  59545. class BasisFileInfo {
  59546. /**
  59547. * If the file has alpha
  59548. */
  59549. hasAlpha: boolean;
  59550. /**
  59551. * Info about each image of the basis file
  59552. */
  59553. images: Array<{
  59554. levels: Array<{
  59555. width: number;
  59556. height: number;
  59557. transcodedPixels: ArrayBufferView;
  59558. }>;
  59559. }>;
  59560. }
  59561. /**
  59562. * Result of transcoding a basis file
  59563. */
  59564. class TranscodeResult {
  59565. /**
  59566. * Info about the .basis file
  59567. */
  59568. fileInfo: BasisFileInfo;
  59569. /**
  59570. * Format to use when loading the file
  59571. */
  59572. format: number;
  59573. }
  59574. /**
  59575. * Configuration options for the Basis transcoder
  59576. */
  59577. export class BasisTranscodeConfiguration {
  59578. /**
  59579. * Supported compression formats used to determine the supported output format of the transcoder
  59580. */
  59581. supportedCompressionFormats?: {
  59582. /**
  59583. * etc1 compression format
  59584. */
  59585. etc1?: boolean;
  59586. /**
  59587. * s3tc compression format
  59588. */
  59589. s3tc?: boolean;
  59590. /**
  59591. * pvrtc compression format
  59592. */
  59593. pvrtc?: boolean;
  59594. /**
  59595. * etc2 compression format
  59596. */
  59597. etc2?: boolean;
  59598. };
  59599. /**
  59600. * If mipmap levels should be loaded for transcoded images (Default: true)
  59601. */
  59602. loadMipmapLevels?: boolean;
  59603. /**
  59604. * Index of a single image to load (Default: all images)
  59605. */
  59606. loadSingleImage?: number;
  59607. }
  59608. /**
  59609. * Used to load .Basis files
  59610. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  59611. */
  59612. export class BasisTools {
  59613. private static _IgnoreSupportedFormats;
  59614. /**
  59615. * URL to use when loading the basis transcoder
  59616. */
  59617. static JSModuleURL: string;
  59618. /**
  59619. * URL to use when loading the wasm module for the transcoder
  59620. */
  59621. static WasmModuleURL: string;
  59622. /**
  59623. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  59624. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  59625. * @returns internal format corresponding to the Basis format
  59626. */
  59627. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  59628. private static _WorkerPromise;
  59629. private static _Worker;
  59630. private static _actionId;
  59631. private static _CreateWorkerAsync;
  59632. /**
  59633. * Transcodes a loaded image file to compressed pixel data
  59634. * @param data image data to transcode
  59635. * @param config configuration options for the transcoding
  59636. * @returns a promise resulting in the transcoded image
  59637. */
  59638. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  59639. /**
  59640. * Loads a texture from the transcode result
  59641. * @param texture texture load to
  59642. * @param transcodeResult the result of transcoding the basis file to load from
  59643. */
  59644. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  59645. }
  59646. }
  59647. declare module BABYLON {
  59648. /**
  59649. * Loader for .basis file format
  59650. */
  59651. export class _BasisTextureLoader implements IInternalTextureLoader {
  59652. /**
  59653. * Defines whether the loader supports cascade loading the different faces.
  59654. */
  59655. readonly supportCascades: boolean;
  59656. /**
  59657. * This returns if the loader support the current file information.
  59658. * @param extension defines the file extension of the file being loaded
  59659. * @returns true if the loader can load the specified file
  59660. */
  59661. canLoad(extension: string): boolean;
  59662. /**
  59663. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59664. * @param data contains the texture data
  59665. * @param texture defines the BabylonJS internal texture
  59666. * @param createPolynomials will be true if polynomials have been requested
  59667. * @param onLoad defines the callback to trigger once the texture is ready
  59668. * @param onError defines the callback to trigger in case of error
  59669. */
  59670. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59671. /**
  59672. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59673. * @param data contains the texture data
  59674. * @param texture defines the BabylonJS internal texture
  59675. * @param callback defines the method to call once ready to upload
  59676. */
  59677. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59678. }
  59679. }
  59680. declare module BABYLON {
  59681. /**
  59682. * Defines the basic options interface of a TexturePacker Frame
  59683. */
  59684. export interface ITexturePackerFrame {
  59685. /**
  59686. * The frame ID
  59687. */
  59688. id: number;
  59689. /**
  59690. * The frames Scale
  59691. */
  59692. scale: Vector2;
  59693. /**
  59694. * The Frames offset
  59695. */
  59696. offset: Vector2;
  59697. }
  59698. /**
  59699. * This is a support class for frame Data on texture packer sets.
  59700. */
  59701. export class TexturePackerFrame implements ITexturePackerFrame {
  59702. /**
  59703. * The frame ID
  59704. */
  59705. id: number;
  59706. /**
  59707. * The frames Scale
  59708. */
  59709. scale: Vector2;
  59710. /**
  59711. * The Frames offset
  59712. */
  59713. offset: Vector2;
  59714. /**
  59715. * Initializes a texture package frame.
  59716. * @param id The numerical frame identifier
  59717. * @param scale Scalar Vector2 for UV frame
  59718. * @param offset Vector2 for the frame position in UV units.
  59719. * @returns TexturePackerFrame
  59720. */
  59721. constructor(id: number, scale: Vector2, offset: Vector2);
  59722. }
  59723. }
  59724. declare module BABYLON {
  59725. /**
  59726. * Defines the basic options interface of a TexturePacker
  59727. */
  59728. export interface ITexturePackerOptions {
  59729. /**
  59730. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59731. */
  59732. map?: string[];
  59733. /**
  59734. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59735. */
  59736. uvsIn?: string;
  59737. /**
  59738. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59739. */
  59740. uvsOut?: string;
  59741. /**
  59742. * number representing the layout style. Defaults to LAYOUT_STRIP
  59743. */
  59744. layout?: number;
  59745. /**
  59746. * number of columns if using custom column count layout(2). This defaults to 4.
  59747. */
  59748. colnum?: number;
  59749. /**
  59750. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59751. */
  59752. updateInputMeshes?: boolean;
  59753. /**
  59754. * boolean flag to dispose all the source textures. Defaults to true.
  59755. */
  59756. disposeSources?: boolean;
  59757. /**
  59758. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59759. */
  59760. fillBlanks?: boolean;
  59761. /**
  59762. * string value representing the context fill style color. Defaults to 'black'.
  59763. */
  59764. customFillColor?: string;
  59765. /**
  59766. * Width and Height Value of each Frame in the TexturePacker Sets
  59767. */
  59768. frameSize?: number;
  59769. /**
  59770. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59771. */
  59772. paddingRatio?: number;
  59773. /**
  59774. * Number that declares the fill method for the padding gutter.
  59775. */
  59776. paddingMode?: number;
  59777. /**
  59778. * If in SUBUV_COLOR padding mode what color to use.
  59779. */
  59780. paddingColor?: Color3 | Color4;
  59781. }
  59782. /**
  59783. * Defines the basic interface of a TexturePacker JSON File
  59784. */
  59785. export interface ITexturePackerJSON {
  59786. /**
  59787. * The frame ID
  59788. */
  59789. name: string;
  59790. /**
  59791. * The base64 channel data
  59792. */
  59793. sets: any;
  59794. /**
  59795. * The options of the Packer
  59796. */
  59797. options: ITexturePackerOptions;
  59798. /**
  59799. * The frame data of the Packer
  59800. */
  59801. frames: Array<number>;
  59802. }
  59803. /**
  59804. * This is a support class that generates a series of packed texture sets.
  59805. * @see https://doc.babylonjs.com/babylon101/materials
  59806. */
  59807. export class TexturePacker {
  59808. /** Packer Layout Constant 0 */
  59809. static readonly LAYOUT_STRIP: number;
  59810. /** Packer Layout Constant 1 */
  59811. static readonly LAYOUT_POWER2: number;
  59812. /** Packer Layout Constant 2 */
  59813. static readonly LAYOUT_COLNUM: number;
  59814. /** Packer Layout Constant 0 */
  59815. static readonly SUBUV_WRAP: number;
  59816. /** Packer Layout Constant 1 */
  59817. static readonly SUBUV_EXTEND: number;
  59818. /** Packer Layout Constant 2 */
  59819. static readonly SUBUV_COLOR: number;
  59820. /** The Name of the Texture Package */
  59821. name: string;
  59822. /** The scene scope of the TexturePacker */
  59823. scene: Scene;
  59824. /** The Meshes to target */
  59825. meshes: AbstractMesh[];
  59826. /** Arguments passed with the Constructor */
  59827. options: ITexturePackerOptions;
  59828. /** The promise that is started upon initialization */
  59829. promise: Nullable<Promise<TexturePacker | string>>;
  59830. /** The Container object for the channel sets that are generated */
  59831. sets: object;
  59832. /** The Container array for the frames that are generated */
  59833. frames: TexturePackerFrame[];
  59834. /** The expected number of textures the system is parsing. */
  59835. private _expecting;
  59836. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59837. private _paddingValue;
  59838. /**
  59839. * Initializes a texture package series from an array of meshes or a single mesh.
  59840. * @param name The name of the package
  59841. * @param meshes The target meshes to compose the package from
  59842. * @param options The arguments that texture packer should follow while building.
  59843. * @param scene The scene which the textures are scoped to.
  59844. * @returns TexturePacker
  59845. */
  59846. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59847. /**
  59848. * Starts the package process
  59849. * @param resolve The promises resolution function
  59850. * @returns TexturePacker
  59851. */
  59852. private _createFrames;
  59853. /**
  59854. * Calculates the Size of the Channel Sets
  59855. * @returns Vector2
  59856. */
  59857. private _calculateSize;
  59858. /**
  59859. * Calculates the UV data for the frames.
  59860. * @param baseSize the base frameSize
  59861. * @param padding the base frame padding
  59862. * @param dtSize size of the Dynamic Texture for that channel
  59863. * @param dtUnits is 1/dtSize
  59864. * @param update flag to update the input meshes
  59865. */
  59866. private _calculateMeshUVFrames;
  59867. /**
  59868. * Calculates the frames Offset.
  59869. * @param index of the frame
  59870. * @returns Vector2
  59871. */
  59872. private _getFrameOffset;
  59873. /**
  59874. * Updates a Mesh to the frame data
  59875. * @param mesh that is the target
  59876. * @param frameID or the frame index
  59877. */
  59878. private _updateMeshUV;
  59879. /**
  59880. * Updates a Meshes materials to use the texture packer channels
  59881. * @param m is the mesh to target
  59882. * @param force all channels on the packer to be set.
  59883. */
  59884. private _updateTextureReferences;
  59885. /**
  59886. * Public method to set a Mesh to a frame
  59887. * @param m that is the target
  59888. * @param frameID or the frame index
  59889. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59890. */
  59891. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59892. /**
  59893. * Starts the async promise to compile the texture packer.
  59894. * @returns Promise<void>
  59895. */
  59896. processAsync(): Promise<void>;
  59897. /**
  59898. * Disposes all textures associated with this packer
  59899. */
  59900. dispose(): void;
  59901. /**
  59902. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59903. * @param imageType is the image type to use.
  59904. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59905. */
  59906. download(imageType?: string, quality?: number): void;
  59907. /**
  59908. * Public method to load a texturePacker JSON file.
  59909. * @param data of the JSON file in string format.
  59910. */
  59911. updateFromJSON(data: string): void;
  59912. }
  59913. }
  59914. declare module BABYLON {
  59915. /**
  59916. * 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.
  59917. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59918. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59919. */
  59920. export class CustomProceduralTexture extends ProceduralTexture {
  59921. private _animate;
  59922. private _time;
  59923. private _config;
  59924. private _texturePath;
  59925. /**
  59926. * Instantiates a new Custom Procedural Texture.
  59927. * 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.
  59928. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59929. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59930. * @param name Define the name of the texture
  59931. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  59932. * @param size Define the size of the texture to create
  59933. * @param scene Define the scene the texture belongs to
  59934. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  59935. * @param generateMipMaps Define if the texture should creates mip maps or not
  59936. */
  59937. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59938. private _loadJson;
  59939. /**
  59940. * Is the texture ready to be used ? (rendered at least once)
  59941. * @returns true if ready, otherwise, false.
  59942. */
  59943. isReady(): boolean;
  59944. /**
  59945. * Render the texture to its associated render target.
  59946. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  59947. */
  59948. render(useCameraPostProcess?: boolean): void;
  59949. /**
  59950. * Update the list of dependant textures samplers in the shader.
  59951. */
  59952. updateTextures(): void;
  59953. /**
  59954. * Update the uniform values of the procedural texture in the shader.
  59955. */
  59956. updateShaderUniforms(): void;
  59957. /**
  59958. * Define if the texture animates or not.
  59959. */
  59960. get animate(): boolean;
  59961. set animate(value: boolean);
  59962. }
  59963. }
  59964. declare module BABYLON {
  59965. /** @hidden */
  59966. export var noisePixelShader: {
  59967. name: string;
  59968. shader: string;
  59969. };
  59970. }
  59971. declare module BABYLON {
  59972. /**
  59973. * Class used to generate noise procedural textures
  59974. */
  59975. export class NoiseProceduralTexture extends ProceduralTexture {
  59976. private _time;
  59977. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  59978. brightness: number;
  59979. /** Defines the number of octaves to process */
  59980. octaves: number;
  59981. /** Defines the level of persistence (0.8 by default) */
  59982. persistence: number;
  59983. /** Gets or sets animation speed factor (default is 1) */
  59984. animationSpeedFactor: number;
  59985. /**
  59986. * Creates a new NoiseProceduralTexture
  59987. * @param name defines the name fo the texture
  59988. * @param size defines the size of the texture (default is 256)
  59989. * @param scene defines the hosting scene
  59990. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  59991. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  59992. */
  59993. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59994. private _updateShaderUniforms;
  59995. protected _getDefines(): string;
  59996. /** Generate the current state of the procedural texture */
  59997. render(useCameraPostProcess?: boolean): void;
  59998. /**
  59999. * Serializes this noise procedural texture
  60000. * @returns a serialized noise procedural texture object
  60001. */
  60002. serialize(): any;
  60003. /**
  60004. * Clone the texture.
  60005. * @returns the cloned texture
  60006. */
  60007. clone(): NoiseProceduralTexture;
  60008. /**
  60009. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60010. * @param parsedTexture defines parsed texture data
  60011. * @param scene defines the current scene
  60012. * @param rootUrl defines the root URL containing noise procedural texture information
  60013. * @returns a parsed NoiseProceduralTexture
  60014. */
  60015. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60016. }
  60017. }
  60018. declare module BABYLON {
  60019. /**
  60020. * Raw cube texture where the raw buffers are passed in
  60021. */
  60022. export class RawCubeTexture extends CubeTexture {
  60023. /**
  60024. * Creates a cube texture where the raw buffers are passed in.
  60025. * @param scene defines the scene the texture is attached to
  60026. * @param data defines the array of data to use to create each face
  60027. * @param size defines the size of the textures
  60028. * @param format defines the format of the data
  60029. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60030. * @param generateMipMaps defines if the engine should generate the mip levels
  60031. * @param invertY defines if data must be stored with Y axis inverted
  60032. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60033. * @param compression defines the compression used (null by default)
  60034. */
  60035. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60036. /**
  60037. * Updates the raw cube texture.
  60038. * @param data defines the data to store
  60039. * @param format defines the data format
  60040. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60041. * @param invertY defines if data must be stored with Y axis inverted
  60042. * @param compression defines the compression used (null by default)
  60043. * @param level defines which level of the texture to update
  60044. */
  60045. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60046. /**
  60047. * Updates a raw cube texture with RGBD encoded data.
  60048. * @param data defines the array of data [mipmap][face] to use to create each face
  60049. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60050. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60051. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60052. * @returns a promsie that resolves when the operation is complete
  60053. */
  60054. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60055. /**
  60056. * Clones the raw cube texture.
  60057. * @return a new cube texture
  60058. */
  60059. clone(): CubeTexture;
  60060. /** @hidden */
  60061. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60062. }
  60063. }
  60064. declare module BABYLON {
  60065. /**
  60066. * Class used to store 2D array textures containing user data
  60067. */
  60068. export class RawTexture2DArray extends Texture {
  60069. /** Gets or sets the texture format to use */
  60070. format: number;
  60071. /**
  60072. * Create a new RawTexture2DArray
  60073. * @param data defines the data of the texture
  60074. * @param width defines the width of the texture
  60075. * @param height defines the height of the texture
  60076. * @param depth defines the number of layers of the texture
  60077. * @param format defines the texture format to use
  60078. * @param scene defines the hosting scene
  60079. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60080. * @param invertY defines if texture must be stored with Y axis inverted
  60081. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60082. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60083. */
  60084. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60085. /** Gets or sets the texture format to use */
  60086. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60087. /**
  60088. * Update the texture with new data
  60089. * @param data defines the data to store in the texture
  60090. */
  60091. update(data: ArrayBufferView): void;
  60092. }
  60093. }
  60094. declare module BABYLON {
  60095. /**
  60096. * Class used to store 3D textures containing user data
  60097. */
  60098. export class RawTexture3D extends Texture {
  60099. /** Gets or sets the texture format to use */
  60100. format: number;
  60101. /**
  60102. * Create a new RawTexture3D
  60103. * @param data defines the data of the texture
  60104. * @param width defines the width of the texture
  60105. * @param height defines the height of the texture
  60106. * @param depth defines the depth of the texture
  60107. * @param format defines the texture format to use
  60108. * @param scene defines the hosting scene
  60109. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60110. * @param invertY defines if texture must be stored with Y axis inverted
  60111. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60112. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60113. */
  60114. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60115. /** Gets or sets the texture format to use */
  60116. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60117. /**
  60118. * Update the texture with new data
  60119. * @param data defines the data to store in the texture
  60120. */
  60121. update(data: ArrayBufferView): void;
  60122. }
  60123. }
  60124. declare module BABYLON {
  60125. /**
  60126. * Creates a refraction texture used by refraction channel of the standard material.
  60127. * It is like a mirror but to see through a material.
  60128. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60129. */
  60130. export class RefractionTexture extends RenderTargetTexture {
  60131. /**
  60132. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  60133. * 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.
  60134. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60135. */
  60136. refractionPlane: Plane;
  60137. /**
  60138. * Define how deep under the surface we should see.
  60139. */
  60140. depth: number;
  60141. /**
  60142. * Creates a refraction texture used by refraction channel of the standard material.
  60143. * It is like a mirror but to see through a material.
  60144. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60145. * @param name Define the texture name
  60146. * @param size Define the size of the underlying texture
  60147. * @param scene Define the scene the refraction belongs to
  60148. * @param generateMipMaps Define if we need to generate mips level for the refraction
  60149. */
  60150. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  60151. /**
  60152. * Clone the refraction texture.
  60153. * @returns the cloned texture
  60154. */
  60155. clone(): RefractionTexture;
  60156. /**
  60157. * Serialize the texture to a JSON representation you could use in Parse later on
  60158. * @returns the serialized JSON representation
  60159. */
  60160. serialize(): any;
  60161. }
  60162. }
  60163. declare module BABYLON {
  60164. /**
  60165. * Block used to add support for vertex skinning (bones)
  60166. */
  60167. export class BonesBlock extends NodeMaterialBlock {
  60168. /**
  60169. * Creates a new BonesBlock
  60170. * @param name defines the block name
  60171. */
  60172. constructor(name: string);
  60173. /**
  60174. * Initialize the block and prepare the context for build
  60175. * @param state defines the state that will be used for the build
  60176. */
  60177. initialize(state: NodeMaterialBuildState): void;
  60178. /**
  60179. * Gets the current class name
  60180. * @returns the class name
  60181. */
  60182. getClassName(): string;
  60183. /**
  60184. * Gets the matrix indices input component
  60185. */
  60186. get matricesIndices(): NodeMaterialConnectionPoint;
  60187. /**
  60188. * Gets the matrix weights input component
  60189. */
  60190. get matricesWeights(): NodeMaterialConnectionPoint;
  60191. /**
  60192. * Gets the extra matrix indices input component
  60193. */
  60194. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60195. /**
  60196. * Gets the extra matrix weights input component
  60197. */
  60198. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60199. /**
  60200. * Gets the world input component
  60201. */
  60202. get world(): NodeMaterialConnectionPoint;
  60203. /**
  60204. * Gets the output component
  60205. */
  60206. get output(): NodeMaterialConnectionPoint;
  60207. autoConfigure(material: NodeMaterial): void;
  60208. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60209. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60210. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60211. protected _buildBlock(state: NodeMaterialBuildState): this;
  60212. }
  60213. }
  60214. declare module BABYLON {
  60215. /**
  60216. * Block used to add support for instances
  60217. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60218. */
  60219. export class InstancesBlock extends NodeMaterialBlock {
  60220. /**
  60221. * Creates a new InstancesBlock
  60222. * @param name defines the block name
  60223. */
  60224. constructor(name: string);
  60225. /**
  60226. * Gets the current class name
  60227. * @returns the class name
  60228. */
  60229. getClassName(): string;
  60230. /**
  60231. * Gets the first world row input component
  60232. */
  60233. get world0(): NodeMaterialConnectionPoint;
  60234. /**
  60235. * Gets the second world row input component
  60236. */
  60237. get world1(): NodeMaterialConnectionPoint;
  60238. /**
  60239. * Gets the third world row input component
  60240. */
  60241. get world2(): NodeMaterialConnectionPoint;
  60242. /**
  60243. * Gets the forth world row input component
  60244. */
  60245. get world3(): NodeMaterialConnectionPoint;
  60246. /**
  60247. * Gets the world input component
  60248. */
  60249. get world(): NodeMaterialConnectionPoint;
  60250. /**
  60251. * Gets the output component
  60252. */
  60253. get output(): NodeMaterialConnectionPoint;
  60254. /**
  60255. * Gets the isntanceID component
  60256. */
  60257. get instanceID(): NodeMaterialConnectionPoint;
  60258. autoConfigure(material: NodeMaterial): void;
  60259. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60260. protected _buildBlock(state: NodeMaterialBuildState): this;
  60261. }
  60262. }
  60263. declare module BABYLON {
  60264. /**
  60265. * Block used to add morph targets support to vertex shader
  60266. */
  60267. export class MorphTargetsBlock extends NodeMaterialBlock {
  60268. private _repeatableContentAnchor;
  60269. /**
  60270. * Create a new MorphTargetsBlock
  60271. * @param name defines the block name
  60272. */
  60273. constructor(name: string);
  60274. /**
  60275. * Gets the current class name
  60276. * @returns the class name
  60277. */
  60278. getClassName(): string;
  60279. /**
  60280. * Gets the position input component
  60281. */
  60282. get position(): NodeMaterialConnectionPoint;
  60283. /**
  60284. * Gets the normal input component
  60285. */
  60286. get normal(): NodeMaterialConnectionPoint;
  60287. /**
  60288. * Gets the tangent input component
  60289. */
  60290. get tangent(): NodeMaterialConnectionPoint;
  60291. /**
  60292. * Gets the tangent input component
  60293. */
  60294. get uv(): NodeMaterialConnectionPoint;
  60295. /**
  60296. * Gets the position output component
  60297. */
  60298. get positionOutput(): NodeMaterialConnectionPoint;
  60299. /**
  60300. * Gets the normal output component
  60301. */
  60302. get normalOutput(): NodeMaterialConnectionPoint;
  60303. /**
  60304. * Gets the tangent output component
  60305. */
  60306. get tangentOutput(): NodeMaterialConnectionPoint;
  60307. /**
  60308. * Gets the tangent output component
  60309. */
  60310. get uvOutput(): NodeMaterialConnectionPoint;
  60311. initialize(state: NodeMaterialBuildState): void;
  60312. autoConfigure(material: NodeMaterial): void;
  60313. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60314. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60315. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60316. protected _buildBlock(state: NodeMaterialBuildState): this;
  60317. }
  60318. }
  60319. declare module BABYLON {
  60320. /**
  60321. * Block used to get data information from a light
  60322. */
  60323. export class LightInformationBlock extends NodeMaterialBlock {
  60324. private _lightDataUniformName;
  60325. private _lightColorUniformName;
  60326. private _lightTypeDefineName;
  60327. /**
  60328. * Gets or sets the light associated with this block
  60329. */
  60330. light: Nullable<Light>;
  60331. /**
  60332. * Creates a new LightInformationBlock
  60333. * @param name defines the block name
  60334. */
  60335. constructor(name: string);
  60336. /**
  60337. * Gets the current class name
  60338. * @returns the class name
  60339. */
  60340. getClassName(): string;
  60341. /**
  60342. * Gets the world position input component
  60343. */
  60344. get worldPosition(): NodeMaterialConnectionPoint;
  60345. /**
  60346. * Gets the direction output component
  60347. */
  60348. get direction(): NodeMaterialConnectionPoint;
  60349. /**
  60350. * Gets the direction output component
  60351. */
  60352. get color(): NodeMaterialConnectionPoint;
  60353. /**
  60354. * Gets the direction output component
  60355. */
  60356. get intensity(): NodeMaterialConnectionPoint;
  60357. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60358. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60359. protected _buildBlock(state: NodeMaterialBuildState): this;
  60360. serialize(): any;
  60361. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60362. }
  60363. }
  60364. declare module BABYLON {
  60365. /**
  60366. * Block used to add image processing support to fragment shader
  60367. */
  60368. export class ImageProcessingBlock extends NodeMaterialBlock {
  60369. /**
  60370. * Create a new ImageProcessingBlock
  60371. * @param name defines the block name
  60372. */
  60373. constructor(name: string);
  60374. /**
  60375. * Gets the current class name
  60376. * @returns the class name
  60377. */
  60378. getClassName(): string;
  60379. /**
  60380. * Gets the color input component
  60381. */
  60382. get color(): NodeMaterialConnectionPoint;
  60383. /**
  60384. * Gets the output component
  60385. */
  60386. get output(): NodeMaterialConnectionPoint;
  60387. /**
  60388. * Initialize the block and prepare the context for build
  60389. * @param state defines the state that will be used for the build
  60390. */
  60391. initialize(state: NodeMaterialBuildState): void;
  60392. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  60393. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60394. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60395. protected _buildBlock(state: NodeMaterialBuildState): this;
  60396. }
  60397. }
  60398. declare module BABYLON {
  60399. /**
  60400. * Block used to pertub normals based on a normal map
  60401. */
  60402. export class PerturbNormalBlock extends NodeMaterialBlock {
  60403. private _tangentSpaceParameterName;
  60404. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60405. invertX: boolean;
  60406. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  60407. invertY: boolean;
  60408. /**
  60409. * Create a new PerturbNormalBlock
  60410. * @param name defines the block name
  60411. */
  60412. constructor(name: string);
  60413. /**
  60414. * Gets the current class name
  60415. * @returns the class name
  60416. */
  60417. getClassName(): string;
  60418. /**
  60419. * Gets the world position input component
  60420. */
  60421. get worldPosition(): NodeMaterialConnectionPoint;
  60422. /**
  60423. * Gets the world normal input component
  60424. */
  60425. get worldNormal(): NodeMaterialConnectionPoint;
  60426. /**
  60427. * Gets the world tangent input component
  60428. */
  60429. get worldTangent(): NodeMaterialConnectionPoint;
  60430. /**
  60431. * Gets the uv input component
  60432. */
  60433. get uv(): NodeMaterialConnectionPoint;
  60434. /**
  60435. * Gets the normal map color input component
  60436. */
  60437. get normalMapColor(): NodeMaterialConnectionPoint;
  60438. /**
  60439. * Gets the strength input component
  60440. */
  60441. get strength(): NodeMaterialConnectionPoint;
  60442. /**
  60443. * Gets the output component
  60444. */
  60445. get output(): NodeMaterialConnectionPoint;
  60446. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60447. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60448. autoConfigure(material: NodeMaterial): void;
  60449. protected _buildBlock(state: NodeMaterialBuildState): this;
  60450. protected _dumpPropertiesCode(): string;
  60451. serialize(): any;
  60452. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60453. }
  60454. }
  60455. declare module BABYLON {
  60456. /**
  60457. * Block used to discard a pixel if a value is smaller than a cutoff
  60458. */
  60459. export class DiscardBlock extends NodeMaterialBlock {
  60460. /**
  60461. * Create a new DiscardBlock
  60462. * @param name defines the block name
  60463. */
  60464. constructor(name: string);
  60465. /**
  60466. * Gets the current class name
  60467. * @returns the class name
  60468. */
  60469. getClassName(): string;
  60470. /**
  60471. * Gets the color input component
  60472. */
  60473. get value(): NodeMaterialConnectionPoint;
  60474. /**
  60475. * Gets the cutoff input component
  60476. */
  60477. get cutoff(): NodeMaterialConnectionPoint;
  60478. protected _buildBlock(state: NodeMaterialBuildState): this;
  60479. }
  60480. }
  60481. declare module BABYLON {
  60482. /**
  60483. * Block used to test if the fragment shader is front facing
  60484. */
  60485. export class FrontFacingBlock extends NodeMaterialBlock {
  60486. /**
  60487. * Creates a new FrontFacingBlock
  60488. * @param name defines the block name
  60489. */
  60490. constructor(name: string);
  60491. /**
  60492. * Gets the current class name
  60493. * @returns the class name
  60494. */
  60495. getClassName(): string;
  60496. /**
  60497. * Gets the output component
  60498. */
  60499. get output(): NodeMaterialConnectionPoint;
  60500. protected _buildBlock(state: NodeMaterialBuildState): this;
  60501. }
  60502. }
  60503. declare module BABYLON {
  60504. /**
  60505. * Block used to get the derivative value on x and y of a given input
  60506. */
  60507. export class DerivativeBlock extends NodeMaterialBlock {
  60508. /**
  60509. * Create a new DerivativeBlock
  60510. * @param name defines the block name
  60511. */
  60512. constructor(name: string);
  60513. /**
  60514. * Gets the current class name
  60515. * @returns the class name
  60516. */
  60517. getClassName(): string;
  60518. /**
  60519. * Gets the input component
  60520. */
  60521. get input(): NodeMaterialConnectionPoint;
  60522. /**
  60523. * Gets the derivative output on x
  60524. */
  60525. get dx(): NodeMaterialConnectionPoint;
  60526. /**
  60527. * Gets the derivative output on y
  60528. */
  60529. get dy(): NodeMaterialConnectionPoint;
  60530. protected _buildBlock(state: NodeMaterialBuildState): this;
  60531. }
  60532. }
  60533. declare module BABYLON {
  60534. /**
  60535. * Block used to add support for scene fog
  60536. */
  60537. export class FogBlock extends NodeMaterialBlock {
  60538. private _fogDistanceName;
  60539. private _fogParameters;
  60540. /**
  60541. * Create a new FogBlock
  60542. * @param name defines the block name
  60543. */
  60544. constructor(name: string);
  60545. /**
  60546. * Gets the current class name
  60547. * @returns the class name
  60548. */
  60549. getClassName(): string;
  60550. /**
  60551. * Gets the world position input component
  60552. */
  60553. get worldPosition(): NodeMaterialConnectionPoint;
  60554. /**
  60555. * Gets the view input component
  60556. */
  60557. get view(): NodeMaterialConnectionPoint;
  60558. /**
  60559. * Gets the color input component
  60560. */
  60561. get input(): NodeMaterialConnectionPoint;
  60562. /**
  60563. * Gets the fog color input component
  60564. */
  60565. get fogColor(): NodeMaterialConnectionPoint;
  60566. /**
  60567. * Gets the output component
  60568. */
  60569. get output(): NodeMaterialConnectionPoint;
  60570. autoConfigure(material: NodeMaterial): void;
  60571. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60572. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60573. protected _buildBlock(state: NodeMaterialBuildState): this;
  60574. }
  60575. }
  60576. declare module BABYLON {
  60577. /**
  60578. * Block used to add light in the fragment shader
  60579. */
  60580. export class LightBlock extends NodeMaterialBlock {
  60581. private _lightId;
  60582. /**
  60583. * Gets or sets the light associated with this block
  60584. */
  60585. light: Nullable<Light>;
  60586. /**
  60587. * Create a new LightBlock
  60588. * @param name defines the block name
  60589. */
  60590. constructor(name: string);
  60591. /**
  60592. * Gets the current class name
  60593. * @returns the class name
  60594. */
  60595. getClassName(): string;
  60596. /**
  60597. * Gets the world position input component
  60598. */
  60599. get worldPosition(): NodeMaterialConnectionPoint;
  60600. /**
  60601. * Gets the world normal input component
  60602. */
  60603. get worldNormal(): NodeMaterialConnectionPoint;
  60604. /**
  60605. * Gets the camera (or eye) position component
  60606. */
  60607. get cameraPosition(): NodeMaterialConnectionPoint;
  60608. /**
  60609. * Gets the glossiness component
  60610. */
  60611. get glossiness(): NodeMaterialConnectionPoint;
  60612. /**
  60613. * Gets the glossinness power component
  60614. */
  60615. get glossPower(): NodeMaterialConnectionPoint;
  60616. /**
  60617. * Gets the diffuse color component
  60618. */
  60619. get diffuseColor(): NodeMaterialConnectionPoint;
  60620. /**
  60621. * Gets the specular color component
  60622. */
  60623. get specularColor(): NodeMaterialConnectionPoint;
  60624. /**
  60625. * Gets the diffuse output component
  60626. */
  60627. get diffuseOutput(): NodeMaterialConnectionPoint;
  60628. /**
  60629. * Gets the specular output component
  60630. */
  60631. get specularOutput(): NodeMaterialConnectionPoint;
  60632. /**
  60633. * Gets the shadow output component
  60634. */
  60635. get shadow(): NodeMaterialConnectionPoint;
  60636. autoConfigure(material: NodeMaterial): void;
  60637. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60638. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60639. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60640. private _injectVertexCode;
  60641. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60642. serialize(): any;
  60643. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60644. }
  60645. }
  60646. declare module BABYLON {
  60647. /**
  60648. * Block used to read a reflection texture from a sampler
  60649. */
  60650. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  60651. /**
  60652. * Create a new ReflectionTextureBlock
  60653. * @param name defines the block name
  60654. */
  60655. constructor(name: string);
  60656. /**
  60657. * Gets the current class name
  60658. * @returns the class name
  60659. */
  60660. getClassName(): string;
  60661. /**
  60662. * Gets the world position input component
  60663. */
  60664. get position(): NodeMaterialConnectionPoint;
  60665. /**
  60666. * Gets the world position input component
  60667. */
  60668. get worldPosition(): NodeMaterialConnectionPoint;
  60669. /**
  60670. * Gets the world normal input component
  60671. */
  60672. get worldNormal(): NodeMaterialConnectionPoint;
  60673. /**
  60674. * Gets the world input component
  60675. */
  60676. get world(): NodeMaterialConnectionPoint;
  60677. /**
  60678. * Gets the camera (or eye) position component
  60679. */
  60680. get cameraPosition(): NodeMaterialConnectionPoint;
  60681. /**
  60682. * Gets the view input component
  60683. */
  60684. get view(): NodeMaterialConnectionPoint;
  60685. /**
  60686. * Gets the rgb output component
  60687. */
  60688. get rgb(): NodeMaterialConnectionPoint;
  60689. /**
  60690. * Gets the r output component
  60691. */
  60692. get r(): NodeMaterialConnectionPoint;
  60693. /**
  60694. * Gets the g output component
  60695. */
  60696. get g(): NodeMaterialConnectionPoint;
  60697. /**
  60698. * Gets the b output component
  60699. */
  60700. get b(): NodeMaterialConnectionPoint;
  60701. autoConfigure(material: NodeMaterial): void;
  60702. protected _buildBlock(state: NodeMaterialBuildState): this;
  60703. }
  60704. }
  60705. declare module BABYLON {
  60706. /**
  60707. * Block used to add 2 vectors
  60708. */
  60709. export class AddBlock extends NodeMaterialBlock {
  60710. /**
  60711. * Creates a new AddBlock
  60712. * @param name defines the block name
  60713. */
  60714. constructor(name: string);
  60715. /**
  60716. * Gets the current class name
  60717. * @returns the class name
  60718. */
  60719. getClassName(): string;
  60720. /**
  60721. * Gets the left operand input component
  60722. */
  60723. get left(): NodeMaterialConnectionPoint;
  60724. /**
  60725. * Gets the right operand input component
  60726. */
  60727. get right(): NodeMaterialConnectionPoint;
  60728. /**
  60729. * Gets the output component
  60730. */
  60731. get output(): NodeMaterialConnectionPoint;
  60732. protected _buildBlock(state: NodeMaterialBuildState): this;
  60733. }
  60734. }
  60735. declare module BABYLON {
  60736. /**
  60737. * Block used to scale a vector by a float
  60738. */
  60739. export class ScaleBlock extends NodeMaterialBlock {
  60740. /**
  60741. * Creates a new ScaleBlock
  60742. * @param name defines the block name
  60743. */
  60744. constructor(name: string);
  60745. /**
  60746. * Gets the current class name
  60747. * @returns the class name
  60748. */
  60749. getClassName(): string;
  60750. /**
  60751. * Gets the input component
  60752. */
  60753. get input(): NodeMaterialConnectionPoint;
  60754. /**
  60755. * Gets the factor input component
  60756. */
  60757. get factor(): NodeMaterialConnectionPoint;
  60758. /**
  60759. * Gets the output component
  60760. */
  60761. get output(): NodeMaterialConnectionPoint;
  60762. protected _buildBlock(state: NodeMaterialBuildState): this;
  60763. }
  60764. }
  60765. declare module BABYLON {
  60766. /**
  60767. * Block used to clamp a float
  60768. */
  60769. export class ClampBlock extends NodeMaterialBlock {
  60770. /** Gets or sets the minimum range */
  60771. minimum: number;
  60772. /** Gets or sets the maximum range */
  60773. maximum: number;
  60774. /**
  60775. * Creates a new ClampBlock
  60776. * @param name defines the block name
  60777. */
  60778. constructor(name: string);
  60779. /**
  60780. * Gets the current class name
  60781. * @returns the class name
  60782. */
  60783. getClassName(): string;
  60784. /**
  60785. * Gets the value input component
  60786. */
  60787. get value(): NodeMaterialConnectionPoint;
  60788. /**
  60789. * Gets the output component
  60790. */
  60791. get output(): NodeMaterialConnectionPoint;
  60792. protected _buildBlock(state: NodeMaterialBuildState): this;
  60793. protected _dumpPropertiesCode(): string;
  60794. serialize(): any;
  60795. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60796. }
  60797. }
  60798. declare module BABYLON {
  60799. /**
  60800. * Block used to apply a cross product between 2 vectors
  60801. */
  60802. export class CrossBlock extends NodeMaterialBlock {
  60803. /**
  60804. * Creates a new CrossBlock
  60805. * @param name defines the block name
  60806. */
  60807. constructor(name: string);
  60808. /**
  60809. * Gets the current class name
  60810. * @returns the class name
  60811. */
  60812. getClassName(): string;
  60813. /**
  60814. * Gets the left operand input component
  60815. */
  60816. get left(): NodeMaterialConnectionPoint;
  60817. /**
  60818. * Gets the right operand input component
  60819. */
  60820. get right(): NodeMaterialConnectionPoint;
  60821. /**
  60822. * Gets the output component
  60823. */
  60824. get output(): NodeMaterialConnectionPoint;
  60825. protected _buildBlock(state: NodeMaterialBuildState): this;
  60826. }
  60827. }
  60828. declare module BABYLON {
  60829. /**
  60830. * Block used to apply a dot product between 2 vectors
  60831. */
  60832. export class DotBlock extends NodeMaterialBlock {
  60833. /**
  60834. * Creates a new DotBlock
  60835. * @param name defines the block name
  60836. */
  60837. constructor(name: string);
  60838. /**
  60839. * Gets the current class name
  60840. * @returns the class name
  60841. */
  60842. getClassName(): string;
  60843. /**
  60844. * Gets the left operand input component
  60845. */
  60846. get left(): NodeMaterialConnectionPoint;
  60847. /**
  60848. * Gets the right operand input component
  60849. */
  60850. get right(): NodeMaterialConnectionPoint;
  60851. /**
  60852. * Gets the output component
  60853. */
  60854. get output(): NodeMaterialConnectionPoint;
  60855. protected _buildBlock(state: NodeMaterialBuildState): this;
  60856. }
  60857. }
  60858. declare module BABYLON {
  60859. /**
  60860. * Block used to normalize a vector
  60861. */
  60862. export class NormalizeBlock extends NodeMaterialBlock {
  60863. /**
  60864. * Creates a new NormalizeBlock
  60865. * @param name defines the block name
  60866. */
  60867. constructor(name: string);
  60868. /**
  60869. * Gets the current class name
  60870. * @returns the class name
  60871. */
  60872. getClassName(): string;
  60873. /**
  60874. * Gets the input component
  60875. */
  60876. get input(): NodeMaterialConnectionPoint;
  60877. /**
  60878. * Gets the output component
  60879. */
  60880. get output(): NodeMaterialConnectionPoint;
  60881. protected _buildBlock(state: NodeMaterialBuildState): this;
  60882. }
  60883. }
  60884. declare module BABYLON {
  60885. /**
  60886. * Operations supported by the Trigonometry block
  60887. */
  60888. export enum TrigonometryBlockOperations {
  60889. /** Cos */
  60890. Cos = 0,
  60891. /** Sin */
  60892. Sin = 1,
  60893. /** Abs */
  60894. Abs = 2,
  60895. /** Exp */
  60896. Exp = 3,
  60897. /** Exp2 */
  60898. Exp2 = 4,
  60899. /** Round */
  60900. Round = 5,
  60901. /** Floor */
  60902. Floor = 6,
  60903. /** Ceiling */
  60904. Ceiling = 7,
  60905. /** Square root */
  60906. Sqrt = 8,
  60907. /** Log */
  60908. Log = 9,
  60909. /** Tangent */
  60910. Tan = 10,
  60911. /** Arc tangent */
  60912. ArcTan = 11,
  60913. /** Arc cosinus */
  60914. ArcCos = 12,
  60915. /** Arc sinus */
  60916. ArcSin = 13,
  60917. /** Fraction */
  60918. Fract = 14,
  60919. /** Sign */
  60920. Sign = 15,
  60921. /** To radians (from degrees) */
  60922. Radians = 16,
  60923. /** To degrees (from radians) */
  60924. Degrees = 17
  60925. }
  60926. /**
  60927. * Block used to apply trigonometry operation to floats
  60928. */
  60929. export class TrigonometryBlock extends NodeMaterialBlock {
  60930. /**
  60931. * Gets or sets the operation applied by the block
  60932. */
  60933. operation: TrigonometryBlockOperations;
  60934. /**
  60935. * Creates a new TrigonometryBlock
  60936. * @param name defines the block name
  60937. */
  60938. constructor(name: string);
  60939. /**
  60940. * Gets the current class name
  60941. * @returns the class name
  60942. */
  60943. getClassName(): string;
  60944. /**
  60945. * Gets the input component
  60946. */
  60947. get input(): NodeMaterialConnectionPoint;
  60948. /**
  60949. * Gets the output component
  60950. */
  60951. get output(): NodeMaterialConnectionPoint;
  60952. protected _buildBlock(state: NodeMaterialBuildState): this;
  60953. serialize(): any;
  60954. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60955. protected _dumpPropertiesCode(): string;
  60956. }
  60957. }
  60958. declare module BABYLON {
  60959. /**
  60960. * Block used to create a Color3/4 out of individual inputs (one for each component)
  60961. */
  60962. export class ColorMergerBlock extends NodeMaterialBlock {
  60963. /**
  60964. * Create a new ColorMergerBlock
  60965. * @param name defines the block name
  60966. */
  60967. constructor(name: string);
  60968. /**
  60969. * Gets the current class name
  60970. * @returns the class name
  60971. */
  60972. getClassName(): string;
  60973. /**
  60974. * Gets the rgb component (input)
  60975. */
  60976. get rgbIn(): NodeMaterialConnectionPoint;
  60977. /**
  60978. * Gets the r component (input)
  60979. */
  60980. get r(): NodeMaterialConnectionPoint;
  60981. /**
  60982. * Gets the g component (input)
  60983. */
  60984. get g(): NodeMaterialConnectionPoint;
  60985. /**
  60986. * Gets the b component (input)
  60987. */
  60988. get b(): NodeMaterialConnectionPoint;
  60989. /**
  60990. * Gets the a component (input)
  60991. */
  60992. get a(): NodeMaterialConnectionPoint;
  60993. /**
  60994. * Gets the rgba component (output)
  60995. */
  60996. get rgba(): NodeMaterialConnectionPoint;
  60997. /**
  60998. * Gets the rgb component (output)
  60999. */
  61000. get rgbOut(): NodeMaterialConnectionPoint;
  61001. /**
  61002. * Gets the rgb component (output)
  61003. * @deprecated Please use rgbOut instead.
  61004. */
  61005. get rgb(): NodeMaterialConnectionPoint;
  61006. protected _buildBlock(state: NodeMaterialBuildState): this;
  61007. }
  61008. }
  61009. declare module BABYLON {
  61010. /**
  61011. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61012. */
  61013. export class VectorSplitterBlock extends NodeMaterialBlock {
  61014. /**
  61015. * Create a new VectorSplitterBlock
  61016. * @param name defines the block name
  61017. */
  61018. constructor(name: string);
  61019. /**
  61020. * Gets the current class name
  61021. * @returns the class name
  61022. */
  61023. getClassName(): string;
  61024. /**
  61025. * Gets the xyzw component (input)
  61026. */
  61027. get xyzw(): NodeMaterialConnectionPoint;
  61028. /**
  61029. * Gets the xyz component (input)
  61030. */
  61031. get xyzIn(): NodeMaterialConnectionPoint;
  61032. /**
  61033. * Gets the xy component (input)
  61034. */
  61035. get xyIn(): NodeMaterialConnectionPoint;
  61036. /**
  61037. * Gets the xyz component (output)
  61038. */
  61039. get xyzOut(): NodeMaterialConnectionPoint;
  61040. /**
  61041. * Gets the xy component (output)
  61042. */
  61043. get xyOut(): NodeMaterialConnectionPoint;
  61044. /**
  61045. * Gets the x component (output)
  61046. */
  61047. get x(): NodeMaterialConnectionPoint;
  61048. /**
  61049. * Gets the y component (output)
  61050. */
  61051. get y(): NodeMaterialConnectionPoint;
  61052. /**
  61053. * Gets the z component (output)
  61054. */
  61055. get z(): NodeMaterialConnectionPoint;
  61056. /**
  61057. * Gets the w component (output)
  61058. */
  61059. get w(): NodeMaterialConnectionPoint;
  61060. protected _inputRename(name: string): string;
  61061. protected _outputRename(name: string): string;
  61062. protected _buildBlock(state: NodeMaterialBuildState): this;
  61063. }
  61064. }
  61065. declare module BABYLON {
  61066. /**
  61067. * Block used to lerp between 2 values
  61068. */
  61069. export class LerpBlock extends NodeMaterialBlock {
  61070. /**
  61071. * Creates a new LerpBlock
  61072. * @param name defines the block name
  61073. */
  61074. constructor(name: string);
  61075. /**
  61076. * Gets the current class name
  61077. * @returns the class name
  61078. */
  61079. getClassName(): string;
  61080. /**
  61081. * Gets the left operand input component
  61082. */
  61083. get left(): NodeMaterialConnectionPoint;
  61084. /**
  61085. * Gets the right operand input component
  61086. */
  61087. get right(): NodeMaterialConnectionPoint;
  61088. /**
  61089. * Gets the gradient operand input component
  61090. */
  61091. get gradient(): NodeMaterialConnectionPoint;
  61092. /**
  61093. * Gets the output component
  61094. */
  61095. get output(): NodeMaterialConnectionPoint;
  61096. protected _buildBlock(state: NodeMaterialBuildState): this;
  61097. }
  61098. }
  61099. declare module BABYLON {
  61100. /**
  61101. * Block used to divide 2 vectors
  61102. */
  61103. export class DivideBlock extends NodeMaterialBlock {
  61104. /**
  61105. * Creates a new DivideBlock
  61106. * @param name defines the block name
  61107. */
  61108. constructor(name: string);
  61109. /**
  61110. * Gets the current class name
  61111. * @returns the class name
  61112. */
  61113. getClassName(): string;
  61114. /**
  61115. * Gets the left operand input component
  61116. */
  61117. get left(): NodeMaterialConnectionPoint;
  61118. /**
  61119. * Gets the right operand input component
  61120. */
  61121. get right(): NodeMaterialConnectionPoint;
  61122. /**
  61123. * Gets the output component
  61124. */
  61125. get output(): NodeMaterialConnectionPoint;
  61126. protected _buildBlock(state: NodeMaterialBuildState): this;
  61127. }
  61128. }
  61129. declare module BABYLON {
  61130. /**
  61131. * Block used to subtract 2 vectors
  61132. */
  61133. export class SubtractBlock extends NodeMaterialBlock {
  61134. /**
  61135. * Creates a new SubtractBlock
  61136. * @param name defines the block name
  61137. */
  61138. constructor(name: string);
  61139. /**
  61140. * Gets the current class name
  61141. * @returns the class name
  61142. */
  61143. getClassName(): string;
  61144. /**
  61145. * Gets the left operand input component
  61146. */
  61147. get left(): NodeMaterialConnectionPoint;
  61148. /**
  61149. * Gets the right operand input component
  61150. */
  61151. get right(): NodeMaterialConnectionPoint;
  61152. /**
  61153. * Gets the output component
  61154. */
  61155. get output(): NodeMaterialConnectionPoint;
  61156. protected _buildBlock(state: NodeMaterialBuildState): this;
  61157. }
  61158. }
  61159. declare module BABYLON {
  61160. /**
  61161. * Block used to step a value
  61162. */
  61163. export class StepBlock extends NodeMaterialBlock {
  61164. /**
  61165. * Creates a new StepBlock
  61166. * @param name defines the block name
  61167. */
  61168. constructor(name: string);
  61169. /**
  61170. * Gets the current class name
  61171. * @returns the class name
  61172. */
  61173. getClassName(): string;
  61174. /**
  61175. * Gets the value operand input component
  61176. */
  61177. get value(): NodeMaterialConnectionPoint;
  61178. /**
  61179. * Gets the edge operand input component
  61180. */
  61181. get edge(): NodeMaterialConnectionPoint;
  61182. /**
  61183. * Gets the output component
  61184. */
  61185. get output(): NodeMaterialConnectionPoint;
  61186. protected _buildBlock(state: NodeMaterialBuildState): this;
  61187. }
  61188. }
  61189. declare module BABYLON {
  61190. /**
  61191. * Block used to get the opposite (1 - x) of a value
  61192. */
  61193. export class OneMinusBlock extends NodeMaterialBlock {
  61194. /**
  61195. * Creates a new OneMinusBlock
  61196. * @param name defines the block name
  61197. */
  61198. constructor(name: string);
  61199. /**
  61200. * Gets the current class name
  61201. * @returns the class name
  61202. */
  61203. getClassName(): string;
  61204. /**
  61205. * Gets the input component
  61206. */
  61207. get input(): NodeMaterialConnectionPoint;
  61208. /**
  61209. * Gets the output component
  61210. */
  61211. get output(): NodeMaterialConnectionPoint;
  61212. protected _buildBlock(state: NodeMaterialBuildState): this;
  61213. }
  61214. }
  61215. declare module BABYLON {
  61216. /**
  61217. * Block used to get the view direction
  61218. */
  61219. export class ViewDirectionBlock extends NodeMaterialBlock {
  61220. /**
  61221. * Creates a new ViewDirectionBlock
  61222. * @param name defines the block name
  61223. */
  61224. constructor(name: string);
  61225. /**
  61226. * Gets the current class name
  61227. * @returns the class name
  61228. */
  61229. getClassName(): string;
  61230. /**
  61231. * Gets the world position component
  61232. */
  61233. get worldPosition(): NodeMaterialConnectionPoint;
  61234. /**
  61235. * Gets the camera position component
  61236. */
  61237. get cameraPosition(): NodeMaterialConnectionPoint;
  61238. /**
  61239. * Gets the output component
  61240. */
  61241. get output(): NodeMaterialConnectionPoint;
  61242. autoConfigure(material: NodeMaterial): void;
  61243. protected _buildBlock(state: NodeMaterialBuildState): this;
  61244. }
  61245. }
  61246. declare module BABYLON {
  61247. /**
  61248. * Block used to compute fresnel value
  61249. */
  61250. export class FresnelBlock extends NodeMaterialBlock {
  61251. /**
  61252. * Create a new FresnelBlock
  61253. * @param name defines the block name
  61254. */
  61255. constructor(name: string);
  61256. /**
  61257. * Gets the current class name
  61258. * @returns the class name
  61259. */
  61260. getClassName(): string;
  61261. /**
  61262. * Gets the world normal input component
  61263. */
  61264. get worldNormal(): NodeMaterialConnectionPoint;
  61265. /**
  61266. * Gets the view direction input component
  61267. */
  61268. get viewDirection(): NodeMaterialConnectionPoint;
  61269. /**
  61270. * Gets the bias input component
  61271. */
  61272. get bias(): NodeMaterialConnectionPoint;
  61273. /**
  61274. * Gets the camera (or eye) position component
  61275. */
  61276. get power(): NodeMaterialConnectionPoint;
  61277. /**
  61278. * Gets the fresnel output component
  61279. */
  61280. get fresnel(): NodeMaterialConnectionPoint;
  61281. autoConfigure(material: NodeMaterial): void;
  61282. protected _buildBlock(state: NodeMaterialBuildState): this;
  61283. }
  61284. }
  61285. declare module BABYLON {
  61286. /**
  61287. * Block used to get the max of 2 values
  61288. */
  61289. export class MaxBlock extends NodeMaterialBlock {
  61290. /**
  61291. * Creates a new MaxBlock
  61292. * @param name defines the block name
  61293. */
  61294. constructor(name: string);
  61295. /**
  61296. * Gets the current class name
  61297. * @returns the class name
  61298. */
  61299. getClassName(): string;
  61300. /**
  61301. * Gets the left operand input component
  61302. */
  61303. get left(): NodeMaterialConnectionPoint;
  61304. /**
  61305. * Gets the right operand input component
  61306. */
  61307. get right(): NodeMaterialConnectionPoint;
  61308. /**
  61309. * Gets the output component
  61310. */
  61311. get output(): NodeMaterialConnectionPoint;
  61312. protected _buildBlock(state: NodeMaterialBuildState): this;
  61313. }
  61314. }
  61315. declare module BABYLON {
  61316. /**
  61317. * Block used to get the min of 2 values
  61318. */
  61319. export class MinBlock extends NodeMaterialBlock {
  61320. /**
  61321. * Creates a new MinBlock
  61322. * @param name defines the block name
  61323. */
  61324. constructor(name: string);
  61325. /**
  61326. * Gets the current class name
  61327. * @returns the class name
  61328. */
  61329. getClassName(): string;
  61330. /**
  61331. * Gets the left operand input component
  61332. */
  61333. get left(): NodeMaterialConnectionPoint;
  61334. /**
  61335. * Gets the right operand input component
  61336. */
  61337. get right(): NodeMaterialConnectionPoint;
  61338. /**
  61339. * Gets the output component
  61340. */
  61341. get output(): NodeMaterialConnectionPoint;
  61342. protected _buildBlock(state: NodeMaterialBuildState): this;
  61343. }
  61344. }
  61345. declare module BABYLON {
  61346. /**
  61347. * Block used to get the distance between 2 values
  61348. */
  61349. export class DistanceBlock extends NodeMaterialBlock {
  61350. /**
  61351. * Creates a new DistanceBlock
  61352. * @param name defines the block name
  61353. */
  61354. constructor(name: string);
  61355. /**
  61356. * Gets the current class name
  61357. * @returns the class name
  61358. */
  61359. getClassName(): string;
  61360. /**
  61361. * Gets the left operand input component
  61362. */
  61363. get left(): NodeMaterialConnectionPoint;
  61364. /**
  61365. * Gets the right operand input component
  61366. */
  61367. get right(): NodeMaterialConnectionPoint;
  61368. /**
  61369. * Gets the output component
  61370. */
  61371. get output(): NodeMaterialConnectionPoint;
  61372. protected _buildBlock(state: NodeMaterialBuildState): this;
  61373. }
  61374. }
  61375. declare module BABYLON {
  61376. /**
  61377. * Block used to get the length of a vector
  61378. */
  61379. export class LengthBlock extends NodeMaterialBlock {
  61380. /**
  61381. * Creates a new LengthBlock
  61382. * @param name defines the block name
  61383. */
  61384. constructor(name: string);
  61385. /**
  61386. * Gets the current class name
  61387. * @returns the class name
  61388. */
  61389. getClassName(): string;
  61390. /**
  61391. * Gets the value input component
  61392. */
  61393. get value(): NodeMaterialConnectionPoint;
  61394. /**
  61395. * Gets the output component
  61396. */
  61397. get output(): NodeMaterialConnectionPoint;
  61398. protected _buildBlock(state: NodeMaterialBuildState): this;
  61399. }
  61400. }
  61401. declare module BABYLON {
  61402. /**
  61403. * Block used to get negative version of a value (i.e. x * -1)
  61404. */
  61405. export class NegateBlock extends NodeMaterialBlock {
  61406. /**
  61407. * Creates a new NegateBlock
  61408. * @param name defines the block name
  61409. */
  61410. constructor(name: string);
  61411. /**
  61412. * Gets the current class name
  61413. * @returns the class name
  61414. */
  61415. getClassName(): string;
  61416. /**
  61417. * Gets the value input component
  61418. */
  61419. get value(): NodeMaterialConnectionPoint;
  61420. /**
  61421. * Gets the output component
  61422. */
  61423. get output(): NodeMaterialConnectionPoint;
  61424. protected _buildBlock(state: NodeMaterialBuildState): this;
  61425. }
  61426. }
  61427. declare module BABYLON {
  61428. /**
  61429. * Block used to get the value of the first parameter raised to the power of the second
  61430. */
  61431. export class PowBlock extends NodeMaterialBlock {
  61432. /**
  61433. * Creates a new PowBlock
  61434. * @param name defines the block name
  61435. */
  61436. constructor(name: string);
  61437. /**
  61438. * Gets the current class name
  61439. * @returns the class name
  61440. */
  61441. getClassName(): string;
  61442. /**
  61443. * Gets the value operand input component
  61444. */
  61445. get value(): NodeMaterialConnectionPoint;
  61446. /**
  61447. * Gets the power operand input component
  61448. */
  61449. get power(): NodeMaterialConnectionPoint;
  61450. /**
  61451. * Gets the output component
  61452. */
  61453. get output(): NodeMaterialConnectionPoint;
  61454. protected _buildBlock(state: NodeMaterialBuildState): this;
  61455. }
  61456. }
  61457. declare module BABYLON {
  61458. /**
  61459. * Block used to get a random number
  61460. */
  61461. export class RandomNumberBlock extends NodeMaterialBlock {
  61462. /**
  61463. * Creates a new RandomNumberBlock
  61464. * @param name defines the block name
  61465. */
  61466. constructor(name: string);
  61467. /**
  61468. * Gets the current class name
  61469. * @returns the class name
  61470. */
  61471. getClassName(): string;
  61472. /**
  61473. * Gets the seed input component
  61474. */
  61475. get seed(): NodeMaterialConnectionPoint;
  61476. /**
  61477. * Gets the output component
  61478. */
  61479. get output(): NodeMaterialConnectionPoint;
  61480. protected _buildBlock(state: NodeMaterialBuildState): this;
  61481. }
  61482. }
  61483. declare module BABYLON {
  61484. /**
  61485. * Block used to compute arc tangent of 2 values
  61486. */
  61487. export class ArcTan2Block extends NodeMaterialBlock {
  61488. /**
  61489. * Creates a new ArcTan2Block
  61490. * @param name defines the block name
  61491. */
  61492. constructor(name: string);
  61493. /**
  61494. * Gets the current class name
  61495. * @returns the class name
  61496. */
  61497. getClassName(): string;
  61498. /**
  61499. * Gets the x operand input component
  61500. */
  61501. get x(): NodeMaterialConnectionPoint;
  61502. /**
  61503. * Gets the y operand input component
  61504. */
  61505. get y(): NodeMaterialConnectionPoint;
  61506. /**
  61507. * Gets the output component
  61508. */
  61509. get output(): NodeMaterialConnectionPoint;
  61510. protected _buildBlock(state: NodeMaterialBuildState): this;
  61511. }
  61512. }
  61513. declare module BABYLON {
  61514. /**
  61515. * Block used to smooth step a value
  61516. */
  61517. export class SmoothStepBlock extends NodeMaterialBlock {
  61518. /**
  61519. * Creates a new SmoothStepBlock
  61520. * @param name defines the block name
  61521. */
  61522. constructor(name: string);
  61523. /**
  61524. * Gets the current class name
  61525. * @returns the class name
  61526. */
  61527. getClassName(): string;
  61528. /**
  61529. * Gets the value operand input component
  61530. */
  61531. get value(): NodeMaterialConnectionPoint;
  61532. /**
  61533. * Gets the first edge operand input component
  61534. */
  61535. get edge0(): NodeMaterialConnectionPoint;
  61536. /**
  61537. * Gets the second edge operand input component
  61538. */
  61539. get edge1(): NodeMaterialConnectionPoint;
  61540. /**
  61541. * Gets the output component
  61542. */
  61543. get output(): NodeMaterialConnectionPoint;
  61544. protected _buildBlock(state: NodeMaterialBuildState): this;
  61545. }
  61546. }
  61547. declare module BABYLON {
  61548. /**
  61549. * Block used to get the reciprocal (1 / x) of a value
  61550. */
  61551. export class ReciprocalBlock extends NodeMaterialBlock {
  61552. /**
  61553. * Creates a new ReciprocalBlock
  61554. * @param name defines the block name
  61555. */
  61556. constructor(name: string);
  61557. /**
  61558. * Gets the current class name
  61559. * @returns the class name
  61560. */
  61561. getClassName(): string;
  61562. /**
  61563. * Gets the input component
  61564. */
  61565. get input(): NodeMaterialConnectionPoint;
  61566. /**
  61567. * Gets the output component
  61568. */
  61569. get output(): NodeMaterialConnectionPoint;
  61570. protected _buildBlock(state: NodeMaterialBuildState): this;
  61571. }
  61572. }
  61573. declare module BABYLON {
  61574. /**
  61575. * Block used to replace a color by another one
  61576. */
  61577. export class ReplaceColorBlock extends NodeMaterialBlock {
  61578. /**
  61579. * Creates a new ReplaceColorBlock
  61580. * @param name defines the block name
  61581. */
  61582. constructor(name: string);
  61583. /**
  61584. * Gets the current class name
  61585. * @returns the class name
  61586. */
  61587. getClassName(): string;
  61588. /**
  61589. * Gets the value input component
  61590. */
  61591. get value(): NodeMaterialConnectionPoint;
  61592. /**
  61593. * Gets the reference input component
  61594. */
  61595. get reference(): NodeMaterialConnectionPoint;
  61596. /**
  61597. * Gets the distance input component
  61598. */
  61599. get distance(): NodeMaterialConnectionPoint;
  61600. /**
  61601. * Gets the replacement input component
  61602. */
  61603. get replacement(): NodeMaterialConnectionPoint;
  61604. /**
  61605. * Gets the output component
  61606. */
  61607. get output(): NodeMaterialConnectionPoint;
  61608. protected _buildBlock(state: NodeMaterialBuildState): this;
  61609. }
  61610. }
  61611. declare module BABYLON {
  61612. /**
  61613. * Block used to posterize a value
  61614. * @see https://en.wikipedia.org/wiki/Posterization
  61615. */
  61616. export class PosterizeBlock extends NodeMaterialBlock {
  61617. /**
  61618. * Creates a new PosterizeBlock
  61619. * @param name defines the block name
  61620. */
  61621. constructor(name: string);
  61622. /**
  61623. * Gets the current class name
  61624. * @returns the class name
  61625. */
  61626. getClassName(): string;
  61627. /**
  61628. * Gets the value input component
  61629. */
  61630. get value(): NodeMaterialConnectionPoint;
  61631. /**
  61632. * Gets the steps input component
  61633. */
  61634. get steps(): NodeMaterialConnectionPoint;
  61635. /**
  61636. * Gets the output component
  61637. */
  61638. get output(): NodeMaterialConnectionPoint;
  61639. protected _buildBlock(state: NodeMaterialBuildState): this;
  61640. }
  61641. }
  61642. declare module BABYLON {
  61643. /**
  61644. * Operations supported by the Wave block
  61645. */
  61646. export enum WaveBlockKind {
  61647. /** SawTooth */
  61648. SawTooth = 0,
  61649. /** Square */
  61650. Square = 1,
  61651. /** Triangle */
  61652. Triangle = 2
  61653. }
  61654. /**
  61655. * Block used to apply wave operation to floats
  61656. */
  61657. export class WaveBlock extends NodeMaterialBlock {
  61658. /**
  61659. * Gets or sets the kibnd of wave to be applied by the block
  61660. */
  61661. kind: WaveBlockKind;
  61662. /**
  61663. * Creates a new WaveBlock
  61664. * @param name defines the block name
  61665. */
  61666. constructor(name: string);
  61667. /**
  61668. * Gets the current class name
  61669. * @returns the class name
  61670. */
  61671. getClassName(): string;
  61672. /**
  61673. * Gets the input component
  61674. */
  61675. get input(): NodeMaterialConnectionPoint;
  61676. /**
  61677. * Gets the output component
  61678. */
  61679. get output(): NodeMaterialConnectionPoint;
  61680. protected _buildBlock(state: NodeMaterialBuildState): this;
  61681. serialize(): any;
  61682. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61683. }
  61684. }
  61685. declare module BABYLON {
  61686. /**
  61687. * Class used to store a color step for the GradientBlock
  61688. */
  61689. export class GradientBlockColorStep {
  61690. /**
  61691. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  61692. */
  61693. step: number;
  61694. /**
  61695. * Gets or sets the color associated with this step
  61696. */
  61697. color: Color3;
  61698. /**
  61699. * Creates a new GradientBlockColorStep
  61700. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  61701. * @param color defines the color associated with this step
  61702. */
  61703. constructor(
  61704. /**
  61705. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  61706. */
  61707. step: number,
  61708. /**
  61709. * Gets or sets the color associated with this step
  61710. */
  61711. color: Color3);
  61712. }
  61713. /**
  61714. * Block used to return a color from a gradient based on an input value between 0 and 1
  61715. */
  61716. export class GradientBlock extends NodeMaterialBlock {
  61717. /**
  61718. * Gets or sets the list of color steps
  61719. */
  61720. colorSteps: GradientBlockColorStep[];
  61721. /**
  61722. * Creates a new GradientBlock
  61723. * @param name defines the block name
  61724. */
  61725. constructor(name: string);
  61726. /**
  61727. * Gets the current class name
  61728. * @returns the class name
  61729. */
  61730. getClassName(): string;
  61731. /**
  61732. * Gets the gradient input component
  61733. */
  61734. get gradient(): NodeMaterialConnectionPoint;
  61735. /**
  61736. * Gets the output component
  61737. */
  61738. get output(): NodeMaterialConnectionPoint;
  61739. private _writeColorConstant;
  61740. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61741. serialize(): any;
  61742. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61743. protected _dumpPropertiesCode(): string;
  61744. }
  61745. }
  61746. declare module BABYLON {
  61747. /**
  61748. * Block used to normalize lerp between 2 values
  61749. */
  61750. export class NLerpBlock extends NodeMaterialBlock {
  61751. /**
  61752. * Creates a new NLerpBlock
  61753. * @param name defines the block name
  61754. */
  61755. constructor(name: string);
  61756. /**
  61757. * Gets the current class name
  61758. * @returns the class name
  61759. */
  61760. getClassName(): string;
  61761. /**
  61762. * Gets the left operand input component
  61763. */
  61764. get left(): NodeMaterialConnectionPoint;
  61765. /**
  61766. * Gets the right operand input component
  61767. */
  61768. get right(): NodeMaterialConnectionPoint;
  61769. /**
  61770. * Gets the gradient operand input component
  61771. */
  61772. get gradient(): NodeMaterialConnectionPoint;
  61773. /**
  61774. * Gets the output component
  61775. */
  61776. get output(): NodeMaterialConnectionPoint;
  61777. protected _buildBlock(state: NodeMaterialBuildState): this;
  61778. }
  61779. }
  61780. declare module BABYLON {
  61781. /**
  61782. * block used to Generate a Worley Noise 3D Noise Pattern
  61783. */
  61784. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  61785. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61786. manhattanDistance: boolean;
  61787. /**
  61788. * Creates a new WorleyNoise3DBlock
  61789. * @param name defines the block name
  61790. */
  61791. constructor(name: string);
  61792. /**
  61793. * Gets the current class name
  61794. * @returns the class name
  61795. */
  61796. getClassName(): string;
  61797. /**
  61798. * Gets the seed input component
  61799. */
  61800. get seed(): NodeMaterialConnectionPoint;
  61801. /**
  61802. * Gets the jitter input component
  61803. */
  61804. get jitter(): NodeMaterialConnectionPoint;
  61805. /**
  61806. * Gets the output component
  61807. */
  61808. get output(): NodeMaterialConnectionPoint;
  61809. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61810. /**
  61811. * Exposes the properties to the UI?
  61812. */
  61813. protected _dumpPropertiesCode(): string;
  61814. /**
  61815. * Exposes the properties to the Seralize?
  61816. */
  61817. serialize(): any;
  61818. /**
  61819. * Exposes the properties to the deseralize?
  61820. */
  61821. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61822. }
  61823. }
  61824. declare module BABYLON {
  61825. /**
  61826. * block used to Generate a Simplex Perlin 3d Noise Pattern
  61827. */
  61828. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  61829. /**
  61830. * Creates a new SimplexPerlin3DBlock
  61831. * @param name defines the block name
  61832. */
  61833. constructor(name: string);
  61834. /**
  61835. * Gets the current class name
  61836. * @returns the class name
  61837. */
  61838. getClassName(): string;
  61839. /**
  61840. * Gets the seed operand input component
  61841. */
  61842. get seed(): NodeMaterialConnectionPoint;
  61843. /**
  61844. * Gets the output component
  61845. */
  61846. get output(): NodeMaterialConnectionPoint;
  61847. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61848. }
  61849. }
  61850. declare module BABYLON {
  61851. /**
  61852. * Block used to blend normals
  61853. */
  61854. export class NormalBlendBlock extends NodeMaterialBlock {
  61855. /**
  61856. * Creates a new NormalBlendBlock
  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 first input component
  61867. */
  61868. get normalMap0(): NodeMaterialConnectionPoint;
  61869. /**
  61870. * Gets the second input component
  61871. */
  61872. get normalMap1(): NodeMaterialConnectionPoint;
  61873. /**
  61874. * Gets the output component
  61875. */
  61876. get output(): NodeMaterialConnectionPoint;
  61877. protected _buildBlock(state: NodeMaterialBuildState): this;
  61878. }
  61879. }
  61880. declare module BABYLON {
  61881. /**
  61882. * Block used to rotate a 2d vector by a given angle
  61883. */
  61884. export class Rotate2dBlock extends NodeMaterialBlock {
  61885. /**
  61886. * Creates a new Rotate2dBlock
  61887. * @param name defines the block name
  61888. */
  61889. constructor(name: string);
  61890. /**
  61891. * Gets the current class name
  61892. * @returns the class name
  61893. */
  61894. getClassName(): string;
  61895. /**
  61896. * Gets the input vector
  61897. */
  61898. get input(): NodeMaterialConnectionPoint;
  61899. /**
  61900. * Gets the input angle
  61901. */
  61902. get angle(): NodeMaterialConnectionPoint;
  61903. /**
  61904. * Gets the output component
  61905. */
  61906. get output(): NodeMaterialConnectionPoint;
  61907. autoConfigure(material: NodeMaterial): void;
  61908. protected _buildBlock(state: NodeMaterialBuildState): this;
  61909. }
  61910. }
  61911. declare module BABYLON {
  61912. /**
  61913. * Block used to get the reflected vector from a direction and a normal
  61914. */
  61915. export class ReflectBlock extends NodeMaterialBlock {
  61916. /**
  61917. * Creates a new ReflectBlock
  61918. * @param name defines the block name
  61919. */
  61920. constructor(name: string);
  61921. /**
  61922. * Gets the current class name
  61923. * @returns the class name
  61924. */
  61925. getClassName(): string;
  61926. /**
  61927. * Gets the incident component
  61928. */
  61929. get incident(): NodeMaterialConnectionPoint;
  61930. /**
  61931. * Gets the normal component
  61932. */
  61933. get normal(): NodeMaterialConnectionPoint;
  61934. /**
  61935. * Gets the output component
  61936. */
  61937. get output(): NodeMaterialConnectionPoint;
  61938. protected _buildBlock(state: NodeMaterialBuildState): this;
  61939. }
  61940. }
  61941. declare module BABYLON {
  61942. /**
  61943. * Block used to get the refracted vector from a direction and a normal
  61944. */
  61945. export class RefractBlock extends NodeMaterialBlock {
  61946. /**
  61947. * Creates a new RefractBlock
  61948. * @param name defines the block name
  61949. */
  61950. constructor(name: string);
  61951. /**
  61952. * Gets the current class name
  61953. * @returns the class name
  61954. */
  61955. getClassName(): string;
  61956. /**
  61957. * Gets the incident component
  61958. */
  61959. get incident(): NodeMaterialConnectionPoint;
  61960. /**
  61961. * Gets the normal component
  61962. */
  61963. get normal(): NodeMaterialConnectionPoint;
  61964. /**
  61965. * Gets the index of refraction component
  61966. */
  61967. get ior(): NodeMaterialConnectionPoint;
  61968. /**
  61969. * Gets the output component
  61970. */
  61971. get output(): NodeMaterialConnectionPoint;
  61972. protected _buildBlock(state: NodeMaterialBuildState): this;
  61973. }
  61974. }
  61975. declare module BABYLON {
  61976. /**
  61977. * Block used to desaturate a color
  61978. */
  61979. export class DesaturateBlock extends NodeMaterialBlock {
  61980. /**
  61981. * Creates a new DesaturateBlock
  61982. * @param name defines the block name
  61983. */
  61984. constructor(name: string);
  61985. /**
  61986. * Gets the current class name
  61987. * @returns the class name
  61988. */
  61989. getClassName(): string;
  61990. /**
  61991. * Gets the color operand input component
  61992. */
  61993. get color(): NodeMaterialConnectionPoint;
  61994. /**
  61995. * Gets the level operand input component
  61996. */
  61997. get level(): NodeMaterialConnectionPoint;
  61998. /**
  61999. * Gets the output component
  62000. */
  62001. get output(): NodeMaterialConnectionPoint;
  62002. protected _buildBlock(state: NodeMaterialBuildState): this;
  62003. }
  62004. }
  62005. declare module BABYLON {
  62006. /**
  62007. * Block used to implement the ambient occlusion module of the PBR material
  62008. */
  62009. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62010. /**
  62011. * Create a new AmbientOcclusionBlock
  62012. * @param name defines the block name
  62013. */
  62014. constructor(name: string);
  62015. /**
  62016. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62017. */
  62018. useAmbientInGrayScale: boolean;
  62019. /**
  62020. * Initialize the block and prepare the context for build
  62021. * @param state defines the state that will be used for the build
  62022. */
  62023. initialize(state: NodeMaterialBuildState): void;
  62024. /**
  62025. * Gets the current class name
  62026. * @returns the class name
  62027. */
  62028. getClassName(): string;
  62029. /**
  62030. * Gets the texture input component
  62031. */
  62032. get texture(): NodeMaterialConnectionPoint;
  62033. /**
  62034. * Gets the texture intensity component
  62035. */
  62036. get intensity(): NodeMaterialConnectionPoint;
  62037. /**
  62038. * Gets the direct light intensity input component
  62039. */
  62040. get directLightIntensity(): NodeMaterialConnectionPoint;
  62041. /**
  62042. * Gets the ambient occlusion object output component
  62043. */
  62044. get ambientOcclusion(): NodeMaterialConnectionPoint;
  62045. /**
  62046. * Gets the main code of the block (fragment side)
  62047. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  62048. * @returns the shader code
  62049. */
  62050. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  62051. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62052. protected _buildBlock(state: NodeMaterialBuildState): this;
  62053. protected _dumpPropertiesCode(): string;
  62054. serialize(): any;
  62055. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62056. }
  62057. }
  62058. declare module BABYLON {
  62059. /**
  62060. * Block used to implement the reflection module of the PBR material
  62061. */
  62062. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  62063. /** @hidden */
  62064. _defineLODReflectionAlpha: string;
  62065. /** @hidden */
  62066. _defineLinearSpecularReflection: string;
  62067. private _vEnvironmentIrradianceName;
  62068. /** @hidden */
  62069. _vReflectionMicrosurfaceInfosName: string;
  62070. /** @hidden */
  62071. _vReflectionInfosName: string;
  62072. private _scene;
  62073. /**
  62074. * The three properties below are set by the main PBR block prior to calling methods of this class.
  62075. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62076. * It's less burden on the user side in the editor part.
  62077. */
  62078. /** @hidden */
  62079. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62080. /** @hidden */
  62081. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62082. /** @hidden */
  62083. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  62084. /**
  62085. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  62086. * diffuse part of the IBL.
  62087. */
  62088. useSphericalHarmonics: boolean;
  62089. /**
  62090. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  62091. */
  62092. forceIrradianceInFragment: boolean;
  62093. /**
  62094. * Create a new ReflectionBlock
  62095. * @param name defines the block name
  62096. */
  62097. constructor(name: string);
  62098. /**
  62099. * Gets the current class name
  62100. * @returns the class name
  62101. */
  62102. getClassName(): string;
  62103. /**
  62104. * Gets the position input component
  62105. */
  62106. get position(): NodeMaterialConnectionPoint;
  62107. /**
  62108. * Gets the world position input component
  62109. */
  62110. get worldPosition(): NodeMaterialConnectionPoint;
  62111. /**
  62112. * Gets the world normal input component
  62113. */
  62114. get worldNormal(): NodeMaterialConnectionPoint;
  62115. /**
  62116. * Gets the world input component
  62117. */
  62118. get world(): NodeMaterialConnectionPoint;
  62119. /**
  62120. * Gets the camera (or eye) position component
  62121. */
  62122. get cameraPosition(): NodeMaterialConnectionPoint;
  62123. /**
  62124. * Gets the view input component
  62125. */
  62126. get view(): NodeMaterialConnectionPoint;
  62127. /**
  62128. * Gets the color input component
  62129. */
  62130. get color(): NodeMaterialConnectionPoint;
  62131. /**
  62132. * Gets the reflection object output component
  62133. */
  62134. get reflection(): NodeMaterialConnectionPoint;
  62135. /**
  62136. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  62137. */
  62138. get hasTexture(): boolean;
  62139. /**
  62140. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  62141. */
  62142. get reflectionColor(): string;
  62143. protected _getTexture(): Nullable<BaseTexture>;
  62144. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62145. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62146. /**
  62147. * Gets the code to inject in the vertex shader
  62148. * @param state current state of the node material building
  62149. * @returns the shader code
  62150. */
  62151. handleVertexSide(state: NodeMaterialBuildState): string;
  62152. /**
  62153. * Gets the main code of the block (fragment side)
  62154. * @param state current state of the node material building
  62155. * @param normalVarName name of the existing variable corresponding to the normal
  62156. * @returns the shader code
  62157. */
  62158. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  62159. protected _buildBlock(state: NodeMaterialBuildState): this;
  62160. protected _dumpPropertiesCode(): string;
  62161. serialize(): any;
  62162. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62163. }
  62164. }
  62165. declare module BABYLON {
  62166. /**
  62167. * Block used to implement the sheen module of the PBR material
  62168. */
  62169. export class SheenBlock extends NodeMaterialBlock {
  62170. /**
  62171. * Create a new SheenBlock
  62172. * @param name defines the block name
  62173. */
  62174. constructor(name: string);
  62175. /**
  62176. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  62177. * It allows the strength of the sheen effect to not depend on the base color of the material,
  62178. * making it easier to setup and tweak the effect
  62179. */
  62180. albedoScaling: boolean;
  62181. /**
  62182. * Defines if the sheen is linked to the sheen color.
  62183. */
  62184. linkSheenWithAlbedo: boolean;
  62185. /**
  62186. * Initialize the block and prepare the context for build
  62187. * @param state defines the state that will be used for the build
  62188. */
  62189. initialize(state: NodeMaterialBuildState): void;
  62190. /**
  62191. * Gets the current class name
  62192. * @returns the class name
  62193. */
  62194. getClassName(): string;
  62195. /**
  62196. * Gets the intensity input component
  62197. */
  62198. get intensity(): NodeMaterialConnectionPoint;
  62199. /**
  62200. * Gets the color input component
  62201. */
  62202. get color(): NodeMaterialConnectionPoint;
  62203. /**
  62204. * Gets the roughness input component
  62205. */
  62206. get roughness(): NodeMaterialConnectionPoint;
  62207. /**
  62208. * Gets the texture input component
  62209. */
  62210. get texture(): NodeMaterialConnectionPoint;
  62211. /**
  62212. * Gets the sheen object output component
  62213. */
  62214. get sheen(): NodeMaterialConnectionPoint;
  62215. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62216. /**
  62217. * Gets the main code of the block (fragment side)
  62218. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62219. * @returns the shader code
  62220. */
  62221. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  62222. protected _buildBlock(state: NodeMaterialBuildState): this;
  62223. protected _dumpPropertiesCode(): string;
  62224. serialize(): any;
  62225. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62226. }
  62227. }
  62228. declare module BABYLON {
  62229. /**
  62230. * Block used to implement the reflectivity module of the PBR material
  62231. */
  62232. export class ReflectivityBlock extends NodeMaterialBlock {
  62233. /**
  62234. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  62235. */
  62236. useAmbientOcclusionFromMetallicTextureRed: boolean;
  62237. /**
  62238. * Specifies if the metallic texture contains the metallness information in its blue channel.
  62239. */
  62240. useMetallnessFromMetallicTextureBlue: boolean;
  62241. /**
  62242. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  62243. */
  62244. useRoughnessFromMetallicTextureAlpha: boolean;
  62245. /**
  62246. * Specifies if the metallic texture contains the roughness information in its green channel.
  62247. */
  62248. useRoughnessFromMetallicTextureGreen: boolean;
  62249. /**
  62250. * Create a new ReflectivityBlock
  62251. * @param name defines the block name
  62252. */
  62253. constructor(name: string);
  62254. /**
  62255. * Initialize the block and prepare the context for build
  62256. * @param state defines the state that will be used for the build
  62257. */
  62258. initialize(state: NodeMaterialBuildState): void;
  62259. /**
  62260. * Gets the current class name
  62261. * @returns the class name
  62262. */
  62263. getClassName(): string;
  62264. /**
  62265. * Gets the metallic input component
  62266. */
  62267. get metallic(): NodeMaterialConnectionPoint;
  62268. /**
  62269. * Gets the roughness input component
  62270. */
  62271. get roughness(): NodeMaterialConnectionPoint;
  62272. /**
  62273. * Gets the texture input component
  62274. */
  62275. get texture(): NodeMaterialConnectionPoint;
  62276. /**
  62277. * Gets the reflectivity object output component
  62278. */
  62279. get reflectivity(): NodeMaterialConnectionPoint;
  62280. /**
  62281. * Gets the main code of the block (fragment side)
  62282. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  62283. * @returns the shader code
  62284. */
  62285. getCode(aoIntensityVarName: string): string;
  62286. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62287. protected _buildBlock(state: NodeMaterialBuildState): this;
  62288. protected _dumpPropertiesCode(): string;
  62289. serialize(): any;
  62290. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62291. }
  62292. }
  62293. declare module BABYLON {
  62294. /**
  62295. * Block used to implement the anisotropy module of the PBR material
  62296. */
  62297. export class AnisotropyBlock extends NodeMaterialBlock {
  62298. /**
  62299. * The two properties below are set by the main PBR block prior to calling methods of this class.
  62300. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62301. * It's less burden on the user side in the editor part.
  62302. */
  62303. /** @hidden */
  62304. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62305. /** @hidden */
  62306. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62307. /**
  62308. * Create a new AnisotropyBlock
  62309. * @param name defines the block name
  62310. */
  62311. constructor(name: string);
  62312. /**
  62313. * Initialize the block and prepare the context for build
  62314. * @param state defines the state that will be used for the build
  62315. */
  62316. initialize(state: NodeMaterialBuildState): void;
  62317. /**
  62318. * Gets the current class name
  62319. * @returns the class name
  62320. */
  62321. getClassName(): string;
  62322. /**
  62323. * Gets the intensity input component
  62324. */
  62325. get intensity(): NodeMaterialConnectionPoint;
  62326. /**
  62327. * Gets the direction input component
  62328. */
  62329. get direction(): NodeMaterialConnectionPoint;
  62330. /**
  62331. * Gets the texture input component
  62332. */
  62333. get texture(): NodeMaterialConnectionPoint;
  62334. /**
  62335. * Gets the uv input component
  62336. */
  62337. get uv(): NodeMaterialConnectionPoint;
  62338. /**
  62339. * Gets the worldTangent input component
  62340. */
  62341. get worldTangent(): NodeMaterialConnectionPoint;
  62342. /**
  62343. * Gets the anisotropy object output component
  62344. */
  62345. get anisotropy(): NodeMaterialConnectionPoint;
  62346. private _generateTBNSpace;
  62347. /**
  62348. * Gets the main code of the block (fragment side)
  62349. * @param state current state of the node material building
  62350. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62351. * @returns the shader code
  62352. */
  62353. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  62354. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62355. protected _buildBlock(state: NodeMaterialBuildState): this;
  62356. }
  62357. }
  62358. declare module BABYLON {
  62359. /**
  62360. * Block used to implement the clear coat module of the PBR material
  62361. */
  62362. export class ClearCoatBlock extends NodeMaterialBlock {
  62363. private _scene;
  62364. /**
  62365. * Create a new ClearCoatBlock
  62366. * @param name defines the block name
  62367. */
  62368. constructor(name: string);
  62369. /**
  62370. * Initialize the block and prepare the context for build
  62371. * @param state defines the state that will be used for the build
  62372. */
  62373. initialize(state: NodeMaterialBuildState): void;
  62374. /**
  62375. * Gets the current class name
  62376. * @returns the class name
  62377. */
  62378. getClassName(): string;
  62379. /**
  62380. * Gets the intensity input component
  62381. */
  62382. get intensity(): NodeMaterialConnectionPoint;
  62383. /**
  62384. * Gets the roughness input component
  62385. */
  62386. get roughness(): NodeMaterialConnectionPoint;
  62387. /**
  62388. * Gets the ior input component
  62389. */
  62390. get ior(): NodeMaterialConnectionPoint;
  62391. /**
  62392. * Gets the texture input component
  62393. */
  62394. get texture(): NodeMaterialConnectionPoint;
  62395. /**
  62396. * Gets the bump texture input component
  62397. */
  62398. get bumpTexture(): NodeMaterialConnectionPoint;
  62399. /**
  62400. * Gets the uv input component
  62401. */
  62402. get uv(): NodeMaterialConnectionPoint;
  62403. /**
  62404. * Gets the tint color input component
  62405. */
  62406. get tintColor(): NodeMaterialConnectionPoint;
  62407. /**
  62408. * Gets the tint "at distance" input component
  62409. */
  62410. get tintAtDistance(): NodeMaterialConnectionPoint;
  62411. /**
  62412. * Gets the tint thickness input component
  62413. */
  62414. get tintThickness(): NodeMaterialConnectionPoint;
  62415. /**
  62416. * Gets the tint texture input component
  62417. */
  62418. get tintTexture(): NodeMaterialConnectionPoint;
  62419. /**
  62420. * Gets the world tangent input component
  62421. */
  62422. get worldTangent(): NodeMaterialConnectionPoint;
  62423. /**
  62424. * Gets the clear coat object output component
  62425. */
  62426. get clearcoat(): NodeMaterialConnectionPoint;
  62427. autoConfigure(material: NodeMaterial): void;
  62428. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62429. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62430. private _generateTBNSpace;
  62431. /**
  62432. * Gets the main code of the block (fragment side)
  62433. * @param state current state of the node material building
  62434. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  62435. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62436. * @param worldPosVarName name of the variable holding the world position
  62437. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62438. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  62439. * @param worldNormalVarName name of the variable holding the world normal
  62440. * @returns the shader code
  62441. */
  62442. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  62443. protected _buildBlock(state: NodeMaterialBuildState): this;
  62444. }
  62445. }
  62446. declare module BABYLON {
  62447. /**
  62448. * Block used to implement the sub surface module of the PBR material
  62449. */
  62450. export class SubSurfaceBlock extends NodeMaterialBlock {
  62451. /**
  62452. * Create a new SubSurfaceBlock
  62453. * @param name defines the block name
  62454. */
  62455. constructor(name: string);
  62456. /**
  62457. * Stores the intensity of the different subsurface effects in the thickness texture.
  62458. * * the green channel is the translucency intensity.
  62459. * * the blue channel is the scattering intensity.
  62460. * * the alpha channel is the refraction intensity.
  62461. */
  62462. useMaskFromThicknessTexture: boolean;
  62463. /**
  62464. * Initialize the block and prepare the context for build
  62465. * @param state defines the state that will be used for the build
  62466. */
  62467. initialize(state: NodeMaterialBuildState): void;
  62468. /**
  62469. * Gets the current class name
  62470. * @returns the class name
  62471. */
  62472. getClassName(): string;
  62473. /**
  62474. * Gets the min thickness input component
  62475. */
  62476. get minThickness(): NodeMaterialConnectionPoint;
  62477. /**
  62478. * Gets the max thickness input component
  62479. */
  62480. get maxThickness(): NodeMaterialConnectionPoint;
  62481. /**
  62482. * Gets the thickness texture component
  62483. */
  62484. get thicknessTexture(): NodeMaterialConnectionPoint;
  62485. /**
  62486. * Gets the tint color input component
  62487. */
  62488. get tintColor(): NodeMaterialConnectionPoint;
  62489. /**
  62490. * Gets the translucency intensity input component
  62491. */
  62492. get translucencyIntensity(): NodeMaterialConnectionPoint;
  62493. /**
  62494. * Gets the translucency diffusion distance input component
  62495. */
  62496. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  62497. /**
  62498. * Gets the refraction object parameters
  62499. */
  62500. get refraction(): NodeMaterialConnectionPoint;
  62501. /**
  62502. * Gets the sub surface object output component
  62503. */
  62504. get subsurface(): NodeMaterialConnectionPoint;
  62505. autoConfigure(material: NodeMaterial): void;
  62506. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62507. /**
  62508. * Gets the main code of the block (fragment side)
  62509. * @param state current state of the node material building
  62510. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  62511. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62512. * @param worldPosVarName name of the variable holding the world position
  62513. * @returns the shader code
  62514. */
  62515. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  62516. protected _buildBlock(state: NodeMaterialBuildState): this;
  62517. }
  62518. }
  62519. declare module BABYLON {
  62520. /**
  62521. * Block used to implement the PBR metallic/roughness model
  62522. */
  62523. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  62524. /**
  62525. * Gets or sets the light associated with this block
  62526. */
  62527. light: Nullable<Light>;
  62528. private _lightId;
  62529. private _scene;
  62530. private _environmentBRDFTexture;
  62531. private _environmentBrdfSamplerName;
  62532. private _vNormalWName;
  62533. private _invertNormalName;
  62534. /**
  62535. * Create a new ReflectionBlock
  62536. * @param name defines the block name
  62537. */
  62538. constructor(name: string);
  62539. /**
  62540. * Intensity of the direct lights e.g. the four lights available in your scene.
  62541. * This impacts both the direct diffuse and specular highlights.
  62542. */
  62543. directIntensity: number;
  62544. /**
  62545. * Intensity of the environment e.g. how much the environment will light the object
  62546. * either through harmonics for rough material or through the refelction for shiny ones.
  62547. */
  62548. environmentIntensity: number;
  62549. /**
  62550. * This is a special control allowing the reduction of the specular highlights coming from the
  62551. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  62552. */
  62553. specularIntensity: number;
  62554. /**
  62555. * Defines the falloff type used in this material.
  62556. * It by default is Physical.
  62557. */
  62558. lightFalloff: number;
  62559. /**
  62560. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  62561. */
  62562. useAlphaFromAlbedoTexture: boolean;
  62563. /**
  62564. * Specifies that alpha test should be used
  62565. */
  62566. useAlphaTest: boolean;
  62567. /**
  62568. * Defines the alpha limits in alpha test mode.
  62569. */
  62570. alphaTestCutoff: number;
  62571. /**
  62572. * Specifies that alpha blending should be used
  62573. */
  62574. useAlphaBlending: boolean;
  62575. /**
  62576. * Defines if the alpha value should be determined via the rgb values.
  62577. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  62578. */
  62579. opacityRGB: boolean;
  62580. /**
  62581. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  62582. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  62583. */
  62584. useRadianceOverAlpha: boolean;
  62585. /**
  62586. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  62587. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  62588. */
  62589. useSpecularOverAlpha: boolean;
  62590. /**
  62591. * Enables specular anti aliasing in the PBR shader.
  62592. * It will both interacts on the Geometry for analytical and IBL lighting.
  62593. * It also prefilter the roughness map based on the bump values.
  62594. */
  62595. enableSpecularAntiAliasing: boolean;
  62596. /**
  62597. * Defines if the material uses energy conservation.
  62598. */
  62599. useEnergyConservation: boolean;
  62600. /**
  62601. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  62602. * too much the area relying on ambient texture to define their ambient occlusion.
  62603. */
  62604. useRadianceOcclusion: boolean;
  62605. /**
  62606. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  62607. * makes the reflect vector face the model (under horizon).
  62608. */
  62609. useHorizonOcclusion: boolean;
  62610. /**
  62611. * If set to true, no lighting calculations will be applied.
  62612. */
  62613. unlit: boolean;
  62614. /**
  62615. * Force normal to face away from face.
  62616. */
  62617. forceNormalForward: boolean;
  62618. /**
  62619. * Defines the material debug mode.
  62620. * It helps seeing only some components of the material while troubleshooting.
  62621. */
  62622. debugMode: number;
  62623. /**
  62624. * Specify from where on screen the debug mode should start.
  62625. * The value goes from -1 (full screen) to 1 (not visible)
  62626. * It helps with side by side comparison against the final render
  62627. * This defaults to 0
  62628. */
  62629. debugLimit: number;
  62630. /**
  62631. * As the default viewing range might not be enough (if the ambient is really small for instance)
  62632. * You can use the factor to better multiply the final value.
  62633. */
  62634. debugFactor: number;
  62635. /**
  62636. * Initialize the block and prepare the context for build
  62637. * @param state defines the state that will be used for the build
  62638. */
  62639. initialize(state: NodeMaterialBuildState): void;
  62640. /**
  62641. * Gets the current class name
  62642. * @returns the class name
  62643. */
  62644. getClassName(): string;
  62645. /**
  62646. * Gets the world position input component
  62647. */
  62648. get worldPosition(): NodeMaterialConnectionPoint;
  62649. /**
  62650. * Gets the world normal input component
  62651. */
  62652. get worldNormal(): NodeMaterialConnectionPoint;
  62653. /**
  62654. * Gets the perturbed normal input component
  62655. */
  62656. get perturbedNormal(): NodeMaterialConnectionPoint;
  62657. /**
  62658. * Gets the camera position input component
  62659. */
  62660. get cameraPosition(): NodeMaterialConnectionPoint;
  62661. /**
  62662. * Gets the base color input component
  62663. */
  62664. get baseColor(): NodeMaterialConnectionPoint;
  62665. /**
  62666. * Gets the base texture input component
  62667. */
  62668. get baseTexture(): NodeMaterialConnectionPoint;
  62669. /**
  62670. * Gets the opacity texture input component
  62671. */
  62672. get opacityTexture(): NodeMaterialConnectionPoint;
  62673. /**
  62674. * Gets the ambient color input component
  62675. */
  62676. get ambientColor(): NodeMaterialConnectionPoint;
  62677. /**
  62678. * Gets the reflectivity object parameters
  62679. */
  62680. get reflectivity(): NodeMaterialConnectionPoint;
  62681. /**
  62682. * Gets the ambient occlusion object parameters
  62683. */
  62684. get ambientOcclusion(): NodeMaterialConnectionPoint;
  62685. /**
  62686. * Gets the reflection object parameters
  62687. */
  62688. get reflection(): NodeMaterialConnectionPoint;
  62689. /**
  62690. * Gets the sheen object parameters
  62691. */
  62692. get sheen(): NodeMaterialConnectionPoint;
  62693. /**
  62694. * Gets the clear coat object parameters
  62695. */
  62696. get clearcoat(): NodeMaterialConnectionPoint;
  62697. /**
  62698. * Gets the sub surface object parameters
  62699. */
  62700. get subsurface(): NodeMaterialConnectionPoint;
  62701. /**
  62702. * Gets the anisotropy object parameters
  62703. */
  62704. get anisotropy(): NodeMaterialConnectionPoint;
  62705. /**
  62706. * Gets the ambient output component
  62707. */
  62708. get ambient(): NodeMaterialConnectionPoint;
  62709. /**
  62710. * Gets the diffuse output component
  62711. */
  62712. get diffuse(): NodeMaterialConnectionPoint;
  62713. /**
  62714. * Gets the specular output component
  62715. */
  62716. get specular(): NodeMaterialConnectionPoint;
  62717. /**
  62718. * Gets the sheen output component
  62719. */
  62720. get sheenDir(): NodeMaterialConnectionPoint;
  62721. /**
  62722. * Gets the clear coat output component
  62723. */
  62724. get clearcoatDir(): NodeMaterialConnectionPoint;
  62725. /**
  62726. * Gets the indirect diffuse output component
  62727. */
  62728. get diffuseIndirect(): NodeMaterialConnectionPoint;
  62729. /**
  62730. * Gets the indirect specular output component
  62731. */
  62732. get specularIndirect(): NodeMaterialConnectionPoint;
  62733. /**
  62734. * Gets the indirect sheen output component
  62735. */
  62736. get sheenIndirect(): NodeMaterialConnectionPoint;
  62737. /**
  62738. * Gets the indirect clear coat output component
  62739. */
  62740. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  62741. /**
  62742. * Gets the refraction output component
  62743. */
  62744. get refraction(): NodeMaterialConnectionPoint;
  62745. /**
  62746. * Gets the global lighting output component
  62747. */
  62748. get lighting(): NodeMaterialConnectionPoint;
  62749. /**
  62750. * Gets the shadow output component
  62751. */
  62752. get shadow(): NodeMaterialConnectionPoint;
  62753. /**
  62754. * Gets the alpha output component
  62755. */
  62756. get alpha(): NodeMaterialConnectionPoint;
  62757. autoConfigure(material: NodeMaterial): void;
  62758. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62759. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62760. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62761. private _injectVertexCode;
  62762. /**
  62763. * Gets the code corresponding to the albedo/opacity module
  62764. * @returns the shader code
  62765. */
  62766. getAlbedoOpacityCode(): string;
  62767. protected _buildBlock(state: NodeMaterialBuildState): this;
  62768. protected _dumpPropertiesCode(): string;
  62769. serialize(): any;
  62770. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62771. }
  62772. }
  62773. declare module BABYLON {
  62774. /**
  62775. * Helper class to push actions to a pool of workers.
  62776. */
  62777. export class WorkerPool implements IDisposable {
  62778. private _workerInfos;
  62779. private _pendingActions;
  62780. /**
  62781. * Constructor
  62782. * @param workers Array of workers to use for actions
  62783. */
  62784. constructor(workers: Array<Worker>);
  62785. /**
  62786. * Terminates all workers and clears any pending actions.
  62787. */
  62788. dispose(): void;
  62789. /**
  62790. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62791. * pended until a worker has completed its action.
  62792. * @param action The action to perform. Call onComplete when the action is complete.
  62793. */
  62794. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62795. private _execute;
  62796. }
  62797. }
  62798. declare module BABYLON {
  62799. /**
  62800. * Configuration for Draco compression
  62801. */
  62802. export interface IDracoCompressionConfiguration {
  62803. /**
  62804. * Configuration for the decoder.
  62805. */
  62806. decoder: {
  62807. /**
  62808. * The url to the WebAssembly module.
  62809. */
  62810. wasmUrl?: string;
  62811. /**
  62812. * The url to the WebAssembly binary.
  62813. */
  62814. wasmBinaryUrl?: string;
  62815. /**
  62816. * The url to the fallback JavaScript module.
  62817. */
  62818. fallbackUrl?: string;
  62819. };
  62820. }
  62821. /**
  62822. * Draco compression (https://google.github.io/draco/)
  62823. *
  62824. * This class wraps the Draco module.
  62825. *
  62826. * **Encoder**
  62827. *
  62828. * The encoder is not currently implemented.
  62829. *
  62830. * **Decoder**
  62831. *
  62832. * 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.
  62833. *
  62834. * To update the configuration, use the following code:
  62835. * ```javascript
  62836. * DracoCompression.Configuration = {
  62837. * decoder: {
  62838. * wasmUrl: "<url to the WebAssembly library>",
  62839. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  62840. * fallbackUrl: "<url to the fallback JavaScript library>",
  62841. * }
  62842. * };
  62843. * ```
  62844. *
  62845. * 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.
  62846. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  62847. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  62848. *
  62849. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  62850. * ```javascript
  62851. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  62852. * ```
  62853. *
  62854. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  62855. */
  62856. export class DracoCompression implements IDisposable {
  62857. private _workerPoolPromise?;
  62858. private _decoderModulePromise?;
  62859. /**
  62860. * The configuration. Defaults to the following urls:
  62861. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  62862. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  62863. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  62864. */
  62865. static Configuration: IDracoCompressionConfiguration;
  62866. /**
  62867. * Returns true if the decoder configuration is available.
  62868. */
  62869. static get DecoderAvailable(): boolean;
  62870. /**
  62871. * Default number of workers to create when creating the draco compression object.
  62872. */
  62873. static DefaultNumWorkers: number;
  62874. private static GetDefaultNumWorkers;
  62875. private static _Default;
  62876. /**
  62877. * Default instance for the draco compression object.
  62878. */
  62879. static get Default(): DracoCompression;
  62880. /**
  62881. * Constructor
  62882. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62883. */
  62884. constructor(numWorkers?: number);
  62885. /**
  62886. * Stop all async operations and release resources.
  62887. */
  62888. dispose(): void;
  62889. /**
  62890. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  62891. * @returns a promise that resolves when ready
  62892. */
  62893. whenReadyAsync(): Promise<void>;
  62894. /**
  62895. * Decode Draco compressed mesh data to vertex data.
  62896. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  62897. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  62898. * @returns A promise that resolves with the decoded vertex data
  62899. */
  62900. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  62901. [kind: string]: number;
  62902. }): Promise<VertexData>;
  62903. }
  62904. }
  62905. declare module BABYLON {
  62906. /**
  62907. * Class for building Constructive Solid Geometry
  62908. */
  62909. export class CSG {
  62910. private polygons;
  62911. /**
  62912. * The world matrix
  62913. */
  62914. matrix: Matrix;
  62915. /**
  62916. * Stores the position
  62917. */
  62918. position: Vector3;
  62919. /**
  62920. * Stores the rotation
  62921. */
  62922. rotation: Vector3;
  62923. /**
  62924. * Stores the rotation quaternion
  62925. */
  62926. rotationQuaternion: Nullable<Quaternion>;
  62927. /**
  62928. * Stores the scaling vector
  62929. */
  62930. scaling: Vector3;
  62931. /**
  62932. * Convert the Mesh to CSG
  62933. * @param mesh The Mesh to convert to CSG
  62934. * @returns A new CSG from the Mesh
  62935. */
  62936. static FromMesh(mesh: Mesh): CSG;
  62937. /**
  62938. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  62939. * @param polygons Polygons used to construct a CSG solid
  62940. */
  62941. private static FromPolygons;
  62942. /**
  62943. * Clones, or makes a deep copy, of the CSG
  62944. * @returns A new CSG
  62945. */
  62946. clone(): CSG;
  62947. /**
  62948. * Unions this CSG with another CSG
  62949. * @param csg The CSG to union against this CSG
  62950. * @returns The unioned CSG
  62951. */
  62952. union(csg: CSG): CSG;
  62953. /**
  62954. * Unions this CSG with another CSG in place
  62955. * @param csg The CSG to union against this CSG
  62956. */
  62957. unionInPlace(csg: CSG): void;
  62958. /**
  62959. * Subtracts this CSG with another CSG
  62960. * @param csg The CSG to subtract against this CSG
  62961. * @returns A new CSG
  62962. */
  62963. subtract(csg: CSG): CSG;
  62964. /**
  62965. * Subtracts this CSG with another CSG in place
  62966. * @param csg The CSG to subtact against this CSG
  62967. */
  62968. subtractInPlace(csg: CSG): void;
  62969. /**
  62970. * Intersect this CSG with another CSG
  62971. * @param csg The CSG to intersect against this CSG
  62972. * @returns A new CSG
  62973. */
  62974. intersect(csg: CSG): CSG;
  62975. /**
  62976. * Intersects this CSG with another CSG in place
  62977. * @param csg The CSG to intersect against this CSG
  62978. */
  62979. intersectInPlace(csg: CSG): void;
  62980. /**
  62981. * Return a new CSG solid with solid and empty space switched. This solid is
  62982. * not modified.
  62983. * @returns A new CSG solid with solid and empty space switched
  62984. */
  62985. inverse(): CSG;
  62986. /**
  62987. * Inverses the CSG in place
  62988. */
  62989. inverseInPlace(): void;
  62990. /**
  62991. * This is used to keep meshes transformations so they can be restored
  62992. * when we build back a Babylon Mesh
  62993. * NB : All CSG operations are performed in world coordinates
  62994. * @param csg The CSG to copy the transform attributes from
  62995. * @returns This CSG
  62996. */
  62997. copyTransformAttributes(csg: CSG): CSG;
  62998. /**
  62999. * Build Raw mesh from CSG
  63000. * Coordinates here are in world space
  63001. * @param name The name of the mesh geometry
  63002. * @param scene The Scene
  63003. * @param keepSubMeshes Specifies if the submeshes should be kept
  63004. * @returns A new Mesh
  63005. */
  63006. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63007. /**
  63008. * Build Mesh from CSG taking material and transforms into account
  63009. * @param name The name of the Mesh
  63010. * @param material The material of the Mesh
  63011. * @param scene The Scene
  63012. * @param keepSubMeshes Specifies if submeshes should be kept
  63013. * @returns The new Mesh
  63014. */
  63015. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63016. }
  63017. }
  63018. declare module BABYLON {
  63019. /**
  63020. * Class used to create a trail following a mesh
  63021. */
  63022. export class TrailMesh extends Mesh {
  63023. private _generator;
  63024. private _autoStart;
  63025. private _running;
  63026. private _diameter;
  63027. private _length;
  63028. private _sectionPolygonPointsCount;
  63029. private _sectionVectors;
  63030. private _sectionNormalVectors;
  63031. private _beforeRenderObserver;
  63032. /**
  63033. * @constructor
  63034. * @param name The value used by scene.getMeshByName() to do a lookup.
  63035. * @param generator The mesh or transform node to generate a trail.
  63036. * @param scene The scene to add this mesh to.
  63037. * @param diameter Diameter of trailing mesh. Default is 1.
  63038. * @param length Length of trailing mesh. Default is 60.
  63039. * @param autoStart Automatically start trailing mesh. Default true.
  63040. */
  63041. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63042. /**
  63043. * "TrailMesh"
  63044. * @returns "TrailMesh"
  63045. */
  63046. getClassName(): string;
  63047. private _createMesh;
  63048. /**
  63049. * Start trailing mesh.
  63050. */
  63051. start(): void;
  63052. /**
  63053. * Stop trailing mesh.
  63054. */
  63055. stop(): void;
  63056. /**
  63057. * Update trailing mesh geometry.
  63058. */
  63059. update(): void;
  63060. /**
  63061. * Returns a new TrailMesh object.
  63062. * @param name is a string, the name given to the new mesh
  63063. * @param newGenerator use new generator object for cloned trail mesh
  63064. * @returns a new mesh
  63065. */
  63066. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63067. /**
  63068. * Serializes this trail mesh
  63069. * @param serializationObject object to write serialization to
  63070. */
  63071. serialize(serializationObject: any): void;
  63072. /**
  63073. * Parses a serialized trail mesh
  63074. * @param parsedMesh the serialized mesh
  63075. * @param scene the scene to create the trail mesh in
  63076. * @returns the created trail mesh
  63077. */
  63078. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63079. }
  63080. }
  63081. declare module BABYLON {
  63082. /**
  63083. * Class containing static functions to help procedurally build meshes
  63084. */
  63085. export class TiledBoxBuilder {
  63086. /**
  63087. * Creates a box mesh
  63088. * 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)
  63089. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63091. * * 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
  63092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63093. * @param name defines the name of the mesh
  63094. * @param options defines the options used to create the mesh
  63095. * @param scene defines the hosting scene
  63096. * @returns the box mesh
  63097. */
  63098. static CreateTiledBox(name: string, options: {
  63099. pattern?: number;
  63100. width?: number;
  63101. height?: number;
  63102. depth?: number;
  63103. tileSize?: number;
  63104. tileWidth?: number;
  63105. tileHeight?: number;
  63106. alignHorizontal?: number;
  63107. alignVertical?: number;
  63108. faceUV?: Vector4[];
  63109. faceColors?: Color4[];
  63110. sideOrientation?: number;
  63111. updatable?: boolean;
  63112. }, scene?: Nullable<Scene>): Mesh;
  63113. }
  63114. }
  63115. declare module BABYLON {
  63116. /**
  63117. * Class containing static functions to help procedurally build meshes
  63118. */
  63119. export class TorusKnotBuilder {
  63120. /**
  63121. * Creates a torus knot mesh
  63122. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63123. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63124. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63125. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63126. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63127. * * 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
  63128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63129. * @param name defines the name of the mesh
  63130. * @param options defines the options used to create the mesh
  63131. * @param scene defines the hosting scene
  63132. * @returns the torus knot mesh
  63133. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63134. */
  63135. static CreateTorusKnot(name: string, options: {
  63136. radius?: number;
  63137. tube?: number;
  63138. radialSegments?: number;
  63139. tubularSegments?: number;
  63140. p?: number;
  63141. q?: number;
  63142. updatable?: boolean;
  63143. sideOrientation?: number;
  63144. frontUVs?: Vector4;
  63145. backUVs?: Vector4;
  63146. }, scene: any): Mesh;
  63147. }
  63148. }
  63149. declare module BABYLON {
  63150. /**
  63151. * Polygon
  63152. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63153. */
  63154. export class Polygon {
  63155. /**
  63156. * Creates a rectangle
  63157. * @param xmin bottom X coord
  63158. * @param ymin bottom Y coord
  63159. * @param xmax top X coord
  63160. * @param ymax top Y coord
  63161. * @returns points that make the resulting rectation
  63162. */
  63163. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63164. /**
  63165. * Creates a circle
  63166. * @param radius radius of circle
  63167. * @param cx scale in x
  63168. * @param cy scale in y
  63169. * @param numberOfSides number of sides that make up the circle
  63170. * @returns points that make the resulting circle
  63171. */
  63172. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63173. /**
  63174. * Creates a polygon from input string
  63175. * @param input Input polygon data
  63176. * @returns the parsed points
  63177. */
  63178. static Parse(input: string): Vector2[];
  63179. /**
  63180. * Starts building a polygon from x and y coordinates
  63181. * @param x x coordinate
  63182. * @param y y coordinate
  63183. * @returns the started path2
  63184. */
  63185. static StartingAt(x: number, y: number): Path2;
  63186. }
  63187. /**
  63188. * Builds a polygon
  63189. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63190. */
  63191. export class PolygonMeshBuilder {
  63192. private _points;
  63193. private _outlinepoints;
  63194. private _holes;
  63195. private _name;
  63196. private _scene;
  63197. private _epoints;
  63198. private _eholes;
  63199. private _addToepoint;
  63200. /**
  63201. * Babylon reference to the earcut plugin.
  63202. */
  63203. bjsEarcut: any;
  63204. /**
  63205. * Creates a PolygonMeshBuilder
  63206. * @param name name of the builder
  63207. * @param contours Path of the polygon
  63208. * @param scene scene to add to when creating the mesh
  63209. * @param earcutInjection can be used to inject your own earcut reference
  63210. */
  63211. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63212. /**
  63213. * Adds a whole within the polygon
  63214. * @param hole Array of points defining the hole
  63215. * @returns this
  63216. */
  63217. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63218. /**
  63219. * Creates the polygon
  63220. * @param updatable If the mesh should be updatable
  63221. * @param depth The depth of the mesh created
  63222. * @returns the created mesh
  63223. */
  63224. build(updatable?: boolean, depth?: number): Mesh;
  63225. /**
  63226. * Creates the polygon
  63227. * @param depth The depth of the mesh created
  63228. * @returns the created VertexData
  63229. */
  63230. buildVertexData(depth?: number): VertexData;
  63231. /**
  63232. * Adds a side to the polygon
  63233. * @param positions points that make the polygon
  63234. * @param normals normals of the polygon
  63235. * @param uvs uvs of the polygon
  63236. * @param indices indices of the polygon
  63237. * @param bounds bounds of the polygon
  63238. * @param points points of the polygon
  63239. * @param depth depth of the polygon
  63240. * @param flip flip of the polygon
  63241. */
  63242. private addSide;
  63243. }
  63244. }
  63245. declare module BABYLON {
  63246. /**
  63247. * Class containing static functions to help procedurally build meshes
  63248. */
  63249. export class PolygonBuilder {
  63250. /**
  63251. * Creates a polygon mesh
  63252. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63253. * * 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
  63254. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63256. * * 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)
  63257. * * Remember you can only change the shape positions, not their number when updating a polygon
  63258. * @param name defines the name of the mesh
  63259. * @param options defines the options used to create the mesh
  63260. * @param scene defines the hosting scene
  63261. * @param earcutInjection can be used to inject your own earcut reference
  63262. * @returns the polygon mesh
  63263. */
  63264. static CreatePolygon(name: string, options: {
  63265. shape: Vector3[];
  63266. holes?: Vector3[][];
  63267. depth?: number;
  63268. faceUV?: Vector4[];
  63269. faceColors?: Color4[];
  63270. updatable?: boolean;
  63271. sideOrientation?: number;
  63272. frontUVs?: Vector4;
  63273. backUVs?: Vector4;
  63274. wrap?: boolean;
  63275. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63276. /**
  63277. * Creates an extruded polygon mesh, with depth in the Y direction.
  63278. * * 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)
  63279. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63280. * @param name defines the name of the mesh
  63281. * @param options defines the options used to create the mesh
  63282. * @param scene defines the hosting scene
  63283. * @param earcutInjection can be used to inject your own earcut reference
  63284. * @returns the polygon mesh
  63285. */
  63286. static ExtrudePolygon(name: string, options: {
  63287. shape: Vector3[];
  63288. holes?: Vector3[][];
  63289. depth?: number;
  63290. faceUV?: Vector4[];
  63291. faceColors?: Color4[];
  63292. updatable?: boolean;
  63293. sideOrientation?: number;
  63294. frontUVs?: Vector4;
  63295. backUVs?: Vector4;
  63296. wrap?: boolean;
  63297. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63298. }
  63299. }
  63300. declare module BABYLON {
  63301. /**
  63302. * Class containing static functions to help procedurally build meshes
  63303. */
  63304. export class LatheBuilder {
  63305. /**
  63306. * Creates lathe mesh.
  63307. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63308. * * 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
  63309. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63310. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63311. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63312. * * 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
  63313. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63314. * * 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
  63315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63316. * * 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
  63317. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63319. * @param name defines the name of the mesh
  63320. * @param options defines the options used to create the mesh
  63321. * @param scene defines the hosting scene
  63322. * @returns the lathe mesh
  63323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63324. */
  63325. static CreateLathe(name: string, options: {
  63326. shape: Vector3[];
  63327. radius?: number;
  63328. tessellation?: number;
  63329. clip?: number;
  63330. arc?: number;
  63331. closed?: boolean;
  63332. updatable?: boolean;
  63333. sideOrientation?: number;
  63334. frontUVs?: Vector4;
  63335. backUVs?: Vector4;
  63336. cap?: number;
  63337. invertUV?: boolean;
  63338. }, scene?: Nullable<Scene>): Mesh;
  63339. }
  63340. }
  63341. declare module BABYLON {
  63342. /**
  63343. * Class containing static functions to help procedurally build meshes
  63344. */
  63345. export class TiledPlaneBuilder {
  63346. /**
  63347. * Creates a tiled plane mesh
  63348. * * The parameter `pattern` will, depending on value, do nothing or
  63349. * * * flip (reflect about central vertical) alternate tiles across and up
  63350. * * * flip every tile on alternate rows
  63351. * * * rotate (180 degs) alternate tiles across and up
  63352. * * * rotate every tile on alternate rows
  63353. * * * flip and rotate alternate tiles across and up
  63354. * * * flip and rotate every tile on alternate rows
  63355. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63356. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63357. * * 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
  63358. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63359. * * 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)
  63360. * * 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)
  63361. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63362. * @param name defines the name of the mesh
  63363. * @param options defines the options used to create the mesh
  63364. * @param scene defines the hosting scene
  63365. * @returns the box mesh
  63366. */
  63367. static CreateTiledPlane(name: string, options: {
  63368. pattern?: number;
  63369. tileSize?: number;
  63370. tileWidth?: number;
  63371. tileHeight?: number;
  63372. size?: number;
  63373. width?: number;
  63374. height?: number;
  63375. alignHorizontal?: number;
  63376. alignVertical?: number;
  63377. sideOrientation?: number;
  63378. frontUVs?: Vector4;
  63379. backUVs?: Vector4;
  63380. updatable?: boolean;
  63381. }, scene?: Nullable<Scene>): Mesh;
  63382. }
  63383. }
  63384. declare module BABYLON {
  63385. /**
  63386. * Class containing static functions to help procedurally build meshes
  63387. */
  63388. export class TubeBuilder {
  63389. /**
  63390. * Creates a tube mesh.
  63391. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63392. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63393. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63394. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63395. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63396. * * 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)
  63397. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63398. * * 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
  63399. * * 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
  63400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63401. * * 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
  63402. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63404. * @param name defines the name of the mesh
  63405. * @param options defines the options used to create the mesh
  63406. * @param scene defines the hosting scene
  63407. * @returns the tube mesh
  63408. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63409. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63410. */
  63411. static CreateTube(name: string, options: {
  63412. path: Vector3[];
  63413. radius?: number;
  63414. tessellation?: number;
  63415. radiusFunction?: {
  63416. (i: number, distance: number): number;
  63417. };
  63418. cap?: number;
  63419. arc?: number;
  63420. updatable?: boolean;
  63421. sideOrientation?: number;
  63422. frontUVs?: Vector4;
  63423. backUVs?: Vector4;
  63424. instance?: Mesh;
  63425. invertUV?: boolean;
  63426. }, scene?: Nullable<Scene>): Mesh;
  63427. }
  63428. }
  63429. declare module BABYLON {
  63430. /**
  63431. * Class containing static functions to help procedurally build meshes
  63432. */
  63433. export class IcoSphereBuilder {
  63434. /**
  63435. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63436. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63437. * * 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`)
  63438. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63439. * * 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
  63440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63441. * * 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
  63442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63443. * @param name defines the name of the mesh
  63444. * @param options defines the options used to create the mesh
  63445. * @param scene defines the hosting scene
  63446. * @returns the icosahedron mesh
  63447. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63448. */
  63449. static CreateIcoSphere(name: string, options: {
  63450. radius?: number;
  63451. radiusX?: number;
  63452. radiusY?: number;
  63453. radiusZ?: number;
  63454. flat?: boolean;
  63455. subdivisions?: number;
  63456. sideOrientation?: number;
  63457. frontUVs?: Vector4;
  63458. backUVs?: Vector4;
  63459. updatable?: boolean;
  63460. }, scene?: Nullable<Scene>): Mesh;
  63461. }
  63462. }
  63463. declare module BABYLON {
  63464. /**
  63465. * Class containing static functions to help procedurally build meshes
  63466. */
  63467. export class DecalBuilder {
  63468. /**
  63469. * Creates a decal mesh.
  63470. * 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
  63471. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63472. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63473. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63474. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63475. * @param name defines the name of the mesh
  63476. * @param sourceMesh defines the mesh where the decal must be applied
  63477. * @param options defines the options used to create the mesh
  63478. * @param scene defines the hosting scene
  63479. * @returns the decal mesh
  63480. * @see https://doc.babylonjs.com/how_to/decals
  63481. */
  63482. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63483. position?: Vector3;
  63484. normal?: Vector3;
  63485. size?: Vector3;
  63486. angle?: number;
  63487. }): Mesh;
  63488. }
  63489. }
  63490. declare module BABYLON {
  63491. /**
  63492. * Class containing static functions to help procedurally build meshes
  63493. */
  63494. export class MeshBuilder {
  63495. /**
  63496. * Creates a box mesh
  63497. * * The parameter `size` sets the size (float) of each box side (default 1)
  63498. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  63499. * * 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)
  63500. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63502. * * 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
  63503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63504. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63505. * @param name defines the name of the mesh
  63506. * @param options defines the options used to create the mesh
  63507. * @param scene defines the hosting scene
  63508. * @returns the box mesh
  63509. */
  63510. static CreateBox(name: string, options: {
  63511. size?: number;
  63512. width?: number;
  63513. height?: number;
  63514. depth?: number;
  63515. faceUV?: Vector4[];
  63516. faceColors?: Color4[];
  63517. sideOrientation?: number;
  63518. frontUVs?: Vector4;
  63519. backUVs?: Vector4;
  63520. wrap?: boolean;
  63521. topBaseAt?: number;
  63522. bottomBaseAt?: number;
  63523. updatable?: boolean;
  63524. }, scene?: Nullable<Scene>): Mesh;
  63525. /**
  63526. * Creates a tiled box mesh
  63527. * * faceTiles sets the pattern, tile size and number of tiles for a face
  63528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63529. * @param name defines the name of the mesh
  63530. * @param options defines the options used to create the mesh
  63531. * @param scene defines the hosting scene
  63532. * @returns the tiled box mesh
  63533. */
  63534. static CreateTiledBox(name: string, options: {
  63535. pattern?: number;
  63536. size?: number;
  63537. width?: number;
  63538. height?: number;
  63539. depth: number;
  63540. tileSize?: number;
  63541. tileWidth?: number;
  63542. tileHeight?: number;
  63543. faceUV?: Vector4[];
  63544. faceColors?: Color4[];
  63545. alignHorizontal?: number;
  63546. alignVertical?: number;
  63547. sideOrientation?: number;
  63548. updatable?: boolean;
  63549. }, scene?: Nullable<Scene>): Mesh;
  63550. /**
  63551. * Creates a sphere mesh
  63552. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  63553. * * 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`)
  63554. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  63555. * * 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
  63556. * * 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)
  63557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63558. * * 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
  63559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63560. * @param name defines the name of the mesh
  63561. * @param options defines the options used to create the mesh
  63562. * @param scene defines the hosting scene
  63563. * @returns the sphere mesh
  63564. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  63565. */
  63566. static CreateSphere(name: string, options: {
  63567. segments?: number;
  63568. diameter?: number;
  63569. diameterX?: number;
  63570. diameterY?: number;
  63571. diameterZ?: number;
  63572. arc?: number;
  63573. slice?: number;
  63574. sideOrientation?: number;
  63575. frontUVs?: Vector4;
  63576. backUVs?: Vector4;
  63577. updatable?: boolean;
  63578. }, scene?: Nullable<Scene>): Mesh;
  63579. /**
  63580. * Creates a plane polygonal mesh. By default, this is a disc
  63581. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  63582. * * 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
  63583. * * 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
  63584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63585. * * 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
  63586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63587. * @param name defines the name of the mesh
  63588. * @param options defines the options used to create the mesh
  63589. * @param scene defines the hosting scene
  63590. * @returns the plane polygonal mesh
  63591. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  63592. */
  63593. static CreateDisc(name: string, options: {
  63594. radius?: number;
  63595. tessellation?: number;
  63596. arc?: number;
  63597. updatable?: boolean;
  63598. sideOrientation?: number;
  63599. frontUVs?: Vector4;
  63600. backUVs?: Vector4;
  63601. }, scene?: Nullable<Scene>): Mesh;
  63602. /**
  63603. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63604. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63605. * * 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`)
  63606. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63607. * * 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
  63608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63609. * * 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
  63610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63611. * @param name defines the name of the mesh
  63612. * @param options defines the options used to create the mesh
  63613. * @param scene defines the hosting scene
  63614. * @returns the icosahedron mesh
  63615. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63616. */
  63617. static CreateIcoSphere(name: string, options: {
  63618. radius?: number;
  63619. radiusX?: number;
  63620. radiusY?: number;
  63621. radiusZ?: number;
  63622. flat?: boolean;
  63623. subdivisions?: number;
  63624. sideOrientation?: number;
  63625. frontUVs?: Vector4;
  63626. backUVs?: Vector4;
  63627. updatable?: boolean;
  63628. }, scene?: Nullable<Scene>): Mesh;
  63629. /**
  63630. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63631. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  63632. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  63633. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  63634. * * 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
  63635. * * 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
  63636. * * 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
  63637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63638. * * 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
  63639. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63640. * * 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
  63641. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  63642. * * 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
  63643. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  63644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63645. * @param name defines the name of the mesh
  63646. * @param options defines the options used to create the mesh
  63647. * @param scene defines the hosting scene
  63648. * @returns the ribbon mesh
  63649. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  63650. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63651. */
  63652. static CreateRibbon(name: string, options: {
  63653. pathArray: Vector3[][];
  63654. closeArray?: boolean;
  63655. closePath?: boolean;
  63656. offset?: number;
  63657. updatable?: boolean;
  63658. sideOrientation?: number;
  63659. frontUVs?: Vector4;
  63660. backUVs?: Vector4;
  63661. instance?: Mesh;
  63662. invertUV?: boolean;
  63663. uvs?: Vector2[];
  63664. colors?: Color4[];
  63665. }, scene?: Nullable<Scene>): Mesh;
  63666. /**
  63667. * Creates a cylinder or a cone mesh
  63668. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  63669. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  63670. * * 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.
  63671. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  63672. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  63673. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  63674. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  63675. * * 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).
  63676. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  63677. * * 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).
  63678. * * 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
  63679. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  63680. * * 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
  63681. * * 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.
  63682. * * If `enclose` is false, a ring surface is one element.
  63683. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  63684. * * 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
  63685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63686. * * 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
  63687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63688. * @param name defines the name of the mesh
  63689. * @param options defines the options used to create the mesh
  63690. * @param scene defines the hosting scene
  63691. * @returns the cylinder mesh
  63692. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  63693. */
  63694. static CreateCylinder(name: string, options: {
  63695. height?: number;
  63696. diameterTop?: number;
  63697. diameterBottom?: number;
  63698. diameter?: number;
  63699. tessellation?: number;
  63700. subdivisions?: number;
  63701. arc?: number;
  63702. faceColors?: Color4[];
  63703. faceUV?: Vector4[];
  63704. updatable?: boolean;
  63705. hasRings?: boolean;
  63706. enclose?: boolean;
  63707. cap?: number;
  63708. sideOrientation?: number;
  63709. frontUVs?: Vector4;
  63710. backUVs?: Vector4;
  63711. }, scene?: Nullable<Scene>): Mesh;
  63712. /**
  63713. * Creates a torus mesh
  63714. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  63715. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  63716. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  63717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63718. * * 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
  63719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63720. * @param name defines the name of the mesh
  63721. * @param options defines the options used to create the mesh
  63722. * @param scene defines the hosting scene
  63723. * @returns the torus mesh
  63724. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  63725. */
  63726. static CreateTorus(name: string, options: {
  63727. diameter?: number;
  63728. thickness?: number;
  63729. tessellation?: number;
  63730. updatable?: boolean;
  63731. sideOrientation?: number;
  63732. frontUVs?: Vector4;
  63733. backUVs?: Vector4;
  63734. }, scene?: Nullable<Scene>): Mesh;
  63735. /**
  63736. * Creates a torus knot mesh
  63737. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63738. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63739. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63740. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63741. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63742. * * 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
  63743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63744. * @param name defines the name of the mesh
  63745. * @param options defines the options used to create the mesh
  63746. * @param scene defines the hosting scene
  63747. * @returns the torus knot mesh
  63748. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63749. */
  63750. static CreateTorusKnot(name: string, options: {
  63751. radius?: number;
  63752. tube?: number;
  63753. radialSegments?: number;
  63754. tubularSegments?: number;
  63755. p?: number;
  63756. q?: number;
  63757. updatable?: boolean;
  63758. sideOrientation?: number;
  63759. frontUVs?: Vector4;
  63760. backUVs?: Vector4;
  63761. }, scene?: Nullable<Scene>): Mesh;
  63762. /**
  63763. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  63764. * * 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
  63765. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  63766. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  63767. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  63768. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  63769. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  63770. * * 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
  63771. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  63772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63773. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  63774. * @param name defines the name of the new line system
  63775. * @param options defines the options used to create the line system
  63776. * @param scene defines the hosting scene
  63777. * @returns a new line system mesh
  63778. */
  63779. static CreateLineSystem(name: string, options: {
  63780. lines: Vector3[][];
  63781. updatable?: boolean;
  63782. instance?: Nullable<LinesMesh>;
  63783. colors?: Nullable<Color4[][]>;
  63784. useVertexAlpha?: boolean;
  63785. }, scene: Nullable<Scene>): LinesMesh;
  63786. /**
  63787. * Creates a line mesh
  63788. * 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
  63789. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63790. * * The parameter `points` is an array successive Vector3
  63791. * * 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
  63792. * * The optional parameter `colors` is an array of successive Color4, one per line point
  63793. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  63794. * * When updating an instance, remember that only point positions can change, not the number of points
  63795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63796. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  63797. * @param name defines the name of the new line system
  63798. * @param options defines the options used to create the line system
  63799. * @param scene defines the hosting scene
  63800. * @returns a new line mesh
  63801. */
  63802. static CreateLines(name: string, options: {
  63803. points: Vector3[];
  63804. updatable?: boolean;
  63805. instance?: Nullable<LinesMesh>;
  63806. colors?: Color4[];
  63807. useVertexAlpha?: boolean;
  63808. }, scene?: Nullable<Scene>): LinesMesh;
  63809. /**
  63810. * Creates a dashed line mesh
  63811. * * 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
  63812. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63813. * * The parameter `points` is an array successive Vector3
  63814. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  63815. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  63816. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  63817. * * 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
  63818. * * When updating an instance, remember that only point positions can change, not the number of points
  63819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63820. * @param name defines the name of the mesh
  63821. * @param options defines the options used to create the mesh
  63822. * @param scene defines the hosting scene
  63823. * @returns the dashed line mesh
  63824. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  63825. */
  63826. static CreateDashedLines(name: string, options: {
  63827. points: Vector3[];
  63828. dashSize?: number;
  63829. gapSize?: number;
  63830. dashNb?: number;
  63831. updatable?: boolean;
  63832. instance?: LinesMesh;
  63833. }, scene?: Nullable<Scene>): LinesMesh;
  63834. /**
  63835. * 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.
  63836. * * 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.
  63837. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  63838. * * 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.
  63839. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  63840. * * 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
  63841. * * 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
  63842. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  63843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63844. * * 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
  63845. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  63846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63847. * @param name defines the name of the mesh
  63848. * @param options defines the options used to create the mesh
  63849. * @param scene defines the hosting scene
  63850. * @returns the extruded shape mesh
  63851. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63852. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  63853. */
  63854. static ExtrudeShape(name: string, options: {
  63855. shape: Vector3[];
  63856. path: Vector3[];
  63857. scale?: number;
  63858. rotation?: number;
  63859. cap?: number;
  63860. updatable?: boolean;
  63861. sideOrientation?: number;
  63862. frontUVs?: Vector4;
  63863. backUVs?: Vector4;
  63864. instance?: Mesh;
  63865. invertUV?: boolean;
  63866. }, scene?: Nullable<Scene>): Mesh;
  63867. /**
  63868. * Creates an custom extruded shape mesh.
  63869. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  63870. * * 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.
  63871. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  63872. * * 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
  63873. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  63874. * * 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
  63875. * * It must returns a float value that will be the scale value applied to the shape on each path point
  63876. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  63877. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  63878. * * 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
  63879. * * 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
  63880. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  63881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63882. * * 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
  63883. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63885. * @param name defines the name of the mesh
  63886. * @param options defines the options used to create the mesh
  63887. * @param scene defines the hosting scene
  63888. * @returns the custom extruded shape mesh
  63889. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  63890. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63891. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  63892. */
  63893. static ExtrudeShapeCustom(name: string, options: {
  63894. shape: Vector3[];
  63895. path: Vector3[];
  63896. scaleFunction?: any;
  63897. rotationFunction?: any;
  63898. ribbonCloseArray?: boolean;
  63899. ribbonClosePath?: boolean;
  63900. cap?: number;
  63901. updatable?: boolean;
  63902. sideOrientation?: number;
  63903. frontUVs?: Vector4;
  63904. backUVs?: Vector4;
  63905. instance?: Mesh;
  63906. invertUV?: boolean;
  63907. }, scene?: Nullable<Scene>): Mesh;
  63908. /**
  63909. * Creates lathe mesh.
  63910. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63911. * * 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
  63912. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63913. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63914. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63915. * * 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
  63916. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63917. * * 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
  63918. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63919. * * 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
  63920. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63922. * @param name defines the name of the mesh
  63923. * @param options defines the options used to create the mesh
  63924. * @param scene defines the hosting scene
  63925. * @returns the lathe mesh
  63926. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63927. */
  63928. static CreateLathe(name: string, options: {
  63929. shape: Vector3[];
  63930. radius?: number;
  63931. tessellation?: number;
  63932. clip?: number;
  63933. arc?: number;
  63934. closed?: boolean;
  63935. updatable?: boolean;
  63936. sideOrientation?: number;
  63937. frontUVs?: Vector4;
  63938. backUVs?: Vector4;
  63939. cap?: number;
  63940. invertUV?: boolean;
  63941. }, scene?: Nullable<Scene>): Mesh;
  63942. /**
  63943. * Creates a tiled plane mesh
  63944. * * You can set a limited pattern arrangement with the tiles
  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 plane mesh
  63952. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  63953. */
  63954. static CreateTiledPlane(name: string, options: {
  63955. pattern?: number;
  63956. tileSize?: number;
  63957. tileWidth?: number;
  63958. tileHeight?: number;
  63959. size?: number;
  63960. width?: number;
  63961. height?: number;
  63962. alignHorizontal?: number;
  63963. alignVertical?: number;
  63964. sideOrientation?: number;
  63965. frontUVs?: Vector4;
  63966. backUVs?: Vector4;
  63967. updatable?: boolean;
  63968. }, scene?: Nullable<Scene>): Mesh;
  63969. /**
  63970. * Creates a plane mesh
  63971. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  63972. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  63973. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  63974. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63975. * * 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
  63976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63977. * @param name defines the name of the mesh
  63978. * @param options defines the options used to create the mesh
  63979. * @param scene defines the hosting scene
  63980. * @returns the plane mesh
  63981. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  63982. */
  63983. static CreatePlane(name: string, options: {
  63984. size?: number;
  63985. width?: number;
  63986. height?: number;
  63987. sideOrientation?: number;
  63988. frontUVs?: Vector4;
  63989. backUVs?: Vector4;
  63990. updatable?: boolean;
  63991. sourcePlane?: Plane;
  63992. }, scene?: Nullable<Scene>): Mesh;
  63993. /**
  63994. * Creates a ground mesh
  63995. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  63996. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  63997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63998. * @param name defines the name of the mesh
  63999. * @param options defines the options used to create the mesh
  64000. * @param scene defines the hosting scene
  64001. * @returns the ground mesh
  64002. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64003. */
  64004. static CreateGround(name: string, options: {
  64005. width?: number;
  64006. height?: number;
  64007. subdivisions?: number;
  64008. subdivisionsX?: number;
  64009. subdivisionsY?: number;
  64010. updatable?: boolean;
  64011. }, scene?: Nullable<Scene>): Mesh;
  64012. /**
  64013. * Creates a tiled ground mesh
  64014. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64015. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64016. * * 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
  64017. * * 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
  64018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64019. * @param name defines the name of the mesh
  64020. * @param options defines the options used to create the mesh
  64021. * @param scene defines the hosting scene
  64022. * @returns the tiled ground mesh
  64023. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64024. */
  64025. static CreateTiledGround(name: string, options: {
  64026. xmin: number;
  64027. zmin: number;
  64028. xmax: number;
  64029. zmax: number;
  64030. subdivisions?: {
  64031. w: number;
  64032. h: number;
  64033. };
  64034. precision?: {
  64035. w: number;
  64036. h: number;
  64037. };
  64038. updatable?: boolean;
  64039. }, scene?: Nullable<Scene>): Mesh;
  64040. /**
  64041. * Creates a ground mesh from a height map
  64042. * * The parameter `url` sets the URL of the height map image resource.
  64043. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64044. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64045. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64046. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64047. * * 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.
  64048. * * 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).
  64049. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64051. * @param name defines the name of the mesh
  64052. * @param url defines the url to the height map
  64053. * @param options defines the options used to create the mesh
  64054. * @param scene defines the hosting scene
  64055. * @returns the ground mesh
  64056. * @see https://doc.babylonjs.com/babylon101/height_map
  64057. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64058. */
  64059. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64060. width?: number;
  64061. height?: number;
  64062. subdivisions?: number;
  64063. minHeight?: number;
  64064. maxHeight?: number;
  64065. colorFilter?: Color3;
  64066. alphaFilter?: number;
  64067. updatable?: boolean;
  64068. onReady?: (mesh: GroundMesh) => void;
  64069. }, scene?: Nullable<Scene>): GroundMesh;
  64070. /**
  64071. * Creates a polygon mesh
  64072. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64073. * * 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
  64074. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64076. * * 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)
  64077. * * Remember you can only change the shape positions, not their number when updating a polygon
  64078. * @param name defines the name of the mesh
  64079. * @param options defines the options used to create the mesh
  64080. * @param scene defines the hosting scene
  64081. * @param earcutInjection can be used to inject your own earcut reference
  64082. * @returns the polygon mesh
  64083. */
  64084. static CreatePolygon(name: string, options: {
  64085. shape: Vector3[];
  64086. holes?: Vector3[][];
  64087. depth?: number;
  64088. faceUV?: Vector4[];
  64089. faceColors?: Color4[];
  64090. updatable?: boolean;
  64091. sideOrientation?: number;
  64092. frontUVs?: Vector4;
  64093. backUVs?: Vector4;
  64094. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64095. /**
  64096. * Creates an extruded polygon mesh, with depth in the Y direction.
  64097. * * 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)
  64098. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64099. * @param name defines the name of the mesh
  64100. * @param options defines the options used to create the mesh
  64101. * @param scene defines the hosting scene
  64102. * @param earcutInjection can be used to inject your own earcut reference
  64103. * @returns the polygon mesh
  64104. */
  64105. static ExtrudePolygon(name: string, options: {
  64106. shape: Vector3[];
  64107. holes?: Vector3[][];
  64108. depth?: number;
  64109. faceUV?: Vector4[];
  64110. faceColors?: Color4[];
  64111. updatable?: boolean;
  64112. sideOrientation?: number;
  64113. frontUVs?: Vector4;
  64114. backUVs?: Vector4;
  64115. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64116. /**
  64117. * Creates a tube mesh.
  64118. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64119. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64120. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64121. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64122. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64123. * * 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)
  64124. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64125. * * 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
  64126. * * 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
  64127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64128. * * 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
  64129. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64131. * @param name defines the name of the mesh
  64132. * @param options defines the options used to create the mesh
  64133. * @param scene defines the hosting scene
  64134. * @returns the tube mesh
  64135. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64136. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64137. */
  64138. static CreateTube(name: string, options: {
  64139. path: Vector3[];
  64140. radius?: number;
  64141. tessellation?: number;
  64142. radiusFunction?: {
  64143. (i: number, distance: number): number;
  64144. };
  64145. cap?: number;
  64146. arc?: number;
  64147. updatable?: boolean;
  64148. sideOrientation?: number;
  64149. frontUVs?: Vector4;
  64150. backUVs?: Vector4;
  64151. instance?: Mesh;
  64152. invertUV?: boolean;
  64153. }, scene?: Nullable<Scene>): Mesh;
  64154. /**
  64155. * Creates a polyhedron mesh
  64156. * * 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
  64157. * * The parameter `size` (positive float, default 1) sets the polygon size
  64158. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64159. * * 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`
  64160. * * 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
  64161. * * 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)`)
  64162. * * 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
  64163. * * 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
  64164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64165. * * 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
  64166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64167. * @param name defines the name of the mesh
  64168. * @param options defines the options used to create the mesh
  64169. * @param scene defines the hosting scene
  64170. * @returns the polyhedron mesh
  64171. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64172. */
  64173. static CreatePolyhedron(name: string, options: {
  64174. type?: number;
  64175. size?: number;
  64176. sizeX?: number;
  64177. sizeY?: number;
  64178. sizeZ?: number;
  64179. custom?: any;
  64180. faceUV?: Vector4[];
  64181. faceColors?: Color4[];
  64182. flat?: boolean;
  64183. updatable?: boolean;
  64184. sideOrientation?: number;
  64185. frontUVs?: Vector4;
  64186. backUVs?: Vector4;
  64187. }, scene?: Nullable<Scene>): Mesh;
  64188. /**
  64189. * Creates a decal mesh.
  64190. * 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
  64191. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64192. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64193. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64194. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64195. * @param name defines the name of the mesh
  64196. * @param sourceMesh defines the mesh where the decal must be applied
  64197. * @param options defines the options used to create the mesh
  64198. * @param scene defines the hosting scene
  64199. * @returns the decal mesh
  64200. * @see https://doc.babylonjs.com/how_to/decals
  64201. */
  64202. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64203. position?: Vector3;
  64204. normal?: Vector3;
  64205. size?: Vector3;
  64206. angle?: number;
  64207. }): Mesh;
  64208. }
  64209. }
  64210. declare module BABYLON {
  64211. /**
  64212. * A simplifier interface for future simplification implementations
  64213. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64214. */
  64215. export interface ISimplifier {
  64216. /**
  64217. * Simplification of a given mesh according to the given settings.
  64218. * Since this requires computation, it is assumed that the function runs async.
  64219. * @param settings The settings of the simplification, including quality and distance
  64220. * @param successCallback A callback that will be called after the mesh was simplified.
  64221. * @param errorCallback in case of an error, this callback will be called. optional.
  64222. */
  64223. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64224. }
  64225. /**
  64226. * Expected simplification settings.
  64227. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64228. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64229. */
  64230. export interface ISimplificationSettings {
  64231. /**
  64232. * Gets or sets the expected quality
  64233. */
  64234. quality: number;
  64235. /**
  64236. * Gets or sets the distance when this optimized version should be used
  64237. */
  64238. distance: number;
  64239. /**
  64240. * Gets an already optimized mesh
  64241. */
  64242. optimizeMesh?: boolean;
  64243. }
  64244. /**
  64245. * Class used to specify simplification options
  64246. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64247. */
  64248. export class SimplificationSettings implements ISimplificationSettings {
  64249. /** expected quality */
  64250. quality: number;
  64251. /** distance when this optimized version should be used */
  64252. distance: number;
  64253. /** already optimized mesh */
  64254. optimizeMesh?: boolean | undefined;
  64255. /**
  64256. * Creates a SimplificationSettings
  64257. * @param quality expected quality
  64258. * @param distance distance when this optimized version should be used
  64259. * @param optimizeMesh already optimized mesh
  64260. */
  64261. constructor(
  64262. /** expected quality */
  64263. quality: number,
  64264. /** distance when this optimized version should be used */
  64265. distance: number,
  64266. /** already optimized mesh */
  64267. optimizeMesh?: boolean | undefined);
  64268. }
  64269. /**
  64270. * Interface used to define a simplification task
  64271. */
  64272. export interface ISimplificationTask {
  64273. /**
  64274. * Array of settings
  64275. */
  64276. settings: Array<ISimplificationSettings>;
  64277. /**
  64278. * Simplification type
  64279. */
  64280. simplificationType: SimplificationType;
  64281. /**
  64282. * Mesh to simplify
  64283. */
  64284. mesh: Mesh;
  64285. /**
  64286. * Callback called on success
  64287. */
  64288. successCallback?: () => void;
  64289. /**
  64290. * Defines if parallel processing can be used
  64291. */
  64292. parallelProcessing: boolean;
  64293. }
  64294. /**
  64295. * Queue used to order the simplification tasks
  64296. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64297. */
  64298. export class SimplificationQueue {
  64299. private _simplificationArray;
  64300. /**
  64301. * Gets a boolean indicating that the process is still running
  64302. */
  64303. running: boolean;
  64304. /**
  64305. * Creates a new queue
  64306. */
  64307. constructor();
  64308. /**
  64309. * Adds a new simplification task
  64310. * @param task defines a task to add
  64311. */
  64312. addTask(task: ISimplificationTask): void;
  64313. /**
  64314. * Execute next task
  64315. */
  64316. executeNext(): void;
  64317. /**
  64318. * Execute a simplification task
  64319. * @param task defines the task to run
  64320. */
  64321. runSimplification(task: ISimplificationTask): void;
  64322. private getSimplifier;
  64323. }
  64324. /**
  64325. * The implemented types of simplification
  64326. * At the moment only Quadratic Error Decimation is implemented
  64327. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64328. */
  64329. export enum SimplificationType {
  64330. /** Quadratic error decimation */
  64331. QUADRATIC = 0
  64332. }
  64333. /**
  64334. * An implementation of the Quadratic Error simplification algorithm.
  64335. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  64336. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  64337. * @author RaananW
  64338. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64339. */
  64340. export class QuadraticErrorSimplification implements ISimplifier {
  64341. private _mesh;
  64342. private triangles;
  64343. private vertices;
  64344. private references;
  64345. private _reconstructedMesh;
  64346. /** Gets or sets the number pf sync interations */
  64347. syncIterations: number;
  64348. /** Gets or sets the aggressiveness of the simplifier */
  64349. aggressiveness: number;
  64350. /** Gets or sets the number of allowed iterations for decimation */
  64351. decimationIterations: number;
  64352. /** Gets or sets the espilon to use for bounding box computation */
  64353. boundingBoxEpsilon: number;
  64354. /**
  64355. * Creates a new QuadraticErrorSimplification
  64356. * @param _mesh defines the target mesh
  64357. */
  64358. constructor(_mesh: Mesh);
  64359. /**
  64360. * Simplification of a given mesh according to the given settings.
  64361. * Since this requires computation, it is assumed that the function runs async.
  64362. * @param settings The settings of the simplification, including quality and distance
  64363. * @param successCallback A callback that will be called after the mesh was simplified.
  64364. */
  64365. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  64366. private runDecimation;
  64367. private initWithMesh;
  64368. private init;
  64369. private reconstructMesh;
  64370. private initDecimatedMesh;
  64371. private isFlipped;
  64372. private updateTriangles;
  64373. private identifyBorder;
  64374. private updateMesh;
  64375. private vertexError;
  64376. private calculateError;
  64377. }
  64378. }
  64379. declare module BABYLON {
  64380. interface Scene {
  64381. /** @hidden (Backing field) */
  64382. _simplificationQueue: SimplificationQueue;
  64383. /**
  64384. * Gets or sets the simplification queue attached to the scene
  64385. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64386. */
  64387. simplificationQueue: SimplificationQueue;
  64388. }
  64389. interface Mesh {
  64390. /**
  64391. * Simplify the mesh according to the given array of settings.
  64392. * Function will return immediately and will simplify async
  64393. * @param settings a collection of simplification settings
  64394. * @param parallelProcessing should all levels calculate parallel or one after the other
  64395. * @param simplificationType the type of simplification to run
  64396. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64397. * @returns the current mesh
  64398. */
  64399. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64400. }
  64401. /**
  64402. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64403. * created in a scene
  64404. */
  64405. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64406. /**
  64407. * The component name helpfull to identify the component in the list of scene components.
  64408. */
  64409. readonly name: string;
  64410. /**
  64411. * The scene the component belongs to.
  64412. */
  64413. scene: Scene;
  64414. /**
  64415. * Creates a new instance of the component for the given scene
  64416. * @param scene Defines the scene to register the component in
  64417. */
  64418. constructor(scene: Scene);
  64419. /**
  64420. * Registers the component in a given scene
  64421. */
  64422. register(): void;
  64423. /**
  64424. * Rebuilds the elements related to this component in case of
  64425. * context lost for instance.
  64426. */
  64427. rebuild(): void;
  64428. /**
  64429. * Disposes the component and the associated ressources
  64430. */
  64431. dispose(): void;
  64432. private _beforeCameraUpdate;
  64433. }
  64434. }
  64435. declare module BABYLON {
  64436. /**
  64437. * Navigation plugin interface to add navigation constrained by a navigation mesh
  64438. */
  64439. export interface INavigationEnginePlugin {
  64440. /**
  64441. * plugin name
  64442. */
  64443. name: string;
  64444. /**
  64445. * Creates a navigation mesh
  64446. * @param meshes array of all the geometry used to compute the navigatio mesh
  64447. * @param parameters bunch of parameters used to filter geometry
  64448. */
  64449. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64450. /**
  64451. * Create a navigation mesh debug mesh
  64452. * @param scene is where the mesh will be added
  64453. * @returns debug display mesh
  64454. */
  64455. createDebugNavMesh(scene: Scene): Mesh;
  64456. /**
  64457. * Get a navigation mesh constrained position, closest to the parameter position
  64458. * @param position world position
  64459. * @returns the closest point to position constrained by the navigation mesh
  64460. */
  64461. getClosestPoint(position: Vector3): Vector3;
  64462. /**
  64463. * Get a navigation mesh constrained position, closest to the parameter position
  64464. * @param position world position
  64465. * @param result output the closest point to position constrained by the navigation mesh
  64466. */
  64467. getClosestPointToRef(position: Vector3, result: Vector3): void;
  64468. /**
  64469. * Get a navigation mesh constrained position, within a particular radius
  64470. * @param position world position
  64471. * @param maxRadius the maximum distance to the constrained world position
  64472. * @returns the closest point to position constrained by the navigation mesh
  64473. */
  64474. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64475. /**
  64476. * Get a navigation mesh constrained position, within a particular radius
  64477. * @param position world position
  64478. * @param maxRadius the maximum distance to the constrained world position
  64479. * @param result output the closest point to position constrained by the navigation mesh
  64480. */
  64481. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  64482. /**
  64483. * Compute the final position from a segment made of destination-position
  64484. * @param position world position
  64485. * @param destination world position
  64486. * @returns the resulting point along the navmesh
  64487. */
  64488. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64489. /**
  64490. * Compute the final position from a segment made of destination-position
  64491. * @param position world position
  64492. * @param destination world position
  64493. * @param result output the resulting point along the navmesh
  64494. */
  64495. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  64496. /**
  64497. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64498. * @param start world position
  64499. * @param end world position
  64500. * @returns array containing world position composing the path
  64501. */
  64502. computePath(start: Vector3, end: Vector3): Vector3[];
  64503. /**
  64504. * If this plugin is supported
  64505. * @returns true if plugin is supported
  64506. */
  64507. isSupported(): boolean;
  64508. /**
  64509. * Create a new Crowd so you can add agents
  64510. * @param maxAgents the maximum agent count in the crowd
  64511. * @param maxAgentRadius the maximum radius an agent can have
  64512. * @param scene to attach the crowd to
  64513. * @returns the crowd you can add agents to
  64514. */
  64515. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64516. /**
  64517. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64518. * The queries will try to find a solution within those bounds
  64519. * default is (1,1,1)
  64520. * @param extent x,y,z value that define the extent around the queries point of reference
  64521. */
  64522. setDefaultQueryExtent(extent: Vector3): void;
  64523. /**
  64524. * Get the Bounding box extent specified by setDefaultQueryExtent
  64525. * @returns the box extent values
  64526. */
  64527. getDefaultQueryExtent(): Vector3;
  64528. /**
  64529. * build the navmesh from a previously saved state using getNavmeshData
  64530. * @param data the Uint8Array returned by getNavmeshData
  64531. */
  64532. buildFromNavmeshData(data: Uint8Array): void;
  64533. /**
  64534. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  64535. * @returns data the Uint8Array that can be saved and reused
  64536. */
  64537. getNavmeshData(): Uint8Array;
  64538. /**
  64539. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64540. * @param result output the box extent values
  64541. */
  64542. getDefaultQueryExtentToRef(result: Vector3): void;
  64543. /**
  64544. * Release all resources
  64545. */
  64546. dispose(): void;
  64547. }
  64548. /**
  64549. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  64550. */
  64551. export interface ICrowd {
  64552. /**
  64553. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64554. * You can attach anything to that node. The node position is updated in the scene update tick.
  64555. * @param pos world position that will be constrained by the navigation mesh
  64556. * @param parameters agent parameters
  64557. * @param transform hooked to the agent that will be update by the scene
  64558. * @returns agent index
  64559. */
  64560. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64561. /**
  64562. * Returns the agent position in world space
  64563. * @param index agent index returned by addAgent
  64564. * @returns world space position
  64565. */
  64566. getAgentPosition(index: number): Vector3;
  64567. /**
  64568. * Gets the agent position result in world space
  64569. * @param index agent index returned by addAgent
  64570. * @param result output world space position
  64571. */
  64572. getAgentPositionToRef(index: number, result: Vector3): void;
  64573. /**
  64574. * Gets the agent velocity in world space
  64575. * @param index agent index returned by addAgent
  64576. * @returns world space velocity
  64577. */
  64578. getAgentVelocity(index: number): Vector3;
  64579. /**
  64580. * Gets the agent velocity result in world space
  64581. * @param index agent index returned by addAgent
  64582. * @param result output world space velocity
  64583. */
  64584. getAgentVelocityToRef(index: number, result: Vector3): void;
  64585. /**
  64586. * remove a particular agent previously created
  64587. * @param index agent index returned by addAgent
  64588. */
  64589. removeAgent(index: number): void;
  64590. /**
  64591. * get the list of all agents attached to this crowd
  64592. * @returns list of agent indices
  64593. */
  64594. getAgents(): number[];
  64595. /**
  64596. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64597. * @param deltaTime in seconds
  64598. */
  64599. update(deltaTime: number): void;
  64600. /**
  64601. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64602. * @param index agent index returned by addAgent
  64603. * @param destination targeted world position
  64604. */
  64605. agentGoto(index: number, destination: Vector3): void;
  64606. /**
  64607. * Teleport the agent to a new position
  64608. * @param index agent index returned by addAgent
  64609. * @param destination targeted world position
  64610. */
  64611. agentTeleport(index: number, destination: Vector3): void;
  64612. /**
  64613. * Update agent parameters
  64614. * @param index agent index returned by addAgent
  64615. * @param parameters agent parameters
  64616. */
  64617. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  64618. /**
  64619. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64620. * The queries will try to find a solution within those bounds
  64621. * default is (1,1,1)
  64622. * @param extent x,y,z value that define the extent around the queries point of reference
  64623. */
  64624. setDefaultQueryExtent(extent: Vector3): void;
  64625. /**
  64626. * Get the Bounding box extent specified by setDefaultQueryExtent
  64627. * @returns the box extent values
  64628. */
  64629. getDefaultQueryExtent(): Vector3;
  64630. /**
  64631. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64632. * @param result output the box extent values
  64633. */
  64634. getDefaultQueryExtentToRef(result: Vector3): void;
  64635. /**
  64636. * Release all resources
  64637. */
  64638. dispose(): void;
  64639. }
  64640. /**
  64641. * Configures an agent
  64642. */
  64643. export interface IAgentParameters {
  64644. /**
  64645. * Agent radius. [Limit: >= 0]
  64646. */
  64647. radius: number;
  64648. /**
  64649. * Agent height. [Limit: > 0]
  64650. */
  64651. height: number;
  64652. /**
  64653. * Maximum allowed acceleration. [Limit: >= 0]
  64654. */
  64655. maxAcceleration: number;
  64656. /**
  64657. * Maximum allowed speed. [Limit: >= 0]
  64658. */
  64659. maxSpeed: number;
  64660. /**
  64661. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  64662. */
  64663. collisionQueryRange: number;
  64664. /**
  64665. * The path visibility optimization range. [Limit: > 0]
  64666. */
  64667. pathOptimizationRange: number;
  64668. /**
  64669. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  64670. */
  64671. separationWeight: number;
  64672. }
  64673. /**
  64674. * Configures the navigation mesh creation
  64675. */
  64676. export interface INavMeshParameters {
  64677. /**
  64678. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  64679. */
  64680. cs: number;
  64681. /**
  64682. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  64683. */
  64684. ch: number;
  64685. /**
  64686. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  64687. */
  64688. walkableSlopeAngle: number;
  64689. /**
  64690. * Minimum floor to 'ceiling' height that will still allow the floor area to
  64691. * be considered walkable. [Limit: >= 3] [Units: vx]
  64692. */
  64693. walkableHeight: number;
  64694. /**
  64695. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  64696. */
  64697. walkableClimb: number;
  64698. /**
  64699. * The distance to erode/shrink the walkable area of the heightfield away from
  64700. * obstructions. [Limit: >=0] [Units: vx]
  64701. */
  64702. walkableRadius: number;
  64703. /**
  64704. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  64705. */
  64706. maxEdgeLen: number;
  64707. /**
  64708. * The maximum distance a simplfied contour's border edges should deviate
  64709. * the original raw contour. [Limit: >=0] [Units: vx]
  64710. */
  64711. maxSimplificationError: number;
  64712. /**
  64713. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  64714. */
  64715. minRegionArea: number;
  64716. /**
  64717. * Any regions with a span count smaller than this value will, if possible,
  64718. * be merged with larger regions. [Limit: >=0] [Units: vx]
  64719. */
  64720. mergeRegionArea: number;
  64721. /**
  64722. * The maximum number of vertices allowed for polygons generated during the
  64723. * contour to polygon conversion process. [Limit: >= 3]
  64724. */
  64725. maxVertsPerPoly: number;
  64726. /**
  64727. * Sets the sampling distance to use when generating the detail mesh.
  64728. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  64729. */
  64730. detailSampleDist: number;
  64731. /**
  64732. * The maximum distance the detail mesh surface should deviate from heightfield
  64733. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  64734. */
  64735. detailSampleMaxError: number;
  64736. }
  64737. }
  64738. declare module BABYLON {
  64739. /**
  64740. * RecastJS navigation plugin
  64741. */
  64742. export class RecastJSPlugin implements INavigationEnginePlugin {
  64743. /**
  64744. * Reference to the Recast library
  64745. */
  64746. bjsRECAST: any;
  64747. /**
  64748. * plugin name
  64749. */
  64750. name: string;
  64751. /**
  64752. * the first navmesh created. We might extend this to support multiple navmeshes
  64753. */
  64754. navMesh: any;
  64755. /**
  64756. * Initializes the recastJS plugin
  64757. * @param recastInjection can be used to inject your own recast reference
  64758. */
  64759. constructor(recastInjection?: any);
  64760. /**
  64761. * Creates a navigation mesh
  64762. * @param meshes array of all the geometry used to compute the navigatio mesh
  64763. * @param parameters bunch of parameters used to filter geometry
  64764. */
  64765. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64766. /**
  64767. * Create a navigation mesh debug mesh
  64768. * @param scene is where the mesh will be added
  64769. * @returns debug display mesh
  64770. */
  64771. createDebugNavMesh(scene: Scene): Mesh;
  64772. /**
  64773. * Get a navigation mesh constrained position, closest to the parameter position
  64774. * @param position world position
  64775. * @returns the closest point to position constrained by the navigation mesh
  64776. */
  64777. getClosestPoint(position: Vector3): Vector3;
  64778. /**
  64779. * Get a navigation mesh constrained position, closest to the parameter position
  64780. * @param position world position
  64781. * @param result output the closest point to position constrained by the navigation mesh
  64782. */
  64783. getClosestPointToRef(position: Vector3, result: Vector3): void;
  64784. /**
  64785. * Get a navigation mesh constrained position, within a particular radius
  64786. * @param position world position
  64787. * @param maxRadius the maximum distance to the constrained world position
  64788. * @returns the closest point to position constrained by the navigation mesh
  64789. */
  64790. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64791. /**
  64792. * Get a navigation mesh constrained position, within a particular radius
  64793. * @param position world position
  64794. * @param maxRadius the maximum distance to the constrained world position
  64795. * @param result output the closest point to position constrained by the navigation mesh
  64796. */
  64797. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  64798. /**
  64799. * Compute the final position from a segment made of destination-position
  64800. * @param position world position
  64801. * @param destination world position
  64802. * @returns the resulting point along the navmesh
  64803. */
  64804. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64805. /**
  64806. * Compute the final position from a segment made of destination-position
  64807. * @param position world position
  64808. * @param destination world position
  64809. * @param result output the resulting point along the navmesh
  64810. */
  64811. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  64812. /**
  64813. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64814. * @param start world position
  64815. * @param end world position
  64816. * @returns array containing world position composing the path
  64817. */
  64818. computePath(start: Vector3, end: Vector3): Vector3[];
  64819. /**
  64820. * Create a new Crowd so you can add agents
  64821. * @param maxAgents the maximum agent count in the crowd
  64822. * @param maxAgentRadius the maximum radius an agent can have
  64823. * @param scene to attach the crowd to
  64824. * @returns the crowd you can add agents to
  64825. */
  64826. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64827. /**
  64828. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64829. * The queries will try to find a solution within those bounds
  64830. * default is (1,1,1)
  64831. * @param extent x,y,z value that define the extent around the queries point of reference
  64832. */
  64833. setDefaultQueryExtent(extent: Vector3): void;
  64834. /**
  64835. * Get the Bounding box extent specified by setDefaultQueryExtent
  64836. * @returns the box extent values
  64837. */
  64838. getDefaultQueryExtent(): Vector3;
  64839. /**
  64840. * build the navmesh from a previously saved state using getNavmeshData
  64841. * @param data the Uint8Array returned by getNavmeshData
  64842. */
  64843. buildFromNavmeshData(data: Uint8Array): void;
  64844. /**
  64845. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  64846. * @returns data the Uint8Array that can be saved and reused
  64847. */
  64848. getNavmeshData(): Uint8Array;
  64849. /**
  64850. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64851. * @param result output the box extent values
  64852. */
  64853. getDefaultQueryExtentToRef(result: Vector3): void;
  64854. /**
  64855. * Disposes
  64856. */
  64857. dispose(): void;
  64858. /**
  64859. * If this plugin is supported
  64860. * @returns true if plugin is supported
  64861. */
  64862. isSupported(): boolean;
  64863. }
  64864. /**
  64865. * Recast detour crowd implementation
  64866. */
  64867. export class RecastJSCrowd implements ICrowd {
  64868. /**
  64869. * Recast/detour plugin
  64870. */
  64871. bjsRECASTPlugin: RecastJSPlugin;
  64872. /**
  64873. * Link to the detour crowd
  64874. */
  64875. recastCrowd: any;
  64876. /**
  64877. * One transform per agent
  64878. */
  64879. transforms: TransformNode[];
  64880. /**
  64881. * All agents created
  64882. */
  64883. agents: number[];
  64884. /**
  64885. * Link to the scene is kept to unregister the crowd from the scene
  64886. */
  64887. private _scene;
  64888. /**
  64889. * Observer for crowd updates
  64890. */
  64891. private _onBeforeAnimationsObserver;
  64892. /**
  64893. * Constructor
  64894. * @param plugin recastJS plugin
  64895. * @param maxAgents the maximum agent count in the crowd
  64896. * @param maxAgentRadius the maximum radius an agent can have
  64897. * @param scene to attach the crowd to
  64898. * @returns the crowd you can add agents to
  64899. */
  64900. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  64901. /**
  64902. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64903. * You can attach anything to that node. The node position is updated in the scene update tick.
  64904. * @param pos world position that will be constrained by the navigation mesh
  64905. * @param parameters agent parameters
  64906. * @param transform hooked to the agent that will be update by the scene
  64907. * @returns agent index
  64908. */
  64909. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64910. /**
  64911. * Returns the agent position in world space
  64912. * @param index agent index returned by addAgent
  64913. * @returns world space position
  64914. */
  64915. getAgentPosition(index: number): Vector3;
  64916. /**
  64917. * Returns the agent position result in world space
  64918. * @param index agent index returned by addAgent
  64919. * @param result output world space position
  64920. */
  64921. getAgentPositionToRef(index: number, result: Vector3): void;
  64922. /**
  64923. * Returns the agent velocity in world space
  64924. * @param index agent index returned by addAgent
  64925. * @returns world space velocity
  64926. */
  64927. getAgentVelocity(index: number): Vector3;
  64928. /**
  64929. * Returns the agent velocity result in world space
  64930. * @param index agent index returned by addAgent
  64931. * @param result output world space velocity
  64932. */
  64933. getAgentVelocityToRef(index: number, result: Vector3): void;
  64934. /**
  64935. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64936. * @param index agent index returned by addAgent
  64937. * @param destination targeted world position
  64938. */
  64939. agentGoto(index: number, destination: Vector3): void;
  64940. /**
  64941. * Teleport the agent to a new position
  64942. * @param index agent index returned by addAgent
  64943. * @param destination targeted world position
  64944. */
  64945. agentTeleport(index: number, destination: Vector3): void;
  64946. /**
  64947. * Update agent parameters
  64948. * @param index agent index returned by addAgent
  64949. * @param parameters agent parameters
  64950. */
  64951. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  64952. /**
  64953. * remove a particular agent previously created
  64954. * @param index agent index returned by addAgent
  64955. */
  64956. removeAgent(index: number): void;
  64957. /**
  64958. * get the list of all agents attached to this crowd
  64959. * @returns list of agent indices
  64960. */
  64961. getAgents(): number[];
  64962. /**
  64963. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64964. * @param deltaTime in seconds
  64965. */
  64966. update(deltaTime: number): void;
  64967. /**
  64968. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64969. * The queries will try to find a solution within those bounds
  64970. * default is (1,1,1)
  64971. * @param extent x,y,z value that define the extent around the queries point of reference
  64972. */
  64973. setDefaultQueryExtent(extent: Vector3): void;
  64974. /**
  64975. * Get the Bounding box extent specified by setDefaultQueryExtent
  64976. * @returns the box extent values
  64977. */
  64978. getDefaultQueryExtent(): Vector3;
  64979. /**
  64980. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64981. * @param result output the box extent values
  64982. */
  64983. getDefaultQueryExtentToRef(result: Vector3): void;
  64984. /**
  64985. * Release all resources
  64986. */
  64987. dispose(): void;
  64988. }
  64989. }
  64990. declare module BABYLON {
  64991. /**
  64992. * Class used to enable access to IndexedDB
  64993. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64994. */
  64995. export class Database implements IOfflineProvider {
  64996. private _callbackManifestChecked;
  64997. private _currentSceneUrl;
  64998. private _db;
  64999. private _enableSceneOffline;
  65000. private _enableTexturesOffline;
  65001. private _manifestVersionFound;
  65002. private _mustUpdateRessources;
  65003. private _hasReachedQuota;
  65004. private _isSupported;
  65005. private _idbFactory;
  65006. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65007. private static IsUASupportingBlobStorage;
  65008. /**
  65009. * Gets a boolean indicating if Database storate is enabled (off by default)
  65010. */
  65011. static IDBStorageEnabled: boolean;
  65012. /**
  65013. * Gets a boolean indicating if scene must be saved in the database
  65014. */
  65015. get enableSceneOffline(): boolean;
  65016. /**
  65017. * Gets a boolean indicating if textures must be saved in the database
  65018. */
  65019. get enableTexturesOffline(): boolean;
  65020. /**
  65021. * Creates a new Database
  65022. * @param urlToScene defines the url to load the scene
  65023. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65024. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65025. */
  65026. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65027. private static _ParseURL;
  65028. private static _ReturnFullUrlLocation;
  65029. private _checkManifestFile;
  65030. /**
  65031. * Open the database and make it available
  65032. * @param successCallback defines the callback to call on success
  65033. * @param errorCallback defines the callback to call on error
  65034. */
  65035. open(successCallback: () => void, errorCallback: () => void): void;
  65036. /**
  65037. * Loads an image from the database
  65038. * @param url defines the url to load from
  65039. * @param image defines the target DOM image
  65040. */
  65041. loadImage(url: string, image: HTMLImageElement): void;
  65042. private _loadImageFromDBAsync;
  65043. private _saveImageIntoDBAsync;
  65044. private _checkVersionFromDB;
  65045. private _loadVersionFromDBAsync;
  65046. private _saveVersionIntoDBAsync;
  65047. /**
  65048. * Loads a file from database
  65049. * @param url defines the URL to load from
  65050. * @param sceneLoaded defines a callback to call on success
  65051. * @param progressCallBack defines a callback to call when progress changed
  65052. * @param errorCallback defines a callback to call on error
  65053. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65054. */
  65055. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65056. private _loadFileAsync;
  65057. private _saveFileAsync;
  65058. /**
  65059. * Validates if xhr data is correct
  65060. * @param xhr defines the request to validate
  65061. * @param dataType defines the expected data type
  65062. * @returns true if data is correct
  65063. */
  65064. private static _ValidateXHRData;
  65065. }
  65066. }
  65067. declare module BABYLON {
  65068. /** @hidden */
  65069. export var gpuUpdateParticlesPixelShader: {
  65070. name: string;
  65071. shader: string;
  65072. };
  65073. }
  65074. declare module BABYLON {
  65075. /** @hidden */
  65076. export var gpuUpdateParticlesVertexShader: {
  65077. name: string;
  65078. shader: string;
  65079. };
  65080. }
  65081. declare module BABYLON {
  65082. /** @hidden */
  65083. export var clipPlaneFragmentDeclaration2: {
  65084. name: string;
  65085. shader: string;
  65086. };
  65087. }
  65088. declare module BABYLON {
  65089. /** @hidden */
  65090. export var gpuRenderParticlesPixelShader: {
  65091. name: string;
  65092. shader: string;
  65093. };
  65094. }
  65095. declare module BABYLON {
  65096. /** @hidden */
  65097. export var clipPlaneVertexDeclaration2: {
  65098. name: string;
  65099. shader: string;
  65100. };
  65101. }
  65102. declare module BABYLON {
  65103. /** @hidden */
  65104. export var gpuRenderParticlesVertexShader: {
  65105. name: string;
  65106. shader: string;
  65107. };
  65108. }
  65109. declare module BABYLON {
  65110. /**
  65111. * This represents a GPU particle system in Babylon
  65112. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65113. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65114. */
  65115. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65116. /**
  65117. * The layer mask we are rendering the particles through.
  65118. */
  65119. layerMask: number;
  65120. private _capacity;
  65121. private _activeCount;
  65122. private _currentActiveCount;
  65123. private _accumulatedCount;
  65124. private _renderEffect;
  65125. private _updateEffect;
  65126. private _buffer0;
  65127. private _buffer1;
  65128. private _spriteBuffer;
  65129. private _updateVAO;
  65130. private _renderVAO;
  65131. private _targetIndex;
  65132. private _sourceBuffer;
  65133. private _targetBuffer;
  65134. private _engine;
  65135. private _currentRenderId;
  65136. private _started;
  65137. private _stopped;
  65138. private _timeDelta;
  65139. private _randomTexture;
  65140. private _randomTexture2;
  65141. private _attributesStrideSize;
  65142. private _updateEffectOptions;
  65143. private _randomTextureSize;
  65144. private _actualFrame;
  65145. private _customEffect;
  65146. private readonly _rawTextureWidth;
  65147. /**
  65148. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65149. */
  65150. static get IsSupported(): boolean;
  65151. /**
  65152. * An event triggered when the system is disposed.
  65153. */
  65154. onDisposeObservable: Observable<IParticleSystem>;
  65155. /**
  65156. * Gets the maximum number of particles active at the same time.
  65157. * @returns The max number of active particles.
  65158. */
  65159. getCapacity(): number;
  65160. /**
  65161. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65162. * to override the particles.
  65163. */
  65164. forceDepthWrite: boolean;
  65165. /**
  65166. * Gets or set the number of active particles
  65167. */
  65168. get activeParticleCount(): number;
  65169. set activeParticleCount(value: number);
  65170. private _preWarmDone;
  65171. /**
  65172. * Specifies if the particles are updated in emitter local space or world space.
  65173. */
  65174. isLocal: boolean;
  65175. /**
  65176. * Is this system ready to be used/rendered
  65177. * @return true if the system is ready
  65178. */
  65179. isReady(): boolean;
  65180. /**
  65181. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65182. * @returns True if it has been started, otherwise false.
  65183. */
  65184. isStarted(): boolean;
  65185. /**
  65186. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  65187. * @returns True if it has been stopped, otherwise false.
  65188. */
  65189. isStopped(): boolean;
  65190. /**
  65191. * Gets a boolean indicating that the system is stopping
  65192. * @returns true if the system is currently stopping
  65193. */
  65194. isStopping(): boolean;
  65195. /**
  65196. * Gets the number of particles active at the same time.
  65197. * @returns The number of active particles.
  65198. */
  65199. getActiveCount(): number;
  65200. /**
  65201. * Starts the particle system and begins to emit
  65202. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65203. */
  65204. start(delay?: number): void;
  65205. /**
  65206. * Stops the particle system.
  65207. */
  65208. stop(): void;
  65209. /**
  65210. * Remove all active particles
  65211. */
  65212. reset(): void;
  65213. /**
  65214. * Returns the string "GPUParticleSystem"
  65215. * @returns a string containing the class name
  65216. */
  65217. getClassName(): string;
  65218. /**
  65219. * Gets the custom effect used to render the particles
  65220. * @param blendMode Blend mode for which the effect should be retrieved
  65221. * @returns The effect
  65222. */
  65223. getCustomEffect(blendMode?: number): Nullable<Effect>;
  65224. /**
  65225. * Sets the custom effect used to render the particles
  65226. * @param effect The effect to set
  65227. * @param blendMode Blend mode for which the effect should be set
  65228. */
  65229. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  65230. /** @hidden */
  65231. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  65232. /**
  65233. * Observable that will be called just before the particles are drawn
  65234. */
  65235. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  65236. /**
  65237. * Gets the name of the particle vertex shader
  65238. */
  65239. get vertexShaderName(): string;
  65240. private _colorGradientsTexture;
  65241. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65242. /**
  65243. * Adds a new color gradient
  65244. * @param gradient defines the gradient to use (between 0 and 1)
  65245. * @param color1 defines the color to affect to the specified gradient
  65246. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65247. * @returns the current particle system
  65248. */
  65249. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65250. private _refreshColorGradient;
  65251. /** Force the system to rebuild all gradients that need to be resync */
  65252. forceRefreshGradients(): void;
  65253. /**
  65254. * Remove a specific color gradient
  65255. * @param gradient defines the gradient to remove
  65256. * @returns the current particle system
  65257. */
  65258. removeColorGradient(gradient: number): GPUParticleSystem;
  65259. private _angularSpeedGradientsTexture;
  65260. private _sizeGradientsTexture;
  65261. private _velocityGradientsTexture;
  65262. private _limitVelocityGradientsTexture;
  65263. private _dragGradientsTexture;
  65264. private _addFactorGradient;
  65265. /**
  65266. * Adds a new size gradient
  65267. * @param gradient defines the gradient to use (between 0 and 1)
  65268. * @param factor defines the size factor to affect to the specified gradient
  65269. * @returns the current particle system
  65270. */
  65271. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65272. /**
  65273. * Remove a specific size gradient
  65274. * @param gradient defines the gradient to remove
  65275. * @returns the current particle system
  65276. */
  65277. removeSizeGradient(gradient: number): GPUParticleSystem;
  65278. private _refreshFactorGradient;
  65279. /**
  65280. * Adds a new angular speed gradient
  65281. * @param gradient defines the gradient to use (between 0 and 1)
  65282. * @param factor defines the angular speed to affect to the specified gradient
  65283. * @returns the current particle system
  65284. */
  65285. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65286. /**
  65287. * Remove a specific angular speed gradient
  65288. * @param gradient defines the gradient to remove
  65289. * @returns the current particle system
  65290. */
  65291. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65292. /**
  65293. * Adds a new velocity gradient
  65294. * @param gradient defines the gradient to use (between 0 and 1)
  65295. * @param factor defines the velocity to affect to the specified gradient
  65296. * @returns the current particle system
  65297. */
  65298. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65299. /**
  65300. * Remove a specific velocity gradient
  65301. * @param gradient defines the gradient to remove
  65302. * @returns the current particle system
  65303. */
  65304. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65305. /**
  65306. * Adds a new limit velocity gradient
  65307. * @param gradient defines the gradient to use (between 0 and 1)
  65308. * @param factor defines the limit velocity value to affect to the specified gradient
  65309. * @returns the current particle system
  65310. */
  65311. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65312. /**
  65313. * Remove a specific limit velocity gradient
  65314. * @param gradient defines the gradient to remove
  65315. * @returns the current particle system
  65316. */
  65317. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65318. /**
  65319. * Adds a new drag gradient
  65320. * @param gradient defines the gradient to use (between 0 and 1)
  65321. * @param factor defines the drag value to affect to the specified gradient
  65322. * @returns the current particle system
  65323. */
  65324. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65325. /**
  65326. * Remove a specific drag gradient
  65327. * @param gradient defines the gradient to remove
  65328. * @returns the current particle system
  65329. */
  65330. removeDragGradient(gradient: number): GPUParticleSystem;
  65331. /**
  65332. * Not supported by GPUParticleSystem
  65333. * @param gradient defines the gradient to use (between 0 and 1)
  65334. * @param factor defines the emit rate value to affect to the specified gradient
  65335. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65336. * @returns the current particle system
  65337. */
  65338. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65339. /**
  65340. * Not supported by GPUParticleSystem
  65341. * @param gradient defines the gradient to remove
  65342. * @returns the current particle system
  65343. */
  65344. removeEmitRateGradient(gradient: number): IParticleSystem;
  65345. /**
  65346. * Not supported by GPUParticleSystem
  65347. * @param gradient defines the gradient to use (between 0 and 1)
  65348. * @param factor defines the start size value to affect to the specified gradient
  65349. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65350. * @returns the current particle system
  65351. */
  65352. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65353. /**
  65354. * Not supported by GPUParticleSystem
  65355. * @param gradient defines the gradient to remove
  65356. * @returns the current particle system
  65357. */
  65358. removeStartSizeGradient(gradient: number): IParticleSystem;
  65359. /**
  65360. * Not supported by GPUParticleSystem
  65361. * @param gradient defines the gradient to use (between 0 and 1)
  65362. * @param min defines the color remap minimal range
  65363. * @param max defines the color remap maximal range
  65364. * @returns the current particle system
  65365. */
  65366. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65367. /**
  65368. * Not supported by GPUParticleSystem
  65369. * @param gradient defines the gradient to remove
  65370. * @returns the current particle system
  65371. */
  65372. removeColorRemapGradient(): IParticleSystem;
  65373. /**
  65374. * Not supported by GPUParticleSystem
  65375. * @param gradient defines the gradient to use (between 0 and 1)
  65376. * @param min defines the alpha remap minimal range
  65377. * @param max defines the alpha remap maximal range
  65378. * @returns the current particle system
  65379. */
  65380. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65381. /**
  65382. * Not supported by GPUParticleSystem
  65383. * @param gradient defines the gradient to remove
  65384. * @returns the current particle system
  65385. */
  65386. removeAlphaRemapGradient(): IParticleSystem;
  65387. /**
  65388. * Not supported by GPUParticleSystem
  65389. * @param gradient defines the gradient to use (between 0 and 1)
  65390. * @param color defines the color to affect to the specified gradient
  65391. * @returns the current particle system
  65392. */
  65393. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65394. /**
  65395. * Not supported by GPUParticleSystem
  65396. * @param gradient defines the gradient to remove
  65397. * @returns the current particle system
  65398. */
  65399. removeRampGradient(): IParticleSystem;
  65400. /**
  65401. * Not supported by GPUParticleSystem
  65402. * @returns the list of ramp gradients
  65403. */
  65404. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65405. /**
  65406. * Not supported by GPUParticleSystem
  65407. * Gets or sets a boolean indicating that ramp gradients must be used
  65408. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65409. */
  65410. get useRampGradients(): boolean;
  65411. set useRampGradients(value: boolean);
  65412. /**
  65413. * Not supported by GPUParticleSystem
  65414. * @param gradient defines the gradient to use (between 0 and 1)
  65415. * @param factor defines the life time factor to affect to the specified gradient
  65416. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65417. * @returns the current particle system
  65418. */
  65419. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65420. /**
  65421. * Not supported by GPUParticleSystem
  65422. * @param gradient defines the gradient to remove
  65423. * @returns the current particle system
  65424. */
  65425. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65426. /**
  65427. * Instantiates a GPU particle system.
  65428. * 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.
  65429. * @param name The name of the particle system
  65430. * @param options The options used to create the system
  65431. * @param scene The scene the particle system belongs to
  65432. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65433. * @param customEffect a custom effect used to change the way particles are rendered by default
  65434. */
  65435. constructor(name: string, options: Partial<{
  65436. capacity: number;
  65437. randomTextureSize: number;
  65438. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  65439. protected _reset(): void;
  65440. private _createUpdateVAO;
  65441. private _createRenderVAO;
  65442. private _initialize;
  65443. /** @hidden */
  65444. _recreateUpdateEffect(): void;
  65445. private _getEffect;
  65446. /**
  65447. * Fill the defines array according to the current settings of the particle system
  65448. * @param defines Array to be updated
  65449. * @param blendMode blend mode to take into account when updating the array
  65450. */
  65451. fillDefines(defines: Array<string>, blendMode?: number): void;
  65452. /**
  65453. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  65454. * @param uniforms Uniforms array to fill
  65455. * @param attributes Attributes array to fill
  65456. * @param samplers Samplers array to fill
  65457. */
  65458. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  65459. /** @hidden */
  65460. _recreateRenderEffect(): Effect;
  65461. /**
  65462. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65463. * @param preWarm defines if we are in the pre-warmimg phase
  65464. */
  65465. animate(preWarm?: boolean): void;
  65466. private _createFactorGradientTexture;
  65467. private _createSizeGradientTexture;
  65468. private _createAngularSpeedGradientTexture;
  65469. private _createVelocityGradientTexture;
  65470. private _createLimitVelocityGradientTexture;
  65471. private _createDragGradientTexture;
  65472. private _createColorGradientTexture;
  65473. /**
  65474. * Renders the particle system in its current state
  65475. * @param preWarm defines if the system should only update the particles but not render them
  65476. * @returns the current number of particles
  65477. */
  65478. render(preWarm?: boolean): number;
  65479. /**
  65480. * Rebuilds the particle system
  65481. */
  65482. rebuild(): void;
  65483. private _releaseBuffers;
  65484. private _releaseVAOs;
  65485. /**
  65486. * Disposes the particle system and free the associated resources
  65487. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65488. */
  65489. dispose(disposeTexture?: boolean): void;
  65490. /**
  65491. * Clones the particle system.
  65492. * @param name The name of the cloned object
  65493. * @param newEmitter The new emitter to use
  65494. * @returns the cloned particle system
  65495. */
  65496. clone(name: string, newEmitter: any): GPUParticleSystem;
  65497. /**
  65498. * Serializes the particle system to a JSON object
  65499. * @param serializeTexture defines if the texture must be serialized as well
  65500. * @returns the JSON object
  65501. */
  65502. serialize(serializeTexture?: boolean): any;
  65503. /**
  65504. * Parses a JSON object to create a GPU particle system.
  65505. * @param parsedParticleSystem The JSON object to parse
  65506. * @param scene The scene to create the particle system in
  65507. * @param rootUrl The root url to use to load external dependencies like texture
  65508. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65509. * @returns the parsed GPU particle system
  65510. */
  65511. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65512. }
  65513. }
  65514. declare module BABYLON {
  65515. /**
  65516. * Represents a set of particle systems working together to create a specific effect
  65517. */
  65518. export class ParticleSystemSet implements IDisposable {
  65519. /**
  65520. * Gets or sets base Assets URL
  65521. */
  65522. static BaseAssetsUrl: string;
  65523. private _emitterCreationOptions;
  65524. private _emitterNode;
  65525. /**
  65526. * Gets the particle system list
  65527. */
  65528. systems: IParticleSystem[];
  65529. /**
  65530. * Gets the emitter node used with this set
  65531. */
  65532. get emitterNode(): Nullable<TransformNode>;
  65533. /**
  65534. * Creates a new emitter mesh as a sphere
  65535. * @param options defines the options used to create the sphere
  65536. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65537. * @param scene defines the hosting scene
  65538. */
  65539. setEmitterAsSphere(options: {
  65540. diameter: number;
  65541. segments: number;
  65542. color: Color3;
  65543. }, renderingGroupId: number, scene: Scene): void;
  65544. /**
  65545. * Starts all particle systems of the set
  65546. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65547. */
  65548. start(emitter?: AbstractMesh): void;
  65549. /**
  65550. * Release all associated resources
  65551. */
  65552. dispose(): void;
  65553. /**
  65554. * Serialize the set into a JSON compatible object
  65555. * @param serializeTexture defines if the texture must be serialized as well
  65556. * @returns a JSON compatible representation of the set
  65557. */
  65558. serialize(serializeTexture?: boolean): any;
  65559. /**
  65560. * Parse a new ParticleSystemSet from a serialized source
  65561. * @param data defines a JSON compatible representation of the set
  65562. * @param scene defines the hosting scene
  65563. * @param gpu defines if we want GPU particles or CPU particles
  65564. * @returns a new ParticleSystemSet
  65565. */
  65566. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  65567. }
  65568. }
  65569. declare module BABYLON {
  65570. /**
  65571. * This class is made for on one-liner static method to help creating particle system set.
  65572. */
  65573. export class ParticleHelper {
  65574. /**
  65575. * Gets or sets base Assets URL
  65576. */
  65577. static BaseAssetsUrl: string;
  65578. /** Define the Url to load snippets */
  65579. static SnippetUrl: string;
  65580. /**
  65581. * Create a default particle system that you can tweak
  65582. * @param emitter defines the emitter to use
  65583. * @param capacity defines the system capacity (default is 500 particles)
  65584. * @param scene defines the hosting scene
  65585. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  65586. * @returns the new Particle system
  65587. */
  65588. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  65589. /**
  65590. * This is the main static method (one-liner) of this helper to create different particle systems
  65591. * @param type This string represents the type to the particle system to create
  65592. * @param scene The scene where the particle system should live
  65593. * @param gpu If the system will use gpu
  65594. * @returns the ParticleSystemSet created
  65595. */
  65596. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  65597. /**
  65598. * Static function used to export a particle system to a ParticleSystemSet variable.
  65599. * Please note that the emitter shape is not exported
  65600. * @param systems defines the particle systems to export
  65601. * @returns the created particle system set
  65602. */
  65603. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  65604. /**
  65605. * Creates a particle system from a snippet saved in a remote file
  65606. * @param name defines the name of the particle system to create
  65607. * @param url defines the url to load from
  65608. * @param scene defines the hosting scene
  65609. * @param gpu If the system will use gpu
  65610. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65611. * @returns a promise that will resolve to the new particle system
  65612. */
  65613. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  65614. /**
  65615. * Creates a particle system from a snippet saved by the particle system editor
  65616. * @param snippetId defines the snippet to load
  65617. * @param scene defines the hosting scene
  65618. * @param gpu If the system will use gpu
  65619. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65620. * @returns a promise that will resolve to the new particle system
  65621. */
  65622. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  65623. }
  65624. }
  65625. declare module BABYLON {
  65626. interface Engine {
  65627. /**
  65628. * Create an effect to use with particle systems.
  65629. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  65630. * the particle system for which you want to create a custom effect in the last parameter
  65631. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  65632. * @param uniformsNames defines a list of attribute names
  65633. * @param samplers defines an array of string used to represent textures
  65634. * @param defines defines the string containing the defines to use to compile the shaders
  65635. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  65636. * @param onCompiled defines a function to call when the effect creation is successful
  65637. * @param onError defines a function to call when the effect creation has failed
  65638. * @param particleSystem the particle system you want to create the effect for
  65639. * @returns the new Effect
  65640. */
  65641. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  65642. }
  65643. interface Mesh {
  65644. /**
  65645. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  65646. * @returns an array of IParticleSystem
  65647. */
  65648. getEmittedParticleSystems(): IParticleSystem[];
  65649. /**
  65650. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  65651. * @returns an array of IParticleSystem
  65652. */
  65653. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  65654. }
  65655. /**
  65656. * @hidden
  65657. */
  65658. export var _IDoNeedToBeInTheBuild: number;
  65659. }
  65660. declare module BABYLON {
  65661. /** Defines the 4 color options */
  65662. export enum PointColor {
  65663. /** color value */
  65664. Color = 2,
  65665. /** uv value */
  65666. UV = 1,
  65667. /** random value */
  65668. Random = 0,
  65669. /** stated value */
  65670. Stated = 3
  65671. }
  65672. /**
  65673. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  65674. * 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.
  65675. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  65676. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  65677. *
  65678. * Full documentation here : TO BE ENTERED
  65679. */
  65680. export class PointsCloudSystem implements IDisposable {
  65681. /**
  65682. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  65683. * Example : var p = SPS.particles[i];
  65684. */
  65685. particles: CloudPoint[];
  65686. /**
  65687. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  65688. */
  65689. nbParticles: number;
  65690. /**
  65691. * This a counter for your own usage. It's not set by any SPS functions.
  65692. */
  65693. counter: number;
  65694. /**
  65695. * The PCS name. This name is also given to the underlying mesh.
  65696. */
  65697. name: string;
  65698. /**
  65699. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  65700. */
  65701. mesh: Mesh;
  65702. /**
  65703. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  65704. * Please read :
  65705. */
  65706. vars: any;
  65707. /**
  65708. * @hidden
  65709. */
  65710. _size: number;
  65711. private _scene;
  65712. private _promises;
  65713. private _positions;
  65714. private _indices;
  65715. private _normals;
  65716. private _colors;
  65717. private _uvs;
  65718. private _indices32;
  65719. private _positions32;
  65720. private _colors32;
  65721. private _uvs32;
  65722. private _updatable;
  65723. private _isVisibilityBoxLocked;
  65724. private _alwaysVisible;
  65725. private _groups;
  65726. private _groupCounter;
  65727. private _computeParticleColor;
  65728. private _computeParticleTexture;
  65729. private _computeParticleRotation;
  65730. private _computeBoundingBox;
  65731. private _isReady;
  65732. /**
  65733. * Creates a PCS (Points Cloud System) object
  65734. * @param name (String) is the PCS name, this will be the underlying mesh name
  65735. * @param pointSize (number) is the size for each point
  65736. * @param scene (Scene) is the scene in which the PCS is added
  65737. * @param options defines the options of the PCS e.g.
  65738. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  65739. */
  65740. constructor(name: string, pointSize: number, scene: Scene, options?: {
  65741. updatable?: boolean;
  65742. });
  65743. /**
  65744. * Builds the PCS underlying mesh. Returns a standard Mesh.
  65745. * If no points were added to the PCS, the returned mesh is just a single point.
  65746. * @returns a promise for the created mesh
  65747. */
  65748. buildMeshAsync(): Promise<Mesh>;
  65749. /**
  65750. * @hidden
  65751. */
  65752. private _buildMesh;
  65753. private _addParticle;
  65754. private _randomUnitVector;
  65755. private _getColorIndicesForCoord;
  65756. private _setPointsColorOrUV;
  65757. private _colorFromTexture;
  65758. private _calculateDensity;
  65759. /**
  65760. * Adds points to the PCS in random positions within a unit sphere
  65761. * @param nb (positive integer) the number of particles to be created from this model
  65762. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  65763. * @returns the number of groups in the system
  65764. */
  65765. addPoints(nb: number, pointFunction?: any): number;
  65766. /**
  65767. * Adds points to the PCS from the surface of the model shape
  65768. * @param mesh is any Mesh object that will be used as a surface model for the points
  65769. * @param nb (positive integer) the number of particles to be created from this model
  65770. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65771. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65772. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65773. * @returns the number of groups in the system
  65774. */
  65775. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65776. /**
  65777. * Adds points to the PCS inside the model shape
  65778. * @param mesh is any Mesh object that will be used as a surface model for the points
  65779. * @param nb (positive integer) the number of particles to be created from this model
  65780. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65781. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65782. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65783. * @returns the number of groups in the system
  65784. */
  65785. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65786. /**
  65787. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  65788. * This method calls `updateParticle()` for each particle of the SPS.
  65789. * For an animated SPS, it is usually called within the render loop.
  65790. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  65791. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  65792. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  65793. * @returns the PCS.
  65794. */
  65795. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  65796. /**
  65797. * Disposes the PCS.
  65798. */
  65799. dispose(): void;
  65800. /**
  65801. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  65802. * doc :
  65803. * @returns the PCS.
  65804. */
  65805. refreshVisibleSize(): PointsCloudSystem;
  65806. /**
  65807. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  65808. * @param size the size (float) of the visibility box
  65809. * note : this doesn't lock the PCS mesh bounding box.
  65810. * doc :
  65811. */
  65812. setVisibilityBox(size: number): void;
  65813. /**
  65814. * Gets whether the PCS is always visible or not
  65815. * doc :
  65816. */
  65817. get isAlwaysVisible(): boolean;
  65818. /**
  65819. * Sets the PCS as always visible or not
  65820. * doc :
  65821. */
  65822. set isAlwaysVisible(val: boolean);
  65823. /**
  65824. * Tells to `setParticles()` to compute the particle rotations or not
  65825. * Default value : false. The PCS is faster when it's set to false
  65826. * Note : particle rotations are only applied to parent particles
  65827. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  65828. */
  65829. set computeParticleRotation(val: boolean);
  65830. /**
  65831. * Tells to `setParticles()` to compute the particle colors or not.
  65832. * Default value : true. The PCS is faster when it's set to false.
  65833. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65834. */
  65835. set computeParticleColor(val: boolean);
  65836. set computeParticleTexture(val: boolean);
  65837. /**
  65838. * Gets if `setParticles()` computes the particle colors or not.
  65839. * Default value : false. The PCS is faster when it's set to false.
  65840. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65841. */
  65842. get computeParticleColor(): boolean;
  65843. /**
  65844. * Gets if `setParticles()` computes the particle textures or not.
  65845. * Default value : false. The PCS is faster when it's set to false.
  65846. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  65847. */
  65848. get computeParticleTexture(): boolean;
  65849. /**
  65850. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  65851. */
  65852. set computeBoundingBox(val: boolean);
  65853. /**
  65854. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  65855. */
  65856. get computeBoundingBox(): boolean;
  65857. /**
  65858. * This function does nothing. It may be overwritten to set all the particle first values.
  65859. * The PCS doesn't call this function, you may have to call it by your own.
  65860. * doc :
  65861. */
  65862. initParticles(): void;
  65863. /**
  65864. * This function does nothing. It may be overwritten to recycle a particle
  65865. * The PCS doesn't call this function, you can to call it
  65866. * doc :
  65867. * @param particle The particle to recycle
  65868. * @returns the recycled particle
  65869. */
  65870. recycleParticle(particle: CloudPoint): CloudPoint;
  65871. /**
  65872. * Updates a particle : this function should be overwritten by the user.
  65873. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  65874. * doc :
  65875. * @example : just set a particle position or velocity and recycle conditions
  65876. * @param particle The particle to update
  65877. * @returns the updated particle
  65878. */
  65879. updateParticle(particle: CloudPoint): CloudPoint;
  65880. /**
  65881. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  65882. * This does nothing and may be overwritten by the user.
  65883. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65884. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65885. * @param update the boolean update value actually passed to setParticles()
  65886. */
  65887. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65888. /**
  65889. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  65890. * This will be passed three parameters.
  65891. * This does nothing and may be overwritten by the user.
  65892. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65893. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65894. * @param update the boolean update value actually passed to setParticles()
  65895. */
  65896. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65897. }
  65898. }
  65899. declare module BABYLON {
  65900. /**
  65901. * Represents one particle of a points cloud system.
  65902. */
  65903. export class CloudPoint {
  65904. /**
  65905. * particle global index
  65906. */
  65907. idx: number;
  65908. /**
  65909. * The color of the particle
  65910. */
  65911. color: Nullable<Color4>;
  65912. /**
  65913. * The world space position of the particle.
  65914. */
  65915. position: Vector3;
  65916. /**
  65917. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  65918. */
  65919. rotation: Vector3;
  65920. /**
  65921. * The world space rotation quaternion of the particle.
  65922. */
  65923. rotationQuaternion: Nullable<Quaternion>;
  65924. /**
  65925. * The uv of the particle.
  65926. */
  65927. uv: Nullable<Vector2>;
  65928. /**
  65929. * The current speed of the particle.
  65930. */
  65931. velocity: Vector3;
  65932. /**
  65933. * The pivot point in the particle local space.
  65934. */
  65935. pivot: Vector3;
  65936. /**
  65937. * Must the particle be translated from its pivot point in its local space ?
  65938. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  65939. * Default : false
  65940. */
  65941. translateFromPivot: boolean;
  65942. /**
  65943. * Index of this particle in the global "positions" array (Internal use)
  65944. * @hidden
  65945. */
  65946. _pos: number;
  65947. /**
  65948. * @hidden Index of this particle in the global "indices" array (Internal use)
  65949. */
  65950. _ind: number;
  65951. /**
  65952. * Group this particle belongs to
  65953. */
  65954. _group: PointsGroup;
  65955. /**
  65956. * Group id of this particle
  65957. */
  65958. groupId: number;
  65959. /**
  65960. * Index of the particle in its group id (Internal use)
  65961. */
  65962. idxInGroup: number;
  65963. /**
  65964. * @hidden Particle BoundingInfo object (Internal use)
  65965. */
  65966. _boundingInfo: BoundingInfo;
  65967. /**
  65968. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  65969. */
  65970. _pcs: PointsCloudSystem;
  65971. /**
  65972. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  65973. */
  65974. _stillInvisible: boolean;
  65975. /**
  65976. * @hidden Last computed particle rotation matrix
  65977. */
  65978. _rotationMatrix: number[];
  65979. /**
  65980. * Parent particle Id, if any.
  65981. * Default null.
  65982. */
  65983. parentId: Nullable<number>;
  65984. /**
  65985. * @hidden Internal global position in the PCS.
  65986. */
  65987. _globalPosition: Vector3;
  65988. /**
  65989. * Creates a Point Cloud object.
  65990. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  65991. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  65992. * @param group (PointsGroup) is the group the particle belongs to
  65993. * @param groupId (integer) is the group identifier in the PCS.
  65994. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  65995. * @param pcs defines the PCS it is associated to
  65996. */
  65997. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  65998. /**
  65999. * get point size
  66000. */
  66001. get size(): Vector3;
  66002. /**
  66003. * Set point size
  66004. */
  66005. set size(scale: Vector3);
  66006. /**
  66007. * Legacy support, changed quaternion to rotationQuaternion
  66008. */
  66009. get quaternion(): Nullable<Quaternion>;
  66010. /**
  66011. * Legacy support, changed quaternion to rotationQuaternion
  66012. */
  66013. set quaternion(q: Nullable<Quaternion>);
  66014. /**
  66015. * Returns a boolean. True if the particle intersects a mesh, else false
  66016. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66017. * @param target is the object (point or mesh) what the intersection is computed against
  66018. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66019. * @returns true if it intersects
  66020. */
  66021. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66022. /**
  66023. * get the rotation matrix of the particle
  66024. * @hidden
  66025. */
  66026. getRotationMatrix(m: Matrix): void;
  66027. }
  66028. /**
  66029. * Represents a group of points in a points cloud system
  66030. * * PCS internal tool, don't use it manually.
  66031. */
  66032. export class PointsGroup {
  66033. /**
  66034. * The group id
  66035. * @hidden
  66036. */
  66037. groupID: number;
  66038. /**
  66039. * image data for group (internal use)
  66040. * @hidden
  66041. */
  66042. _groupImageData: Nullable<ArrayBufferView>;
  66043. /**
  66044. * Image Width (internal use)
  66045. * @hidden
  66046. */
  66047. _groupImgWidth: number;
  66048. /**
  66049. * Image Height (internal use)
  66050. * @hidden
  66051. */
  66052. _groupImgHeight: number;
  66053. /**
  66054. * Custom position function (internal use)
  66055. * @hidden
  66056. */
  66057. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66058. /**
  66059. * density per facet for surface points
  66060. * @hidden
  66061. */
  66062. _groupDensity: number[];
  66063. /**
  66064. * Only when points are colored by texture carries pointer to texture list array
  66065. * @hidden
  66066. */
  66067. _textureNb: number;
  66068. /**
  66069. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66070. * PCS internal tool, don't use it manually.
  66071. * @hidden
  66072. */
  66073. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66074. }
  66075. }
  66076. declare module BABYLON {
  66077. interface Scene {
  66078. /** @hidden (Backing field) */
  66079. _physicsEngine: Nullable<IPhysicsEngine>;
  66080. /** @hidden */
  66081. _physicsTimeAccumulator: number;
  66082. /**
  66083. * Gets the current physics engine
  66084. * @returns a IPhysicsEngine or null if none attached
  66085. */
  66086. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66087. /**
  66088. * Enables physics to the current scene
  66089. * @param gravity defines the scene's gravity for the physics engine
  66090. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66091. * @return a boolean indicating if the physics engine was initialized
  66092. */
  66093. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66094. /**
  66095. * Disables and disposes the physics engine associated with the scene
  66096. */
  66097. disablePhysicsEngine(): void;
  66098. /**
  66099. * Gets a boolean indicating if there is an active physics engine
  66100. * @returns a boolean indicating if there is an active physics engine
  66101. */
  66102. isPhysicsEnabled(): boolean;
  66103. /**
  66104. * Deletes a physics compound impostor
  66105. * @param compound defines the compound to delete
  66106. */
  66107. deleteCompoundImpostor(compound: any): void;
  66108. /**
  66109. * An event triggered when physic simulation is about to be run
  66110. */
  66111. onBeforePhysicsObservable: Observable<Scene>;
  66112. /**
  66113. * An event triggered when physic simulation has been done
  66114. */
  66115. onAfterPhysicsObservable: Observable<Scene>;
  66116. }
  66117. interface AbstractMesh {
  66118. /** @hidden */
  66119. _physicsImpostor: Nullable<PhysicsImpostor>;
  66120. /**
  66121. * Gets or sets impostor used for physic simulation
  66122. * @see http://doc.babylonjs.com/features/physics_engine
  66123. */
  66124. physicsImpostor: Nullable<PhysicsImpostor>;
  66125. /**
  66126. * Gets the current physics impostor
  66127. * @see http://doc.babylonjs.com/features/physics_engine
  66128. * @returns a physics impostor or null
  66129. */
  66130. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66131. /** Apply a physic impulse to the mesh
  66132. * @param force defines the force to apply
  66133. * @param contactPoint defines where to apply the force
  66134. * @returns the current mesh
  66135. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66136. */
  66137. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66138. /**
  66139. * Creates a physic joint between two meshes
  66140. * @param otherMesh defines the other mesh to use
  66141. * @param pivot1 defines the pivot to use on this mesh
  66142. * @param pivot2 defines the pivot to use on the other mesh
  66143. * @param options defines additional options (can be plugin dependent)
  66144. * @returns the current mesh
  66145. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66146. */
  66147. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66148. /** @hidden */
  66149. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66150. }
  66151. /**
  66152. * Defines the physics engine scene component responsible to manage a physics engine
  66153. */
  66154. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66155. /**
  66156. * The component name helpful to identify the component in the list of scene components.
  66157. */
  66158. readonly name: string;
  66159. /**
  66160. * The scene the component belongs to.
  66161. */
  66162. scene: Scene;
  66163. /**
  66164. * Creates a new instance of the component for the given scene
  66165. * @param scene Defines the scene to register the component in
  66166. */
  66167. constructor(scene: Scene);
  66168. /**
  66169. * Registers the component in a given scene
  66170. */
  66171. register(): void;
  66172. /**
  66173. * Rebuilds the elements related to this component in case of
  66174. * context lost for instance.
  66175. */
  66176. rebuild(): void;
  66177. /**
  66178. * Disposes the component and the associated ressources
  66179. */
  66180. dispose(): void;
  66181. }
  66182. }
  66183. declare module BABYLON {
  66184. /**
  66185. * A helper for physics simulations
  66186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66187. */
  66188. export class PhysicsHelper {
  66189. private _scene;
  66190. private _physicsEngine;
  66191. /**
  66192. * Initializes the Physics helper
  66193. * @param scene Babylon.js scene
  66194. */
  66195. constructor(scene: Scene);
  66196. /**
  66197. * Applies a radial explosion impulse
  66198. * @param origin the origin of the explosion
  66199. * @param radiusOrEventOptions the radius or the options of radial explosion
  66200. * @param strength the explosion strength
  66201. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66202. * @returns A physics radial explosion event, or null
  66203. */
  66204. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66205. /**
  66206. * Applies a radial explosion force
  66207. * @param origin the origin of the explosion
  66208. * @param radiusOrEventOptions the radius or the options of radial explosion
  66209. * @param strength the explosion strength
  66210. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66211. * @returns A physics radial explosion event, or null
  66212. */
  66213. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66214. /**
  66215. * Creates a gravitational field
  66216. * @param origin the origin of the explosion
  66217. * @param radiusOrEventOptions the radius or the options of radial explosion
  66218. * @param strength the explosion strength
  66219. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66220. * @returns A physics gravitational field event, or null
  66221. */
  66222. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66223. /**
  66224. * Creates a physics updraft event
  66225. * @param origin the origin of the updraft
  66226. * @param radiusOrEventOptions the radius or the options of the updraft
  66227. * @param strength the strength of the updraft
  66228. * @param height the height of the updraft
  66229. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66230. * @returns A physics updraft event, or null
  66231. */
  66232. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66233. /**
  66234. * Creates a physics vortex event
  66235. * @param origin the of the vortex
  66236. * @param radiusOrEventOptions the radius or the options of the vortex
  66237. * @param strength the strength of the vortex
  66238. * @param height the height of the vortex
  66239. * @returns a Physics vortex event, or null
  66240. * A physics vortex event or null
  66241. */
  66242. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66243. }
  66244. /**
  66245. * Represents a physics radial explosion event
  66246. */
  66247. class PhysicsRadialExplosionEvent {
  66248. private _scene;
  66249. private _options;
  66250. private _sphere;
  66251. private _dataFetched;
  66252. /**
  66253. * Initializes a radial explosioin event
  66254. * @param _scene BabylonJS scene
  66255. * @param _options The options for the vortex event
  66256. */
  66257. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66258. /**
  66259. * Returns the data related to the radial explosion event (sphere).
  66260. * @returns The radial explosion event data
  66261. */
  66262. getData(): PhysicsRadialExplosionEventData;
  66263. /**
  66264. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66265. * @param impostor A physics imposter
  66266. * @param origin the origin of the explosion
  66267. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66268. */
  66269. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66270. /**
  66271. * Triggers affecterd impostors callbacks
  66272. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66273. */
  66274. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66275. /**
  66276. * Disposes the sphere.
  66277. * @param force Specifies if the sphere should be disposed by force
  66278. */
  66279. dispose(force?: boolean): void;
  66280. /*** Helpers ***/
  66281. private _prepareSphere;
  66282. private _intersectsWithSphere;
  66283. }
  66284. /**
  66285. * Represents a gravitational field event
  66286. */
  66287. class PhysicsGravitationalFieldEvent {
  66288. private _physicsHelper;
  66289. private _scene;
  66290. private _origin;
  66291. private _options;
  66292. private _tickCallback;
  66293. private _sphere;
  66294. private _dataFetched;
  66295. /**
  66296. * Initializes the physics gravitational field event
  66297. * @param _physicsHelper A physics helper
  66298. * @param _scene BabylonJS scene
  66299. * @param _origin The origin position of the gravitational field event
  66300. * @param _options The options for the vortex event
  66301. */
  66302. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66303. /**
  66304. * Returns the data related to the gravitational field event (sphere).
  66305. * @returns A gravitational field event
  66306. */
  66307. getData(): PhysicsGravitationalFieldEventData;
  66308. /**
  66309. * Enables the gravitational field.
  66310. */
  66311. enable(): void;
  66312. /**
  66313. * Disables the gravitational field.
  66314. */
  66315. disable(): void;
  66316. /**
  66317. * Disposes the sphere.
  66318. * @param force The force to dispose from the gravitational field event
  66319. */
  66320. dispose(force?: boolean): void;
  66321. private _tick;
  66322. }
  66323. /**
  66324. * Represents a physics updraft event
  66325. */
  66326. class PhysicsUpdraftEvent {
  66327. private _scene;
  66328. private _origin;
  66329. private _options;
  66330. private _physicsEngine;
  66331. private _originTop;
  66332. private _originDirection;
  66333. private _tickCallback;
  66334. private _cylinder;
  66335. private _cylinderPosition;
  66336. private _dataFetched;
  66337. /**
  66338. * Initializes the physics updraft event
  66339. * @param _scene BabylonJS scene
  66340. * @param _origin The origin position of the updraft
  66341. * @param _options The options for the updraft event
  66342. */
  66343. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66344. /**
  66345. * Returns the data related to the updraft event (cylinder).
  66346. * @returns A physics updraft event
  66347. */
  66348. getData(): PhysicsUpdraftEventData;
  66349. /**
  66350. * Enables the updraft.
  66351. */
  66352. enable(): void;
  66353. /**
  66354. * Disables the updraft.
  66355. */
  66356. disable(): void;
  66357. /**
  66358. * Disposes the cylinder.
  66359. * @param force Specifies if the updraft should be disposed by force
  66360. */
  66361. dispose(force?: boolean): void;
  66362. private getImpostorHitData;
  66363. private _tick;
  66364. /*** Helpers ***/
  66365. private _prepareCylinder;
  66366. private _intersectsWithCylinder;
  66367. }
  66368. /**
  66369. * Represents a physics vortex event
  66370. */
  66371. class PhysicsVortexEvent {
  66372. private _scene;
  66373. private _origin;
  66374. private _options;
  66375. private _physicsEngine;
  66376. private _originTop;
  66377. private _tickCallback;
  66378. private _cylinder;
  66379. private _cylinderPosition;
  66380. private _dataFetched;
  66381. /**
  66382. * Initializes the physics vortex event
  66383. * @param _scene The BabylonJS scene
  66384. * @param _origin The origin position of the vortex
  66385. * @param _options The options for the vortex event
  66386. */
  66387. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66388. /**
  66389. * Returns the data related to the vortex event (cylinder).
  66390. * @returns The physics vortex event data
  66391. */
  66392. getData(): PhysicsVortexEventData;
  66393. /**
  66394. * Enables the vortex.
  66395. */
  66396. enable(): void;
  66397. /**
  66398. * Disables the cortex.
  66399. */
  66400. disable(): void;
  66401. /**
  66402. * Disposes the sphere.
  66403. * @param force
  66404. */
  66405. dispose(force?: boolean): void;
  66406. private getImpostorHitData;
  66407. private _tick;
  66408. /*** Helpers ***/
  66409. private _prepareCylinder;
  66410. private _intersectsWithCylinder;
  66411. }
  66412. /**
  66413. * Options fot the radial explosion event
  66414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66415. */
  66416. export class PhysicsRadialExplosionEventOptions {
  66417. /**
  66418. * The radius of the sphere for the radial explosion.
  66419. */
  66420. radius: number;
  66421. /**
  66422. * The strenth of the explosion.
  66423. */
  66424. strength: number;
  66425. /**
  66426. * The strenght of the force in correspondence to the distance of the affected object
  66427. */
  66428. falloff: PhysicsRadialImpulseFalloff;
  66429. /**
  66430. * Sphere options for the radial explosion.
  66431. */
  66432. sphere: {
  66433. segments: number;
  66434. diameter: number;
  66435. };
  66436. /**
  66437. * Sphere options for the radial explosion.
  66438. */
  66439. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66440. }
  66441. /**
  66442. * Options fot the updraft event
  66443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66444. */
  66445. export class PhysicsUpdraftEventOptions {
  66446. /**
  66447. * The radius of the cylinder for the vortex
  66448. */
  66449. radius: number;
  66450. /**
  66451. * The strenth of the updraft.
  66452. */
  66453. strength: number;
  66454. /**
  66455. * The height of the cylinder for the updraft.
  66456. */
  66457. height: number;
  66458. /**
  66459. * The mode for the the updraft.
  66460. */
  66461. updraftMode: PhysicsUpdraftMode;
  66462. }
  66463. /**
  66464. * Options fot the vortex event
  66465. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66466. */
  66467. export class PhysicsVortexEventOptions {
  66468. /**
  66469. * The radius of the cylinder for the vortex
  66470. */
  66471. radius: number;
  66472. /**
  66473. * The strenth of the vortex.
  66474. */
  66475. strength: number;
  66476. /**
  66477. * The height of the cylinder for the vortex.
  66478. */
  66479. height: number;
  66480. /**
  66481. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66482. */
  66483. centripetalForceThreshold: number;
  66484. /**
  66485. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66486. */
  66487. centripetalForceMultiplier: number;
  66488. /**
  66489. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66490. */
  66491. centrifugalForceMultiplier: number;
  66492. /**
  66493. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66494. */
  66495. updraftForceMultiplier: number;
  66496. }
  66497. /**
  66498. * The strenght of the force in correspondence to the distance of the affected object
  66499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66500. */
  66501. export enum PhysicsRadialImpulseFalloff {
  66502. /** Defines that impulse is constant in strength across it's whole radius */
  66503. Constant = 0,
  66504. /** Defines that impulse gets weaker if it's further from the origin */
  66505. Linear = 1
  66506. }
  66507. /**
  66508. * The strength of the force in correspondence to the distance of the affected object
  66509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66510. */
  66511. export enum PhysicsUpdraftMode {
  66512. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66513. Center = 0,
  66514. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66515. Perpendicular = 1
  66516. }
  66517. /**
  66518. * Interface for a physics hit data
  66519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66520. */
  66521. export interface PhysicsHitData {
  66522. /**
  66523. * The force applied at the contact point
  66524. */
  66525. force: Vector3;
  66526. /**
  66527. * The contact point
  66528. */
  66529. contactPoint: Vector3;
  66530. /**
  66531. * The distance from the origin to the contact point
  66532. */
  66533. distanceFromOrigin: number;
  66534. }
  66535. /**
  66536. * Interface for radial explosion event data
  66537. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66538. */
  66539. export interface PhysicsRadialExplosionEventData {
  66540. /**
  66541. * A sphere used for the radial explosion event
  66542. */
  66543. sphere: Mesh;
  66544. }
  66545. /**
  66546. * Interface for gravitational field event data
  66547. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66548. */
  66549. export interface PhysicsGravitationalFieldEventData {
  66550. /**
  66551. * A sphere mesh used for the gravitational field event
  66552. */
  66553. sphere: Mesh;
  66554. }
  66555. /**
  66556. * Interface for updraft event data
  66557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66558. */
  66559. export interface PhysicsUpdraftEventData {
  66560. /**
  66561. * A cylinder used for the updraft event
  66562. */
  66563. cylinder: Mesh;
  66564. }
  66565. /**
  66566. * Interface for vortex event data
  66567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66568. */
  66569. export interface PhysicsVortexEventData {
  66570. /**
  66571. * A cylinder used for the vortex event
  66572. */
  66573. cylinder: Mesh;
  66574. }
  66575. /**
  66576. * Interface for an affected physics impostor
  66577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66578. */
  66579. export interface PhysicsAffectedImpostorWithData {
  66580. /**
  66581. * The impostor affected by the effect
  66582. */
  66583. impostor: PhysicsImpostor;
  66584. /**
  66585. * The data about the hit/horce from the explosion
  66586. */
  66587. hitData: PhysicsHitData;
  66588. }
  66589. }
  66590. declare module BABYLON {
  66591. /** @hidden */
  66592. export var blackAndWhitePixelShader: {
  66593. name: string;
  66594. shader: string;
  66595. };
  66596. }
  66597. declare module BABYLON {
  66598. /**
  66599. * Post process used to render in black and white
  66600. */
  66601. export class BlackAndWhitePostProcess extends PostProcess {
  66602. /**
  66603. * Linear about to convert he result to black and white (default: 1)
  66604. */
  66605. degree: number;
  66606. /**
  66607. * Creates a black and white post process
  66608. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  66609. * @param name The name of the effect.
  66610. * @param options The required width/height ratio to downsize to before computing the render pass.
  66611. * @param camera The camera to apply the render pass to.
  66612. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66613. * @param engine The engine which the post process will be applied. (default: current engine)
  66614. * @param reusable If the post process can be reused on the same frame. (default: false)
  66615. */
  66616. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66617. }
  66618. }
  66619. declare module BABYLON {
  66620. /**
  66621. * This represents a set of one or more post processes in Babylon.
  66622. * A post process can be used to apply a shader to a texture after it is rendered.
  66623. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66624. */
  66625. export class PostProcessRenderEffect {
  66626. private _postProcesses;
  66627. private _getPostProcesses;
  66628. private _singleInstance;
  66629. private _cameras;
  66630. private _indicesForCamera;
  66631. /**
  66632. * Name of the effect
  66633. * @hidden
  66634. */
  66635. _name: string;
  66636. /**
  66637. * Instantiates a post process render effect.
  66638. * A post process can be used to apply a shader to a texture after it is rendered.
  66639. * @param engine The engine the effect is tied to
  66640. * @param name The name of the effect
  66641. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  66642. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  66643. */
  66644. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  66645. /**
  66646. * Checks if all the post processes in the effect are supported.
  66647. */
  66648. get isSupported(): boolean;
  66649. /**
  66650. * Updates the current state of the effect
  66651. * @hidden
  66652. */
  66653. _update(): void;
  66654. /**
  66655. * Attaches the effect on cameras
  66656. * @param cameras The camera to attach to.
  66657. * @hidden
  66658. */
  66659. _attachCameras(cameras: Camera): void;
  66660. /**
  66661. * Attaches the effect on cameras
  66662. * @param cameras The camera to attach to.
  66663. * @hidden
  66664. */
  66665. _attachCameras(cameras: Camera[]): void;
  66666. /**
  66667. * Detaches the effect on cameras
  66668. * @param cameras The camera to detatch from.
  66669. * @hidden
  66670. */
  66671. _detachCameras(cameras: Camera): void;
  66672. /**
  66673. * Detatches the effect on cameras
  66674. * @param cameras The camera to detatch from.
  66675. * @hidden
  66676. */
  66677. _detachCameras(cameras: Camera[]): void;
  66678. /**
  66679. * Enables the effect on given cameras
  66680. * @param cameras The camera to enable.
  66681. * @hidden
  66682. */
  66683. _enable(cameras: Camera): void;
  66684. /**
  66685. * Enables the effect on given cameras
  66686. * @param cameras The camera to enable.
  66687. * @hidden
  66688. */
  66689. _enable(cameras: Nullable<Camera[]>): void;
  66690. /**
  66691. * Disables the effect on the given cameras
  66692. * @param cameras The camera to disable.
  66693. * @hidden
  66694. */
  66695. _disable(cameras: Camera): void;
  66696. /**
  66697. * Disables the effect on the given cameras
  66698. * @param cameras The camera to disable.
  66699. * @hidden
  66700. */
  66701. _disable(cameras: Nullable<Camera[]>): void;
  66702. /**
  66703. * Gets a list of the post processes contained in the effect.
  66704. * @param camera The camera to get the post processes on.
  66705. * @returns The list of the post processes in the effect.
  66706. */
  66707. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  66708. }
  66709. }
  66710. declare module BABYLON {
  66711. /** @hidden */
  66712. export var extractHighlightsPixelShader: {
  66713. name: string;
  66714. shader: string;
  66715. };
  66716. }
  66717. declare module BABYLON {
  66718. /**
  66719. * 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.
  66720. */
  66721. export class ExtractHighlightsPostProcess extends PostProcess {
  66722. /**
  66723. * The luminance threshold, pixels below this value will be set to black.
  66724. */
  66725. threshold: number;
  66726. /** @hidden */
  66727. _exposure: number;
  66728. /**
  66729. * Post process which has the input texture to be used when performing highlight extraction
  66730. * @hidden
  66731. */
  66732. _inputPostProcess: Nullable<PostProcess>;
  66733. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66734. }
  66735. }
  66736. declare module BABYLON {
  66737. /** @hidden */
  66738. export var bloomMergePixelShader: {
  66739. name: string;
  66740. shader: string;
  66741. };
  66742. }
  66743. declare module BABYLON {
  66744. /**
  66745. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  66746. */
  66747. export class BloomMergePostProcess extends PostProcess {
  66748. /** Weight of the bloom to be added to the original input. */
  66749. weight: number;
  66750. /**
  66751. * Creates a new instance of @see BloomMergePostProcess
  66752. * @param name The name of the effect.
  66753. * @param originalFromInput Post process which's input will be used for the merge.
  66754. * @param blurred Blurred highlights post process which's output will be used.
  66755. * @param weight Weight of the bloom to be added to the original input.
  66756. * @param options The required width/height ratio to downsize to before computing the render pass.
  66757. * @param camera The camera to apply the render pass to.
  66758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66759. * @param engine The engine which the post process will be applied. (default: current engine)
  66760. * @param reusable If the post process can be reused on the same frame. (default: false)
  66761. * @param textureType Type of textures used when performing the post process. (default: 0)
  66762. * @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)
  66763. */
  66764. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  66765. /** Weight of the bloom to be added to the original input. */
  66766. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66767. }
  66768. }
  66769. declare module BABYLON {
  66770. /**
  66771. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  66772. */
  66773. export class BloomEffect extends PostProcessRenderEffect {
  66774. private bloomScale;
  66775. /**
  66776. * @hidden Internal
  66777. */
  66778. _effects: Array<PostProcess>;
  66779. /**
  66780. * @hidden Internal
  66781. */
  66782. _downscale: ExtractHighlightsPostProcess;
  66783. private _blurX;
  66784. private _blurY;
  66785. private _merge;
  66786. /**
  66787. * The luminance threshold to find bright areas of the image to bloom.
  66788. */
  66789. get threshold(): number;
  66790. set threshold(value: number);
  66791. /**
  66792. * The strength of the bloom.
  66793. */
  66794. get weight(): number;
  66795. set weight(value: number);
  66796. /**
  66797. * Specifies the size of the bloom blur kernel, relative to the final output size
  66798. */
  66799. get kernel(): number;
  66800. set kernel(value: number);
  66801. /**
  66802. * Creates a new instance of @see BloomEffect
  66803. * @param scene The scene the effect belongs to.
  66804. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  66805. * @param bloomKernel The size of the kernel to be used when applying the blur.
  66806. * @param bloomWeight The the strength of bloom.
  66807. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  66808. * @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)
  66809. */
  66810. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  66811. /**
  66812. * Disposes each of the internal effects for a given camera.
  66813. * @param camera The camera to dispose the effect on.
  66814. */
  66815. disposeEffects(camera: Camera): void;
  66816. /**
  66817. * @hidden Internal
  66818. */
  66819. _updateEffects(): void;
  66820. /**
  66821. * Internal
  66822. * @returns if all the contained post processes are ready.
  66823. * @hidden
  66824. */
  66825. _isReady(): boolean;
  66826. }
  66827. }
  66828. declare module BABYLON {
  66829. /** @hidden */
  66830. export var chromaticAberrationPixelShader: {
  66831. name: string;
  66832. shader: string;
  66833. };
  66834. }
  66835. declare module BABYLON {
  66836. /**
  66837. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  66838. */
  66839. export class ChromaticAberrationPostProcess extends PostProcess {
  66840. /**
  66841. * The amount of seperation of rgb channels (default: 30)
  66842. */
  66843. aberrationAmount: number;
  66844. /**
  66845. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  66846. */
  66847. radialIntensity: number;
  66848. /**
  66849. * 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))
  66850. */
  66851. direction: Vector2;
  66852. /**
  66853. * 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))
  66854. */
  66855. centerPosition: Vector2;
  66856. /**
  66857. * Creates a new instance ChromaticAberrationPostProcess
  66858. * @param name The name of the effect.
  66859. * @param screenWidth The width of the screen to apply the effect on.
  66860. * @param screenHeight The height of the screen to apply the effect on.
  66861. * @param options The required width/height ratio to downsize to before computing the render pass.
  66862. * @param camera The camera to apply the render pass to.
  66863. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66864. * @param engine The engine which the post process will be applied. (default: current engine)
  66865. * @param reusable If the post process can be reused on the same frame. (default: false)
  66866. * @param textureType Type of textures used when performing the post process. (default: 0)
  66867. * @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)
  66868. */
  66869. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66870. }
  66871. }
  66872. declare module BABYLON {
  66873. /** @hidden */
  66874. export var circleOfConfusionPixelShader: {
  66875. name: string;
  66876. shader: string;
  66877. };
  66878. }
  66879. declare module BABYLON {
  66880. /**
  66881. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  66882. */
  66883. export class CircleOfConfusionPostProcess extends PostProcess {
  66884. /**
  66885. * 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.
  66886. */
  66887. lensSize: number;
  66888. /**
  66889. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  66890. */
  66891. fStop: number;
  66892. /**
  66893. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  66894. */
  66895. focusDistance: number;
  66896. /**
  66897. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  66898. */
  66899. focalLength: number;
  66900. private _depthTexture;
  66901. /**
  66902. * Creates a new instance CircleOfConfusionPostProcess
  66903. * @param name The name of the effect.
  66904. * @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.
  66905. * @param options The required width/height ratio to downsize to before computing the render pass.
  66906. * @param camera The camera to apply the render pass to.
  66907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66908. * @param engine The engine which the post process will be applied. (default: current engine)
  66909. * @param reusable If the post process can be reused on the same frame. (default: false)
  66910. * @param textureType Type of textures used when performing the post process. (default: 0)
  66911. * @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)
  66912. */
  66913. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66914. /**
  66915. * 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.
  66916. */
  66917. set depthTexture(value: RenderTargetTexture);
  66918. }
  66919. }
  66920. declare module BABYLON {
  66921. /** @hidden */
  66922. export var colorCorrectionPixelShader: {
  66923. name: string;
  66924. shader: string;
  66925. };
  66926. }
  66927. declare module BABYLON {
  66928. /**
  66929. *
  66930. * This post-process allows the modification of rendered colors by using
  66931. * a 'look-up table' (LUT). This effect is also called Color Grading.
  66932. *
  66933. * The object needs to be provided an url to a texture containing the color
  66934. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  66935. * Use an image editing software to tweak the LUT to match your needs.
  66936. *
  66937. * For an example of a color LUT, see here:
  66938. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  66939. * For explanations on color grading, see here:
  66940. * @see http://udn.epicgames.com/Three/ColorGrading.html
  66941. *
  66942. */
  66943. export class ColorCorrectionPostProcess extends PostProcess {
  66944. private _colorTableTexture;
  66945. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66946. }
  66947. }
  66948. declare module BABYLON {
  66949. /** @hidden */
  66950. export var convolutionPixelShader: {
  66951. name: string;
  66952. shader: string;
  66953. };
  66954. }
  66955. declare module BABYLON {
  66956. /**
  66957. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  66958. * input texture to perform effects such as edge detection or sharpening
  66959. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  66960. */
  66961. export class ConvolutionPostProcess extends PostProcess {
  66962. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  66963. kernel: number[];
  66964. /**
  66965. * Creates a new instance ConvolutionPostProcess
  66966. * @param name The name of the effect.
  66967. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  66968. * @param options The required width/height ratio to downsize to before computing the render pass.
  66969. * @param camera The camera to apply the render pass to.
  66970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66971. * @param engine The engine which the post process will be applied. (default: current engine)
  66972. * @param reusable If the post process can be reused on the same frame. (default: false)
  66973. * @param textureType Type of textures used when performing the post process. (default: 0)
  66974. */
  66975. constructor(name: string,
  66976. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  66977. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66978. /**
  66979. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66980. */
  66981. static EdgeDetect0Kernel: number[];
  66982. /**
  66983. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66984. */
  66985. static EdgeDetect1Kernel: number[];
  66986. /**
  66987. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66988. */
  66989. static EdgeDetect2Kernel: number[];
  66990. /**
  66991. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66992. */
  66993. static SharpenKernel: number[];
  66994. /**
  66995. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66996. */
  66997. static EmbossKernel: number[];
  66998. /**
  66999. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67000. */
  67001. static GaussianKernel: number[];
  67002. }
  67003. }
  67004. declare module BABYLON {
  67005. /**
  67006. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67007. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67008. * based on samples that have a large difference in distance than the center pixel.
  67009. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67010. */
  67011. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67012. direction: Vector2;
  67013. /**
  67014. * Creates a new instance CircleOfConfusionPostProcess
  67015. * @param name The name of the effect.
  67016. * @param scene The scene the effect belongs to.
  67017. * @param direction The direction the blur should be applied.
  67018. * @param kernel The size of the kernel used to blur.
  67019. * @param options The required width/height ratio to downsize to before computing the render pass.
  67020. * @param camera The camera to apply the render pass to.
  67021. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67022. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67024. * @param engine The engine which the post process will be applied. (default: current engine)
  67025. * @param reusable If the post process can be reused on the same frame. (default: false)
  67026. * @param textureType Type of textures used when performing the post process. (default: 0)
  67027. * @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)
  67028. */
  67029. 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);
  67030. }
  67031. }
  67032. declare module BABYLON {
  67033. /** @hidden */
  67034. export var depthOfFieldMergePixelShader: {
  67035. name: string;
  67036. shader: string;
  67037. };
  67038. }
  67039. declare module BABYLON {
  67040. /**
  67041. * Options to be set when merging outputs from the default pipeline.
  67042. */
  67043. export class DepthOfFieldMergePostProcessOptions {
  67044. /**
  67045. * The original image to merge on top of
  67046. */
  67047. originalFromInput: PostProcess;
  67048. /**
  67049. * Parameters to perform the merge of the depth of field effect
  67050. */
  67051. depthOfField?: {
  67052. circleOfConfusion: PostProcess;
  67053. blurSteps: Array<PostProcess>;
  67054. };
  67055. /**
  67056. * Parameters to perform the merge of bloom effect
  67057. */
  67058. bloom?: {
  67059. blurred: PostProcess;
  67060. weight: number;
  67061. };
  67062. }
  67063. /**
  67064. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67065. */
  67066. export class DepthOfFieldMergePostProcess extends PostProcess {
  67067. private blurSteps;
  67068. /**
  67069. * Creates a new instance of DepthOfFieldMergePostProcess
  67070. * @param name The name of the effect.
  67071. * @param originalFromInput Post process which's input will be used for the merge.
  67072. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67073. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67074. * @param options The required width/height ratio to downsize to before computing the render pass.
  67075. * @param camera The camera to apply the render pass to.
  67076. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67077. * @param engine The engine which the post process will be applied. (default: current engine)
  67078. * @param reusable If the post process can be reused on the same frame. (default: false)
  67079. * @param textureType Type of textures used when performing the post process. (default: 0)
  67080. * @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)
  67081. */
  67082. 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);
  67083. /**
  67084. * Updates the effect with the current post process compile time values and recompiles the shader.
  67085. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67086. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67087. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67088. * @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
  67089. * @param onCompiled Called when the shader has been compiled.
  67090. * @param onError Called if there is an error when compiling a shader.
  67091. */
  67092. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67093. }
  67094. }
  67095. declare module BABYLON {
  67096. /**
  67097. * Specifies the level of max blur that should be applied when using the depth of field effect
  67098. */
  67099. export enum DepthOfFieldEffectBlurLevel {
  67100. /**
  67101. * Subtle blur
  67102. */
  67103. Low = 0,
  67104. /**
  67105. * Medium blur
  67106. */
  67107. Medium = 1,
  67108. /**
  67109. * Large blur
  67110. */
  67111. High = 2
  67112. }
  67113. /**
  67114. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67115. */
  67116. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67117. private _circleOfConfusion;
  67118. /**
  67119. * @hidden Internal, blurs from high to low
  67120. */
  67121. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67122. private _depthOfFieldBlurY;
  67123. private _dofMerge;
  67124. /**
  67125. * @hidden Internal post processes in depth of field effect
  67126. */
  67127. _effects: Array<PostProcess>;
  67128. /**
  67129. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67130. */
  67131. set focalLength(value: number);
  67132. get focalLength(): number;
  67133. /**
  67134. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67135. */
  67136. set fStop(value: number);
  67137. get fStop(): number;
  67138. /**
  67139. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67140. */
  67141. set focusDistance(value: number);
  67142. get focusDistance(): number;
  67143. /**
  67144. * 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.
  67145. */
  67146. set lensSize(value: number);
  67147. get lensSize(): number;
  67148. /**
  67149. * Creates a new instance DepthOfFieldEffect
  67150. * @param scene The scene the effect belongs to.
  67151. * @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.
  67152. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67153. * @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)
  67154. */
  67155. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67156. /**
  67157. * Get the current class name of the current effet
  67158. * @returns "DepthOfFieldEffect"
  67159. */
  67160. getClassName(): string;
  67161. /**
  67162. * 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.
  67163. */
  67164. set depthTexture(value: RenderTargetTexture);
  67165. /**
  67166. * Disposes each of the internal effects for a given camera.
  67167. * @param camera The camera to dispose the effect on.
  67168. */
  67169. disposeEffects(camera: Camera): void;
  67170. /**
  67171. * @hidden Internal
  67172. */
  67173. _updateEffects(): void;
  67174. /**
  67175. * Internal
  67176. * @returns if all the contained post processes are ready.
  67177. * @hidden
  67178. */
  67179. _isReady(): boolean;
  67180. }
  67181. }
  67182. declare module BABYLON {
  67183. /** @hidden */
  67184. export var displayPassPixelShader: {
  67185. name: string;
  67186. shader: string;
  67187. };
  67188. }
  67189. declare module BABYLON {
  67190. /**
  67191. * DisplayPassPostProcess which produces an output the same as it's input
  67192. */
  67193. export class DisplayPassPostProcess extends PostProcess {
  67194. /**
  67195. * Creates the DisplayPassPostProcess
  67196. * @param name The name of the effect.
  67197. * @param options The required width/height ratio to downsize to before computing the render pass.
  67198. * @param camera The camera to apply the render pass to.
  67199. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67200. * @param engine The engine which the post process will be applied. (default: current engine)
  67201. * @param reusable If the post process can be reused on the same frame. (default: false)
  67202. */
  67203. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67204. }
  67205. }
  67206. declare module BABYLON {
  67207. /** @hidden */
  67208. export var filterPixelShader: {
  67209. name: string;
  67210. shader: string;
  67211. };
  67212. }
  67213. declare module BABYLON {
  67214. /**
  67215. * Applies a kernel filter to the image
  67216. */
  67217. export class FilterPostProcess extends PostProcess {
  67218. /** The matrix to be applied to the image */
  67219. kernelMatrix: Matrix;
  67220. /**
  67221. *
  67222. * @param name The name of the effect.
  67223. * @param kernelMatrix The matrix to be applied to the image
  67224. * @param options The required width/height ratio to downsize to before computing the render pass.
  67225. * @param camera The camera to apply the render pass to.
  67226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67227. * @param engine The engine which the post process will be applied. (default: current engine)
  67228. * @param reusable If the post process can be reused on the same frame. (default: false)
  67229. */
  67230. constructor(name: string,
  67231. /** The matrix to be applied to the image */
  67232. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67233. }
  67234. }
  67235. declare module BABYLON {
  67236. /** @hidden */
  67237. export var fxaaPixelShader: {
  67238. name: string;
  67239. shader: string;
  67240. };
  67241. }
  67242. declare module BABYLON {
  67243. /** @hidden */
  67244. export var fxaaVertexShader: {
  67245. name: string;
  67246. shader: string;
  67247. };
  67248. }
  67249. declare module BABYLON {
  67250. /**
  67251. * Fxaa post process
  67252. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67253. */
  67254. export class FxaaPostProcess extends PostProcess {
  67255. /** @hidden */
  67256. texelWidth: number;
  67257. /** @hidden */
  67258. texelHeight: number;
  67259. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67260. private _getDefines;
  67261. }
  67262. }
  67263. declare module BABYLON {
  67264. /** @hidden */
  67265. export var grainPixelShader: {
  67266. name: string;
  67267. shader: string;
  67268. };
  67269. }
  67270. declare module BABYLON {
  67271. /**
  67272. * The GrainPostProcess adds noise to the image at mid luminance levels
  67273. */
  67274. export class GrainPostProcess extends PostProcess {
  67275. /**
  67276. * The intensity of the grain added (default: 30)
  67277. */
  67278. intensity: number;
  67279. /**
  67280. * If the grain should be randomized on every frame
  67281. */
  67282. animated: boolean;
  67283. /**
  67284. * Creates a new instance of @see GrainPostProcess
  67285. * @param name The name of the effect.
  67286. * @param options The required width/height ratio to downsize to before computing the render pass.
  67287. * @param camera The camera to apply the render pass to.
  67288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67289. * @param engine The engine which the post process will be applied. (default: current engine)
  67290. * @param reusable If the post process can be reused on the same frame. (default: false)
  67291. * @param textureType Type of textures used when performing the post process. (default: 0)
  67292. * @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)
  67293. */
  67294. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67295. }
  67296. }
  67297. declare module BABYLON {
  67298. /** @hidden */
  67299. export var highlightsPixelShader: {
  67300. name: string;
  67301. shader: string;
  67302. };
  67303. }
  67304. declare module BABYLON {
  67305. /**
  67306. * Extracts highlights from the image
  67307. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67308. */
  67309. export class HighlightsPostProcess extends PostProcess {
  67310. /**
  67311. * Extracts highlights from the image
  67312. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67313. * @param name The name of the effect.
  67314. * @param options The required width/height ratio to downsize to before computing the render pass.
  67315. * @param camera The camera to apply the render pass to.
  67316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67317. * @param engine The engine which the post process will be applied. (default: current engine)
  67318. * @param reusable If the post process can be reused on the same frame. (default: false)
  67319. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67320. */
  67321. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67322. }
  67323. }
  67324. declare module BABYLON {
  67325. /** @hidden */
  67326. export var mrtFragmentDeclaration: {
  67327. name: string;
  67328. shader: string;
  67329. };
  67330. }
  67331. declare module BABYLON {
  67332. /** @hidden */
  67333. export var geometryPixelShader: {
  67334. name: string;
  67335. shader: string;
  67336. };
  67337. }
  67338. declare module BABYLON {
  67339. /** @hidden */
  67340. export var geometryVertexShader: {
  67341. name: string;
  67342. shader: string;
  67343. };
  67344. }
  67345. declare module BABYLON {
  67346. /** @hidden */
  67347. interface ISavedTransformationMatrix {
  67348. world: Matrix;
  67349. viewProjection: Matrix;
  67350. }
  67351. /**
  67352. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67353. */
  67354. export class GeometryBufferRenderer {
  67355. /**
  67356. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67357. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67358. */
  67359. static readonly POSITION_TEXTURE_TYPE: number;
  67360. /**
  67361. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67362. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67363. */
  67364. static readonly VELOCITY_TEXTURE_TYPE: number;
  67365. /**
  67366. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67367. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67368. */
  67369. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67370. /**
  67371. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67372. * in order to compute objects velocities when enableVelocity is set to "true"
  67373. * @hidden
  67374. */
  67375. _previousTransformationMatrices: {
  67376. [index: number]: ISavedTransformationMatrix;
  67377. };
  67378. /**
  67379. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67380. * in order to compute objects velocities when enableVelocity is set to "true"
  67381. * @hidden
  67382. */
  67383. _previousBonesTransformationMatrices: {
  67384. [index: number]: Float32Array;
  67385. };
  67386. /**
  67387. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67388. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67389. */
  67390. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67391. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67392. renderTransparentMeshes: boolean;
  67393. private _scene;
  67394. private _multiRenderTarget;
  67395. private _ratio;
  67396. private _enablePosition;
  67397. private _enableVelocity;
  67398. private _enableReflectivity;
  67399. private _positionIndex;
  67400. private _velocityIndex;
  67401. private _reflectivityIndex;
  67402. protected _effect: Effect;
  67403. protected _cachedDefines: string;
  67404. /**
  67405. * Set the render list (meshes to be rendered) used in the G buffer.
  67406. */
  67407. set renderList(meshes: Mesh[]);
  67408. /**
  67409. * Gets wether or not G buffer are supported by the running hardware.
  67410. * This requires draw buffer supports
  67411. */
  67412. get isSupported(): boolean;
  67413. /**
  67414. * Returns the index of the given texture type in the G-Buffer textures array
  67415. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  67416. * @returns the index of the given texture type in the G-Buffer textures array
  67417. */
  67418. getTextureIndex(textureType: number): number;
  67419. /**
  67420. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  67421. */
  67422. get enablePosition(): boolean;
  67423. /**
  67424. * Sets whether or not objects positions are enabled for the G buffer.
  67425. */
  67426. set enablePosition(enable: boolean);
  67427. /**
  67428. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  67429. */
  67430. get enableVelocity(): boolean;
  67431. /**
  67432. * Sets wether or not objects velocities are enabled for the G buffer.
  67433. */
  67434. set enableVelocity(enable: boolean);
  67435. /**
  67436. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  67437. */
  67438. get enableReflectivity(): boolean;
  67439. /**
  67440. * Sets wether or not objects roughness are enabled for the G buffer.
  67441. */
  67442. set enableReflectivity(enable: boolean);
  67443. /**
  67444. * Gets the scene associated with the buffer.
  67445. */
  67446. get scene(): Scene;
  67447. /**
  67448. * Gets the ratio used by the buffer during its creation.
  67449. * How big is the buffer related to the main canvas.
  67450. */
  67451. get ratio(): number;
  67452. /** @hidden */
  67453. static _SceneComponentInitialization: (scene: Scene) => void;
  67454. /**
  67455. * Creates a new G Buffer for the scene
  67456. * @param scene The scene the buffer belongs to
  67457. * @param ratio How big is the buffer related to the main canvas.
  67458. */
  67459. constructor(scene: Scene, ratio?: number);
  67460. /**
  67461. * Checks wether everything is ready to render a submesh to the G buffer.
  67462. * @param subMesh the submesh to check readiness for
  67463. * @param useInstances is the mesh drawn using instance or not
  67464. * @returns true if ready otherwise false
  67465. */
  67466. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67467. /**
  67468. * Gets the current underlying G Buffer.
  67469. * @returns the buffer
  67470. */
  67471. getGBuffer(): MultiRenderTarget;
  67472. /**
  67473. * Gets the number of samples used to render the buffer (anti aliasing).
  67474. */
  67475. get samples(): number;
  67476. /**
  67477. * Sets the number of samples used to render the buffer (anti aliasing).
  67478. */
  67479. set samples(value: number);
  67480. /**
  67481. * Disposes the renderer and frees up associated resources.
  67482. */
  67483. dispose(): void;
  67484. protected _createRenderTargets(): void;
  67485. private _copyBonesTransformationMatrices;
  67486. }
  67487. }
  67488. declare module BABYLON {
  67489. interface Scene {
  67490. /** @hidden (Backing field) */
  67491. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67492. /**
  67493. * Gets or Sets the current geometry buffer associated to the scene.
  67494. */
  67495. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67496. /**
  67497. * Enables a GeometryBufferRender and associates it with the scene
  67498. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  67499. * @returns the GeometryBufferRenderer
  67500. */
  67501. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  67502. /**
  67503. * Disables the GeometryBufferRender associated with the scene
  67504. */
  67505. disableGeometryBufferRenderer(): void;
  67506. }
  67507. /**
  67508. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  67509. * in several rendering techniques.
  67510. */
  67511. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  67512. /**
  67513. * The component name helpful to identify the component in the list of scene components.
  67514. */
  67515. readonly name: string;
  67516. /**
  67517. * The scene the component belongs to.
  67518. */
  67519. scene: Scene;
  67520. /**
  67521. * Creates a new instance of the component for the given scene
  67522. * @param scene Defines the scene to register the component in
  67523. */
  67524. constructor(scene: Scene);
  67525. /**
  67526. * Registers the component in a given scene
  67527. */
  67528. register(): void;
  67529. /**
  67530. * Rebuilds the elements related to this component in case of
  67531. * context lost for instance.
  67532. */
  67533. rebuild(): void;
  67534. /**
  67535. * Disposes the component and the associated ressources
  67536. */
  67537. dispose(): void;
  67538. private _gatherRenderTargets;
  67539. }
  67540. }
  67541. declare module BABYLON {
  67542. /** @hidden */
  67543. export var motionBlurPixelShader: {
  67544. name: string;
  67545. shader: string;
  67546. };
  67547. }
  67548. declare module BABYLON {
  67549. /**
  67550. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  67551. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  67552. * As an example, all you have to do is to create the post-process:
  67553. * var mb = new BABYLON.MotionBlurPostProcess(
  67554. * 'mb', // The name of the effect.
  67555. * scene, // The scene containing the objects to blur according to their velocity.
  67556. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  67557. * camera // The camera to apply the render pass to.
  67558. * );
  67559. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  67560. */
  67561. export class MotionBlurPostProcess extends PostProcess {
  67562. /**
  67563. * Defines how much the image is blurred by the movement. Default value is equal to 1
  67564. */
  67565. motionStrength: number;
  67566. /**
  67567. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  67568. */
  67569. get motionBlurSamples(): number;
  67570. /**
  67571. * Sets the number of iterations to be used for motion blur quality
  67572. */
  67573. set motionBlurSamples(samples: number);
  67574. private _motionBlurSamples;
  67575. private _geometryBufferRenderer;
  67576. /**
  67577. * Creates a new instance MotionBlurPostProcess
  67578. * @param name The name of the effect.
  67579. * @param scene The scene containing the objects to blur according to their velocity.
  67580. * @param options The required width/height ratio to downsize to before computing the render pass.
  67581. * @param camera The camera to apply the render pass to.
  67582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67583. * @param engine The engine which the post process will be applied. (default: current engine)
  67584. * @param reusable If the post process can be reused on the same frame. (default: false)
  67585. * @param textureType Type of textures used when performing the post process. (default: 0)
  67586. * @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)
  67587. */
  67588. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67589. /**
  67590. * Excludes the given skinned mesh from computing bones velocities.
  67591. * 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.
  67592. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  67593. */
  67594. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67595. /**
  67596. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  67597. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  67598. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  67599. */
  67600. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67601. /**
  67602. * Disposes the post process.
  67603. * @param camera The camera to dispose the post process on.
  67604. */
  67605. dispose(camera?: Camera): void;
  67606. }
  67607. }
  67608. declare module BABYLON {
  67609. /** @hidden */
  67610. export var refractionPixelShader: {
  67611. name: string;
  67612. shader: string;
  67613. };
  67614. }
  67615. declare module BABYLON {
  67616. /**
  67617. * Post process which applies a refractin texture
  67618. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67619. */
  67620. export class RefractionPostProcess extends PostProcess {
  67621. /** the base color of the refraction (used to taint the rendering) */
  67622. color: Color3;
  67623. /** simulated refraction depth */
  67624. depth: number;
  67625. /** the coefficient of the base color (0 to remove base color tainting) */
  67626. colorLevel: number;
  67627. private _refTexture;
  67628. private _ownRefractionTexture;
  67629. /**
  67630. * Gets or sets the refraction texture
  67631. * Please note that you are responsible for disposing the texture if you set it manually
  67632. */
  67633. get refractionTexture(): Texture;
  67634. set refractionTexture(value: Texture);
  67635. /**
  67636. * Initializes the RefractionPostProcess
  67637. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67638. * @param name The name of the effect.
  67639. * @param refractionTextureUrl Url of the refraction texture to use
  67640. * @param color the base color of the refraction (used to taint the rendering)
  67641. * @param depth simulated refraction depth
  67642. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  67643. * @param camera The camera to apply the render pass to.
  67644. * @param options The required width/height ratio to downsize to before computing the render pass.
  67645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67646. * @param engine The engine which the post process will be applied. (default: current engine)
  67647. * @param reusable If the post process can be reused on the same frame. (default: false)
  67648. */
  67649. constructor(name: string, refractionTextureUrl: string,
  67650. /** the base color of the refraction (used to taint the rendering) */
  67651. color: Color3,
  67652. /** simulated refraction depth */
  67653. depth: number,
  67654. /** the coefficient of the base color (0 to remove base color tainting) */
  67655. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67656. /**
  67657. * Disposes of the post process
  67658. * @param camera Camera to dispose post process on
  67659. */
  67660. dispose(camera: Camera): void;
  67661. }
  67662. }
  67663. declare module BABYLON {
  67664. /** @hidden */
  67665. export var sharpenPixelShader: {
  67666. name: string;
  67667. shader: string;
  67668. };
  67669. }
  67670. declare module BABYLON {
  67671. /**
  67672. * The SharpenPostProcess applies a sharpen kernel to every pixel
  67673. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67674. */
  67675. export class SharpenPostProcess extends PostProcess {
  67676. /**
  67677. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  67678. */
  67679. colorAmount: number;
  67680. /**
  67681. * How much sharpness should be applied (default: 0.3)
  67682. */
  67683. edgeAmount: number;
  67684. /**
  67685. * Creates a new instance ConvolutionPostProcess
  67686. * @param name The name of the effect.
  67687. * @param options The required width/height ratio to downsize to before computing the render pass.
  67688. * @param camera The camera to apply the render pass to.
  67689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67690. * @param engine The engine which the post process will be applied. (default: current engine)
  67691. * @param reusable If the post process can be reused on the same frame. (default: false)
  67692. * @param textureType Type of textures used when performing the post process. (default: 0)
  67693. * @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)
  67694. */
  67695. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67696. }
  67697. }
  67698. declare module BABYLON {
  67699. /**
  67700. * PostProcessRenderPipeline
  67701. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67702. */
  67703. export class PostProcessRenderPipeline {
  67704. private engine;
  67705. private _renderEffects;
  67706. private _renderEffectsForIsolatedPass;
  67707. /**
  67708. * List of inspectable custom properties (used by the Inspector)
  67709. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67710. */
  67711. inspectableCustomProperties: IInspectable[];
  67712. /**
  67713. * @hidden
  67714. */
  67715. protected _cameras: Camera[];
  67716. /** @hidden */
  67717. _name: string;
  67718. /**
  67719. * Gets pipeline name
  67720. */
  67721. get name(): string;
  67722. /** Gets the list of attached cameras */
  67723. get cameras(): Camera[];
  67724. /**
  67725. * Initializes a PostProcessRenderPipeline
  67726. * @param engine engine to add the pipeline to
  67727. * @param name name of the pipeline
  67728. */
  67729. constructor(engine: Engine, name: string);
  67730. /**
  67731. * Gets the class name
  67732. * @returns "PostProcessRenderPipeline"
  67733. */
  67734. getClassName(): string;
  67735. /**
  67736. * If all the render effects in the pipeline are supported
  67737. */
  67738. get isSupported(): boolean;
  67739. /**
  67740. * Adds an effect to the pipeline
  67741. * @param renderEffect the effect to add
  67742. */
  67743. addEffect(renderEffect: PostProcessRenderEffect): void;
  67744. /** @hidden */
  67745. _rebuild(): void;
  67746. /** @hidden */
  67747. _enableEffect(renderEffectName: string, cameras: Camera): void;
  67748. /** @hidden */
  67749. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  67750. /** @hidden */
  67751. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  67752. /** @hidden */
  67753. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  67754. /** @hidden */
  67755. _attachCameras(cameras: Camera, unique: boolean): void;
  67756. /** @hidden */
  67757. _attachCameras(cameras: Camera[], unique: boolean): void;
  67758. /** @hidden */
  67759. _detachCameras(cameras: Camera): void;
  67760. /** @hidden */
  67761. _detachCameras(cameras: Nullable<Camera[]>): void;
  67762. /** @hidden */
  67763. _update(): void;
  67764. /** @hidden */
  67765. _reset(): void;
  67766. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  67767. /**
  67768. * Disposes of the pipeline
  67769. */
  67770. dispose(): void;
  67771. }
  67772. }
  67773. declare module BABYLON {
  67774. /**
  67775. * PostProcessRenderPipelineManager class
  67776. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67777. */
  67778. export class PostProcessRenderPipelineManager {
  67779. private _renderPipelines;
  67780. /**
  67781. * Initializes a PostProcessRenderPipelineManager
  67782. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67783. */
  67784. constructor();
  67785. /**
  67786. * Gets the list of supported render pipelines
  67787. */
  67788. get supportedPipelines(): PostProcessRenderPipeline[];
  67789. /**
  67790. * Adds a pipeline to the manager
  67791. * @param renderPipeline The pipeline to add
  67792. */
  67793. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  67794. /**
  67795. * Attaches a camera to the pipeline
  67796. * @param renderPipelineName The name of the pipeline to attach to
  67797. * @param cameras the camera to attach
  67798. * @param unique if the camera can be attached multiple times to the pipeline
  67799. */
  67800. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  67801. /**
  67802. * Detaches a camera from the pipeline
  67803. * @param renderPipelineName The name of the pipeline to detach from
  67804. * @param cameras the camera to detach
  67805. */
  67806. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  67807. /**
  67808. * Enables an effect by name on a pipeline
  67809. * @param renderPipelineName the name of the pipeline to enable the effect in
  67810. * @param renderEffectName the name of the effect to enable
  67811. * @param cameras the cameras that the effect should be enabled on
  67812. */
  67813. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  67814. /**
  67815. * Disables an effect by name on a pipeline
  67816. * @param renderPipelineName the name of the pipeline to disable the effect in
  67817. * @param renderEffectName the name of the effect to disable
  67818. * @param cameras the cameras that the effect should be disabled on
  67819. */
  67820. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  67821. /**
  67822. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  67823. */
  67824. update(): void;
  67825. /** @hidden */
  67826. _rebuild(): void;
  67827. /**
  67828. * Disposes of the manager and pipelines
  67829. */
  67830. dispose(): void;
  67831. }
  67832. }
  67833. declare module BABYLON {
  67834. interface Scene {
  67835. /** @hidden (Backing field) */
  67836. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  67837. /**
  67838. * Gets the postprocess render pipeline manager
  67839. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67840. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  67841. */
  67842. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  67843. }
  67844. /**
  67845. * Defines the Render Pipeline scene component responsible to rendering pipelines
  67846. */
  67847. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  67848. /**
  67849. * The component name helpfull to identify the component in the list of scene components.
  67850. */
  67851. readonly name: string;
  67852. /**
  67853. * The scene the component belongs to.
  67854. */
  67855. scene: Scene;
  67856. /**
  67857. * Creates a new instance of the component for the given scene
  67858. * @param scene Defines the scene to register the component in
  67859. */
  67860. constructor(scene: Scene);
  67861. /**
  67862. * Registers the component in a given scene
  67863. */
  67864. register(): void;
  67865. /**
  67866. * Rebuilds the elements related to this component in case of
  67867. * context lost for instance.
  67868. */
  67869. rebuild(): void;
  67870. /**
  67871. * Disposes the component and the associated ressources
  67872. */
  67873. dispose(): void;
  67874. private _gatherRenderTargets;
  67875. }
  67876. }
  67877. declare module BABYLON {
  67878. /**
  67879. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  67880. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  67881. */
  67882. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  67883. private _scene;
  67884. private _camerasToBeAttached;
  67885. /**
  67886. * ID of the sharpen post process,
  67887. */
  67888. private readonly SharpenPostProcessId;
  67889. /**
  67890. * @ignore
  67891. * ID of the image processing post process;
  67892. */
  67893. readonly ImageProcessingPostProcessId: string;
  67894. /**
  67895. * @ignore
  67896. * ID of the Fast Approximate Anti-Aliasing post process;
  67897. */
  67898. readonly FxaaPostProcessId: string;
  67899. /**
  67900. * ID of the chromatic aberration post process,
  67901. */
  67902. private readonly ChromaticAberrationPostProcessId;
  67903. /**
  67904. * ID of the grain post process
  67905. */
  67906. private readonly GrainPostProcessId;
  67907. /**
  67908. * Sharpen post process which will apply a sharpen convolution to enhance edges
  67909. */
  67910. sharpen: SharpenPostProcess;
  67911. private _sharpenEffect;
  67912. private bloom;
  67913. /**
  67914. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  67915. */
  67916. depthOfField: DepthOfFieldEffect;
  67917. /**
  67918. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  67919. */
  67920. fxaa: FxaaPostProcess;
  67921. /**
  67922. * Image post processing pass used to perform operations such as tone mapping or color grading.
  67923. */
  67924. imageProcessing: ImageProcessingPostProcess;
  67925. /**
  67926. * Chromatic aberration post process which will shift rgb colors in the image
  67927. */
  67928. chromaticAberration: ChromaticAberrationPostProcess;
  67929. private _chromaticAberrationEffect;
  67930. /**
  67931. * Grain post process which add noise to the image
  67932. */
  67933. grain: GrainPostProcess;
  67934. private _grainEffect;
  67935. /**
  67936. * Glow post process which adds a glow to emissive areas of the image
  67937. */
  67938. private _glowLayer;
  67939. /**
  67940. * Animations which can be used to tweak settings over a period of time
  67941. */
  67942. animations: Animation[];
  67943. private _imageProcessingConfigurationObserver;
  67944. private _sharpenEnabled;
  67945. private _bloomEnabled;
  67946. private _depthOfFieldEnabled;
  67947. private _depthOfFieldBlurLevel;
  67948. private _fxaaEnabled;
  67949. private _imageProcessingEnabled;
  67950. private _defaultPipelineTextureType;
  67951. private _bloomScale;
  67952. private _chromaticAberrationEnabled;
  67953. private _grainEnabled;
  67954. private _buildAllowed;
  67955. /**
  67956. * Gets active scene
  67957. */
  67958. get scene(): Scene;
  67959. /**
  67960. * Enable or disable the sharpen process from the pipeline
  67961. */
  67962. set sharpenEnabled(enabled: boolean);
  67963. get sharpenEnabled(): boolean;
  67964. private _resizeObserver;
  67965. private _hardwareScaleLevel;
  67966. private _bloomKernel;
  67967. /**
  67968. * Specifies the size of the bloom blur kernel, relative to the final output size
  67969. */
  67970. get bloomKernel(): number;
  67971. set bloomKernel(value: number);
  67972. /**
  67973. * Specifies the weight of the bloom in the final rendering
  67974. */
  67975. private _bloomWeight;
  67976. /**
  67977. * Specifies the luma threshold for the area that will be blurred by the bloom
  67978. */
  67979. private _bloomThreshold;
  67980. private _hdr;
  67981. /**
  67982. * The strength of the bloom.
  67983. */
  67984. set bloomWeight(value: number);
  67985. get bloomWeight(): number;
  67986. /**
  67987. * The strength of the bloom.
  67988. */
  67989. set bloomThreshold(value: number);
  67990. get bloomThreshold(): number;
  67991. /**
  67992. * The scale of the bloom, lower value will provide better performance.
  67993. */
  67994. set bloomScale(value: number);
  67995. get bloomScale(): number;
  67996. /**
  67997. * Enable or disable the bloom from the pipeline
  67998. */
  67999. set bloomEnabled(enabled: boolean);
  68000. get bloomEnabled(): boolean;
  68001. private _rebuildBloom;
  68002. /**
  68003. * If the depth of field is enabled.
  68004. */
  68005. get depthOfFieldEnabled(): boolean;
  68006. set depthOfFieldEnabled(enabled: boolean);
  68007. /**
  68008. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68009. */
  68010. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68011. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68012. /**
  68013. * If the anti aliasing is enabled.
  68014. */
  68015. set fxaaEnabled(enabled: boolean);
  68016. get fxaaEnabled(): boolean;
  68017. private _samples;
  68018. /**
  68019. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68020. */
  68021. set samples(sampleCount: number);
  68022. get samples(): number;
  68023. /**
  68024. * If image processing is enabled.
  68025. */
  68026. set imageProcessingEnabled(enabled: boolean);
  68027. get imageProcessingEnabled(): boolean;
  68028. /**
  68029. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68030. */
  68031. set glowLayerEnabled(enabled: boolean);
  68032. get glowLayerEnabled(): boolean;
  68033. /**
  68034. * Gets the glow layer (or null if not defined)
  68035. */
  68036. get glowLayer(): Nullable<GlowLayer>;
  68037. /**
  68038. * Enable or disable the chromaticAberration process from the pipeline
  68039. */
  68040. set chromaticAberrationEnabled(enabled: boolean);
  68041. get chromaticAberrationEnabled(): boolean;
  68042. /**
  68043. * Enable or disable the grain process from the pipeline
  68044. */
  68045. set grainEnabled(enabled: boolean);
  68046. get grainEnabled(): boolean;
  68047. /**
  68048. * @constructor
  68049. * @param name - The rendering pipeline name (default: "")
  68050. * @param hdr - If high dynamic range textures should be used (default: true)
  68051. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68052. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68053. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68054. */
  68055. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68056. /**
  68057. * Get the class name
  68058. * @returns "DefaultRenderingPipeline"
  68059. */
  68060. getClassName(): string;
  68061. /**
  68062. * Force the compilation of the entire pipeline.
  68063. */
  68064. prepare(): void;
  68065. private _hasCleared;
  68066. private _prevPostProcess;
  68067. private _prevPrevPostProcess;
  68068. private _setAutoClearAndTextureSharing;
  68069. private _depthOfFieldSceneObserver;
  68070. private _buildPipeline;
  68071. private _disposePostProcesses;
  68072. /**
  68073. * Adds a camera to the pipeline
  68074. * @param camera the camera to be added
  68075. */
  68076. addCamera(camera: Camera): void;
  68077. /**
  68078. * Removes a camera from the pipeline
  68079. * @param camera the camera to remove
  68080. */
  68081. removeCamera(camera: Camera): void;
  68082. /**
  68083. * Dispose of the pipeline and stop all post processes
  68084. */
  68085. dispose(): void;
  68086. /**
  68087. * Serialize the rendering pipeline (Used when exporting)
  68088. * @returns the serialized object
  68089. */
  68090. serialize(): any;
  68091. /**
  68092. * Parse the serialized pipeline
  68093. * @param source Source pipeline.
  68094. * @param scene The scene to load the pipeline to.
  68095. * @param rootUrl The URL of the serialized pipeline.
  68096. * @returns An instantiated pipeline from the serialized object.
  68097. */
  68098. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68099. }
  68100. }
  68101. declare module BABYLON {
  68102. /** @hidden */
  68103. export var lensHighlightsPixelShader: {
  68104. name: string;
  68105. shader: string;
  68106. };
  68107. }
  68108. declare module BABYLON {
  68109. /** @hidden */
  68110. export var depthOfFieldPixelShader: {
  68111. name: string;
  68112. shader: string;
  68113. };
  68114. }
  68115. declare module BABYLON {
  68116. /**
  68117. * BABYLON.JS Chromatic Aberration GLSL Shader
  68118. * Author: Olivier Guyot
  68119. * Separates very slightly R, G and B colors on the edges of the screen
  68120. * Inspired by Francois Tarlier & Martins Upitis
  68121. */
  68122. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68123. /**
  68124. * @ignore
  68125. * The chromatic aberration PostProcess id in the pipeline
  68126. */
  68127. LensChromaticAberrationEffect: string;
  68128. /**
  68129. * @ignore
  68130. * The highlights enhancing PostProcess id in the pipeline
  68131. */
  68132. HighlightsEnhancingEffect: string;
  68133. /**
  68134. * @ignore
  68135. * The depth-of-field PostProcess id in the pipeline
  68136. */
  68137. LensDepthOfFieldEffect: string;
  68138. private _scene;
  68139. private _depthTexture;
  68140. private _grainTexture;
  68141. private _chromaticAberrationPostProcess;
  68142. private _highlightsPostProcess;
  68143. private _depthOfFieldPostProcess;
  68144. private _edgeBlur;
  68145. private _grainAmount;
  68146. private _chromaticAberration;
  68147. private _distortion;
  68148. private _highlightsGain;
  68149. private _highlightsThreshold;
  68150. private _dofDistance;
  68151. private _dofAperture;
  68152. private _dofDarken;
  68153. private _dofPentagon;
  68154. private _blurNoise;
  68155. /**
  68156. * @constructor
  68157. *
  68158. * Effect parameters are as follow:
  68159. * {
  68160. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68161. * edge_blur: number; // from 0 to x (1 for realism)
  68162. * distortion: number; // from 0 to x (1 for realism)
  68163. * grain_amount: number; // from 0 to 1
  68164. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68165. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68166. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68167. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68168. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68169. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68170. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68171. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68172. * }
  68173. * Note: if an effect parameter is unset, effect is disabled
  68174. *
  68175. * @param name The rendering pipeline name
  68176. * @param parameters - An object containing all parameters (see above)
  68177. * @param scene The scene linked to this pipeline
  68178. * @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)
  68179. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68180. */
  68181. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68182. /**
  68183. * Get the class name
  68184. * @returns "LensRenderingPipeline"
  68185. */
  68186. getClassName(): string;
  68187. /**
  68188. * Gets associated scene
  68189. */
  68190. get scene(): Scene;
  68191. /**
  68192. * Gets or sets the edge blur
  68193. */
  68194. get edgeBlur(): number;
  68195. set edgeBlur(value: number);
  68196. /**
  68197. * Gets or sets the grain amount
  68198. */
  68199. get grainAmount(): number;
  68200. set grainAmount(value: number);
  68201. /**
  68202. * Gets or sets the chromatic aberration amount
  68203. */
  68204. get chromaticAberration(): number;
  68205. set chromaticAberration(value: number);
  68206. /**
  68207. * Gets or sets the depth of field aperture
  68208. */
  68209. get dofAperture(): number;
  68210. set dofAperture(value: number);
  68211. /**
  68212. * Gets or sets the edge distortion
  68213. */
  68214. get edgeDistortion(): number;
  68215. set edgeDistortion(value: number);
  68216. /**
  68217. * Gets or sets the depth of field distortion
  68218. */
  68219. get dofDistortion(): number;
  68220. set dofDistortion(value: number);
  68221. /**
  68222. * Gets or sets the darken out of focus amount
  68223. */
  68224. get darkenOutOfFocus(): number;
  68225. set darkenOutOfFocus(value: number);
  68226. /**
  68227. * Gets or sets a boolean indicating if blur noise is enabled
  68228. */
  68229. get blurNoise(): boolean;
  68230. set blurNoise(value: boolean);
  68231. /**
  68232. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68233. */
  68234. get pentagonBokeh(): boolean;
  68235. set pentagonBokeh(value: boolean);
  68236. /**
  68237. * Gets or sets the highlight grain amount
  68238. */
  68239. get highlightsGain(): number;
  68240. set highlightsGain(value: number);
  68241. /**
  68242. * Gets or sets the highlight threshold
  68243. */
  68244. get highlightsThreshold(): number;
  68245. set highlightsThreshold(value: number);
  68246. /**
  68247. * Sets the amount of blur at the edges
  68248. * @param amount blur amount
  68249. */
  68250. setEdgeBlur(amount: number): void;
  68251. /**
  68252. * Sets edge blur to 0
  68253. */
  68254. disableEdgeBlur(): void;
  68255. /**
  68256. * Sets the amout of grain
  68257. * @param amount Amount of grain
  68258. */
  68259. setGrainAmount(amount: number): void;
  68260. /**
  68261. * Set grain amount to 0
  68262. */
  68263. disableGrain(): void;
  68264. /**
  68265. * Sets the chromatic aberration amount
  68266. * @param amount amount of chromatic aberration
  68267. */
  68268. setChromaticAberration(amount: number): void;
  68269. /**
  68270. * Sets chromatic aberration amount to 0
  68271. */
  68272. disableChromaticAberration(): void;
  68273. /**
  68274. * Sets the EdgeDistortion amount
  68275. * @param amount amount of EdgeDistortion
  68276. */
  68277. setEdgeDistortion(amount: number): void;
  68278. /**
  68279. * Sets edge distortion to 0
  68280. */
  68281. disableEdgeDistortion(): void;
  68282. /**
  68283. * Sets the FocusDistance amount
  68284. * @param amount amount of FocusDistance
  68285. */
  68286. setFocusDistance(amount: number): void;
  68287. /**
  68288. * Disables depth of field
  68289. */
  68290. disableDepthOfField(): void;
  68291. /**
  68292. * Sets the Aperture amount
  68293. * @param amount amount of Aperture
  68294. */
  68295. setAperture(amount: number): void;
  68296. /**
  68297. * Sets the DarkenOutOfFocus amount
  68298. * @param amount amount of DarkenOutOfFocus
  68299. */
  68300. setDarkenOutOfFocus(amount: number): void;
  68301. private _pentagonBokehIsEnabled;
  68302. /**
  68303. * Creates a pentagon bokeh effect
  68304. */
  68305. enablePentagonBokeh(): void;
  68306. /**
  68307. * Disables the pentagon bokeh effect
  68308. */
  68309. disablePentagonBokeh(): void;
  68310. /**
  68311. * Enables noise blur
  68312. */
  68313. enableNoiseBlur(): void;
  68314. /**
  68315. * Disables noise blur
  68316. */
  68317. disableNoiseBlur(): void;
  68318. /**
  68319. * Sets the HighlightsGain amount
  68320. * @param amount amount of HighlightsGain
  68321. */
  68322. setHighlightsGain(amount: number): void;
  68323. /**
  68324. * Sets the HighlightsThreshold amount
  68325. * @param amount amount of HighlightsThreshold
  68326. */
  68327. setHighlightsThreshold(amount: number): void;
  68328. /**
  68329. * Disables highlights
  68330. */
  68331. disableHighlights(): void;
  68332. /**
  68333. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68334. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68335. */
  68336. dispose(disableDepthRender?: boolean): void;
  68337. private _createChromaticAberrationPostProcess;
  68338. private _createHighlightsPostProcess;
  68339. private _createDepthOfFieldPostProcess;
  68340. private _createGrainTexture;
  68341. }
  68342. }
  68343. declare module BABYLON {
  68344. /** @hidden */
  68345. export var ssao2PixelShader: {
  68346. name: string;
  68347. shader: string;
  68348. };
  68349. }
  68350. declare module BABYLON {
  68351. /** @hidden */
  68352. export var ssaoCombinePixelShader: {
  68353. name: string;
  68354. shader: string;
  68355. };
  68356. }
  68357. declare module BABYLON {
  68358. /**
  68359. * Render pipeline to produce ssao effect
  68360. */
  68361. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  68362. /**
  68363. * @ignore
  68364. * The PassPostProcess id in the pipeline that contains the original scene color
  68365. */
  68366. SSAOOriginalSceneColorEffect: string;
  68367. /**
  68368. * @ignore
  68369. * The SSAO PostProcess id in the pipeline
  68370. */
  68371. SSAORenderEffect: string;
  68372. /**
  68373. * @ignore
  68374. * The horizontal blur PostProcess id in the pipeline
  68375. */
  68376. SSAOBlurHRenderEffect: string;
  68377. /**
  68378. * @ignore
  68379. * The vertical blur PostProcess id in the pipeline
  68380. */
  68381. SSAOBlurVRenderEffect: string;
  68382. /**
  68383. * @ignore
  68384. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68385. */
  68386. SSAOCombineRenderEffect: string;
  68387. /**
  68388. * The output strength of the SSAO post-process. Default value is 1.0.
  68389. */
  68390. totalStrength: number;
  68391. /**
  68392. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  68393. */
  68394. maxZ: number;
  68395. /**
  68396. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  68397. */
  68398. minZAspect: number;
  68399. private _samples;
  68400. /**
  68401. * Number of samples used for the SSAO calculations. Default value is 8
  68402. */
  68403. set samples(n: number);
  68404. get samples(): number;
  68405. private _textureSamples;
  68406. /**
  68407. * Number of samples to use for antialiasing
  68408. */
  68409. set textureSamples(n: number);
  68410. get textureSamples(): number;
  68411. /**
  68412. * Ratio object used for SSAO ratio and blur ratio
  68413. */
  68414. private _ratio;
  68415. /**
  68416. * Dynamically generated sphere sampler.
  68417. */
  68418. private _sampleSphere;
  68419. /**
  68420. * Blur filter offsets
  68421. */
  68422. private _samplerOffsets;
  68423. private _expensiveBlur;
  68424. /**
  68425. * If bilateral blur should be used
  68426. */
  68427. set expensiveBlur(b: boolean);
  68428. get expensiveBlur(): boolean;
  68429. /**
  68430. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  68431. */
  68432. radius: number;
  68433. /**
  68434. * The base color of the SSAO post-process
  68435. * The final result is "base + ssao" between [0, 1]
  68436. */
  68437. base: number;
  68438. /**
  68439. * Support test.
  68440. */
  68441. static get IsSupported(): boolean;
  68442. private _scene;
  68443. private _depthTexture;
  68444. private _normalTexture;
  68445. private _randomTexture;
  68446. private _originalColorPostProcess;
  68447. private _ssaoPostProcess;
  68448. private _blurHPostProcess;
  68449. private _blurVPostProcess;
  68450. private _ssaoCombinePostProcess;
  68451. /**
  68452. * Gets active scene
  68453. */
  68454. get scene(): Scene;
  68455. /**
  68456. * @constructor
  68457. * @param name The rendering pipeline name
  68458. * @param scene The scene linked to this pipeline
  68459. * @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 }
  68460. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68461. */
  68462. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68463. /**
  68464. * Get the class name
  68465. * @returns "SSAO2RenderingPipeline"
  68466. */
  68467. getClassName(): string;
  68468. /**
  68469. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68470. */
  68471. dispose(disableGeometryBufferRenderer?: boolean): void;
  68472. private _createBlurPostProcess;
  68473. /** @hidden */
  68474. _rebuild(): void;
  68475. private _bits;
  68476. private _radicalInverse_VdC;
  68477. private _hammersley;
  68478. private _hemisphereSample_uniform;
  68479. private _generateHemisphere;
  68480. private _createSSAOPostProcess;
  68481. private _createSSAOCombinePostProcess;
  68482. private _createRandomTexture;
  68483. /**
  68484. * Serialize the rendering pipeline (Used when exporting)
  68485. * @returns the serialized object
  68486. */
  68487. serialize(): any;
  68488. /**
  68489. * Parse the serialized pipeline
  68490. * @param source Source pipeline.
  68491. * @param scene The scene to load the pipeline to.
  68492. * @param rootUrl The URL of the serialized pipeline.
  68493. * @returns An instantiated pipeline from the serialized object.
  68494. */
  68495. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  68496. }
  68497. }
  68498. declare module BABYLON {
  68499. /** @hidden */
  68500. export var ssaoPixelShader: {
  68501. name: string;
  68502. shader: string;
  68503. };
  68504. }
  68505. declare module BABYLON {
  68506. /**
  68507. * Render pipeline to produce ssao effect
  68508. */
  68509. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  68510. /**
  68511. * @ignore
  68512. * The PassPostProcess id in the pipeline that contains the original scene color
  68513. */
  68514. SSAOOriginalSceneColorEffect: string;
  68515. /**
  68516. * @ignore
  68517. * The SSAO PostProcess id in the pipeline
  68518. */
  68519. SSAORenderEffect: string;
  68520. /**
  68521. * @ignore
  68522. * The horizontal blur PostProcess id in the pipeline
  68523. */
  68524. SSAOBlurHRenderEffect: string;
  68525. /**
  68526. * @ignore
  68527. * The vertical blur PostProcess id in the pipeline
  68528. */
  68529. SSAOBlurVRenderEffect: string;
  68530. /**
  68531. * @ignore
  68532. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68533. */
  68534. SSAOCombineRenderEffect: string;
  68535. /**
  68536. * The output strength of the SSAO post-process. Default value is 1.0.
  68537. */
  68538. totalStrength: number;
  68539. /**
  68540. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  68541. */
  68542. radius: number;
  68543. /**
  68544. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  68545. * Must not be equal to fallOff and superior to fallOff.
  68546. * Default value is 0.0075
  68547. */
  68548. area: number;
  68549. /**
  68550. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  68551. * Must not be equal to area and inferior to area.
  68552. * Default value is 0.000001
  68553. */
  68554. fallOff: number;
  68555. /**
  68556. * The base color of the SSAO post-process
  68557. * The final result is "base + ssao" between [0, 1]
  68558. */
  68559. base: number;
  68560. private _scene;
  68561. private _depthTexture;
  68562. private _randomTexture;
  68563. private _originalColorPostProcess;
  68564. private _ssaoPostProcess;
  68565. private _blurHPostProcess;
  68566. private _blurVPostProcess;
  68567. private _ssaoCombinePostProcess;
  68568. private _firstUpdate;
  68569. /**
  68570. * Gets active scene
  68571. */
  68572. get scene(): Scene;
  68573. /**
  68574. * @constructor
  68575. * @param name - The rendering pipeline name
  68576. * @param scene - The scene linked to this pipeline
  68577. * @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 }
  68578. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  68579. */
  68580. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68581. /**
  68582. * Get the class name
  68583. * @returns "SSAORenderingPipeline"
  68584. */
  68585. getClassName(): string;
  68586. /**
  68587. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68588. */
  68589. dispose(disableDepthRender?: boolean): void;
  68590. private _createBlurPostProcess;
  68591. /** @hidden */
  68592. _rebuild(): void;
  68593. private _createSSAOPostProcess;
  68594. private _createSSAOCombinePostProcess;
  68595. private _createRandomTexture;
  68596. }
  68597. }
  68598. declare module BABYLON {
  68599. /** @hidden */
  68600. export var screenSpaceReflectionPixelShader: {
  68601. name: string;
  68602. shader: string;
  68603. };
  68604. }
  68605. declare module BABYLON {
  68606. /**
  68607. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  68608. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  68609. */
  68610. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  68611. /**
  68612. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  68613. */
  68614. threshold: number;
  68615. /**
  68616. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  68617. */
  68618. strength: number;
  68619. /**
  68620. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  68621. */
  68622. reflectionSpecularFalloffExponent: number;
  68623. /**
  68624. * 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]
  68625. */
  68626. step: number;
  68627. /**
  68628. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  68629. */
  68630. roughnessFactor: number;
  68631. private _geometryBufferRenderer;
  68632. private _enableSmoothReflections;
  68633. private _reflectionSamples;
  68634. private _smoothSteps;
  68635. /**
  68636. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  68637. * @param name The name of the effect.
  68638. * @param scene The scene containing the objects to calculate reflections.
  68639. * @param options The required width/height ratio to downsize to before computing the render pass.
  68640. * @param camera The camera to apply the render pass to.
  68641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68642. * @param engine The engine which the post process will be applied. (default: current engine)
  68643. * @param reusable If the post process can be reused on the same frame. (default: false)
  68644. * @param textureType Type of textures used when performing the post process. (default: 0)
  68645. * @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)
  68646. */
  68647. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68648. /**
  68649. * Gets wether or not smoothing reflections is enabled.
  68650. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  68651. */
  68652. get enableSmoothReflections(): boolean;
  68653. /**
  68654. * Sets wether or not smoothing reflections is enabled.
  68655. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  68656. */
  68657. set enableSmoothReflections(enabled: boolean);
  68658. /**
  68659. * Gets the number of samples taken while computing reflections. More samples count is high,
  68660. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  68661. */
  68662. get reflectionSamples(): number;
  68663. /**
  68664. * Sets the number of samples taken while computing reflections. More samples count is high,
  68665. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  68666. */
  68667. set reflectionSamples(samples: number);
  68668. /**
  68669. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  68670. * more the post-process will require GPU power and can generate a drop in FPS.
  68671. * Default value (5.0) work pretty well in all cases but can be adjusted.
  68672. */
  68673. get smoothSteps(): number;
  68674. set smoothSteps(steps: number);
  68675. private _updateEffectDefines;
  68676. }
  68677. }
  68678. declare module BABYLON {
  68679. /** @hidden */
  68680. export var standardPixelShader: {
  68681. name: string;
  68682. shader: string;
  68683. };
  68684. }
  68685. declare module BABYLON {
  68686. /**
  68687. * Standard rendering pipeline
  68688. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  68689. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  68690. */
  68691. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68692. /**
  68693. * Public members
  68694. */
  68695. /**
  68696. * Post-process which contains the original scene color before the pipeline applies all the effects
  68697. */
  68698. originalPostProcess: Nullable<PostProcess>;
  68699. /**
  68700. * Post-process used to down scale an image x4
  68701. */
  68702. downSampleX4PostProcess: Nullable<PostProcess>;
  68703. /**
  68704. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  68705. */
  68706. brightPassPostProcess: Nullable<PostProcess>;
  68707. /**
  68708. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  68709. */
  68710. blurHPostProcesses: PostProcess[];
  68711. /**
  68712. * Post-process array storing all the vertical blur post-processes used by the pipeline
  68713. */
  68714. blurVPostProcesses: PostProcess[];
  68715. /**
  68716. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  68717. */
  68718. textureAdderPostProcess: Nullable<PostProcess>;
  68719. /**
  68720. * Post-process used to create volumetric lighting effect
  68721. */
  68722. volumetricLightPostProcess: Nullable<PostProcess>;
  68723. /**
  68724. * Post-process used to smooth the previous volumetric light post-process on the X axis
  68725. */
  68726. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  68727. /**
  68728. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  68729. */
  68730. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  68731. /**
  68732. * Post-process used to merge the volumetric light effect and the real scene color
  68733. */
  68734. volumetricLightMergePostProces: Nullable<PostProcess>;
  68735. /**
  68736. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  68737. */
  68738. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  68739. /**
  68740. * Base post-process used to calculate the average luminance of the final image for HDR
  68741. */
  68742. luminancePostProcess: Nullable<PostProcess>;
  68743. /**
  68744. * Post-processes used to create down sample post-processes in order to get
  68745. * the average luminance of the final image for HDR
  68746. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  68747. */
  68748. luminanceDownSamplePostProcesses: PostProcess[];
  68749. /**
  68750. * Post-process used to create a HDR effect (light adaptation)
  68751. */
  68752. hdrPostProcess: Nullable<PostProcess>;
  68753. /**
  68754. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  68755. */
  68756. textureAdderFinalPostProcess: Nullable<PostProcess>;
  68757. /**
  68758. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  68759. */
  68760. lensFlareFinalPostProcess: Nullable<PostProcess>;
  68761. /**
  68762. * Post-process used to merge the final HDR post-process and the real scene color
  68763. */
  68764. hdrFinalPostProcess: Nullable<PostProcess>;
  68765. /**
  68766. * Post-process used to create a lens flare effect
  68767. */
  68768. lensFlarePostProcess: Nullable<PostProcess>;
  68769. /**
  68770. * Post-process that merges the result of the lens flare post-process and the real scene color
  68771. */
  68772. lensFlareComposePostProcess: Nullable<PostProcess>;
  68773. /**
  68774. * Post-process used to create a motion blur effect
  68775. */
  68776. motionBlurPostProcess: Nullable<PostProcess>;
  68777. /**
  68778. * Post-process used to create a depth of field effect
  68779. */
  68780. depthOfFieldPostProcess: Nullable<PostProcess>;
  68781. /**
  68782. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68783. */
  68784. fxaaPostProcess: Nullable<FxaaPostProcess>;
  68785. /**
  68786. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  68787. */
  68788. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  68789. /**
  68790. * Represents the brightness threshold in order to configure the illuminated surfaces
  68791. */
  68792. brightThreshold: number;
  68793. /**
  68794. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  68795. */
  68796. blurWidth: number;
  68797. /**
  68798. * Sets if the blur for highlighted surfaces must be only horizontal
  68799. */
  68800. horizontalBlur: boolean;
  68801. /**
  68802. * Gets the overall exposure used by the pipeline
  68803. */
  68804. get exposure(): number;
  68805. /**
  68806. * Sets the overall exposure used by the pipeline
  68807. */
  68808. set exposure(value: number);
  68809. /**
  68810. * Texture used typically to simulate "dirty" on camera lens
  68811. */
  68812. lensTexture: Nullable<Texture>;
  68813. /**
  68814. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  68815. */
  68816. volumetricLightCoefficient: number;
  68817. /**
  68818. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  68819. */
  68820. volumetricLightPower: number;
  68821. /**
  68822. * Used the set the blur intensity to smooth the volumetric lights
  68823. */
  68824. volumetricLightBlurScale: number;
  68825. /**
  68826. * Light (spot or directional) used to generate the volumetric lights rays
  68827. * The source light must have a shadow generate so the pipeline can get its
  68828. * depth map
  68829. */
  68830. sourceLight: Nullable<SpotLight | DirectionalLight>;
  68831. /**
  68832. * For eye adaptation, represents the minimum luminance the eye can see
  68833. */
  68834. hdrMinimumLuminance: number;
  68835. /**
  68836. * For eye adaptation, represents the decrease luminance speed
  68837. */
  68838. hdrDecreaseRate: number;
  68839. /**
  68840. * For eye adaptation, represents the increase luminance speed
  68841. */
  68842. hdrIncreaseRate: number;
  68843. /**
  68844. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  68845. */
  68846. get hdrAutoExposure(): boolean;
  68847. /**
  68848. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  68849. */
  68850. set hdrAutoExposure(value: boolean);
  68851. /**
  68852. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  68853. */
  68854. lensColorTexture: Nullable<Texture>;
  68855. /**
  68856. * The overall strengh for the lens flare effect
  68857. */
  68858. lensFlareStrength: number;
  68859. /**
  68860. * Dispersion coefficient for lens flare ghosts
  68861. */
  68862. lensFlareGhostDispersal: number;
  68863. /**
  68864. * Main lens flare halo width
  68865. */
  68866. lensFlareHaloWidth: number;
  68867. /**
  68868. * Based on the lens distortion effect, defines how much the lens flare result
  68869. * is distorted
  68870. */
  68871. lensFlareDistortionStrength: number;
  68872. /**
  68873. * Configures the blur intensity used for for lens flare (halo)
  68874. */
  68875. lensFlareBlurWidth: number;
  68876. /**
  68877. * Lens star texture must be used to simulate rays on the flares and is available
  68878. * in the documentation
  68879. */
  68880. lensStarTexture: Nullable<Texture>;
  68881. /**
  68882. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  68883. * flare effect by taking account of the dirt texture
  68884. */
  68885. lensFlareDirtTexture: Nullable<Texture>;
  68886. /**
  68887. * Represents the focal length for the depth of field effect
  68888. */
  68889. depthOfFieldDistance: number;
  68890. /**
  68891. * Represents the blur intensity for the blurred part of the depth of field effect
  68892. */
  68893. depthOfFieldBlurWidth: number;
  68894. /**
  68895. * Gets how much the image is blurred by the movement while using the motion blur post-process
  68896. */
  68897. get motionStrength(): number;
  68898. /**
  68899. * Sets how much the image is blurred by the movement while using the motion blur post-process
  68900. */
  68901. set motionStrength(strength: number);
  68902. /**
  68903. * Gets wether or not the motion blur post-process is object based or screen based.
  68904. */
  68905. get objectBasedMotionBlur(): boolean;
  68906. /**
  68907. * Sets wether or not the motion blur post-process should be object based or screen based
  68908. */
  68909. set objectBasedMotionBlur(value: boolean);
  68910. /**
  68911. * List of animations for the pipeline (IAnimatable implementation)
  68912. */
  68913. animations: Animation[];
  68914. /**
  68915. * Private members
  68916. */
  68917. private _scene;
  68918. private _currentDepthOfFieldSource;
  68919. private _basePostProcess;
  68920. private _fixedExposure;
  68921. private _currentExposure;
  68922. private _hdrAutoExposure;
  68923. private _hdrCurrentLuminance;
  68924. private _motionStrength;
  68925. private _isObjectBasedMotionBlur;
  68926. private _floatTextureType;
  68927. private _camerasToBeAttached;
  68928. private _ratio;
  68929. private _bloomEnabled;
  68930. private _depthOfFieldEnabled;
  68931. private _vlsEnabled;
  68932. private _lensFlareEnabled;
  68933. private _hdrEnabled;
  68934. private _motionBlurEnabled;
  68935. private _fxaaEnabled;
  68936. private _screenSpaceReflectionsEnabled;
  68937. private _motionBlurSamples;
  68938. private _volumetricLightStepsCount;
  68939. private _samples;
  68940. /**
  68941. * @ignore
  68942. * Specifies if the bloom pipeline is enabled
  68943. */
  68944. get BloomEnabled(): boolean;
  68945. set BloomEnabled(enabled: boolean);
  68946. /**
  68947. * @ignore
  68948. * Specifies if the depth of field pipeline is enabed
  68949. */
  68950. get DepthOfFieldEnabled(): boolean;
  68951. set DepthOfFieldEnabled(enabled: boolean);
  68952. /**
  68953. * @ignore
  68954. * Specifies if the lens flare pipeline is enabed
  68955. */
  68956. get LensFlareEnabled(): boolean;
  68957. set LensFlareEnabled(enabled: boolean);
  68958. /**
  68959. * @ignore
  68960. * Specifies if the HDR pipeline is enabled
  68961. */
  68962. get HDREnabled(): boolean;
  68963. set HDREnabled(enabled: boolean);
  68964. /**
  68965. * @ignore
  68966. * Specifies if the volumetric lights scattering effect is enabled
  68967. */
  68968. get VLSEnabled(): boolean;
  68969. set VLSEnabled(enabled: boolean);
  68970. /**
  68971. * @ignore
  68972. * Specifies if the motion blur effect is enabled
  68973. */
  68974. get MotionBlurEnabled(): boolean;
  68975. set MotionBlurEnabled(enabled: boolean);
  68976. /**
  68977. * Specifies if anti-aliasing is enabled
  68978. */
  68979. get fxaaEnabled(): boolean;
  68980. set fxaaEnabled(enabled: boolean);
  68981. /**
  68982. * Specifies if screen space reflections are enabled.
  68983. */
  68984. get screenSpaceReflectionsEnabled(): boolean;
  68985. set screenSpaceReflectionsEnabled(enabled: boolean);
  68986. /**
  68987. * Specifies the number of steps used to calculate the volumetric lights
  68988. * Typically in interval [50, 200]
  68989. */
  68990. get volumetricLightStepsCount(): number;
  68991. set volumetricLightStepsCount(count: number);
  68992. /**
  68993. * Specifies the number of samples used for the motion blur effect
  68994. * Typically in interval [16, 64]
  68995. */
  68996. get motionBlurSamples(): number;
  68997. set motionBlurSamples(samples: number);
  68998. /**
  68999. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69000. */
  69001. get samples(): number;
  69002. set samples(sampleCount: number);
  69003. /**
  69004. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69005. * @constructor
  69006. * @param name The rendering pipeline name
  69007. * @param scene The scene linked to this pipeline
  69008. * @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)
  69009. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69010. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69011. */
  69012. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69013. private _buildPipeline;
  69014. private _createDownSampleX4PostProcess;
  69015. private _createBrightPassPostProcess;
  69016. private _createBlurPostProcesses;
  69017. private _createTextureAdderPostProcess;
  69018. private _createVolumetricLightPostProcess;
  69019. private _createLuminancePostProcesses;
  69020. private _createHdrPostProcess;
  69021. private _createLensFlarePostProcess;
  69022. private _createDepthOfFieldPostProcess;
  69023. private _createMotionBlurPostProcess;
  69024. private _getDepthTexture;
  69025. private _disposePostProcesses;
  69026. /**
  69027. * Dispose of the pipeline and stop all post processes
  69028. */
  69029. dispose(): void;
  69030. /**
  69031. * Serialize the rendering pipeline (Used when exporting)
  69032. * @returns the serialized object
  69033. */
  69034. serialize(): any;
  69035. /**
  69036. * Parse the serialized pipeline
  69037. * @param source Source pipeline.
  69038. * @param scene The scene to load the pipeline to.
  69039. * @param rootUrl The URL of the serialized pipeline.
  69040. * @returns An instantiated pipeline from the serialized object.
  69041. */
  69042. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69043. /**
  69044. * Luminance steps
  69045. */
  69046. static LuminanceSteps: number;
  69047. }
  69048. }
  69049. declare module BABYLON {
  69050. /** @hidden */
  69051. export var stereoscopicInterlacePixelShader: {
  69052. name: string;
  69053. shader: string;
  69054. };
  69055. }
  69056. declare module BABYLON {
  69057. /**
  69058. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  69059. */
  69060. export class StereoscopicInterlacePostProcessI extends PostProcess {
  69061. private _stepSize;
  69062. private _passedProcess;
  69063. /**
  69064. * Initializes a StereoscopicInterlacePostProcessI
  69065. * @param name The name of the effect.
  69066. * @param rigCameras The rig cameras to be appled to the post process
  69067. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  69068. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  69069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69070. * @param engine The engine which the post process will be applied. (default: current engine)
  69071. * @param reusable If the post process can be reused on the same frame. (default: false)
  69072. */
  69073. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69074. }
  69075. /**
  69076. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  69077. */
  69078. export class StereoscopicInterlacePostProcess extends PostProcess {
  69079. private _stepSize;
  69080. private _passedProcess;
  69081. /**
  69082. * Initializes a StereoscopicInterlacePostProcess
  69083. * @param name The name of the effect.
  69084. * @param rigCameras The rig cameras to be appled to the post process
  69085. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  69086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69087. * @param engine The engine which the post process will be applied. (default: current engine)
  69088. * @param reusable If the post process can be reused on the same frame. (default: false)
  69089. */
  69090. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69091. }
  69092. }
  69093. declare module BABYLON {
  69094. /** @hidden */
  69095. export var tonemapPixelShader: {
  69096. name: string;
  69097. shader: string;
  69098. };
  69099. }
  69100. declare module BABYLON {
  69101. /** Defines operator used for tonemapping */
  69102. export enum TonemappingOperator {
  69103. /** Hable */
  69104. Hable = 0,
  69105. /** Reinhard */
  69106. Reinhard = 1,
  69107. /** HejiDawson */
  69108. HejiDawson = 2,
  69109. /** Photographic */
  69110. Photographic = 3
  69111. }
  69112. /**
  69113. * Defines a post process to apply tone mapping
  69114. */
  69115. export class TonemapPostProcess extends PostProcess {
  69116. private _operator;
  69117. /** Defines the required exposure adjustement */
  69118. exposureAdjustment: number;
  69119. /**
  69120. * Creates a new TonemapPostProcess
  69121. * @param name defines the name of the postprocess
  69122. * @param _operator defines the operator to use
  69123. * @param exposureAdjustment defines the required exposure adjustement
  69124. * @param camera defines the camera to use (can be null)
  69125. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69126. * @param engine defines the hosting engine (can be ignore if camera is set)
  69127. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69128. */
  69129. constructor(name: string, _operator: TonemappingOperator,
  69130. /** Defines the required exposure adjustement */
  69131. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69132. }
  69133. }
  69134. declare module BABYLON {
  69135. /** @hidden */
  69136. export var volumetricLightScatteringPixelShader: {
  69137. name: string;
  69138. shader: string;
  69139. };
  69140. }
  69141. declare module BABYLON {
  69142. /** @hidden */
  69143. export var volumetricLightScatteringPassVertexShader: {
  69144. name: string;
  69145. shader: string;
  69146. };
  69147. }
  69148. declare module BABYLON {
  69149. /** @hidden */
  69150. export var volumetricLightScatteringPassPixelShader: {
  69151. name: string;
  69152. shader: string;
  69153. };
  69154. }
  69155. declare module BABYLON {
  69156. /**
  69157. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69158. */
  69159. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69160. private _volumetricLightScatteringPass;
  69161. private _volumetricLightScatteringRTT;
  69162. private _viewPort;
  69163. private _screenCoordinates;
  69164. private _cachedDefines;
  69165. /**
  69166. * If not undefined, the mesh position is computed from the attached node position
  69167. */
  69168. attachedNode: {
  69169. position: Vector3;
  69170. };
  69171. /**
  69172. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69173. */
  69174. customMeshPosition: Vector3;
  69175. /**
  69176. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69177. */
  69178. useCustomMeshPosition: boolean;
  69179. /**
  69180. * If the post-process should inverse the light scattering direction
  69181. */
  69182. invert: boolean;
  69183. /**
  69184. * The internal mesh used by the post-process
  69185. */
  69186. mesh: Mesh;
  69187. /**
  69188. * @hidden
  69189. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69190. */
  69191. get useDiffuseColor(): boolean;
  69192. set useDiffuseColor(useDiffuseColor: boolean);
  69193. /**
  69194. * Array containing the excluded meshes not rendered in the internal pass
  69195. */
  69196. excludedMeshes: AbstractMesh[];
  69197. /**
  69198. * Controls the overall intensity of the post-process
  69199. */
  69200. exposure: number;
  69201. /**
  69202. * Dissipates each sample's contribution in range [0, 1]
  69203. */
  69204. decay: number;
  69205. /**
  69206. * Controls the overall intensity of each sample
  69207. */
  69208. weight: number;
  69209. /**
  69210. * Controls the density of each sample
  69211. */
  69212. density: number;
  69213. /**
  69214. * @constructor
  69215. * @param name The post-process name
  69216. * @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)
  69217. * @param camera The camera that the post-process will be attached to
  69218. * @param mesh The mesh used to create the light scattering
  69219. * @param samples The post-process quality, default 100
  69220. * @param samplingModeThe post-process filtering mode
  69221. * @param engine The babylon engine
  69222. * @param reusable If the post-process is reusable
  69223. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69224. */
  69225. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69226. /**
  69227. * Returns the string "VolumetricLightScatteringPostProcess"
  69228. * @returns "VolumetricLightScatteringPostProcess"
  69229. */
  69230. getClassName(): string;
  69231. private _isReady;
  69232. /**
  69233. * Sets the new light position for light scattering effect
  69234. * @param position The new custom light position
  69235. */
  69236. setCustomMeshPosition(position: Vector3): void;
  69237. /**
  69238. * Returns the light position for light scattering effect
  69239. * @return Vector3 The custom light position
  69240. */
  69241. getCustomMeshPosition(): Vector3;
  69242. /**
  69243. * Disposes the internal assets and detaches the post-process from the camera
  69244. */
  69245. dispose(camera: Camera): void;
  69246. /**
  69247. * Returns the render target texture used by the post-process
  69248. * @return the render target texture used by the post-process
  69249. */
  69250. getPass(): RenderTargetTexture;
  69251. private _meshExcluded;
  69252. private _createPass;
  69253. private _updateMeshScreenCoordinates;
  69254. /**
  69255. * Creates a default mesh for the Volumeric Light Scattering post-process
  69256. * @param name The mesh name
  69257. * @param scene The scene where to create the mesh
  69258. * @return the default mesh
  69259. */
  69260. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69261. }
  69262. }
  69263. declare module BABYLON {
  69264. interface Scene {
  69265. /** @hidden (Backing field) */
  69266. _boundingBoxRenderer: BoundingBoxRenderer;
  69267. /** @hidden (Backing field) */
  69268. _forceShowBoundingBoxes: boolean;
  69269. /**
  69270. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  69271. */
  69272. forceShowBoundingBoxes: boolean;
  69273. /**
  69274. * Gets the bounding box renderer associated with the scene
  69275. * @returns a BoundingBoxRenderer
  69276. */
  69277. getBoundingBoxRenderer(): BoundingBoxRenderer;
  69278. }
  69279. interface AbstractMesh {
  69280. /** @hidden (Backing field) */
  69281. _showBoundingBox: boolean;
  69282. /**
  69283. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  69284. */
  69285. showBoundingBox: boolean;
  69286. }
  69287. /**
  69288. * Component responsible of rendering the bounding box of the meshes in a scene.
  69289. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  69290. */
  69291. export class BoundingBoxRenderer implements ISceneComponent {
  69292. /**
  69293. * The component name helpfull to identify the component in the list of scene components.
  69294. */
  69295. readonly name: string;
  69296. /**
  69297. * The scene the component belongs to.
  69298. */
  69299. scene: Scene;
  69300. /**
  69301. * Color of the bounding box lines placed in front of an object
  69302. */
  69303. frontColor: Color3;
  69304. /**
  69305. * Color of the bounding box lines placed behind an object
  69306. */
  69307. backColor: Color3;
  69308. /**
  69309. * Defines if the renderer should show the back lines or not
  69310. */
  69311. showBackLines: boolean;
  69312. /**
  69313. * Observable raised before rendering a bounding box
  69314. */
  69315. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  69316. /**
  69317. * Observable raised after rendering a bounding box
  69318. */
  69319. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  69320. /**
  69321. * @hidden
  69322. */
  69323. renderList: SmartArray<BoundingBox>;
  69324. private _colorShader;
  69325. private _vertexBuffers;
  69326. private _indexBuffer;
  69327. private _fillIndexBuffer;
  69328. private _fillIndexData;
  69329. /**
  69330. * Instantiates a new bounding box renderer in a scene.
  69331. * @param scene the scene the renderer renders in
  69332. */
  69333. constructor(scene: Scene);
  69334. /**
  69335. * Registers the component in a given scene
  69336. */
  69337. register(): void;
  69338. private _evaluateSubMesh;
  69339. private _activeMesh;
  69340. private _prepareRessources;
  69341. private _createIndexBuffer;
  69342. /**
  69343. * Rebuilds the elements related to this component in case of
  69344. * context lost for instance.
  69345. */
  69346. rebuild(): void;
  69347. /**
  69348. * @hidden
  69349. */
  69350. reset(): void;
  69351. /**
  69352. * Render the bounding boxes of a specific rendering group
  69353. * @param renderingGroupId defines the rendering group to render
  69354. */
  69355. render(renderingGroupId: number): void;
  69356. /**
  69357. * In case of occlusion queries, we can render the occlusion bounding box through this method
  69358. * @param mesh Define the mesh to render the occlusion bounding box for
  69359. */
  69360. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  69361. /**
  69362. * Dispose and release the resources attached to this renderer.
  69363. */
  69364. dispose(): void;
  69365. }
  69366. }
  69367. declare module BABYLON {
  69368. interface Scene {
  69369. /** @hidden (Backing field) */
  69370. _depthRenderer: {
  69371. [id: string]: DepthRenderer;
  69372. };
  69373. /**
  69374. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  69375. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  69376. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  69377. * @returns the created depth renderer
  69378. */
  69379. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  69380. /**
  69381. * Disables a depth renderer for a given camera
  69382. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  69383. */
  69384. disableDepthRenderer(camera?: Nullable<Camera>): void;
  69385. }
  69386. /**
  69387. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  69388. * in several rendering techniques.
  69389. */
  69390. export class DepthRendererSceneComponent implements ISceneComponent {
  69391. /**
  69392. * The component name helpfull to identify the component in the list of scene components.
  69393. */
  69394. readonly name: string;
  69395. /**
  69396. * The scene the component belongs to.
  69397. */
  69398. scene: Scene;
  69399. /**
  69400. * Creates a new instance of the component for the given scene
  69401. * @param scene Defines the scene to register the component in
  69402. */
  69403. constructor(scene: Scene);
  69404. /**
  69405. * Registers the component in a given scene
  69406. */
  69407. register(): void;
  69408. /**
  69409. * Rebuilds the elements related to this component in case of
  69410. * context lost for instance.
  69411. */
  69412. rebuild(): void;
  69413. /**
  69414. * Disposes the component and the associated ressources
  69415. */
  69416. dispose(): void;
  69417. private _gatherRenderTargets;
  69418. private _gatherActiveCameraRenderTargets;
  69419. }
  69420. }
  69421. declare module BABYLON {
  69422. /** @hidden */
  69423. export var outlinePixelShader: {
  69424. name: string;
  69425. shader: string;
  69426. };
  69427. }
  69428. declare module BABYLON {
  69429. /** @hidden */
  69430. export var outlineVertexShader: {
  69431. name: string;
  69432. shader: string;
  69433. };
  69434. }
  69435. declare module BABYLON {
  69436. interface Scene {
  69437. /** @hidden */
  69438. _outlineRenderer: OutlineRenderer;
  69439. /**
  69440. * Gets the outline renderer associated with the scene
  69441. * @returns a OutlineRenderer
  69442. */
  69443. getOutlineRenderer(): OutlineRenderer;
  69444. }
  69445. interface AbstractMesh {
  69446. /** @hidden (Backing field) */
  69447. _renderOutline: boolean;
  69448. /**
  69449. * Gets or sets a boolean indicating if the outline must be rendered as well
  69450. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  69451. */
  69452. renderOutline: boolean;
  69453. /** @hidden (Backing field) */
  69454. _renderOverlay: boolean;
  69455. /**
  69456. * Gets or sets a boolean indicating if the overlay must be rendered as well
  69457. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  69458. */
  69459. renderOverlay: boolean;
  69460. }
  69461. /**
  69462. * This class is responsible to draw bothe outline/overlay of meshes.
  69463. * It should not be used directly but through the available method on mesh.
  69464. */
  69465. export class OutlineRenderer implements ISceneComponent {
  69466. /**
  69467. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  69468. */
  69469. private static _StencilReference;
  69470. /**
  69471. * The name of the component. Each component must have a unique name.
  69472. */
  69473. name: string;
  69474. /**
  69475. * The scene the component belongs to.
  69476. */
  69477. scene: Scene;
  69478. /**
  69479. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  69480. */
  69481. zOffset: number;
  69482. private _engine;
  69483. private _effect;
  69484. private _cachedDefines;
  69485. private _savedDepthWrite;
  69486. /**
  69487. * Instantiates a new outline renderer. (There could be only one per scene).
  69488. * @param scene Defines the scene it belongs to
  69489. */
  69490. constructor(scene: Scene);
  69491. /**
  69492. * Register the component to one instance of a scene.
  69493. */
  69494. register(): void;
  69495. /**
  69496. * Rebuilds the elements related to this component in case of
  69497. * context lost for instance.
  69498. */
  69499. rebuild(): void;
  69500. /**
  69501. * Disposes the component and the associated ressources.
  69502. */
  69503. dispose(): void;
  69504. /**
  69505. * Renders the outline in the canvas.
  69506. * @param subMesh Defines the sumesh to render
  69507. * @param batch Defines the batch of meshes in case of instances
  69508. * @param useOverlay Defines if the rendering is for the overlay or the outline
  69509. */
  69510. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  69511. /**
  69512. * Returns whether or not the outline renderer is ready for a given submesh.
  69513. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  69514. * @param subMesh Defines the submesh to check readyness for
  69515. * @param useInstances Defines wheter wee are trying to render instances or not
  69516. * @returns true if ready otherwise false
  69517. */
  69518. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69519. private _beforeRenderingMesh;
  69520. private _afterRenderingMesh;
  69521. }
  69522. }
  69523. declare module BABYLON {
  69524. /**
  69525. * Defines the basic options interface of a Sprite Frame Source Size.
  69526. */
  69527. export interface ISpriteJSONSpriteSourceSize {
  69528. /**
  69529. * number of the original width of the Frame
  69530. */
  69531. w: number;
  69532. /**
  69533. * number of the original height of the Frame
  69534. */
  69535. h: number;
  69536. }
  69537. /**
  69538. * Defines the basic options interface of a Sprite Frame Data.
  69539. */
  69540. export interface ISpriteJSONSpriteFrameData {
  69541. /**
  69542. * number of the x offset of the Frame
  69543. */
  69544. x: number;
  69545. /**
  69546. * number of the y offset of the Frame
  69547. */
  69548. y: number;
  69549. /**
  69550. * number of the width of the Frame
  69551. */
  69552. w: number;
  69553. /**
  69554. * number of the height of the Frame
  69555. */
  69556. h: number;
  69557. }
  69558. /**
  69559. * Defines the basic options interface of a JSON Sprite.
  69560. */
  69561. export interface ISpriteJSONSprite {
  69562. /**
  69563. * string name of the Frame
  69564. */
  69565. filename: string;
  69566. /**
  69567. * ISpriteJSONSpriteFrame basic object of the frame data
  69568. */
  69569. frame: ISpriteJSONSpriteFrameData;
  69570. /**
  69571. * boolean to flag is the frame was rotated.
  69572. */
  69573. rotated: boolean;
  69574. /**
  69575. * boolean to flag is the frame was trimmed.
  69576. */
  69577. trimmed: boolean;
  69578. /**
  69579. * ISpriteJSONSpriteFrame basic object of the source data
  69580. */
  69581. spriteSourceSize: ISpriteJSONSpriteFrameData;
  69582. /**
  69583. * ISpriteJSONSpriteFrame basic object of the source data
  69584. */
  69585. sourceSize: ISpriteJSONSpriteSourceSize;
  69586. }
  69587. /**
  69588. * Defines the basic options interface of a JSON atlas.
  69589. */
  69590. export interface ISpriteJSONAtlas {
  69591. /**
  69592. * Array of objects that contain the frame data.
  69593. */
  69594. frames: Array<ISpriteJSONSprite>;
  69595. /**
  69596. * object basic object containing the sprite meta data.
  69597. */
  69598. meta?: object;
  69599. }
  69600. }
  69601. declare module BABYLON {
  69602. /** @hidden */
  69603. export var spriteMapPixelShader: {
  69604. name: string;
  69605. shader: string;
  69606. };
  69607. }
  69608. declare module BABYLON {
  69609. /** @hidden */
  69610. export var spriteMapVertexShader: {
  69611. name: string;
  69612. shader: string;
  69613. };
  69614. }
  69615. declare module BABYLON {
  69616. /**
  69617. * Defines the basic options interface of a SpriteMap
  69618. */
  69619. export interface ISpriteMapOptions {
  69620. /**
  69621. * Vector2 of the number of cells in the grid.
  69622. */
  69623. stageSize?: Vector2;
  69624. /**
  69625. * Vector2 of the size of the output plane in World Units.
  69626. */
  69627. outputSize?: Vector2;
  69628. /**
  69629. * Vector3 of the position of the output plane in World Units.
  69630. */
  69631. outputPosition?: Vector3;
  69632. /**
  69633. * Vector3 of the rotation of the output plane.
  69634. */
  69635. outputRotation?: Vector3;
  69636. /**
  69637. * number of layers that the system will reserve in resources.
  69638. */
  69639. layerCount?: number;
  69640. /**
  69641. * number of max animation frames a single cell will reserve in resources.
  69642. */
  69643. maxAnimationFrames?: number;
  69644. /**
  69645. * number cell index of the base tile when the system compiles.
  69646. */
  69647. baseTile?: number;
  69648. /**
  69649. * boolean flip the sprite after its been repositioned by the framing data.
  69650. */
  69651. flipU?: boolean;
  69652. /**
  69653. * Vector3 scalar of the global RGB values of the SpriteMap.
  69654. */
  69655. colorMultiply?: Vector3;
  69656. }
  69657. /**
  69658. * Defines the IDisposable interface in order to be cleanable from resources.
  69659. */
  69660. export interface ISpriteMap extends IDisposable {
  69661. /**
  69662. * String name of the SpriteMap.
  69663. */
  69664. name: string;
  69665. /**
  69666. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  69667. */
  69668. atlasJSON: ISpriteJSONAtlas;
  69669. /**
  69670. * Texture of the SpriteMap.
  69671. */
  69672. spriteSheet: Texture;
  69673. /**
  69674. * The parameters to initialize the SpriteMap with.
  69675. */
  69676. options: ISpriteMapOptions;
  69677. }
  69678. /**
  69679. * Class used to manage a grid restricted sprite deployment on an Output plane.
  69680. */
  69681. export class SpriteMap implements ISpriteMap {
  69682. /** The Name of the spriteMap */
  69683. name: string;
  69684. /** The JSON file with the frame and meta data */
  69685. atlasJSON: ISpriteJSONAtlas;
  69686. /** The systems Sprite Sheet Texture */
  69687. spriteSheet: Texture;
  69688. /** Arguments passed with the Constructor */
  69689. options: ISpriteMapOptions;
  69690. /** Public Sprite Storage array, parsed from atlasJSON */
  69691. sprites: Array<ISpriteJSONSprite>;
  69692. /** Returns the Number of Sprites in the System */
  69693. get spriteCount(): number;
  69694. /** Returns the Position of Output Plane*/
  69695. get position(): Vector3;
  69696. /** Returns the Position of Output Plane*/
  69697. set position(v: Vector3);
  69698. /** Returns the Rotation of Output Plane*/
  69699. get rotation(): Vector3;
  69700. /** Returns the Rotation of Output Plane*/
  69701. set rotation(v: Vector3);
  69702. /** Sets the AnimationMap*/
  69703. get animationMap(): RawTexture;
  69704. /** Sets the AnimationMap*/
  69705. set animationMap(v: RawTexture);
  69706. /** Scene that the SpriteMap was created in */
  69707. private _scene;
  69708. /** Texture Buffer of Float32 that holds tile frame data*/
  69709. private _frameMap;
  69710. /** Texture Buffers of Float32 that holds tileMap data*/
  69711. private _tileMaps;
  69712. /** Texture Buffer of Float32 that holds Animation Data*/
  69713. private _animationMap;
  69714. /** Custom ShaderMaterial Central to the System*/
  69715. private _material;
  69716. /** Custom ShaderMaterial Central to the System*/
  69717. private _output;
  69718. /** Systems Time Ticker*/
  69719. private _time;
  69720. /**
  69721. * Creates a new SpriteMap
  69722. * @param name defines the SpriteMaps Name
  69723. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  69724. * @param spriteSheet is the Texture that the Sprites are on.
  69725. * @param options a basic deployment configuration
  69726. * @param scene The Scene that the map is deployed on
  69727. */
  69728. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  69729. /**
  69730. * Returns tileID location
  69731. * @returns Vector2 the cell position ID
  69732. */
  69733. getTileID(): Vector2;
  69734. /**
  69735. * Gets the UV location of the mouse over the SpriteMap.
  69736. * @returns Vector2 the UV position of the mouse interaction
  69737. */
  69738. getMousePosition(): Vector2;
  69739. /**
  69740. * Creates the "frame" texture Buffer
  69741. * -------------------------------------
  69742. * Structure of frames
  69743. * "filename": "Falling-Water-2.png",
  69744. * "frame": {"x":69,"y":103,"w":24,"h":32},
  69745. * "rotated": true,
  69746. * "trimmed": true,
  69747. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  69748. * "sourceSize": {"w":32,"h":32}
  69749. * @returns RawTexture of the frameMap
  69750. */
  69751. private _createFrameBuffer;
  69752. /**
  69753. * Creates the tileMap texture Buffer
  69754. * @param buffer normally and array of numbers, or a false to generate from scratch
  69755. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  69756. * @returns RawTexture of the tileMap
  69757. */
  69758. private _createTileBuffer;
  69759. /**
  69760. * Modifies the data of the tileMaps
  69761. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  69762. * @param pos is the iVector2 Coordinates of the Tile
  69763. * @param tile The SpriteIndex of the new Tile
  69764. */
  69765. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  69766. /**
  69767. * Creates the animationMap texture Buffer
  69768. * @param buffer normally and array of numbers, or a false to generate from scratch
  69769. * @returns RawTexture of the animationMap
  69770. */
  69771. private _createTileAnimationBuffer;
  69772. /**
  69773. * Modifies the data of the animationMap
  69774. * @param cellID is the Index of the Sprite
  69775. * @param _frame is the target Animation frame
  69776. * @param toCell is the Target Index of the next frame of the animation
  69777. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  69778. * @param speed is a global scalar of the time variable on the map.
  69779. */
  69780. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  69781. /**
  69782. * Exports the .tilemaps file
  69783. */
  69784. saveTileMaps(): void;
  69785. /**
  69786. * Imports the .tilemaps file
  69787. * @param url of the .tilemaps file
  69788. */
  69789. loadTileMaps(url: string): void;
  69790. /**
  69791. * Release associated resources
  69792. */
  69793. dispose(): void;
  69794. }
  69795. }
  69796. declare module BABYLON {
  69797. /**
  69798. * Class used to manage multiple sprites of different sizes on the same spritesheet
  69799. * @see http://doc.babylonjs.com/babylon101/sprites
  69800. */
  69801. export class SpritePackedManager extends SpriteManager {
  69802. /** defines the packed manager's name */
  69803. name: string;
  69804. /**
  69805. * Creates a new sprite manager from a packed sprite sheet
  69806. * @param name defines the manager's name
  69807. * @param imgUrl defines the sprite sheet url
  69808. * @param capacity defines the maximum allowed number of sprites
  69809. * @param scene defines the hosting scene
  69810. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  69811. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69812. * @param samplingMode defines the smapling mode to use with spritesheet
  69813. * @param fromPacked set to true; do not alter
  69814. */
  69815. constructor(
  69816. /** defines the packed manager's name */
  69817. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  69818. }
  69819. }
  69820. declare module BABYLON {
  69821. /**
  69822. * Defines the list of states available for a task inside a AssetsManager
  69823. */
  69824. export enum AssetTaskState {
  69825. /**
  69826. * Initialization
  69827. */
  69828. INIT = 0,
  69829. /**
  69830. * Running
  69831. */
  69832. RUNNING = 1,
  69833. /**
  69834. * Done
  69835. */
  69836. DONE = 2,
  69837. /**
  69838. * Error
  69839. */
  69840. ERROR = 3
  69841. }
  69842. /**
  69843. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  69844. */
  69845. export abstract class AbstractAssetTask {
  69846. /**
  69847. * Task name
  69848. */ name: string;
  69849. /**
  69850. * Callback called when the task is successful
  69851. */
  69852. onSuccess: (task: any) => void;
  69853. /**
  69854. * Callback called when the task is not successful
  69855. */
  69856. onError: (task: any, message?: string, exception?: any) => void;
  69857. /**
  69858. * Creates a new AssetsManager
  69859. * @param name defines the name of the task
  69860. */
  69861. constructor(
  69862. /**
  69863. * Task name
  69864. */ name: string);
  69865. private _isCompleted;
  69866. private _taskState;
  69867. private _errorObject;
  69868. /**
  69869. * Get if the task is completed
  69870. */
  69871. get isCompleted(): boolean;
  69872. /**
  69873. * Gets the current state of the task
  69874. */
  69875. get taskState(): AssetTaskState;
  69876. /**
  69877. * Gets the current error object (if task is in error)
  69878. */
  69879. get errorObject(): {
  69880. message?: string;
  69881. exception?: any;
  69882. };
  69883. /**
  69884. * Internal only
  69885. * @hidden
  69886. */
  69887. _setErrorObject(message?: string, exception?: any): void;
  69888. /**
  69889. * Execute the current task
  69890. * @param scene defines the scene where you want your assets to be loaded
  69891. * @param onSuccess is a callback called when the task is successfully executed
  69892. * @param onError is a callback called if an error occurs
  69893. */
  69894. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69895. /**
  69896. * Execute the current task
  69897. * @param scene defines the scene where you want your assets to be loaded
  69898. * @param onSuccess is a callback called when the task is successfully executed
  69899. * @param onError is a callback called if an error occurs
  69900. */
  69901. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69902. /**
  69903. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  69904. * This can be used with failed tasks that have the reason for failure fixed.
  69905. */
  69906. reset(): void;
  69907. private onErrorCallback;
  69908. private onDoneCallback;
  69909. }
  69910. /**
  69911. * Define the interface used by progress events raised during assets loading
  69912. */
  69913. export interface IAssetsProgressEvent {
  69914. /**
  69915. * Defines the number of remaining tasks to process
  69916. */
  69917. remainingCount: number;
  69918. /**
  69919. * Defines the total number of tasks
  69920. */
  69921. totalCount: number;
  69922. /**
  69923. * Defines the task that was just processed
  69924. */
  69925. task: AbstractAssetTask;
  69926. }
  69927. /**
  69928. * Class used to share progress information about assets loading
  69929. */
  69930. export class AssetsProgressEvent implements IAssetsProgressEvent {
  69931. /**
  69932. * Defines the number of remaining tasks to process
  69933. */
  69934. remainingCount: number;
  69935. /**
  69936. * Defines the total number of tasks
  69937. */
  69938. totalCount: number;
  69939. /**
  69940. * Defines the task that was just processed
  69941. */
  69942. task: AbstractAssetTask;
  69943. /**
  69944. * Creates a AssetsProgressEvent
  69945. * @param remainingCount defines the number of remaining tasks to process
  69946. * @param totalCount defines the total number of tasks
  69947. * @param task defines the task that was just processed
  69948. */
  69949. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  69950. }
  69951. /**
  69952. * Define a task used by AssetsManager to load meshes
  69953. */
  69954. export class MeshAssetTask extends AbstractAssetTask {
  69955. /**
  69956. * Defines the name of the task
  69957. */
  69958. name: string;
  69959. /**
  69960. * Defines the list of mesh's names you want to load
  69961. */
  69962. meshesNames: any;
  69963. /**
  69964. * Defines the root url to use as a base to load your meshes and associated resources
  69965. */
  69966. rootUrl: string;
  69967. /**
  69968. * Defines the filename or File of the scene to load from
  69969. */
  69970. sceneFilename: string | File;
  69971. /**
  69972. * Gets the list of loaded meshes
  69973. */
  69974. loadedMeshes: Array<AbstractMesh>;
  69975. /**
  69976. * Gets the list of loaded particle systems
  69977. */
  69978. loadedParticleSystems: Array<IParticleSystem>;
  69979. /**
  69980. * Gets the list of loaded skeletons
  69981. */
  69982. loadedSkeletons: Array<Skeleton>;
  69983. /**
  69984. * Gets the list of loaded animation groups
  69985. */
  69986. loadedAnimationGroups: Array<AnimationGroup>;
  69987. /**
  69988. * Callback called when the task is successful
  69989. */
  69990. onSuccess: (task: MeshAssetTask) => void;
  69991. /**
  69992. * Callback called when the task is successful
  69993. */
  69994. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  69995. /**
  69996. * Creates a new MeshAssetTask
  69997. * @param name defines the name of the task
  69998. * @param meshesNames defines the list of mesh's names you want to load
  69999. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70000. * @param sceneFilename defines the filename or File of the scene to load from
  70001. */
  70002. constructor(
  70003. /**
  70004. * Defines the name of the task
  70005. */
  70006. name: string,
  70007. /**
  70008. * Defines the list of mesh's names you want to load
  70009. */
  70010. meshesNames: any,
  70011. /**
  70012. * Defines the root url to use as a base to load your meshes and associated resources
  70013. */
  70014. rootUrl: string,
  70015. /**
  70016. * Defines the filename or File of the scene to load from
  70017. */
  70018. sceneFilename: string | File);
  70019. /**
  70020. * Execute the current task
  70021. * @param scene defines the scene where you want your assets to be loaded
  70022. * @param onSuccess is a callback called when the task is successfully executed
  70023. * @param onError is a callback called if an error occurs
  70024. */
  70025. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70026. }
  70027. /**
  70028. * Define a task used by AssetsManager to load text content
  70029. */
  70030. export class TextFileAssetTask extends AbstractAssetTask {
  70031. /**
  70032. * Defines the name of the task
  70033. */
  70034. name: string;
  70035. /**
  70036. * Defines the location of the file to load
  70037. */
  70038. url: string;
  70039. /**
  70040. * Gets the loaded text string
  70041. */
  70042. text: string;
  70043. /**
  70044. * Callback called when the task is successful
  70045. */
  70046. onSuccess: (task: TextFileAssetTask) => void;
  70047. /**
  70048. * Callback called when the task is successful
  70049. */
  70050. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70051. /**
  70052. * Creates a new TextFileAssetTask object
  70053. * @param name defines the name of the task
  70054. * @param url defines the location of the file to load
  70055. */
  70056. constructor(
  70057. /**
  70058. * Defines the name of the task
  70059. */
  70060. name: string,
  70061. /**
  70062. * Defines the location of the file to load
  70063. */
  70064. url: string);
  70065. /**
  70066. * Execute the current task
  70067. * @param scene defines the scene where you want your assets to be loaded
  70068. * @param onSuccess is a callback called when the task is successfully executed
  70069. * @param onError is a callback called if an error occurs
  70070. */
  70071. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70072. }
  70073. /**
  70074. * Define a task used by AssetsManager to load binary data
  70075. */
  70076. export class BinaryFileAssetTask extends AbstractAssetTask {
  70077. /**
  70078. * Defines the name of the task
  70079. */
  70080. name: string;
  70081. /**
  70082. * Defines the location of the file to load
  70083. */
  70084. url: string;
  70085. /**
  70086. * Gets the lodaded data (as an array buffer)
  70087. */
  70088. data: ArrayBuffer;
  70089. /**
  70090. * Callback called when the task is successful
  70091. */
  70092. onSuccess: (task: BinaryFileAssetTask) => void;
  70093. /**
  70094. * Callback called when the task is successful
  70095. */
  70096. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70097. /**
  70098. * Creates a new BinaryFileAssetTask object
  70099. * @param name defines the name of the new task
  70100. * @param url defines the location of the file to load
  70101. */
  70102. constructor(
  70103. /**
  70104. * Defines the name of the task
  70105. */
  70106. name: string,
  70107. /**
  70108. * Defines the location of the file to load
  70109. */
  70110. url: string);
  70111. /**
  70112. * Execute the current task
  70113. * @param scene defines the scene where you want your assets to be loaded
  70114. * @param onSuccess is a callback called when the task is successfully executed
  70115. * @param onError is a callback called if an error occurs
  70116. */
  70117. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70118. }
  70119. /**
  70120. * Define a task used by AssetsManager to load images
  70121. */
  70122. export class ImageAssetTask extends AbstractAssetTask {
  70123. /**
  70124. * Defines the name of the task
  70125. */
  70126. name: string;
  70127. /**
  70128. * Defines the location of the image to load
  70129. */
  70130. url: string;
  70131. /**
  70132. * Gets the loaded images
  70133. */
  70134. image: HTMLImageElement;
  70135. /**
  70136. * Callback called when the task is successful
  70137. */
  70138. onSuccess: (task: ImageAssetTask) => void;
  70139. /**
  70140. * Callback called when the task is successful
  70141. */
  70142. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70143. /**
  70144. * Creates a new ImageAssetTask
  70145. * @param name defines the name of the task
  70146. * @param url defines the location of the image to load
  70147. */
  70148. constructor(
  70149. /**
  70150. * Defines the name of the task
  70151. */
  70152. name: string,
  70153. /**
  70154. * Defines the location of the image to load
  70155. */
  70156. url: string);
  70157. /**
  70158. * Execute the current task
  70159. * @param scene defines the scene where you want your assets to be loaded
  70160. * @param onSuccess is a callback called when the task is successfully executed
  70161. * @param onError is a callback called if an error occurs
  70162. */
  70163. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70164. }
  70165. /**
  70166. * Defines the interface used by texture loading tasks
  70167. */
  70168. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70169. /**
  70170. * Gets the loaded texture
  70171. */
  70172. texture: TEX;
  70173. }
  70174. /**
  70175. * Define a task used by AssetsManager to load 2D textures
  70176. */
  70177. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70178. /**
  70179. * Defines the name of the task
  70180. */
  70181. name: string;
  70182. /**
  70183. * Defines the location of the file to load
  70184. */
  70185. url: string;
  70186. /**
  70187. * Defines if mipmap should not be generated (default is false)
  70188. */
  70189. noMipmap?: boolean | undefined;
  70190. /**
  70191. * Defines if texture must be inverted on Y axis (default is true)
  70192. */
  70193. invertY: boolean;
  70194. /**
  70195. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70196. */
  70197. samplingMode: number;
  70198. /**
  70199. * Gets the loaded texture
  70200. */
  70201. texture: Texture;
  70202. /**
  70203. * Callback called when the task is successful
  70204. */
  70205. onSuccess: (task: TextureAssetTask) => void;
  70206. /**
  70207. * Callback called when the task is successful
  70208. */
  70209. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  70210. /**
  70211. * Creates a new TextureAssetTask object
  70212. * @param name defines the name of the task
  70213. * @param url defines the location of the file to load
  70214. * @param noMipmap defines if mipmap should not be generated (default is false)
  70215. * @param invertY defines if texture must be inverted on Y axis (default is true)
  70216. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70217. */
  70218. constructor(
  70219. /**
  70220. * Defines the name of the task
  70221. */
  70222. name: string,
  70223. /**
  70224. * Defines the location of the file to load
  70225. */
  70226. url: string,
  70227. /**
  70228. * Defines if mipmap should not be generated (default is false)
  70229. */
  70230. noMipmap?: boolean | undefined,
  70231. /**
  70232. * Defines if texture must be inverted on Y axis (default is true)
  70233. */
  70234. invertY?: boolean,
  70235. /**
  70236. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70237. */
  70238. samplingMode?: number);
  70239. /**
  70240. * Execute the current task
  70241. * @param scene defines the scene where you want your assets to be loaded
  70242. * @param onSuccess is a callback called when the task is successfully executed
  70243. * @param onError is a callback called if an error occurs
  70244. */
  70245. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70246. }
  70247. /**
  70248. * Define a task used by AssetsManager to load cube textures
  70249. */
  70250. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  70251. /**
  70252. * Defines the name of the task
  70253. */
  70254. name: string;
  70255. /**
  70256. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70257. */
  70258. url: string;
  70259. /**
  70260. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70261. */
  70262. extensions?: string[] | undefined;
  70263. /**
  70264. * Defines if mipmaps should not be generated (default is false)
  70265. */
  70266. noMipmap?: boolean | undefined;
  70267. /**
  70268. * Defines the explicit list of files (undefined by default)
  70269. */
  70270. files?: string[] | undefined;
  70271. /**
  70272. * Gets the loaded texture
  70273. */
  70274. texture: CubeTexture;
  70275. /**
  70276. * Callback called when the task is successful
  70277. */
  70278. onSuccess: (task: CubeTextureAssetTask) => void;
  70279. /**
  70280. * Callback called when the task is successful
  70281. */
  70282. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  70283. /**
  70284. * Creates a new CubeTextureAssetTask
  70285. * @param name defines the name of the task
  70286. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70287. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70288. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70289. * @param files defines the explicit list of files (undefined by default)
  70290. */
  70291. constructor(
  70292. /**
  70293. * Defines the name of the task
  70294. */
  70295. name: string,
  70296. /**
  70297. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70298. */
  70299. url: string,
  70300. /**
  70301. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70302. */
  70303. extensions?: string[] | undefined,
  70304. /**
  70305. * Defines if mipmaps should not be generated (default is false)
  70306. */
  70307. noMipmap?: boolean | undefined,
  70308. /**
  70309. * Defines the explicit list of files (undefined by default)
  70310. */
  70311. files?: string[] | undefined);
  70312. /**
  70313. * Execute the current task
  70314. * @param scene defines the scene where you want your assets to be loaded
  70315. * @param onSuccess is a callback called when the task is successfully executed
  70316. * @param onError is a callback called if an error occurs
  70317. */
  70318. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70319. }
  70320. /**
  70321. * Define a task used by AssetsManager to load HDR cube textures
  70322. */
  70323. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  70324. /**
  70325. * Defines the name of the task
  70326. */
  70327. name: string;
  70328. /**
  70329. * Defines the location of the file to load
  70330. */
  70331. url: string;
  70332. /**
  70333. * Defines the desired size (the more it increases the longer the generation will be)
  70334. */
  70335. size: number;
  70336. /**
  70337. * Defines if mipmaps should not be generated (default is false)
  70338. */
  70339. noMipmap: boolean;
  70340. /**
  70341. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70342. */
  70343. generateHarmonics: boolean;
  70344. /**
  70345. * 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)
  70346. */
  70347. gammaSpace: boolean;
  70348. /**
  70349. * Internal Use Only
  70350. */
  70351. reserved: boolean;
  70352. /**
  70353. * Gets the loaded texture
  70354. */
  70355. texture: HDRCubeTexture;
  70356. /**
  70357. * Callback called when the task is successful
  70358. */
  70359. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  70360. /**
  70361. * Callback called when the task is successful
  70362. */
  70363. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  70364. /**
  70365. * Creates a new HDRCubeTextureAssetTask object
  70366. * @param name defines the name of the task
  70367. * @param url defines the location of the file to load
  70368. * @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.
  70369. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70370. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70371. * @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)
  70372. * @param reserved Internal use only
  70373. */
  70374. constructor(
  70375. /**
  70376. * Defines the name of the task
  70377. */
  70378. name: string,
  70379. /**
  70380. * Defines the location of the file to load
  70381. */
  70382. url: string,
  70383. /**
  70384. * Defines the desired size (the more it increases the longer the generation will be)
  70385. */
  70386. size: number,
  70387. /**
  70388. * Defines if mipmaps should not be generated (default is false)
  70389. */
  70390. noMipmap?: boolean,
  70391. /**
  70392. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70393. */
  70394. generateHarmonics?: boolean,
  70395. /**
  70396. * 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)
  70397. */
  70398. gammaSpace?: boolean,
  70399. /**
  70400. * Internal Use Only
  70401. */
  70402. reserved?: boolean);
  70403. /**
  70404. * Execute the current task
  70405. * @param scene defines the scene where you want your assets to be loaded
  70406. * @param onSuccess is a callback called when the task is successfully executed
  70407. * @param onError is a callback called if an error occurs
  70408. */
  70409. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70410. }
  70411. /**
  70412. * Define a task used by AssetsManager to load Equirectangular cube textures
  70413. */
  70414. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  70415. /**
  70416. * Defines the name of the task
  70417. */
  70418. name: string;
  70419. /**
  70420. * Defines the location of the file to load
  70421. */
  70422. url: string;
  70423. /**
  70424. * Defines the desired size (the more it increases the longer the generation will be)
  70425. */
  70426. size: number;
  70427. /**
  70428. * Defines if mipmaps should not be generated (default is false)
  70429. */
  70430. noMipmap: boolean;
  70431. /**
  70432. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70433. * but the standard material would require them in Gamma space) (default is true)
  70434. */
  70435. gammaSpace: boolean;
  70436. /**
  70437. * Gets the loaded texture
  70438. */
  70439. texture: EquiRectangularCubeTexture;
  70440. /**
  70441. * Callback called when the task is successful
  70442. */
  70443. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  70444. /**
  70445. * Callback called when the task is successful
  70446. */
  70447. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  70448. /**
  70449. * Creates a new EquiRectangularCubeTextureAssetTask object
  70450. * @param name defines the name of the task
  70451. * @param url defines the location of the file to load
  70452. * @param size defines the desired size (the more it increases the longer the generation will be)
  70453. * If the size is omitted this implies you are using a preprocessed cubemap.
  70454. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70455. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  70456. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  70457. * (default is true)
  70458. */
  70459. constructor(
  70460. /**
  70461. * Defines the name of the task
  70462. */
  70463. name: string,
  70464. /**
  70465. * Defines the location of the file to load
  70466. */
  70467. url: string,
  70468. /**
  70469. * Defines the desired size (the more it increases the longer the generation will be)
  70470. */
  70471. size: number,
  70472. /**
  70473. * Defines if mipmaps should not be generated (default is false)
  70474. */
  70475. noMipmap?: boolean,
  70476. /**
  70477. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70478. * but the standard material would require them in Gamma space) (default is true)
  70479. */
  70480. gammaSpace?: boolean);
  70481. /**
  70482. * Execute the current task
  70483. * @param scene defines the scene where you want your assets to be loaded
  70484. * @param onSuccess is a callback called when the task is successfully executed
  70485. * @param onError is a callback called if an error occurs
  70486. */
  70487. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70488. }
  70489. /**
  70490. * This class can be used to easily import assets into a scene
  70491. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  70492. */
  70493. export class AssetsManager {
  70494. private _scene;
  70495. private _isLoading;
  70496. protected _tasks: AbstractAssetTask[];
  70497. protected _waitingTasksCount: number;
  70498. protected _totalTasksCount: number;
  70499. /**
  70500. * Callback called when all tasks are processed
  70501. */
  70502. onFinish: (tasks: AbstractAssetTask[]) => void;
  70503. /**
  70504. * Callback called when a task is successful
  70505. */
  70506. onTaskSuccess: (task: AbstractAssetTask) => void;
  70507. /**
  70508. * Callback called when a task had an error
  70509. */
  70510. onTaskError: (task: AbstractAssetTask) => void;
  70511. /**
  70512. * Callback called when a task is done (whatever the result is)
  70513. */
  70514. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  70515. /**
  70516. * Observable called when all tasks are processed
  70517. */
  70518. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  70519. /**
  70520. * Observable called when a task had an error
  70521. */
  70522. onTaskErrorObservable: Observable<AbstractAssetTask>;
  70523. /**
  70524. * Observable called when all tasks were executed
  70525. */
  70526. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  70527. /**
  70528. * Observable called when a task is done (whatever the result is)
  70529. */
  70530. onProgressObservable: Observable<IAssetsProgressEvent>;
  70531. /**
  70532. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  70533. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  70534. */
  70535. useDefaultLoadingScreen: boolean;
  70536. /**
  70537. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  70538. * when all assets have been downloaded.
  70539. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  70540. */
  70541. autoHideLoadingUI: boolean;
  70542. /**
  70543. * Creates a new AssetsManager
  70544. * @param scene defines the scene to work on
  70545. */
  70546. constructor(scene: Scene);
  70547. /**
  70548. * Add a MeshAssetTask to the list of active tasks
  70549. * @param taskName defines the name of the new task
  70550. * @param meshesNames defines the name of meshes to load
  70551. * @param rootUrl defines the root url to use to locate files
  70552. * @param sceneFilename defines the filename of the scene file
  70553. * @returns a new MeshAssetTask object
  70554. */
  70555. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  70556. /**
  70557. * Add a TextFileAssetTask to the list of active tasks
  70558. * @param taskName defines the name of the new task
  70559. * @param url defines the url of the file to load
  70560. * @returns a new TextFileAssetTask object
  70561. */
  70562. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  70563. /**
  70564. * Add a BinaryFileAssetTask to the list of active tasks
  70565. * @param taskName defines the name of the new task
  70566. * @param url defines the url of the file to load
  70567. * @returns a new BinaryFileAssetTask object
  70568. */
  70569. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  70570. /**
  70571. * Add a ImageAssetTask to the list of active tasks
  70572. * @param taskName defines the name of the new task
  70573. * @param url defines the url of the file to load
  70574. * @returns a new ImageAssetTask object
  70575. */
  70576. addImageTask(taskName: string, url: string): ImageAssetTask;
  70577. /**
  70578. * Add a TextureAssetTask to the list of active tasks
  70579. * @param taskName defines the name of the new task
  70580. * @param url defines the url of the file to load
  70581. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70582. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  70583. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  70584. * @returns a new TextureAssetTask object
  70585. */
  70586. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  70587. /**
  70588. * Add a CubeTextureAssetTask to the list of active tasks
  70589. * @param taskName defines the name of the new task
  70590. * @param url defines the url of the file to load
  70591. * @param extensions defines the extension to use to load the cube map (can be null)
  70592. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70593. * @param files defines the list of files to load (can be null)
  70594. * @returns a new CubeTextureAssetTask object
  70595. */
  70596. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  70597. /**
  70598. *
  70599. * Add a HDRCubeTextureAssetTask to the list of active tasks
  70600. * @param taskName defines the name of the new task
  70601. * @param url defines the url of the file to load
  70602. * @param size defines the size you want for the cubemap (can be null)
  70603. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70604. * @param generateHarmonics defines if you want to automatically generate (true by default)
  70605. * @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)
  70606. * @param reserved Internal use only
  70607. * @returns a new HDRCubeTextureAssetTask object
  70608. */
  70609. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  70610. /**
  70611. *
  70612. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  70613. * @param taskName defines the name of the new task
  70614. * @param url defines the url of the file to load
  70615. * @param size defines the size you want for the cubemap (can be null)
  70616. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70617. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  70618. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  70619. * @returns a new EquiRectangularCubeTextureAssetTask object
  70620. */
  70621. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  70622. /**
  70623. * Remove a task from the assets manager.
  70624. * @param task the task to remove
  70625. */
  70626. removeTask(task: AbstractAssetTask): void;
  70627. private _decreaseWaitingTasksCount;
  70628. private _runTask;
  70629. /**
  70630. * Reset the AssetsManager and remove all tasks
  70631. * @return the current instance of the AssetsManager
  70632. */
  70633. reset(): AssetsManager;
  70634. /**
  70635. * Start the loading process
  70636. * @return the current instance of the AssetsManager
  70637. */
  70638. load(): AssetsManager;
  70639. /**
  70640. * Start the loading process as an async operation
  70641. * @return a promise returning the list of failed tasks
  70642. */
  70643. loadAsync(): Promise<void>;
  70644. }
  70645. }
  70646. declare module BABYLON {
  70647. /**
  70648. * Wrapper class for promise with external resolve and reject.
  70649. */
  70650. export class Deferred<T> {
  70651. /**
  70652. * The promise associated with this deferred object.
  70653. */
  70654. readonly promise: Promise<T>;
  70655. private _resolve;
  70656. private _reject;
  70657. /**
  70658. * The resolve method of the promise associated with this deferred object.
  70659. */
  70660. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  70661. /**
  70662. * The reject method of the promise associated with this deferred object.
  70663. */
  70664. get reject(): (reason?: any) => void;
  70665. /**
  70666. * Constructor for this deferred object.
  70667. */
  70668. constructor();
  70669. }
  70670. }
  70671. declare module BABYLON {
  70672. /**
  70673. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  70674. */
  70675. export class MeshExploder {
  70676. private _centerMesh;
  70677. private _meshes;
  70678. private _meshesOrigins;
  70679. private _toCenterVectors;
  70680. private _scaledDirection;
  70681. private _newPosition;
  70682. private _centerPosition;
  70683. /**
  70684. * Explodes meshes from a center mesh.
  70685. * @param meshes The meshes to explode.
  70686. * @param centerMesh The mesh to be center of explosion.
  70687. */
  70688. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  70689. private _setCenterMesh;
  70690. /**
  70691. * Get class name
  70692. * @returns "MeshExploder"
  70693. */
  70694. getClassName(): string;
  70695. /**
  70696. * "Exploded meshes"
  70697. * @returns Array of meshes with the centerMesh at index 0.
  70698. */
  70699. getMeshes(): Array<Mesh>;
  70700. /**
  70701. * Explodes meshes giving a specific direction
  70702. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  70703. */
  70704. explode(direction?: number): void;
  70705. }
  70706. }
  70707. declare module BABYLON {
  70708. /**
  70709. * Class used to help managing file picking and drag'n'drop
  70710. */
  70711. export class FilesInput {
  70712. /**
  70713. * List of files ready to be loaded
  70714. */
  70715. static get FilesToLoad(): {
  70716. [key: string]: File;
  70717. };
  70718. /**
  70719. * Callback called when a file is processed
  70720. */
  70721. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  70722. private _engine;
  70723. private _currentScene;
  70724. private _sceneLoadedCallback;
  70725. private _progressCallback;
  70726. private _additionalRenderLoopLogicCallback;
  70727. private _textureLoadingCallback;
  70728. private _startingProcessingFilesCallback;
  70729. private _onReloadCallback;
  70730. private _errorCallback;
  70731. private _elementToMonitor;
  70732. private _sceneFileToLoad;
  70733. private _filesToLoad;
  70734. /**
  70735. * Creates a new FilesInput
  70736. * @param engine defines the rendering engine
  70737. * @param scene defines the hosting scene
  70738. * @param sceneLoadedCallback callback called when scene is loaded
  70739. * @param progressCallback callback called to track progress
  70740. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  70741. * @param textureLoadingCallback callback called when a texture is loading
  70742. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  70743. * @param onReloadCallback callback called when a reload is requested
  70744. * @param errorCallback callback call if an error occurs
  70745. */
  70746. 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);
  70747. private _dragEnterHandler;
  70748. private _dragOverHandler;
  70749. private _dropHandler;
  70750. /**
  70751. * Calls this function to listen to drag'n'drop events on a specific DOM element
  70752. * @param elementToMonitor defines the DOM element to track
  70753. */
  70754. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  70755. /**
  70756. * Release all associated resources
  70757. */
  70758. dispose(): void;
  70759. private renderFunction;
  70760. private drag;
  70761. private drop;
  70762. private _traverseFolder;
  70763. private _processFiles;
  70764. /**
  70765. * Load files from a drop event
  70766. * @param event defines the drop event to use as source
  70767. */
  70768. loadFiles(event: any): void;
  70769. private _processReload;
  70770. /**
  70771. * Reload the current scene from the loaded files
  70772. */
  70773. reload(): void;
  70774. }
  70775. }
  70776. declare module BABYLON {
  70777. /**
  70778. * Defines the root class used to create scene optimization to use with SceneOptimizer
  70779. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70780. */
  70781. export class SceneOptimization {
  70782. /**
  70783. * Defines the priority of this optimization (0 by default which means first in the list)
  70784. */
  70785. priority: number;
  70786. /**
  70787. * Gets a string describing the action executed by the current optimization
  70788. * @returns description string
  70789. */
  70790. getDescription(): string;
  70791. /**
  70792. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70793. * @param scene defines the current scene where to apply this optimization
  70794. * @param optimizer defines the current optimizer
  70795. * @returns true if everything that can be done was applied
  70796. */
  70797. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70798. /**
  70799. * Creates the SceneOptimization object
  70800. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70801. * @param desc defines the description associated with the optimization
  70802. */
  70803. constructor(
  70804. /**
  70805. * Defines the priority of this optimization (0 by default which means first in the list)
  70806. */
  70807. priority?: number);
  70808. }
  70809. /**
  70810. * Defines an optimization used to reduce the size of render target textures
  70811. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70812. */
  70813. export class TextureOptimization extends SceneOptimization {
  70814. /**
  70815. * Defines the priority of this optimization (0 by default which means first in the list)
  70816. */
  70817. priority: number;
  70818. /**
  70819. * 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
  70820. */
  70821. maximumSize: number;
  70822. /**
  70823. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70824. */
  70825. step: number;
  70826. /**
  70827. * Gets a string describing the action executed by the current optimization
  70828. * @returns description string
  70829. */
  70830. getDescription(): string;
  70831. /**
  70832. * Creates the TextureOptimization object
  70833. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70834. * @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
  70835. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70836. */
  70837. constructor(
  70838. /**
  70839. * Defines the priority of this optimization (0 by default which means first in the list)
  70840. */
  70841. priority?: number,
  70842. /**
  70843. * 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
  70844. */
  70845. maximumSize?: number,
  70846. /**
  70847. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70848. */
  70849. step?: number);
  70850. /**
  70851. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70852. * @param scene defines the current scene where to apply this optimization
  70853. * @param optimizer defines the current optimizer
  70854. * @returns true if everything that can be done was applied
  70855. */
  70856. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70857. }
  70858. /**
  70859. * Defines an optimization used to increase or decrease the rendering resolution
  70860. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70861. */
  70862. export class HardwareScalingOptimization extends SceneOptimization {
  70863. /**
  70864. * Defines the priority of this optimization (0 by default which means first in the list)
  70865. */
  70866. priority: number;
  70867. /**
  70868. * Defines the maximum scale to use (2 by default)
  70869. */
  70870. maximumScale: number;
  70871. /**
  70872. * Defines the step to use between two passes (0.5 by default)
  70873. */
  70874. step: number;
  70875. private _currentScale;
  70876. private _directionOffset;
  70877. /**
  70878. * Gets a string describing the action executed by the current optimization
  70879. * @return description string
  70880. */
  70881. getDescription(): string;
  70882. /**
  70883. * Creates the HardwareScalingOptimization object
  70884. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70885. * @param maximumScale defines the maximum scale to use (2 by default)
  70886. * @param step defines the step to use between two passes (0.5 by default)
  70887. */
  70888. constructor(
  70889. /**
  70890. * Defines the priority of this optimization (0 by default which means first in the list)
  70891. */
  70892. priority?: number,
  70893. /**
  70894. * Defines the maximum scale to use (2 by default)
  70895. */
  70896. maximumScale?: number,
  70897. /**
  70898. * Defines the step to use between two passes (0.5 by default)
  70899. */
  70900. step?: number);
  70901. /**
  70902. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70903. * @param scene defines the current scene where to apply this optimization
  70904. * @param optimizer defines the current optimizer
  70905. * @returns true if everything that can be done was applied
  70906. */
  70907. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70908. }
  70909. /**
  70910. * Defines an optimization used to remove shadows
  70911. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70912. */
  70913. export class ShadowsOptimization extends SceneOptimization {
  70914. /**
  70915. * Gets a string describing the action executed by the current optimization
  70916. * @return description string
  70917. */
  70918. getDescription(): string;
  70919. /**
  70920. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70921. * @param scene defines the current scene where to apply this optimization
  70922. * @param optimizer defines the current optimizer
  70923. * @returns true if everything that can be done was applied
  70924. */
  70925. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70926. }
  70927. /**
  70928. * Defines an optimization used to turn post-processes off
  70929. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70930. */
  70931. export class PostProcessesOptimization extends SceneOptimization {
  70932. /**
  70933. * Gets a string describing the action executed by the current optimization
  70934. * @return description string
  70935. */
  70936. getDescription(): string;
  70937. /**
  70938. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70939. * @param scene defines the current scene where to apply this optimization
  70940. * @param optimizer defines the current optimizer
  70941. * @returns true if everything that can be done was applied
  70942. */
  70943. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70944. }
  70945. /**
  70946. * Defines an optimization used to turn lens flares off
  70947. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70948. */
  70949. export class LensFlaresOptimization extends SceneOptimization {
  70950. /**
  70951. * Gets a string describing the action executed by the current optimization
  70952. * @return description string
  70953. */
  70954. getDescription(): string;
  70955. /**
  70956. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70957. * @param scene defines the current scene where to apply this optimization
  70958. * @param optimizer defines the current optimizer
  70959. * @returns true if everything that can be done was applied
  70960. */
  70961. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70962. }
  70963. /**
  70964. * Defines an optimization based on user defined callback.
  70965. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70966. */
  70967. export class CustomOptimization extends SceneOptimization {
  70968. /**
  70969. * Callback called to apply the custom optimization.
  70970. */
  70971. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  70972. /**
  70973. * Callback called to get custom description
  70974. */
  70975. onGetDescription: () => string;
  70976. /**
  70977. * Gets a string describing the action executed by the current optimization
  70978. * @returns description string
  70979. */
  70980. getDescription(): string;
  70981. /**
  70982. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70983. * @param scene defines the current scene where to apply this optimization
  70984. * @param optimizer defines the current optimizer
  70985. * @returns true if everything that can be done was applied
  70986. */
  70987. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70988. }
  70989. /**
  70990. * Defines an optimization used to turn particles off
  70991. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70992. */
  70993. export class ParticlesOptimization extends SceneOptimization {
  70994. /**
  70995. * Gets a string describing the action executed by the current optimization
  70996. * @return description string
  70997. */
  70998. getDescription(): string;
  70999. /**
  71000. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71001. * @param scene defines the current scene where to apply this optimization
  71002. * @param optimizer defines the current optimizer
  71003. * @returns true if everything that can be done was applied
  71004. */
  71005. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71006. }
  71007. /**
  71008. * Defines an optimization used to turn render targets off
  71009. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71010. */
  71011. export class RenderTargetsOptimization extends SceneOptimization {
  71012. /**
  71013. * Gets a string describing the action executed by the current optimization
  71014. * @return description string
  71015. */
  71016. getDescription(): string;
  71017. /**
  71018. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71019. * @param scene defines the current scene where to apply this optimization
  71020. * @param optimizer defines the current optimizer
  71021. * @returns true if everything that can be done was applied
  71022. */
  71023. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71024. }
  71025. /**
  71026. * Defines an optimization used to merge meshes with compatible materials
  71027. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71028. */
  71029. export class MergeMeshesOptimization extends SceneOptimization {
  71030. private static _UpdateSelectionTree;
  71031. /**
  71032. * Gets or sets a boolean which defines if optimization octree has to be updated
  71033. */
  71034. static get UpdateSelectionTree(): boolean;
  71035. /**
  71036. * Gets or sets a boolean which defines if optimization octree has to be updated
  71037. */
  71038. static set UpdateSelectionTree(value: boolean);
  71039. /**
  71040. * Gets a string describing the action executed by the current optimization
  71041. * @return description string
  71042. */
  71043. getDescription(): string;
  71044. private _canBeMerged;
  71045. /**
  71046. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71047. * @param scene defines the current scene where to apply this optimization
  71048. * @param optimizer defines the current optimizer
  71049. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71050. * @returns true if everything that can be done was applied
  71051. */
  71052. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71053. }
  71054. /**
  71055. * Defines a list of options used by SceneOptimizer
  71056. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71057. */
  71058. export class SceneOptimizerOptions {
  71059. /**
  71060. * Defines the target frame rate to reach (60 by default)
  71061. */
  71062. targetFrameRate: number;
  71063. /**
  71064. * Defines the interval between two checkes (2000ms by default)
  71065. */
  71066. trackerDuration: number;
  71067. /**
  71068. * Gets the list of optimizations to apply
  71069. */
  71070. optimizations: SceneOptimization[];
  71071. /**
  71072. * Creates a new list of options used by SceneOptimizer
  71073. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71074. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71075. */
  71076. constructor(
  71077. /**
  71078. * Defines the target frame rate to reach (60 by default)
  71079. */
  71080. targetFrameRate?: number,
  71081. /**
  71082. * Defines the interval between two checkes (2000ms by default)
  71083. */
  71084. trackerDuration?: number);
  71085. /**
  71086. * Add a new optimization
  71087. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71088. * @returns the current SceneOptimizerOptions
  71089. */
  71090. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71091. /**
  71092. * Add a new custom optimization
  71093. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71094. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71095. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71096. * @returns the current SceneOptimizerOptions
  71097. */
  71098. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71099. /**
  71100. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71101. * @param targetFrameRate defines the target frame rate (60 by default)
  71102. * @returns a SceneOptimizerOptions object
  71103. */
  71104. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71105. /**
  71106. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71107. * @param targetFrameRate defines the target frame rate (60 by default)
  71108. * @returns a SceneOptimizerOptions object
  71109. */
  71110. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71111. /**
  71112. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71113. * @param targetFrameRate defines the target frame rate (60 by default)
  71114. * @returns a SceneOptimizerOptions object
  71115. */
  71116. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71117. }
  71118. /**
  71119. * Class used to run optimizations in order to reach a target frame rate
  71120. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71121. */
  71122. export class SceneOptimizer implements IDisposable {
  71123. private _isRunning;
  71124. private _options;
  71125. private _scene;
  71126. private _currentPriorityLevel;
  71127. private _targetFrameRate;
  71128. private _trackerDuration;
  71129. private _currentFrameRate;
  71130. private _sceneDisposeObserver;
  71131. private _improvementMode;
  71132. /**
  71133. * Defines an observable called when the optimizer reaches the target frame rate
  71134. */
  71135. onSuccessObservable: Observable<SceneOptimizer>;
  71136. /**
  71137. * Defines an observable called when the optimizer enables an optimization
  71138. */
  71139. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71140. /**
  71141. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71142. */
  71143. onFailureObservable: Observable<SceneOptimizer>;
  71144. /**
  71145. * Gets a boolean indicating if the optimizer is in improvement mode
  71146. */
  71147. get isInImprovementMode(): boolean;
  71148. /**
  71149. * Gets the current priority level (0 at start)
  71150. */
  71151. get currentPriorityLevel(): number;
  71152. /**
  71153. * Gets the current frame rate checked by the SceneOptimizer
  71154. */
  71155. get currentFrameRate(): number;
  71156. /**
  71157. * Gets or sets the current target frame rate (60 by default)
  71158. */
  71159. get targetFrameRate(): number;
  71160. /**
  71161. * Gets or sets the current target frame rate (60 by default)
  71162. */
  71163. set targetFrameRate(value: number);
  71164. /**
  71165. * Gets or sets the current interval between two checks (every 2000ms by default)
  71166. */
  71167. get trackerDuration(): number;
  71168. /**
  71169. * Gets or sets the current interval between two checks (every 2000ms by default)
  71170. */
  71171. set trackerDuration(value: number);
  71172. /**
  71173. * Gets the list of active optimizations
  71174. */
  71175. get optimizations(): SceneOptimization[];
  71176. /**
  71177. * Creates a new SceneOptimizer
  71178. * @param scene defines the scene to work on
  71179. * @param options defines the options to use with the SceneOptimizer
  71180. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71181. * @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)
  71182. */
  71183. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71184. /**
  71185. * Stops the current optimizer
  71186. */
  71187. stop(): void;
  71188. /**
  71189. * Reset the optimizer to initial step (current priority level = 0)
  71190. */
  71191. reset(): void;
  71192. /**
  71193. * Start the optimizer. By default it will try to reach a specific framerate
  71194. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  71195. */
  71196. start(): void;
  71197. private _checkCurrentState;
  71198. /**
  71199. * Release all resources
  71200. */
  71201. dispose(): void;
  71202. /**
  71203. * Helper function to create a SceneOptimizer with one single line of code
  71204. * @param scene defines the scene to work on
  71205. * @param options defines the options to use with the SceneOptimizer
  71206. * @param onSuccess defines a callback to call on success
  71207. * @param onFailure defines a callback to call on failure
  71208. * @returns the new SceneOptimizer object
  71209. */
  71210. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  71211. }
  71212. }
  71213. declare module BABYLON {
  71214. /**
  71215. * Class used to serialize a scene into a string
  71216. */
  71217. export class SceneSerializer {
  71218. /**
  71219. * Clear cache used by a previous serialization
  71220. */
  71221. static ClearCache(): void;
  71222. /**
  71223. * Serialize a scene into a JSON compatible object
  71224. * @param scene defines the scene to serialize
  71225. * @returns a JSON compatible object
  71226. */
  71227. static Serialize(scene: Scene): any;
  71228. /**
  71229. * Serialize a mesh into a JSON compatible object
  71230. * @param toSerialize defines the mesh to serialize
  71231. * @param withParents defines if parents must be serialized as well
  71232. * @param withChildren defines if children must be serialized as well
  71233. * @returns a JSON compatible object
  71234. */
  71235. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  71236. }
  71237. }
  71238. declare module BABYLON {
  71239. /**
  71240. * Class used to host texture specific utilities
  71241. */
  71242. export class TextureTools {
  71243. /**
  71244. * Uses the GPU to create a copy texture rescaled at a given size
  71245. * @param texture Texture to copy from
  71246. * @param width defines the desired width
  71247. * @param height defines the desired height
  71248. * @param useBilinearMode defines if bilinear mode has to be used
  71249. * @return the generated texture
  71250. */
  71251. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  71252. }
  71253. }
  71254. declare module BABYLON {
  71255. /**
  71256. * This represents the different options available for the video capture.
  71257. */
  71258. export interface VideoRecorderOptions {
  71259. /** Defines the mime type of the video. */
  71260. mimeType: string;
  71261. /** Defines the FPS the video should be recorded at. */
  71262. fps: number;
  71263. /** Defines the chunk size for the recording data. */
  71264. recordChunckSize: number;
  71265. /** The audio tracks to attach to the recording. */
  71266. audioTracks?: MediaStreamTrack[];
  71267. }
  71268. /**
  71269. * This can help with recording videos from BabylonJS.
  71270. * This is based on the available WebRTC functionalities of the browser.
  71271. *
  71272. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  71273. */
  71274. export class VideoRecorder {
  71275. private static readonly _defaultOptions;
  71276. /**
  71277. * Returns whether or not the VideoRecorder is available in your browser.
  71278. * @param engine Defines the Babylon Engine.
  71279. * @returns true if supported otherwise false.
  71280. */
  71281. static IsSupported(engine: Engine): boolean;
  71282. private readonly _options;
  71283. private _canvas;
  71284. private _mediaRecorder;
  71285. private _recordedChunks;
  71286. private _fileName;
  71287. private _resolve;
  71288. private _reject;
  71289. /**
  71290. * True when a recording is already in progress.
  71291. */
  71292. get isRecording(): boolean;
  71293. /**
  71294. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  71295. * @param engine Defines the BabylonJS Engine you wish to record.
  71296. * @param options Defines options that can be used to customize the capture.
  71297. */
  71298. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  71299. /**
  71300. * Stops the current recording before the default capture timeout passed in the startRecording function.
  71301. */
  71302. stopRecording(): void;
  71303. /**
  71304. * Starts recording the canvas for a max duration specified in parameters.
  71305. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  71306. * If null no automatic download will start and you can rely on the promise to get the data back.
  71307. * @param maxDuration Defines the maximum recording time in seconds.
  71308. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  71309. * @return A promise callback at the end of the recording with the video data in Blob.
  71310. */
  71311. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  71312. /**
  71313. * Releases internal resources used during the recording.
  71314. */
  71315. dispose(): void;
  71316. private _handleDataAvailable;
  71317. private _handleError;
  71318. private _handleStop;
  71319. }
  71320. }
  71321. declare module BABYLON {
  71322. /**
  71323. * Class containing a set of static utilities functions for screenshots
  71324. */
  71325. export class ScreenshotTools {
  71326. /**
  71327. * Captures a screenshot of the current rendering
  71328. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71329. * @param engine defines the rendering engine
  71330. * @param camera defines the source camera
  71331. * @param size This parameter can be set to a single number or to an object with the
  71332. * following (optional) properties: precision, width, height. If a single number is passed,
  71333. * it will be used for both width and height. If an object is passed, the screenshot size
  71334. * will be derived from the parameters. The precision property is a multiplier allowing
  71335. * rendering at a higher or lower resolution
  71336. * @param successCallback defines the callback receives a single parameter which contains the
  71337. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71338. * src parameter of an <img> to display it
  71339. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71340. * Check your browser for supported MIME types
  71341. */
  71342. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  71343. /**
  71344. * Captures a screenshot of the current rendering
  71345. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71346. * @param engine defines the rendering engine
  71347. * @param camera defines the source camera
  71348. * @param size This parameter can be set to a single number or to an object with the
  71349. * following (optional) properties: precision, width, height. If a single number is passed,
  71350. * it will be used for both width and height. If an object is passed, the screenshot size
  71351. * will be derived from the parameters. The precision property is a multiplier allowing
  71352. * rendering at a higher or lower resolution
  71353. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71354. * Check your browser for supported MIME types
  71355. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71356. * to the src parameter of an <img> to display it
  71357. */
  71358. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  71359. /**
  71360. * Generates an image screenshot from the specified camera.
  71361. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71362. * @param engine The engine to use for rendering
  71363. * @param camera The camera to use for rendering
  71364. * @param size This parameter can be set to a single number or to an object with the
  71365. * following (optional) properties: precision, width, height. If a single number is passed,
  71366. * it will be used for both width and height. If an object is passed, the screenshot size
  71367. * will be derived from the parameters. The precision property is a multiplier allowing
  71368. * rendering at a higher or lower resolution
  71369. * @param successCallback The callback receives a single parameter which contains the
  71370. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71371. * src parameter of an <img> to display it
  71372. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71373. * Check your browser for supported MIME types
  71374. * @param samples Texture samples (default: 1)
  71375. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71376. * @param fileName A name for for the downloaded file.
  71377. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71378. */
  71379. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  71380. /**
  71381. * Generates an image screenshot from the specified camera.
  71382. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71383. * @param engine The engine to use for rendering
  71384. * @param camera The camera to use for rendering
  71385. * @param size This parameter can be set to a single number or to an object with the
  71386. * following (optional) properties: precision, width, height. If a single number is passed,
  71387. * it will be used for both width and height. If an object is passed, the screenshot size
  71388. * will be derived from the parameters. The precision property is a multiplier allowing
  71389. * rendering at a higher or lower resolution
  71390. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71391. * Check your browser for supported MIME types
  71392. * @param samples Texture samples (default: 1)
  71393. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71394. * @param fileName A name for for the downloaded file.
  71395. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71396. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71397. * to the src parameter of an <img> to display it
  71398. */
  71399. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  71400. /**
  71401. * Gets height and width for screenshot size
  71402. * @private
  71403. */
  71404. private static _getScreenshotSize;
  71405. }
  71406. }
  71407. declare module BABYLON {
  71408. /**
  71409. * Interface for a data buffer
  71410. */
  71411. export interface IDataBuffer {
  71412. /**
  71413. * Reads bytes from the data buffer.
  71414. * @param byteOffset The byte offset to read
  71415. * @param byteLength The byte length to read
  71416. * @returns A promise that resolves when the bytes are read
  71417. */
  71418. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  71419. /**
  71420. * The byte length of the buffer.
  71421. */
  71422. readonly byteLength: number;
  71423. }
  71424. /**
  71425. * Utility class for reading from a data buffer
  71426. */
  71427. export class DataReader {
  71428. /**
  71429. * The data buffer associated with this data reader.
  71430. */
  71431. readonly buffer: IDataBuffer;
  71432. /**
  71433. * The current byte offset from the beginning of the data buffer.
  71434. */
  71435. byteOffset: number;
  71436. private _dataView;
  71437. private _dataByteOffset;
  71438. /**
  71439. * Constructor
  71440. * @param buffer The buffer to read
  71441. */
  71442. constructor(buffer: IDataBuffer);
  71443. /**
  71444. * Loads the given byte length.
  71445. * @param byteLength The byte length to load
  71446. * @returns A promise that resolves when the load is complete
  71447. */
  71448. loadAsync(byteLength: number): Promise<void>;
  71449. /**
  71450. * Read a unsigned 32-bit integer from the currently loaded data range.
  71451. * @returns The 32-bit integer read
  71452. */
  71453. readUint32(): number;
  71454. /**
  71455. * Read a byte array from the currently loaded data range.
  71456. * @param byteLength The byte length to read
  71457. * @returns The byte array read
  71458. */
  71459. readUint8Array(byteLength: number): Uint8Array;
  71460. /**
  71461. * Read a string from the currently loaded data range.
  71462. * @param byteLength The byte length to read
  71463. * @returns The string read
  71464. */
  71465. readString(byteLength: number): string;
  71466. /**
  71467. * Skips the given byte length the currently loaded data range.
  71468. * @param byteLength The byte length to skip
  71469. */
  71470. skipBytes(byteLength: number): void;
  71471. }
  71472. }
  71473. declare module BABYLON {
  71474. /**
  71475. * Class for storing data to local storage if available or in-memory storage otherwise
  71476. */
  71477. export class DataStorage {
  71478. private static _Storage;
  71479. private static _GetStorage;
  71480. /**
  71481. * Reads a string from the data storage
  71482. * @param key The key to read
  71483. * @param defaultValue The value if the key doesn't exist
  71484. * @returns The string value
  71485. */
  71486. static ReadString(key: string, defaultValue: string): string;
  71487. /**
  71488. * Writes a string to the data storage
  71489. * @param key The key to write
  71490. * @param value The value to write
  71491. */
  71492. static WriteString(key: string, value: string): void;
  71493. /**
  71494. * Reads a boolean from the data storage
  71495. * @param key The key to read
  71496. * @param defaultValue The value if the key doesn't exist
  71497. * @returns The boolean value
  71498. */
  71499. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  71500. /**
  71501. * Writes a boolean to the data storage
  71502. * @param key The key to write
  71503. * @param value The value to write
  71504. */
  71505. static WriteBoolean(key: string, value: boolean): void;
  71506. /**
  71507. * Reads a number from the data storage
  71508. * @param key The key to read
  71509. * @param defaultValue The value if the key doesn't exist
  71510. * @returns The number value
  71511. */
  71512. static ReadNumber(key: string, defaultValue: number): number;
  71513. /**
  71514. * Writes a number to the data storage
  71515. * @param key The key to write
  71516. * @param value The value to write
  71517. */
  71518. static WriteNumber(key: string, value: number): void;
  71519. }
  71520. }
  71521. declare module BABYLON {
  71522. /**
  71523. * Options used for hit testing
  71524. */
  71525. export interface IWebXRLegacyHitTestOptions {
  71526. /**
  71527. * Only test when user interacted with the scene. Default - hit test every frame
  71528. */
  71529. testOnPointerDownOnly?: boolean;
  71530. /**
  71531. * The node to use to transform the local results to world coordinates
  71532. */
  71533. worldParentNode?: TransformNode;
  71534. }
  71535. /**
  71536. * Interface defining the babylon result of raycasting/hit-test
  71537. */
  71538. export interface IWebXRLegacyHitResult {
  71539. /**
  71540. * Transformation matrix that can be applied to a node that will put it in the hit point location
  71541. */
  71542. transformationMatrix: Matrix;
  71543. /**
  71544. * The native hit test result
  71545. */
  71546. xrHitResult: XRHitResult | XRHitTestResult;
  71547. }
  71548. /**
  71549. * The currently-working hit-test module.
  71550. * Hit test (or Ray-casting) is used to interact with the real world.
  71551. * For further information read here - https://github.com/immersive-web/hit-test
  71552. */
  71553. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  71554. /**
  71555. * options to use when constructing this feature
  71556. */
  71557. readonly options: IWebXRLegacyHitTestOptions;
  71558. private _direction;
  71559. private _mat;
  71560. private _onSelectEnabled;
  71561. private _origin;
  71562. /**
  71563. * The module's name
  71564. */
  71565. static readonly Name: string;
  71566. /**
  71567. * The (Babylon) version of this module.
  71568. * This is an integer representing the implementation version.
  71569. * This number does not correspond to the WebXR specs version
  71570. */
  71571. static readonly Version: number;
  71572. /**
  71573. * Populated with the last native XR Hit Results
  71574. */
  71575. lastNativeXRHitResults: XRHitResult[];
  71576. /**
  71577. * Triggered when new babylon (transformed) hit test results are available
  71578. */
  71579. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  71580. /**
  71581. * Creates a new instance of the (legacy version) hit test feature
  71582. * @param _xrSessionManager an instance of WebXRSessionManager
  71583. * @param options options to use when constructing this feature
  71584. */
  71585. constructor(_xrSessionManager: WebXRSessionManager,
  71586. /**
  71587. * options to use when constructing this feature
  71588. */
  71589. options?: IWebXRLegacyHitTestOptions);
  71590. /**
  71591. * execute a hit test with an XR Ray
  71592. *
  71593. * @param xrSession a native xrSession that will execute this hit test
  71594. * @param xrRay the ray (position and direction) to use for ray-casting
  71595. * @param referenceSpace native XR reference space to use for the hit-test
  71596. * @param filter filter function that will filter the results
  71597. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  71598. */
  71599. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  71600. /**
  71601. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  71602. * @param event the (select) event to use to select with
  71603. * @param referenceSpace the reference space to use for this hit test
  71604. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  71605. */
  71606. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  71607. /**
  71608. * attach this feature
  71609. * Will usually be called by the features manager
  71610. *
  71611. * @returns true if successful.
  71612. */
  71613. attach(): boolean;
  71614. /**
  71615. * detach this feature.
  71616. * Will usually be called by the features manager
  71617. *
  71618. * @returns true if successful.
  71619. */
  71620. detach(): boolean;
  71621. /**
  71622. * Dispose this feature and all of the resources attached
  71623. */
  71624. dispose(): void;
  71625. protected _onXRFrame(frame: XRFrame): void;
  71626. private _onHitTestResults;
  71627. private _onSelect;
  71628. }
  71629. }
  71630. declare module BABYLON {
  71631. /**
  71632. * Options used in the plane detector module
  71633. */
  71634. export interface IWebXRPlaneDetectorOptions {
  71635. /**
  71636. * The node to use to transform the local results to world coordinates
  71637. */
  71638. worldParentNode?: TransformNode;
  71639. }
  71640. /**
  71641. * A babylon interface for a WebXR plane.
  71642. * A Plane is actually a polygon, built from N points in space
  71643. *
  71644. * Supported in chrome 79, not supported in canary 81 ATM
  71645. */
  71646. export interface IWebXRPlane {
  71647. /**
  71648. * a babylon-assigned ID for this polygon
  71649. */
  71650. id: number;
  71651. /**
  71652. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  71653. */
  71654. polygonDefinition: Array<Vector3>;
  71655. /**
  71656. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  71657. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  71658. */
  71659. transformationMatrix: Matrix;
  71660. /**
  71661. * the native xr-plane object
  71662. */
  71663. xrPlane: XRPlane;
  71664. }
  71665. /**
  71666. * The plane detector is used to detect planes in the real world when in AR
  71667. * For more information see https://github.com/immersive-web/real-world-geometry/
  71668. */
  71669. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  71670. private _options;
  71671. private _detectedPlanes;
  71672. private _enabled;
  71673. private _lastFrameDetected;
  71674. /**
  71675. * The module's name
  71676. */
  71677. static readonly Name: string;
  71678. /**
  71679. * The (Babylon) version of this module.
  71680. * This is an integer representing the implementation version.
  71681. * This number does not correspond to the WebXR specs version
  71682. */
  71683. static readonly Version: number;
  71684. /**
  71685. * Observers registered here will be executed when a new plane was added to the session
  71686. */
  71687. onPlaneAddedObservable: Observable<IWebXRPlane>;
  71688. /**
  71689. * Observers registered here will be executed when a plane is no longer detected in the session
  71690. */
  71691. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  71692. /**
  71693. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  71694. * This can execute N times every frame
  71695. */
  71696. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  71697. /**
  71698. * construct a new Plane Detector
  71699. * @param _xrSessionManager an instance of xr Session manager
  71700. * @param _options configuration to use when constructing this feature
  71701. */
  71702. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  71703. /**
  71704. * Dispose this feature and all of the resources attached
  71705. */
  71706. dispose(): void;
  71707. protected _onXRFrame(frame: XRFrame): void;
  71708. private _init;
  71709. private _updatePlaneWithXRPlane;
  71710. /**
  71711. * avoiding using Array.find for global support.
  71712. * @param xrPlane the plane to find in the array
  71713. */
  71714. private findIndexInPlaneArray;
  71715. }
  71716. }
  71717. declare module BABYLON {
  71718. /**
  71719. * Configuration options of the anchor system
  71720. */
  71721. export interface IWebXRAnchorSystemOptions {
  71722. /**
  71723. * Should a new anchor be added every time a select event is triggered
  71724. */
  71725. addAnchorOnSelect?: boolean;
  71726. /**
  71727. * should the anchor system use plane detection.
  71728. * If set to true, the plane-detection feature should be set using setPlaneDetector
  71729. */
  71730. usePlaneDetection?: boolean;
  71731. /**
  71732. * a node that will be used to convert local to world coordinates
  71733. */
  71734. worldParentNode?: TransformNode;
  71735. }
  71736. /**
  71737. * A babylon container for an XR Anchor
  71738. */
  71739. export interface IWebXRAnchor {
  71740. /**
  71741. * A babylon-assigned ID for this anchor
  71742. */
  71743. id: number;
  71744. /**
  71745. * Transformation matrix to apply to an object attached to this anchor
  71746. */
  71747. transformationMatrix: Matrix;
  71748. /**
  71749. * The native anchor object
  71750. */
  71751. xrAnchor: XRAnchor;
  71752. }
  71753. /**
  71754. * An implementation of the anchor system of WebXR.
  71755. * Note that the current documented implementation is not available in any browser. Future implementations
  71756. * will use the frame to create an anchor and not the session or a detected plane
  71757. * For further information see https://github.com/immersive-web/anchors/
  71758. */
  71759. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  71760. private _options;
  71761. private _enabled;
  71762. private _hitTestModule;
  71763. private _lastFrameDetected;
  71764. private _onSelect;
  71765. private _planeDetector;
  71766. private _trackedAnchors;
  71767. /**
  71768. * The module's name
  71769. */
  71770. static readonly Name: string;
  71771. /**
  71772. * The (Babylon) version of this module.
  71773. * This is an integer representing the implementation version.
  71774. * This number does not correspond to the WebXR specs version
  71775. */
  71776. static readonly Version: number;
  71777. /**
  71778. * Observers registered here will be executed when a new anchor was added to the session
  71779. */
  71780. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  71781. /**
  71782. * Observers registered here will be executed when an anchor was removed from the session
  71783. */
  71784. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  71785. /**
  71786. * Observers registered here will be executed when an existing anchor updates
  71787. * This can execute N times every frame
  71788. */
  71789. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  71790. /**
  71791. * constructs a new anchor system
  71792. * @param _xrSessionManager an instance of WebXRSessionManager
  71793. * @param _options configuration object for this feature
  71794. */
  71795. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  71796. /**
  71797. * Add anchor at a specific XR point.
  71798. *
  71799. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  71800. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  71801. * @returns a promise the fulfills when the anchor was created
  71802. */
  71803. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  71804. /**
  71805. * attach this feature
  71806. * Will usually be called by the features manager
  71807. *
  71808. * @returns true if successful.
  71809. */
  71810. attach(): boolean;
  71811. /**
  71812. * detach this feature.
  71813. * Will usually be called by the features manager
  71814. *
  71815. * @returns true if successful.
  71816. */
  71817. detach(): boolean;
  71818. /**
  71819. * Dispose this feature and all of the resources attached
  71820. */
  71821. dispose(): void;
  71822. /**
  71823. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  71824. * @param hitTestModule the hit-test module to use.
  71825. */
  71826. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  71827. /**
  71828. * set the plane detector to use in order to create anchors from frames
  71829. * @param planeDetector the plane-detector module to use
  71830. * @param enable enable plane-anchors. default is true
  71831. */
  71832. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  71833. protected _onXRFrame(frame: XRFrame): void;
  71834. /**
  71835. * avoiding using Array.find for global support.
  71836. * @param xrAnchor the plane to find in the array
  71837. */
  71838. private _findIndexInAnchorArray;
  71839. private _updateAnchorWithXRFrame;
  71840. }
  71841. }
  71842. declare module BABYLON {
  71843. /**
  71844. * Options interface for the background remover plugin
  71845. */
  71846. export interface IWebXRBackgroundRemoverOptions {
  71847. /**
  71848. * Further background meshes to disable when entering AR
  71849. */
  71850. backgroundMeshes?: AbstractMesh[];
  71851. /**
  71852. * flags to configure the removal of the environment helper.
  71853. * If not set, the entire background will be removed. If set, flags should be set as well.
  71854. */
  71855. environmentHelperRemovalFlags?: {
  71856. /**
  71857. * Should the skybox be removed (default false)
  71858. */
  71859. skyBox?: boolean;
  71860. /**
  71861. * Should the ground be removed (default false)
  71862. */
  71863. ground?: boolean;
  71864. };
  71865. /**
  71866. * don't disable the environment helper
  71867. */
  71868. ignoreEnvironmentHelper?: boolean;
  71869. }
  71870. /**
  71871. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  71872. */
  71873. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  71874. /**
  71875. * read-only options to be used in this module
  71876. */
  71877. readonly options: IWebXRBackgroundRemoverOptions;
  71878. /**
  71879. * The module's name
  71880. */
  71881. static readonly Name: string;
  71882. /**
  71883. * The (Babylon) version of this module.
  71884. * This is an integer representing the implementation version.
  71885. * This number does not correspond to the WebXR specs version
  71886. */
  71887. static readonly Version: number;
  71888. /**
  71889. * registered observers will be triggered when the background state changes
  71890. */
  71891. onBackgroundStateChangedObservable: Observable<boolean>;
  71892. /**
  71893. * constructs a new background remover module
  71894. * @param _xrSessionManager the session manager for this module
  71895. * @param options read-only options to be used in this module
  71896. */
  71897. constructor(_xrSessionManager: WebXRSessionManager,
  71898. /**
  71899. * read-only options to be used in this module
  71900. */
  71901. options?: IWebXRBackgroundRemoverOptions);
  71902. /**
  71903. * attach this feature
  71904. * Will usually be called by the features manager
  71905. *
  71906. * @returns true if successful.
  71907. */
  71908. attach(): boolean;
  71909. /**
  71910. * detach this feature.
  71911. * Will usually be called by the features manager
  71912. *
  71913. * @returns true if successful.
  71914. */
  71915. detach(): boolean;
  71916. /**
  71917. * Dispose this feature and all of the resources attached
  71918. */
  71919. dispose(): void;
  71920. protected _onXRFrame(_xrFrame: XRFrame): void;
  71921. private _setBackgroundState;
  71922. }
  71923. }
  71924. declare module BABYLON {
  71925. /**
  71926. * Options for the controller physics feature
  71927. */
  71928. export class IWebXRControllerPhysicsOptions {
  71929. /**
  71930. * Should the headset get its own impostor
  71931. */
  71932. enableHeadsetImpostor?: boolean;
  71933. /**
  71934. * Optional parameters for the headset impostor
  71935. */
  71936. headsetImpostorParams?: {
  71937. /**
  71938. * The type of impostor to create. Default is sphere
  71939. */
  71940. impostorType: number;
  71941. /**
  71942. * the size of the impostor. Defaults to 10cm
  71943. */
  71944. impostorSize?: number | {
  71945. width: number;
  71946. height: number;
  71947. depth: number;
  71948. };
  71949. /**
  71950. * Friction definitions
  71951. */
  71952. friction?: number;
  71953. /**
  71954. * Restitution
  71955. */
  71956. restitution?: number;
  71957. };
  71958. /**
  71959. * The physics properties of the future impostors
  71960. */
  71961. physicsProperties?: {
  71962. /**
  71963. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  71964. * Note that this requires a physics engine that supports mesh impostors!
  71965. */
  71966. useControllerMesh?: boolean;
  71967. /**
  71968. * The type of impostor to create. Default is sphere
  71969. */
  71970. impostorType?: number;
  71971. /**
  71972. * the size of the impostor. Defaults to 10cm
  71973. */
  71974. impostorSize?: number | {
  71975. width: number;
  71976. height: number;
  71977. depth: number;
  71978. };
  71979. /**
  71980. * Friction definitions
  71981. */
  71982. friction?: number;
  71983. /**
  71984. * Restitution
  71985. */
  71986. restitution?: number;
  71987. };
  71988. /**
  71989. * the xr input to use with this pointer selection
  71990. */
  71991. xrInput: WebXRInput;
  71992. }
  71993. /**
  71994. * Add physics impostor to your webxr controllers,
  71995. * including naive calculation of their linear and angular velocity
  71996. */
  71997. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  71998. private readonly _options;
  71999. private _attachController;
  72000. private _controllers;
  72001. private _debugMode;
  72002. private _delta;
  72003. private _headsetImpostor?;
  72004. private _headsetMesh?;
  72005. private _lastTimestamp;
  72006. private _tmpQuaternion;
  72007. private _tmpVector;
  72008. /**
  72009. * The module's name
  72010. */
  72011. static readonly Name: string;
  72012. /**
  72013. * The (Babylon) version of this module.
  72014. * This is an integer representing the implementation version.
  72015. * This number does not correspond to the webxr specs version
  72016. */
  72017. static readonly Version: number;
  72018. /**
  72019. * Construct a new Controller Physics Feature
  72020. * @param _xrSessionManager the corresponding xr session manager
  72021. * @param _options options to create this feature with
  72022. */
  72023. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72024. /**
  72025. * @hidden
  72026. * enable debugging - will show console outputs and the impostor mesh
  72027. */
  72028. _enablePhysicsDebug(): void;
  72029. /**
  72030. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72031. * @param xrController the controller to add
  72032. */
  72033. addController(xrController: WebXRInputSource): void;
  72034. /**
  72035. * attach this feature
  72036. * Will usually be called by the features manager
  72037. *
  72038. * @returns true if successful.
  72039. */
  72040. attach(): boolean;
  72041. /**
  72042. * detach this feature.
  72043. * Will usually be called by the features manager
  72044. *
  72045. * @returns true if successful.
  72046. */
  72047. detach(): boolean;
  72048. /**
  72049. * Get the headset impostor, if enabled
  72050. * @returns the impostor
  72051. */
  72052. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72053. /**
  72054. * Get the physics impostor of a specific controller.
  72055. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72056. * @param controller the controller or the controller id of which to get the impostor
  72057. * @returns the impostor or null
  72058. */
  72059. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72060. /**
  72061. * Update the physics properties provided in the constructor
  72062. * @param newProperties the new properties object
  72063. */
  72064. setPhysicsProperties(newProperties: {
  72065. impostorType?: number;
  72066. impostorSize?: number | {
  72067. width: number;
  72068. height: number;
  72069. depth: number;
  72070. };
  72071. friction?: number;
  72072. restitution?: number;
  72073. }): void;
  72074. protected _onXRFrame(_xrFrame: any): void;
  72075. private _detachController;
  72076. }
  72077. }
  72078. declare module BABYLON {
  72079. /**
  72080. * Options used for hit testing (version 2)
  72081. */
  72082. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72083. /**
  72084. * Do not create a permanent hit test. Will usually be used when only
  72085. * transient inputs are needed.
  72086. */
  72087. disablePermanentHitTest?: boolean;
  72088. /**
  72089. * Enable transient (for example touch-based) hit test inspections
  72090. */
  72091. enableTransientHitTest?: boolean;
  72092. /**
  72093. * Offset ray for the permanent hit test
  72094. */
  72095. offsetRay?: Vector3;
  72096. /**
  72097. * Offset ray for the transient hit test
  72098. */
  72099. transientOffsetRay?: Vector3;
  72100. /**
  72101. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72102. */
  72103. useReferenceSpace?: boolean;
  72104. }
  72105. /**
  72106. * Interface defining the babylon result of hit-test
  72107. */
  72108. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72109. /**
  72110. * The input source that generated this hit test (if transient)
  72111. */
  72112. inputSource?: XRInputSource;
  72113. /**
  72114. * Is this a transient hit test
  72115. */
  72116. isTransient?: boolean;
  72117. /**
  72118. * Position of the hit test result
  72119. */
  72120. position: Vector3;
  72121. /**
  72122. * Rotation of the hit test result
  72123. */
  72124. rotationQuaternion: Quaternion;
  72125. }
  72126. /**
  72127. * The currently-working hit-test module.
  72128. * Hit test (or Ray-casting) is used to interact with the real world.
  72129. * For further information read here - https://github.com/immersive-web/hit-test
  72130. *
  72131. * Tested on chrome (mobile) 80.
  72132. */
  72133. export class WebXRHitTest extends WebXRAbstractFeature {
  72134. /**
  72135. * options to use when constructing this feature
  72136. */
  72137. readonly options: IWebXRHitTestOptions;
  72138. private _tmpMat;
  72139. private _tmpPos;
  72140. private _tmpQuat;
  72141. private _transientXrHitTestSource;
  72142. private _xrHitTestSource;
  72143. private initHitTestSource;
  72144. /**
  72145. * The module's name
  72146. */
  72147. static readonly Name: string;
  72148. /**
  72149. * The (Babylon) version of this module.
  72150. * This is an integer representing the implementation version.
  72151. * This number does not correspond to the WebXR specs version
  72152. */
  72153. static readonly Version: number;
  72154. /**
  72155. * When set to true, each hit test will have its own position/rotation objects
  72156. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72157. * the developers will clone them or copy them as they see fit.
  72158. */
  72159. autoCloneTransformation: boolean;
  72160. /**
  72161. * Populated with the last native XR Hit Results
  72162. */
  72163. lastNativeXRHitResults: XRHitResult[];
  72164. /**
  72165. * Triggered when new babylon (transformed) hit test results are available
  72166. */
  72167. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72168. /**
  72169. * Use this to temporarily pause hit test checks.
  72170. */
  72171. paused: boolean;
  72172. /**
  72173. * Creates a new instance of the hit test feature
  72174. * @param _xrSessionManager an instance of WebXRSessionManager
  72175. * @param options options to use when constructing this feature
  72176. */
  72177. constructor(_xrSessionManager: WebXRSessionManager,
  72178. /**
  72179. * options to use when constructing this feature
  72180. */
  72181. options?: IWebXRHitTestOptions);
  72182. /**
  72183. * attach this feature
  72184. * Will usually be called by the features manager
  72185. *
  72186. * @returns true if successful.
  72187. */
  72188. attach(): boolean;
  72189. /**
  72190. * detach this feature.
  72191. * Will usually be called by the features manager
  72192. *
  72193. * @returns true if successful.
  72194. */
  72195. detach(): boolean;
  72196. /**
  72197. * Dispose this feature and all of the resources attached
  72198. */
  72199. dispose(): void;
  72200. protected _onXRFrame(frame: XRFrame): void;
  72201. private _processWebXRHitTestResult;
  72202. }
  72203. }
  72204. declare module BABYLON {
  72205. /**
  72206. * The motion controller class for all microsoft mixed reality controllers
  72207. */
  72208. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72209. protected readonly _mapping: {
  72210. defaultButton: {
  72211. valueNodeName: string;
  72212. unpressedNodeName: string;
  72213. pressedNodeName: string;
  72214. };
  72215. defaultAxis: {
  72216. valueNodeName: string;
  72217. minNodeName: string;
  72218. maxNodeName: string;
  72219. };
  72220. buttons: {
  72221. "xr-standard-trigger": {
  72222. rootNodeName: string;
  72223. componentProperty: string;
  72224. states: string[];
  72225. };
  72226. "xr-standard-squeeze": {
  72227. rootNodeName: string;
  72228. componentProperty: string;
  72229. states: string[];
  72230. };
  72231. "xr-standard-touchpad": {
  72232. rootNodeName: string;
  72233. labelAnchorNodeName: string;
  72234. touchPointNodeName: string;
  72235. };
  72236. "xr-standard-thumbstick": {
  72237. rootNodeName: string;
  72238. componentProperty: string;
  72239. states: string[];
  72240. };
  72241. };
  72242. axes: {
  72243. "xr-standard-touchpad": {
  72244. "x-axis": {
  72245. rootNodeName: string;
  72246. };
  72247. "y-axis": {
  72248. rootNodeName: string;
  72249. };
  72250. };
  72251. "xr-standard-thumbstick": {
  72252. "x-axis": {
  72253. rootNodeName: string;
  72254. };
  72255. "y-axis": {
  72256. rootNodeName: string;
  72257. };
  72258. };
  72259. };
  72260. };
  72261. /**
  72262. * The base url used to load the left and right controller models
  72263. */
  72264. static MODEL_BASE_URL: string;
  72265. /**
  72266. * The name of the left controller model file
  72267. */
  72268. static MODEL_LEFT_FILENAME: string;
  72269. /**
  72270. * The name of the right controller model file
  72271. */
  72272. static MODEL_RIGHT_FILENAME: string;
  72273. profileId: string;
  72274. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72275. protected _getFilenameAndPath(): {
  72276. filename: string;
  72277. path: string;
  72278. };
  72279. protected _getModelLoadingConstraints(): boolean;
  72280. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72281. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72282. protected _updateModel(): void;
  72283. }
  72284. }
  72285. declare module BABYLON {
  72286. /**
  72287. * The motion controller class for oculus touch (quest, rift).
  72288. * This class supports legacy mapping as well the standard xr mapping
  72289. */
  72290. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  72291. private _forceLegacyControllers;
  72292. private _modelRootNode;
  72293. /**
  72294. * The base url used to load the left and right controller models
  72295. */
  72296. static MODEL_BASE_URL: string;
  72297. /**
  72298. * The name of the left controller model file
  72299. */
  72300. static MODEL_LEFT_FILENAME: string;
  72301. /**
  72302. * The name of the right controller model file
  72303. */
  72304. static MODEL_RIGHT_FILENAME: string;
  72305. /**
  72306. * Base Url for the Quest controller model.
  72307. */
  72308. static QUEST_MODEL_BASE_URL: string;
  72309. profileId: string;
  72310. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  72311. protected _getFilenameAndPath(): {
  72312. filename: string;
  72313. path: string;
  72314. };
  72315. protected _getModelLoadingConstraints(): boolean;
  72316. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72317. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72318. protected _updateModel(): void;
  72319. /**
  72320. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  72321. * between the touch and touch 2.
  72322. */
  72323. private _isQuest;
  72324. }
  72325. }
  72326. declare module BABYLON {
  72327. /**
  72328. * The motion controller class for the standard HTC-Vive controllers
  72329. */
  72330. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  72331. private _modelRootNode;
  72332. /**
  72333. * The base url used to load the left and right controller models
  72334. */
  72335. static MODEL_BASE_URL: string;
  72336. /**
  72337. * File name for the controller model.
  72338. */
  72339. static MODEL_FILENAME: string;
  72340. profileId: string;
  72341. /**
  72342. * Create a new Vive motion controller object
  72343. * @param scene the scene to use to create this controller
  72344. * @param gamepadObject the corresponding gamepad object
  72345. * @param handedness the handedness of the controller
  72346. */
  72347. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72348. protected _getFilenameAndPath(): {
  72349. filename: string;
  72350. path: string;
  72351. };
  72352. protected _getModelLoadingConstraints(): boolean;
  72353. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72354. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72355. protected _updateModel(): void;
  72356. }
  72357. }
  72358. declare module BABYLON {
  72359. /**
  72360. * A cursor which tracks a point on a path
  72361. */
  72362. export class PathCursor {
  72363. private path;
  72364. /**
  72365. * Stores path cursor callbacks for when an onchange event is triggered
  72366. */
  72367. private _onchange;
  72368. /**
  72369. * The value of the path cursor
  72370. */
  72371. value: number;
  72372. /**
  72373. * The animation array of the path cursor
  72374. */
  72375. animations: Animation[];
  72376. /**
  72377. * Initializes the path cursor
  72378. * @param path The path to track
  72379. */
  72380. constructor(path: Path2);
  72381. /**
  72382. * Gets the cursor point on the path
  72383. * @returns A point on the path cursor at the cursor location
  72384. */
  72385. getPoint(): Vector3;
  72386. /**
  72387. * Moves the cursor ahead by the step amount
  72388. * @param step The amount to move the cursor forward
  72389. * @returns This path cursor
  72390. */
  72391. moveAhead(step?: number): PathCursor;
  72392. /**
  72393. * Moves the cursor behind by the step amount
  72394. * @param step The amount to move the cursor back
  72395. * @returns This path cursor
  72396. */
  72397. moveBack(step?: number): PathCursor;
  72398. /**
  72399. * Moves the cursor by the step amount
  72400. * If the step amount is greater than one, an exception is thrown
  72401. * @param step The amount to move the cursor
  72402. * @returns This path cursor
  72403. */
  72404. move(step: number): PathCursor;
  72405. /**
  72406. * Ensures that the value is limited between zero and one
  72407. * @returns This path cursor
  72408. */
  72409. private ensureLimits;
  72410. /**
  72411. * Runs onchange callbacks on change (used by the animation engine)
  72412. * @returns This path cursor
  72413. */
  72414. private raiseOnChange;
  72415. /**
  72416. * Executes a function on change
  72417. * @param f A path cursor onchange callback
  72418. * @returns This path cursor
  72419. */
  72420. onchange(f: (cursor: PathCursor) => void): PathCursor;
  72421. }
  72422. }
  72423. declare module BABYLON {
  72424. /** @hidden */
  72425. export var blurPixelShader: {
  72426. name: string;
  72427. shader: string;
  72428. };
  72429. }
  72430. declare module BABYLON {
  72431. /** @hidden */
  72432. export var pointCloudVertexDeclaration: {
  72433. name: string;
  72434. shader: string;
  72435. };
  72436. }
  72437. // Mixins
  72438. interface Window {
  72439. mozIndexedDB: IDBFactory;
  72440. webkitIndexedDB: IDBFactory;
  72441. msIndexedDB: IDBFactory;
  72442. webkitURL: typeof URL;
  72443. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  72444. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  72445. WebGLRenderingContext: WebGLRenderingContext;
  72446. MSGesture: MSGesture;
  72447. CANNON: any;
  72448. AudioContext: AudioContext;
  72449. webkitAudioContext: AudioContext;
  72450. PointerEvent: any;
  72451. Math: Math;
  72452. Uint8Array: Uint8ArrayConstructor;
  72453. Float32Array: Float32ArrayConstructor;
  72454. mozURL: typeof URL;
  72455. msURL: typeof URL;
  72456. VRFrameData: any; // WebVR, from specs 1.1
  72457. DracoDecoderModule: any;
  72458. setImmediate(handler: (...args: any[]) => void): number;
  72459. }
  72460. interface HTMLCanvasElement {
  72461. requestPointerLock(): void;
  72462. msRequestPointerLock?(): void;
  72463. mozRequestPointerLock?(): void;
  72464. webkitRequestPointerLock?(): void;
  72465. /** Track wether a record is in progress */
  72466. isRecording: boolean;
  72467. /** Capture Stream method defined by some browsers */
  72468. captureStream(fps?: number): MediaStream;
  72469. }
  72470. interface CanvasRenderingContext2D {
  72471. msImageSmoothingEnabled: boolean;
  72472. }
  72473. interface MouseEvent {
  72474. mozMovementX: number;
  72475. mozMovementY: number;
  72476. webkitMovementX: number;
  72477. webkitMovementY: number;
  72478. msMovementX: number;
  72479. msMovementY: number;
  72480. }
  72481. interface Navigator {
  72482. mozGetVRDevices: (any: any) => any;
  72483. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72484. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72485. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72486. webkitGetGamepads(): Gamepad[];
  72487. msGetGamepads(): Gamepad[];
  72488. webkitGamepads(): Gamepad[];
  72489. }
  72490. interface HTMLVideoElement {
  72491. mozSrcObject: any;
  72492. }
  72493. interface Math {
  72494. fround(x: number): number;
  72495. imul(a: number, b: number): number;
  72496. }
  72497. interface WebGLRenderingContext {
  72498. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  72499. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  72500. vertexAttribDivisor(index: number, divisor: number): void;
  72501. createVertexArray(): any;
  72502. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  72503. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  72504. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  72505. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  72506. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  72507. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  72508. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  72509. // Queries
  72510. createQuery(): WebGLQuery;
  72511. deleteQuery(query: WebGLQuery): void;
  72512. beginQuery(target: number, query: WebGLQuery): void;
  72513. endQuery(target: number): void;
  72514. getQueryParameter(query: WebGLQuery, pname: number): any;
  72515. getQuery(target: number, pname: number): any;
  72516. MAX_SAMPLES: number;
  72517. RGBA8: number;
  72518. READ_FRAMEBUFFER: number;
  72519. DRAW_FRAMEBUFFER: number;
  72520. UNIFORM_BUFFER: number;
  72521. HALF_FLOAT_OES: number;
  72522. RGBA16F: number;
  72523. RGBA32F: number;
  72524. R32F: number;
  72525. RG32F: number;
  72526. RGB32F: number;
  72527. R16F: number;
  72528. RG16F: number;
  72529. RGB16F: number;
  72530. RED: number;
  72531. RG: number;
  72532. R8: number;
  72533. RG8: number;
  72534. UNSIGNED_INT_24_8: number;
  72535. DEPTH24_STENCIL8: number;
  72536. MIN: number;
  72537. MAX: number;
  72538. /* Multiple Render Targets */
  72539. drawBuffers(buffers: number[]): void;
  72540. readBuffer(src: number): void;
  72541. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  72542. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  72543. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  72544. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  72545. // Occlusion Query
  72546. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  72547. ANY_SAMPLES_PASSED: number;
  72548. QUERY_RESULT_AVAILABLE: number;
  72549. QUERY_RESULT: number;
  72550. }
  72551. interface WebGLProgram {
  72552. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  72553. }
  72554. interface EXT_disjoint_timer_query {
  72555. QUERY_COUNTER_BITS_EXT: number;
  72556. TIME_ELAPSED_EXT: number;
  72557. TIMESTAMP_EXT: number;
  72558. GPU_DISJOINT_EXT: number;
  72559. QUERY_RESULT_EXT: number;
  72560. QUERY_RESULT_AVAILABLE_EXT: number;
  72561. queryCounterEXT(query: WebGLQuery, target: number): void;
  72562. createQueryEXT(): WebGLQuery;
  72563. beginQueryEXT(target: number, query: WebGLQuery): void;
  72564. endQueryEXT(target: number): void;
  72565. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  72566. deleteQueryEXT(query: WebGLQuery): void;
  72567. }
  72568. interface WebGLUniformLocation {
  72569. _currentState: any;
  72570. }
  72571. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  72572. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  72573. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  72574. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  72575. interface WebGLRenderingContext {
  72576. readonly RASTERIZER_DISCARD: number;
  72577. readonly DEPTH_COMPONENT24: number;
  72578. readonly TEXTURE_3D: number;
  72579. readonly TEXTURE_2D_ARRAY: number;
  72580. readonly TEXTURE_COMPARE_FUNC: number;
  72581. readonly TEXTURE_COMPARE_MODE: number;
  72582. readonly COMPARE_REF_TO_TEXTURE: number;
  72583. readonly TEXTURE_WRAP_R: number;
  72584. readonly HALF_FLOAT: number;
  72585. readonly RGB8: number;
  72586. readonly RED_INTEGER: number;
  72587. readonly RG_INTEGER: number;
  72588. readonly RGB_INTEGER: number;
  72589. readonly RGBA_INTEGER: number;
  72590. readonly R8_SNORM: number;
  72591. readonly RG8_SNORM: number;
  72592. readonly RGB8_SNORM: number;
  72593. readonly RGBA8_SNORM: number;
  72594. readonly R8I: number;
  72595. readonly RG8I: number;
  72596. readonly RGB8I: number;
  72597. readonly RGBA8I: number;
  72598. readonly R8UI: number;
  72599. readonly RG8UI: number;
  72600. readonly RGB8UI: number;
  72601. readonly RGBA8UI: number;
  72602. readonly R16I: number;
  72603. readonly RG16I: number;
  72604. readonly RGB16I: number;
  72605. readonly RGBA16I: number;
  72606. readonly R16UI: number;
  72607. readonly RG16UI: number;
  72608. readonly RGB16UI: number;
  72609. readonly RGBA16UI: number;
  72610. readonly R32I: number;
  72611. readonly RG32I: number;
  72612. readonly RGB32I: number;
  72613. readonly RGBA32I: number;
  72614. readonly R32UI: number;
  72615. readonly RG32UI: number;
  72616. readonly RGB32UI: number;
  72617. readonly RGBA32UI: number;
  72618. readonly RGB10_A2UI: number;
  72619. readonly R11F_G11F_B10F: number;
  72620. readonly RGB9_E5: number;
  72621. readonly RGB10_A2: number;
  72622. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  72623. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  72624. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  72625. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  72626. readonly DEPTH_COMPONENT32F: number;
  72627. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  72628. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  72629. 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;
  72630. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  72631. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  72632. readonly TRANSFORM_FEEDBACK: number;
  72633. readonly INTERLEAVED_ATTRIBS: number;
  72634. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  72635. createTransformFeedback(): WebGLTransformFeedback;
  72636. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  72637. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  72638. beginTransformFeedback(primitiveMode: number): void;
  72639. endTransformFeedback(): void;
  72640. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  72641. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72642. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72643. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72644. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  72645. }
  72646. interface ImageBitmap {
  72647. readonly width: number;
  72648. readonly height: number;
  72649. close(): void;
  72650. }
  72651. interface WebGLQuery extends WebGLObject {
  72652. }
  72653. declare var WebGLQuery: {
  72654. prototype: WebGLQuery;
  72655. new(): WebGLQuery;
  72656. };
  72657. interface WebGLSampler extends WebGLObject {
  72658. }
  72659. declare var WebGLSampler: {
  72660. prototype: WebGLSampler;
  72661. new(): WebGLSampler;
  72662. };
  72663. interface WebGLSync extends WebGLObject {
  72664. }
  72665. declare var WebGLSync: {
  72666. prototype: WebGLSync;
  72667. new(): WebGLSync;
  72668. };
  72669. interface WebGLTransformFeedback extends WebGLObject {
  72670. }
  72671. declare var WebGLTransformFeedback: {
  72672. prototype: WebGLTransformFeedback;
  72673. new(): WebGLTransformFeedback;
  72674. };
  72675. interface WebGLVertexArrayObject extends WebGLObject {
  72676. }
  72677. declare var WebGLVertexArrayObject: {
  72678. prototype: WebGLVertexArrayObject;
  72679. new(): WebGLVertexArrayObject;
  72680. };
  72681. // Type definitions for WebVR API
  72682. // Project: https://w3c.github.io/webvr/
  72683. // Definitions by: six a <https://github.com/lostfictions>
  72684. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  72685. interface VRDisplay extends EventTarget {
  72686. /**
  72687. * Dictionary of capabilities describing the VRDisplay.
  72688. */
  72689. readonly capabilities: VRDisplayCapabilities;
  72690. /**
  72691. * z-depth defining the far plane of the eye view frustum
  72692. * enables mapping of values in the render target depth
  72693. * attachment to scene coordinates. Initially set to 10000.0.
  72694. */
  72695. depthFar: number;
  72696. /**
  72697. * z-depth defining the near plane of the eye view frustum
  72698. * enables mapping of values in the render target depth
  72699. * attachment to scene coordinates. Initially set to 0.01.
  72700. */
  72701. depthNear: number;
  72702. /**
  72703. * An identifier for this distinct VRDisplay. Used as an
  72704. * association point in the Gamepad API.
  72705. */
  72706. readonly displayId: number;
  72707. /**
  72708. * A display name, a user-readable name identifying it.
  72709. */
  72710. readonly displayName: string;
  72711. readonly isConnected: boolean;
  72712. readonly isPresenting: boolean;
  72713. /**
  72714. * If this VRDisplay supports room-scale experiences, the optional
  72715. * stage attribute contains details on the room-scale parameters.
  72716. */
  72717. readonly stageParameters: VRStageParameters | null;
  72718. /**
  72719. * Passing the value returned by `requestAnimationFrame` to
  72720. * `cancelAnimationFrame` will unregister the callback.
  72721. * @param handle Define the hanle of the request to cancel
  72722. */
  72723. cancelAnimationFrame(handle: number): void;
  72724. /**
  72725. * Stops presenting to the VRDisplay.
  72726. * @returns a promise to know when it stopped
  72727. */
  72728. exitPresent(): Promise<void>;
  72729. /**
  72730. * Return the current VREyeParameters for the given eye.
  72731. * @param whichEye Define the eye we want the parameter for
  72732. * @returns the eye parameters
  72733. */
  72734. getEyeParameters(whichEye: string): VREyeParameters;
  72735. /**
  72736. * Populates the passed VRFrameData with the information required to render
  72737. * the current frame.
  72738. * @param frameData Define the data structure to populate
  72739. * @returns true if ok otherwise false
  72740. */
  72741. getFrameData(frameData: VRFrameData): boolean;
  72742. /**
  72743. * Get the layers currently being presented.
  72744. * @returns the list of VR layers
  72745. */
  72746. getLayers(): VRLayer[];
  72747. /**
  72748. * Return a VRPose containing the future predicted pose of the VRDisplay
  72749. * when the current frame will be presented. The value returned will not
  72750. * change until JavaScript has returned control to the browser.
  72751. *
  72752. * The VRPose will contain the position, orientation, velocity,
  72753. * and acceleration of each of these properties.
  72754. * @returns the pose object
  72755. */
  72756. getPose(): VRPose;
  72757. /**
  72758. * Return the current instantaneous pose of the VRDisplay, with no
  72759. * prediction applied.
  72760. * @returns the current instantaneous pose
  72761. */
  72762. getImmediatePose(): VRPose;
  72763. /**
  72764. * The callback passed to `requestAnimationFrame` will be called
  72765. * any time a new frame should be rendered. When the VRDisplay is
  72766. * presenting the callback will be called at the native refresh
  72767. * rate of the HMD. When not presenting this function acts
  72768. * identically to how window.requestAnimationFrame acts. Content should
  72769. * make no assumptions of frame rate or vsync behavior as the HMD runs
  72770. * asynchronously from other displays and at differing refresh rates.
  72771. * @param callback Define the eaction to run next frame
  72772. * @returns the request handle it
  72773. */
  72774. requestAnimationFrame(callback: FrameRequestCallback): number;
  72775. /**
  72776. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  72777. * Repeat calls while already presenting will update the VRLayers being displayed.
  72778. * @param layers Define the list of layer to present
  72779. * @returns a promise to know when the request has been fulfilled
  72780. */
  72781. requestPresent(layers: VRLayer[]): Promise<void>;
  72782. /**
  72783. * Reset the pose for this display, treating its current position and
  72784. * orientation as the "origin/zero" values. VRPose.position,
  72785. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  72786. * updated when calling resetPose(). This should be called in only
  72787. * sitting-space experiences.
  72788. */
  72789. resetPose(): void;
  72790. /**
  72791. * The VRLayer provided to the VRDisplay will be captured and presented
  72792. * in the HMD. Calling this function has the same effect on the source
  72793. * canvas as any other operation that uses its source image, and canvases
  72794. * created without preserveDrawingBuffer set to true will be cleared.
  72795. * @param pose Define the pose to submit
  72796. */
  72797. submitFrame(pose?: VRPose): void;
  72798. }
  72799. declare var VRDisplay: {
  72800. prototype: VRDisplay;
  72801. new(): VRDisplay;
  72802. };
  72803. interface VRLayer {
  72804. leftBounds?: number[] | Float32Array | null;
  72805. rightBounds?: number[] | Float32Array | null;
  72806. source?: HTMLCanvasElement | null;
  72807. }
  72808. interface VRDisplayCapabilities {
  72809. readonly canPresent: boolean;
  72810. readonly hasExternalDisplay: boolean;
  72811. readonly hasOrientation: boolean;
  72812. readonly hasPosition: boolean;
  72813. readonly maxLayers: number;
  72814. }
  72815. interface VREyeParameters {
  72816. /** @deprecated */
  72817. readonly fieldOfView: VRFieldOfView;
  72818. readonly offset: Float32Array;
  72819. readonly renderHeight: number;
  72820. readonly renderWidth: number;
  72821. }
  72822. interface VRFieldOfView {
  72823. readonly downDegrees: number;
  72824. readonly leftDegrees: number;
  72825. readonly rightDegrees: number;
  72826. readonly upDegrees: number;
  72827. }
  72828. interface VRFrameData {
  72829. readonly leftProjectionMatrix: Float32Array;
  72830. readonly leftViewMatrix: Float32Array;
  72831. readonly pose: VRPose;
  72832. readonly rightProjectionMatrix: Float32Array;
  72833. readonly rightViewMatrix: Float32Array;
  72834. readonly timestamp: number;
  72835. }
  72836. interface VRPose {
  72837. readonly angularAcceleration: Float32Array | null;
  72838. readonly angularVelocity: Float32Array | null;
  72839. readonly linearAcceleration: Float32Array | null;
  72840. readonly linearVelocity: Float32Array | null;
  72841. readonly orientation: Float32Array | null;
  72842. readonly position: Float32Array | null;
  72843. readonly timestamp: number;
  72844. }
  72845. interface VRStageParameters {
  72846. sittingToStandingTransform?: Float32Array;
  72847. sizeX?: number;
  72848. sizeY?: number;
  72849. }
  72850. interface Navigator {
  72851. getVRDisplays(): Promise<VRDisplay[]>;
  72852. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  72853. }
  72854. interface Window {
  72855. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  72856. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  72857. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  72858. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  72859. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  72860. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  72861. }
  72862. interface Gamepad {
  72863. readonly displayId: number;
  72864. }
  72865. type XRSessionMode =
  72866. | "inline"
  72867. | "immersive-vr"
  72868. | "immersive-ar";
  72869. type XRReferenceSpaceType =
  72870. | "viewer"
  72871. | "local"
  72872. | "local-floor"
  72873. | "bounded-floor"
  72874. | "unbounded";
  72875. type XREnvironmentBlendMode =
  72876. | "opaque"
  72877. | "additive"
  72878. | "alpha-blend";
  72879. type XRVisibilityState =
  72880. | "visible"
  72881. | "visible-blurred"
  72882. | "hidden";
  72883. type XRHandedness =
  72884. | "none"
  72885. | "left"
  72886. | "right";
  72887. type XRTargetRayMode =
  72888. | "gaze"
  72889. | "tracked-pointer"
  72890. | "screen";
  72891. type XREye =
  72892. | "none"
  72893. | "left"
  72894. | "right";
  72895. type XREventType =
  72896. | "devicechange"
  72897. | "visibilitychange"
  72898. | "end"
  72899. | "inputsourceschange"
  72900. | "select"
  72901. | "selectstart"
  72902. | "selectend"
  72903. | "squeeze"
  72904. | "squeezestart"
  72905. | "squeezeend"
  72906. | "reset";
  72907. interface XRSpace extends EventTarget {
  72908. }
  72909. interface XRRenderState {
  72910. depthNear?: number;
  72911. depthFar?: number;
  72912. inlineVerticalFieldOfView?: number;
  72913. baseLayer?: XRWebGLLayer;
  72914. }
  72915. interface XRInputSource {
  72916. handedness: XRHandedness;
  72917. targetRayMode: XRTargetRayMode;
  72918. targetRaySpace: XRSpace;
  72919. gripSpace: XRSpace | undefined;
  72920. gamepad: Gamepad | undefined;
  72921. profiles: Array<string>;
  72922. }
  72923. interface XRSessionInit {
  72924. optionalFeatures?: string[];
  72925. requiredFeatures?: string[];
  72926. }
  72927. interface XRSession extends XRAnchorCreator {
  72928. addEventListener: Function;
  72929. removeEventListener: Function;
  72930. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  72931. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  72932. requestAnimationFrame: Function;
  72933. end(): Promise<void>;
  72934. renderState: XRRenderState;
  72935. inputSources: Array<XRInputSource>;
  72936. // hit test
  72937. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  72938. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  72939. // legacy AR hit test
  72940. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72941. // legacy plane detection
  72942. updateWorldTrackingState(options: {
  72943. planeDetectionState?: { enabled: boolean; }
  72944. }): void;
  72945. }
  72946. interface XRReferenceSpace extends XRSpace {
  72947. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  72948. onreset: any;
  72949. }
  72950. type XRPlaneSet = Set<XRPlane>;
  72951. type XRAnchorSet = Set<XRAnchor>;
  72952. interface XRFrame {
  72953. session: XRSession;
  72954. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  72955. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  72956. // AR
  72957. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  72958. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  72959. // Anchors
  72960. trackedAnchors?: XRAnchorSet;
  72961. // Planes
  72962. worldInformation: {
  72963. detectedPlanes?: XRPlaneSet;
  72964. };
  72965. }
  72966. interface XRViewerPose extends XRPose {
  72967. views: Array<XRView>;
  72968. }
  72969. interface XRPose {
  72970. transform: XRRigidTransform;
  72971. emulatedPosition: boolean;
  72972. }
  72973. interface XRWebGLLayerOptions {
  72974. antialias?: boolean;
  72975. depth?: boolean;
  72976. stencil?: boolean;
  72977. alpha?: boolean;
  72978. multiview?: boolean;
  72979. framebufferScaleFactor?: number;
  72980. }
  72981. declare var XRWebGLLayer: {
  72982. prototype: XRWebGLLayer;
  72983. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  72984. };
  72985. interface XRWebGLLayer {
  72986. framebuffer: WebGLFramebuffer;
  72987. framebufferWidth: number;
  72988. framebufferHeight: number;
  72989. getViewport: Function;
  72990. }
  72991. declare class XRRigidTransform {
  72992. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  72993. position: DOMPointReadOnly;
  72994. orientation: DOMPointReadOnly;
  72995. matrix: Float32Array;
  72996. inverse: XRRigidTransform;
  72997. }
  72998. interface XRView {
  72999. eye: XREye;
  73000. projectionMatrix: Float32Array;
  73001. transform: XRRigidTransform;
  73002. }
  73003. interface XRInputSourceChangeEvent {
  73004. session: XRSession;
  73005. removed: Array<XRInputSource>;
  73006. added: Array<XRInputSource>;
  73007. }
  73008. interface XRInputSourceEvent extends Event {
  73009. readonly frame: XRFrame;
  73010. readonly inputSource: XRInputSource;
  73011. }
  73012. // Experimental(er) features
  73013. declare class XRRay {
  73014. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  73015. origin: DOMPointReadOnly;
  73016. direction: DOMPointReadOnly;
  73017. matrix: Float32Array;
  73018. }
  73019. declare enum XRHitTestTrackableType {
  73020. "point",
  73021. "plane"
  73022. }
  73023. interface XRHitResult {
  73024. hitMatrix: Float32Array;
  73025. }
  73026. interface XRTransientInputHitTestResult {
  73027. readonly inputSource: XRInputSource;
  73028. readonly results: Array<XRHitTestResult>;
  73029. }
  73030. interface XRHitTestResult {
  73031. getPose(baseSpace: XRSpace): XRPose | undefined;
  73032. }
  73033. interface XRHitTestSource {
  73034. cancel(): void;
  73035. }
  73036. interface XRTransientInputHitTestSource {
  73037. cancel(): void;
  73038. }
  73039. interface XRHitTestOptionsInit {
  73040. space: XRSpace;
  73041. entityTypes?: Array<XRHitTestTrackableType>;
  73042. offsetRay?: XRRay;
  73043. }
  73044. interface XRTransientInputHitTestOptionsInit {
  73045. profile: string;
  73046. entityTypes?: Array<XRHitTestTrackableType>;
  73047. offsetRay?: XRRay;
  73048. }
  73049. interface XRAnchor {
  73050. // remove?
  73051. id?: string;
  73052. anchorSpace: XRSpace;
  73053. lastChangedTime: number;
  73054. detach(): void;
  73055. }
  73056. interface XRPlane extends XRAnchorCreator {
  73057. orientation: "Horizontal" | "Vertical";
  73058. planeSpace: XRSpace;
  73059. polygon: Array<DOMPointReadOnly>;
  73060. lastChangedTime: number;
  73061. }
  73062. interface XRAnchorCreator {
  73063. // AR Anchors
  73064. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  73065. }
  73066. /**
  73067. * @ignore
  73068. */
  73069. declare module BABYLON.GLTF2.Exporter {
  73070. }
  73071. /**
  73072. * @ignore
  73073. */
  73074. declare module BABYLON.GLTF1 {
  73075. }
  73076. declare module BABYLON.GUI {
  73077. /**
  73078. * Class used to specific a value and its associated unit
  73079. */
  73080. export class ValueAndUnit {
  73081. /** defines the unit to store */
  73082. unit: number;
  73083. /** defines a boolean indicating if the value can be negative */
  73084. negativeValueAllowed: boolean;
  73085. private _value;
  73086. private _originalUnit;
  73087. /**
  73088. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  73089. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73090. */
  73091. ignoreAdaptiveScaling: boolean;
  73092. /**
  73093. * Creates a new ValueAndUnit
  73094. * @param value defines the value to store
  73095. * @param unit defines the unit to store
  73096. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  73097. */
  73098. constructor(value: number,
  73099. /** defines the unit to store */
  73100. unit?: number,
  73101. /** defines a boolean indicating if the value can be negative */
  73102. negativeValueAllowed?: boolean);
  73103. /** Gets a boolean indicating if the value is a percentage */
  73104. get isPercentage(): boolean;
  73105. /** Gets a boolean indicating if the value is store as pixel */
  73106. get isPixel(): boolean;
  73107. /** Gets direct internal value */
  73108. get internalValue(): number;
  73109. /**
  73110. * Gets value as pixel
  73111. * @param host defines the root host
  73112. * @param refValue defines the reference value for percentages
  73113. * @returns the value as pixel
  73114. */
  73115. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  73116. /**
  73117. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  73118. * @param value defines the value to store
  73119. * @param unit defines the unit to store
  73120. * @returns the current ValueAndUnit
  73121. */
  73122. updateInPlace(value: number, unit?: number): ValueAndUnit;
  73123. /**
  73124. * Gets the value accordingly to its unit
  73125. * @param host defines the root host
  73126. * @returns the value
  73127. */
  73128. getValue(host: AdvancedDynamicTexture): number;
  73129. /**
  73130. * Gets a string representation of the value
  73131. * @param host defines the root host
  73132. * @param decimals defines an optional number of decimals to display
  73133. * @returns a string
  73134. */
  73135. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  73136. /**
  73137. * Store a value parsed from a string
  73138. * @param source defines the source string
  73139. * @returns true if the value was successfully parsed
  73140. */
  73141. fromString(source: string | number): boolean;
  73142. private static _Regex;
  73143. private static _UNITMODE_PERCENTAGE;
  73144. private static _UNITMODE_PIXEL;
  73145. /** UNITMODE_PERCENTAGE */
  73146. static get UNITMODE_PERCENTAGE(): number;
  73147. /** UNITMODE_PIXEL */
  73148. static get UNITMODE_PIXEL(): number;
  73149. }
  73150. }
  73151. declare module BABYLON.GUI {
  73152. /**
  73153. * Define a style used by control to automatically setup properties based on a template.
  73154. * Only support font related properties so far
  73155. */
  73156. export class Style implements BABYLON.IDisposable {
  73157. private _fontFamily;
  73158. private _fontStyle;
  73159. private _fontWeight;
  73160. /** @hidden */
  73161. _host: AdvancedDynamicTexture;
  73162. /** @hidden */
  73163. _fontSize: ValueAndUnit;
  73164. /**
  73165. * BABYLON.Observable raised when the style values are changed
  73166. */
  73167. onChangedObservable: BABYLON.Observable<Style>;
  73168. /**
  73169. * Creates a new style object
  73170. * @param host defines the AdvancedDynamicTexture which hosts this style
  73171. */
  73172. constructor(host: AdvancedDynamicTexture);
  73173. /**
  73174. * Gets or sets the font size
  73175. */
  73176. get fontSize(): string | number;
  73177. set fontSize(value: string | number);
  73178. /**
  73179. * Gets or sets the font family
  73180. */
  73181. get fontFamily(): string;
  73182. set fontFamily(value: string);
  73183. /**
  73184. * Gets or sets the font style
  73185. */
  73186. get fontStyle(): string;
  73187. set fontStyle(value: string);
  73188. /** Gets or sets font weight */
  73189. get fontWeight(): string;
  73190. set fontWeight(value: string);
  73191. /** Dispose all associated resources */
  73192. dispose(): void;
  73193. }
  73194. }
  73195. declare module BABYLON.GUI {
  73196. /**
  73197. * Class used to transport BABYLON.Vector2 information for pointer events
  73198. */
  73199. export class Vector2WithInfo extends BABYLON.Vector2 {
  73200. /** defines the current mouse button index */
  73201. buttonIndex: number;
  73202. /**
  73203. * Creates a new Vector2WithInfo
  73204. * @param source defines the vector2 data to transport
  73205. * @param buttonIndex defines the current mouse button index
  73206. */
  73207. constructor(source: BABYLON.Vector2,
  73208. /** defines the current mouse button index */
  73209. buttonIndex?: number);
  73210. }
  73211. /** Class used to provide 2D matrix features */
  73212. export class Matrix2D {
  73213. /** Gets the internal array of 6 floats used to store matrix data */
  73214. m: Float32Array;
  73215. /**
  73216. * Creates a new matrix
  73217. * @param m00 defines value for (0, 0)
  73218. * @param m01 defines value for (0, 1)
  73219. * @param m10 defines value for (1, 0)
  73220. * @param m11 defines value for (1, 1)
  73221. * @param m20 defines value for (2, 0)
  73222. * @param m21 defines value for (2, 1)
  73223. */
  73224. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  73225. /**
  73226. * Fills the matrix from direct values
  73227. * @param m00 defines value for (0, 0)
  73228. * @param m01 defines value for (0, 1)
  73229. * @param m10 defines value for (1, 0)
  73230. * @param m11 defines value for (1, 1)
  73231. * @param m20 defines value for (2, 0)
  73232. * @param m21 defines value for (2, 1)
  73233. * @returns the current modified matrix
  73234. */
  73235. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  73236. /**
  73237. * Gets matrix determinant
  73238. * @returns the determinant
  73239. */
  73240. determinant(): number;
  73241. /**
  73242. * Inverses the matrix and stores it in a target matrix
  73243. * @param result defines the target matrix
  73244. * @returns the current matrix
  73245. */
  73246. invertToRef(result: Matrix2D): Matrix2D;
  73247. /**
  73248. * Multiplies the current matrix with another one
  73249. * @param other defines the second operand
  73250. * @param result defines the target matrix
  73251. * @returns the current matrix
  73252. */
  73253. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  73254. /**
  73255. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  73256. * @param x defines the x coordinate to transform
  73257. * @param y defines the x coordinate to transform
  73258. * @param result defines the target vector2
  73259. * @returns the current matrix
  73260. */
  73261. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  73262. /**
  73263. * Creates an identity matrix
  73264. * @returns a new matrix
  73265. */
  73266. static Identity(): Matrix2D;
  73267. /**
  73268. * Creates a translation matrix and stores it in a target matrix
  73269. * @param x defines the x coordinate of the translation
  73270. * @param y defines the y coordinate of the translation
  73271. * @param result defines the target matrix
  73272. */
  73273. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  73274. /**
  73275. * Creates a scaling matrix and stores it in a target matrix
  73276. * @param x defines the x coordinate of the scaling
  73277. * @param y defines the y coordinate of the scaling
  73278. * @param result defines the target matrix
  73279. */
  73280. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  73281. /**
  73282. * Creates a rotation matrix and stores it in a target matrix
  73283. * @param angle defines the rotation angle
  73284. * @param result defines the target matrix
  73285. */
  73286. static RotationToRef(angle: number, result: Matrix2D): void;
  73287. private static _TempPreTranslationMatrix;
  73288. private static _TempPostTranslationMatrix;
  73289. private static _TempRotationMatrix;
  73290. private static _TempScalingMatrix;
  73291. private static _TempCompose0;
  73292. private static _TempCompose1;
  73293. private static _TempCompose2;
  73294. /**
  73295. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  73296. * @param tx defines the x coordinate of the translation
  73297. * @param ty defines the y coordinate of the translation
  73298. * @param angle defines the rotation angle
  73299. * @param scaleX defines the x coordinate of the scaling
  73300. * @param scaleY defines the y coordinate of the scaling
  73301. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  73302. * @param result defines the target matrix
  73303. */
  73304. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  73305. }
  73306. }
  73307. declare module BABYLON.GUI {
  73308. /**
  73309. * Class used to store 2D control sizes
  73310. */
  73311. export class Measure {
  73312. /** defines left coordinate */
  73313. left: number;
  73314. /** defines top coordinate */
  73315. top: number;
  73316. /** defines width dimension */
  73317. width: number;
  73318. /** defines height dimension */
  73319. height: number;
  73320. /**
  73321. * Creates a new measure
  73322. * @param left defines left coordinate
  73323. * @param top defines top coordinate
  73324. * @param width defines width dimension
  73325. * @param height defines height dimension
  73326. */
  73327. constructor(
  73328. /** defines left coordinate */
  73329. left: number,
  73330. /** defines top coordinate */
  73331. top: number,
  73332. /** defines width dimension */
  73333. width: number,
  73334. /** defines height dimension */
  73335. height: number);
  73336. /**
  73337. * Copy from another measure
  73338. * @param other defines the other measure to copy from
  73339. */
  73340. copyFrom(other: Measure): void;
  73341. /**
  73342. * Copy from a group of 4 floats
  73343. * @param left defines left coordinate
  73344. * @param top defines top coordinate
  73345. * @param width defines width dimension
  73346. * @param height defines height dimension
  73347. */
  73348. copyFromFloats(left: number, top: number, width: number, height: number): void;
  73349. /**
  73350. * Computes the axis aligned bounding box measure for two given measures
  73351. * @param a Input measure
  73352. * @param b Input measure
  73353. * @param result the resulting bounding measure
  73354. */
  73355. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  73356. /**
  73357. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  73358. * @param transform the matrix to transform the measure before computing the AABB
  73359. * @param result the resulting AABB
  73360. */
  73361. transformToRef(transform: Matrix2D, result: Measure): void;
  73362. /**
  73363. * Check equality between this measure and another one
  73364. * @param other defines the other measures
  73365. * @returns true if both measures are equals
  73366. */
  73367. isEqualsTo(other: Measure): boolean;
  73368. /**
  73369. * Creates an empty measure
  73370. * @returns a new measure
  73371. */
  73372. static Empty(): Measure;
  73373. }
  73374. }
  73375. declare module BABYLON.GUI {
  73376. /**
  73377. * Interface used to define a control that can receive focus
  73378. */
  73379. export interface IFocusableControl {
  73380. /**
  73381. * Function called when the control receives the focus
  73382. */
  73383. onFocus(): void;
  73384. /**
  73385. * Function called when the control loses the focus
  73386. */
  73387. onBlur(): void;
  73388. /**
  73389. * Function called to let the control handle keyboard events
  73390. * @param evt defines the current keyboard event
  73391. */
  73392. processKeyboard(evt: KeyboardEvent): void;
  73393. /**
  73394. * Function called to get the list of controls that should not steal the focus from this control
  73395. * @returns an array of controls
  73396. */
  73397. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73398. }
  73399. /**
  73400. * Class used to create texture to support 2D GUI elements
  73401. * @see http://doc.babylonjs.com/how_to/gui
  73402. */
  73403. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  73404. private _isDirty;
  73405. private _renderObserver;
  73406. private _resizeObserver;
  73407. private _preKeyboardObserver;
  73408. private _pointerMoveObserver;
  73409. private _pointerObserver;
  73410. private _canvasPointerOutObserver;
  73411. private _background;
  73412. /** @hidden */
  73413. _rootContainer: Container;
  73414. /** @hidden */
  73415. _lastPickedControl: Control;
  73416. /** @hidden */
  73417. _lastControlOver: {
  73418. [pointerId: number]: Control;
  73419. };
  73420. /** @hidden */
  73421. _lastControlDown: {
  73422. [pointerId: number]: Control;
  73423. };
  73424. /** @hidden */
  73425. _capturingControl: {
  73426. [pointerId: number]: Control;
  73427. };
  73428. /** @hidden */
  73429. _shouldBlockPointer: boolean;
  73430. /** @hidden */
  73431. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  73432. /** @hidden */
  73433. _linkedControls: Control[];
  73434. private _isFullscreen;
  73435. private _fullscreenViewport;
  73436. private _idealWidth;
  73437. private _idealHeight;
  73438. private _useSmallestIdeal;
  73439. private _renderAtIdealSize;
  73440. private _focusedControl;
  73441. private _blockNextFocusCheck;
  73442. private _renderScale;
  73443. private _rootElement;
  73444. private _cursorChanged;
  73445. private _defaultMousePointerId;
  73446. /** @hidden */
  73447. _numLayoutCalls: number;
  73448. /** Gets the number of layout calls made the last time the ADT has been rendered */
  73449. get numLayoutCalls(): number;
  73450. /** @hidden */
  73451. _numRenderCalls: number;
  73452. /** Gets the number of render calls made the last time the ADT has been rendered */
  73453. get numRenderCalls(): number;
  73454. /**
  73455. * Define type to string to ensure compatibility across browsers
  73456. * Safari doesn't support DataTransfer constructor
  73457. */
  73458. private _clipboardData;
  73459. /**
  73460. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  73461. */
  73462. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  73463. /**
  73464. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  73465. */
  73466. onControlPickedObservable: BABYLON.Observable<Control>;
  73467. /**
  73468. * BABYLON.Observable event triggered before layout is evaluated
  73469. */
  73470. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73471. /**
  73472. * BABYLON.Observable event triggered after the layout was evaluated
  73473. */
  73474. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73475. /**
  73476. * BABYLON.Observable event triggered before the texture is rendered
  73477. */
  73478. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73479. /**
  73480. * BABYLON.Observable event triggered after the texture was rendered
  73481. */
  73482. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73483. /**
  73484. * Gets or sets a boolean defining if alpha is stored as premultiplied
  73485. */
  73486. premulAlpha: boolean;
  73487. /**
  73488. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  73489. * Useful when you want more antialiasing
  73490. */
  73491. get renderScale(): number;
  73492. set renderScale(value: number);
  73493. /** Gets or sets the background color */
  73494. get background(): string;
  73495. set background(value: string);
  73496. /**
  73497. * Gets or sets the ideal width used to design controls.
  73498. * The GUI will then rescale everything accordingly
  73499. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73500. */
  73501. get idealWidth(): number;
  73502. set idealWidth(value: number);
  73503. /**
  73504. * Gets or sets the ideal height used to design controls.
  73505. * The GUI will then rescale everything accordingly
  73506. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73507. */
  73508. get idealHeight(): number;
  73509. set idealHeight(value: number);
  73510. /**
  73511. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  73512. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73513. */
  73514. get useSmallestIdeal(): boolean;
  73515. set useSmallestIdeal(value: boolean);
  73516. /**
  73517. * Gets or sets a boolean indicating if adaptive scaling must be used
  73518. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73519. */
  73520. get renderAtIdealSize(): boolean;
  73521. set renderAtIdealSize(value: boolean);
  73522. /**
  73523. * Gets the ratio used when in "ideal mode"
  73524. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73525. * */
  73526. get idealRatio(): number;
  73527. /**
  73528. * Gets the underlying layer used to render the texture when in fullscreen mode
  73529. */
  73530. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  73531. /**
  73532. * Gets the root container control
  73533. */
  73534. get rootContainer(): Container;
  73535. /**
  73536. * Returns an array containing the root container.
  73537. * This is mostly used to let the Inspector introspects the ADT
  73538. * @returns an array containing the rootContainer
  73539. */
  73540. getChildren(): Array<Container>;
  73541. /**
  73542. * Will return all controls that are inside this texture
  73543. * @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
  73544. * @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
  73545. * @return all child controls
  73546. */
  73547. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  73548. /**
  73549. * Gets or sets the current focused control
  73550. */
  73551. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  73552. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  73553. /**
  73554. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  73555. */
  73556. get isForeground(): boolean;
  73557. set isForeground(value: boolean);
  73558. /**
  73559. * Gets or set information about clipboardData
  73560. */
  73561. get clipboardData(): string;
  73562. set clipboardData(value: string);
  73563. /**
  73564. * Creates a new AdvancedDynamicTexture
  73565. * @param name defines the name of the texture
  73566. * @param width defines the width of the texture
  73567. * @param height defines the height of the texture
  73568. * @param scene defines the hosting scene
  73569. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  73570. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  73571. */
  73572. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  73573. /**
  73574. * Get the current class name of the texture useful for serialization or dynamic coding.
  73575. * @returns "AdvancedDynamicTexture"
  73576. */
  73577. getClassName(): string;
  73578. /**
  73579. * Function used to execute a function on all controls
  73580. * @param func defines the function to execute
  73581. * @param container defines the container where controls belong. If null the root container will be used
  73582. */
  73583. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  73584. private _useInvalidateRectOptimization;
  73585. /**
  73586. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  73587. */
  73588. get useInvalidateRectOptimization(): boolean;
  73589. set useInvalidateRectOptimization(value: boolean);
  73590. private _invalidatedRectangle;
  73591. /**
  73592. * Invalidates a rectangle area on the gui texture
  73593. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  73594. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  73595. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  73596. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  73597. */
  73598. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  73599. /**
  73600. * Marks the texture as dirty forcing a complete update
  73601. */
  73602. markAsDirty(): void;
  73603. /**
  73604. * Helper function used to create a new style
  73605. * @returns a new style
  73606. * @see http://doc.babylonjs.com/how_to/gui#styles
  73607. */
  73608. createStyle(): Style;
  73609. /**
  73610. * Adds a new control to the root container
  73611. * @param control defines the control to add
  73612. * @returns the current texture
  73613. */
  73614. addControl(control: Control): AdvancedDynamicTexture;
  73615. /**
  73616. * Removes a control from the root container
  73617. * @param control defines the control to remove
  73618. * @returns the current texture
  73619. */
  73620. removeControl(control: Control): AdvancedDynamicTexture;
  73621. /**
  73622. * Release all resources
  73623. */
  73624. dispose(): void;
  73625. private _onResize;
  73626. /** @hidden */
  73627. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  73628. /**
  73629. * Get screen coordinates for a vector3
  73630. * @param position defines the position to project
  73631. * @param worldMatrix defines the world matrix to use
  73632. * @returns the projected position
  73633. */
  73634. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  73635. private _checkUpdate;
  73636. private _clearMeasure;
  73637. private _render;
  73638. /** @hidden */
  73639. _changeCursor(cursor: string): void;
  73640. /** @hidden */
  73641. _registerLastControlDown(control: Control, pointerId: number): void;
  73642. private _doPicking;
  73643. /** @hidden */
  73644. _cleanControlAfterRemovalFromList(list: {
  73645. [pointerId: number]: Control;
  73646. }, control: Control): void;
  73647. /** @hidden */
  73648. _cleanControlAfterRemoval(control: Control): void;
  73649. /** Attach to all scene events required to support pointer events */
  73650. attach(): void;
  73651. /** @hidden */
  73652. private onClipboardCopy;
  73653. /** @hidden */
  73654. private onClipboardCut;
  73655. /** @hidden */
  73656. private onClipboardPaste;
  73657. /**
  73658. * Register the clipboard Events onto the canvas
  73659. */
  73660. registerClipboardEvents(): void;
  73661. /**
  73662. * Unregister the clipboard Events from the canvas
  73663. */
  73664. unRegisterClipboardEvents(): void;
  73665. /**
  73666. * Connect the texture to a hosting mesh to enable interactions
  73667. * @param mesh defines the mesh to attach to
  73668. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  73669. */
  73670. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  73671. /**
  73672. * Move the focus to a specific control
  73673. * @param control defines the control which will receive the focus
  73674. */
  73675. moveFocusToControl(control: IFocusableControl): void;
  73676. private _manageFocus;
  73677. private _attachToOnPointerOut;
  73678. /**
  73679. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  73680. * @param mesh defines the mesh which will receive the texture
  73681. * @param width defines the texture width (1024 by default)
  73682. * @param height defines the texture height (1024 by default)
  73683. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  73684. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  73685. * @returns a new AdvancedDynamicTexture
  73686. */
  73687. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  73688. /**
  73689. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  73690. * In this mode the texture will rely on a layer for its rendering.
  73691. * This allows it to be treated like any other layer.
  73692. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  73693. * LayerMask is set through advancedTexture.layer.layerMask
  73694. * @param name defines name for the texture
  73695. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  73696. * @param scene defines the hsoting scene
  73697. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  73698. * @returns a new AdvancedDynamicTexture
  73699. */
  73700. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  73701. }
  73702. }
  73703. declare module BABYLON.GUI {
  73704. /**
  73705. * Root class used for all 2D controls
  73706. * @see http://doc.babylonjs.com/how_to/gui#controls
  73707. */
  73708. export class Control {
  73709. /** defines the name of the control */
  73710. name?: string | undefined;
  73711. /**
  73712. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  73713. */
  73714. static AllowAlphaInheritance: boolean;
  73715. private _alpha;
  73716. private _alphaSet;
  73717. private _zIndex;
  73718. /** @hidden */
  73719. _host: AdvancedDynamicTexture;
  73720. /** Gets or sets the control parent */
  73721. parent: BABYLON.Nullable<Container>;
  73722. /** @hidden */
  73723. _currentMeasure: Measure;
  73724. private _fontFamily;
  73725. private _fontStyle;
  73726. private _fontWeight;
  73727. private _fontSize;
  73728. private _font;
  73729. /** @hidden */
  73730. _width: ValueAndUnit;
  73731. /** @hidden */
  73732. _height: ValueAndUnit;
  73733. /** @hidden */
  73734. protected _fontOffset: {
  73735. ascent: number;
  73736. height: number;
  73737. descent: number;
  73738. };
  73739. private _color;
  73740. private _style;
  73741. private _styleObserver;
  73742. /** @hidden */
  73743. protected _horizontalAlignment: number;
  73744. /** @hidden */
  73745. protected _verticalAlignment: number;
  73746. /** @hidden */
  73747. protected _isDirty: boolean;
  73748. /** @hidden */
  73749. protected _wasDirty: boolean;
  73750. /** @hidden */
  73751. _tempParentMeasure: Measure;
  73752. /** @hidden */
  73753. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  73754. /** @hidden */
  73755. protected _cachedParentMeasure: Measure;
  73756. private _paddingLeft;
  73757. private _paddingRight;
  73758. private _paddingTop;
  73759. private _paddingBottom;
  73760. /** @hidden */
  73761. _left: ValueAndUnit;
  73762. /** @hidden */
  73763. _top: ValueAndUnit;
  73764. private _scaleX;
  73765. private _scaleY;
  73766. private _rotation;
  73767. private _transformCenterX;
  73768. private _transformCenterY;
  73769. /** @hidden */
  73770. _transformMatrix: Matrix2D;
  73771. /** @hidden */
  73772. protected _invertTransformMatrix: Matrix2D;
  73773. /** @hidden */
  73774. protected _transformedPosition: BABYLON.Vector2;
  73775. private _isMatrixDirty;
  73776. private _cachedOffsetX;
  73777. private _cachedOffsetY;
  73778. private _isVisible;
  73779. private _isHighlighted;
  73780. /** @hidden */
  73781. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  73782. private _fontSet;
  73783. private _dummyVector2;
  73784. private _downCount;
  73785. private _enterCount;
  73786. private _doNotRender;
  73787. private _downPointerIds;
  73788. protected _isEnabled: boolean;
  73789. protected _disabledColor: string;
  73790. protected _disabledColorItem: string;
  73791. /** @hidden */
  73792. protected _rebuildLayout: boolean;
  73793. /** @hidden */
  73794. _customData: any;
  73795. /** @hidden */
  73796. _isClipped: boolean;
  73797. /** @hidden */
  73798. _automaticSize: boolean;
  73799. /** @hidden */
  73800. _tag: any;
  73801. /**
  73802. * 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
  73803. */
  73804. uniqueId: number;
  73805. /**
  73806. * Gets or sets an object used to store user defined information for the node
  73807. */
  73808. metadata: any;
  73809. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  73810. isHitTestVisible: boolean;
  73811. /** Gets or sets a boolean indicating if the control can block pointer events */
  73812. isPointerBlocker: boolean;
  73813. /** Gets or sets a boolean indicating if the control can be focusable */
  73814. isFocusInvisible: boolean;
  73815. /**
  73816. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  73817. * 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
  73818. */
  73819. clipChildren: boolean;
  73820. /**
  73821. * Gets or sets a boolean indicating that control content must be clipped
  73822. * 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
  73823. */
  73824. clipContent: boolean;
  73825. /**
  73826. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  73827. */
  73828. useBitmapCache: boolean;
  73829. private _cacheData;
  73830. private _shadowOffsetX;
  73831. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  73832. get shadowOffsetX(): number;
  73833. set shadowOffsetX(value: number);
  73834. private _shadowOffsetY;
  73835. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  73836. get shadowOffsetY(): number;
  73837. set shadowOffsetY(value: number);
  73838. private _shadowBlur;
  73839. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  73840. get shadowBlur(): number;
  73841. set shadowBlur(value: number);
  73842. private _shadowColor;
  73843. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  73844. get shadowColor(): string;
  73845. set shadowColor(value: string);
  73846. /** Gets or sets the cursor to use when the control is hovered */
  73847. hoverCursor: string;
  73848. /** @hidden */
  73849. protected _linkOffsetX: ValueAndUnit;
  73850. /** @hidden */
  73851. protected _linkOffsetY: ValueAndUnit;
  73852. /** Gets the control type name */
  73853. get typeName(): string;
  73854. /**
  73855. * Get the current class name of the control.
  73856. * @returns current class name
  73857. */
  73858. getClassName(): string;
  73859. /**
  73860. * An event triggered when pointer wheel is scrolled
  73861. */
  73862. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  73863. /**
  73864. * An event triggered when the pointer move over the control.
  73865. */
  73866. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  73867. /**
  73868. * An event triggered when the pointer move out of the control.
  73869. */
  73870. onPointerOutObservable: BABYLON.Observable<Control>;
  73871. /**
  73872. * An event triggered when the pointer taps the control
  73873. */
  73874. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  73875. /**
  73876. * An event triggered when pointer up
  73877. */
  73878. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  73879. /**
  73880. * An event triggered when a control is clicked on
  73881. */
  73882. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  73883. /**
  73884. * An event triggered when pointer enters the control
  73885. */
  73886. onPointerEnterObservable: BABYLON.Observable<Control>;
  73887. /**
  73888. * An event triggered when the control is marked as dirty
  73889. */
  73890. onDirtyObservable: BABYLON.Observable<Control>;
  73891. /**
  73892. * An event triggered before drawing the control
  73893. */
  73894. onBeforeDrawObservable: BABYLON.Observable<Control>;
  73895. /**
  73896. * An event triggered after the control was drawn
  73897. */
  73898. onAfterDrawObservable: BABYLON.Observable<Control>;
  73899. /**
  73900. * An event triggered when the control has been disposed
  73901. */
  73902. onDisposeObservable: BABYLON.Observable<Control>;
  73903. /**
  73904. * Get the hosting AdvancedDynamicTexture
  73905. */
  73906. get host(): AdvancedDynamicTexture;
  73907. /** Gets or set information about font offsets (used to render and align text) */
  73908. get fontOffset(): {
  73909. ascent: number;
  73910. height: number;
  73911. descent: number;
  73912. };
  73913. set fontOffset(offset: {
  73914. ascent: number;
  73915. height: number;
  73916. descent: number;
  73917. });
  73918. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  73919. get alpha(): number;
  73920. set alpha(value: number);
  73921. /**
  73922. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  73923. */
  73924. get isHighlighted(): boolean;
  73925. set isHighlighted(value: boolean);
  73926. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  73927. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73928. */
  73929. get scaleX(): number;
  73930. set scaleX(value: number);
  73931. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  73932. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73933. */
  73934. get scaleY(): number;
  73935. set scaleY(value: number);
  73936. /** Gets or sets the rotation angle (0 by default)
  73937. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73938. */
  73939. get rotation(): number;
  73940. set rotation(value: number);
  73941. /** Gets or sets the transformation center on Y axis (0 by default)
  73942. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73943. */
  73944. get transformCenterY(): number;
  73945. set transformCenterY(value: number);
  73946. /** Gets or sets the transformation center on X axis (0 by default)
  73947. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73948. */
  73949. get transformCenterX(): number;
  73950. set transformCenterX(value: number);
  73951. /**
  73952. * Gets or sets the horizontal alignment
  73953. * @see http://doc.babylonjs.com/how_to/gui#alignments
  73954. */
  73955. get horizontalAlignment(): number;
  73956. set horizontalAlignment(value: number);
  73957. /**
  73958. * Gets or sets the vertical alignment
  73959. * @see http://doc.babylonjs.com/how_to/gui#alignments
  73960. */
  73961. get verticalAlignment(): number;
  73962. set verticalAlignment(value: number);
  73963. /**
  73964. * Gets or sets control width
  73965. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73966. */
  73967. get width(): string | number;
  73968. set width(value: string | number);
  73969. /**
  73970. * Gets or sets the control width in pixel
  73971. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73972. */
  73973. get widthInPixels(): number;
  73974. set widthInPixels(value: number);
  73975. /**
  73976. * Gets or sets control height
  73977. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73978. */
  73979. get height(): string | number;
  73980. set height(value: string | number);
  73981. /**
  73982. * Gets or sets control height in pixel
  73983. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73984. */
  73985. get heightInPixels(): number;
  73986. set heightInPixels(value: number);
  73987. /** Gets or set font family */
  73988. get fontFamily(): string;
  73989. set fontFamily(value: string);
  73990. /** Gets or sets font style */
  73991. get fontStyle(): string;
  73992. set fontStyle(value: string);
  73993. /** Gets or sets font weight */
  73994. get fontWeight(): string;
  73995. set fontWeight(value: string);
  73996. /**
  73997. * Gets or sets style
  73998. * @see http://doc.babylonjs.com/how_to/gui#styles
  73999. */
  74000. get style(): BABYLON.Nullable<Style>;
  74001. set style(value: BABYLON.Nullable<Style>);
  74002. /** @hidden */
  74003. get _isFontSizeInPercentage(): boolean;
  74004. /** Gets or sets font size in pixels */
  74005. get fontSizeInPixels(): number;
  74006. set fontSizeInPixels(value: number);
  74007. /** Gets or sets font size */
  74008. get fontSize(): string | number;
  74009. set fontSize(value: string | number);
  74010. /** Gets or sets foreground color */
  74011. get color(): string;
  74012. set color(value: string);
  74013. /** Gets or sets z index which is used to reorder controls on the z axis */
  74014. get zIndex(): number;
  74015. set zIndex(value: number);
  74016. /** Gets or sets a boolean indicating if the control can be rendered */
  74017. get notRenderable(): boolean;
  74018. set notRenderable(value: boolean);
  74019. /** Gets or sets a boolean indicating if the control is visible */
  74020. get isVisible(): boolean;
  74021. set isVisible(value: boolean);
  74022. /** Gets a boolean indicating that the control needs to update its rendering */
  74023. get isDirty(): boolean;
  74024. /**
  74025. * Gets the current linked mesh (or null if none)
  74026. */
  74027. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74028. /**
  74029. * Gets or sets a value indicating the padding to use on the left of the control
  74030. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74031. */
  74032. get paddingLeft(): string | number;
  74033. set paddingLeft(value: string | number);
  74034. /**
  74035. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  74036. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74037. */
  74038. get paddingLeftInPixels(): number;
  74039. set paddingLeftInPixels(value: number);
  74040. /**
  74041. * Gets or sets a value indicating the padding to use on the right of the control
  74042. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74043. */
  74044. get paddingRight(): string | number;
  74045. set paddingRight(value: string | number);
  74046. /**
  74047. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  74048. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74049. */
  74050. get paddingRightInPixels(): number;
  74051. set paddingRightInPixels(value: number);
  74052. /**
  74053. * Gets or sets a value indicating the padding to use on the top of the control
  74054. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74055. */
  74056. get paddingTop(): string | number;
  74057. set paddingTop(value: string | number);
  74058. /**
  74059. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  74060. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74061. */
  74062. get paddingTopInPixels(): number;
  74063. set paddingTopInPixels(value: number);
  74064. /**
  74065. * Gets or sets a value indicating the padding to use on the bottom of the control
  74066. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74067. */
  74068. get paddingBottom(): string | number;
  74069. set paddingBottom(value: string | number);
  74070. /**
  74071. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  74072. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74073. */
  74074. get paddingBottomInPixels(): number;
  74075. set paddingBottomInPixels(value: number);
  74076. /**
  74077. * Gets or sets a value indicating the left coordinate of the control
  74078. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74079. */
  74080. get left(): string | number;
  74081. set left(value: string | number);
  74082. /**
  74083. * Gets or sets a value indicating the left coordinate in pixels of the control
  74084. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74085. */
  74086. get leftInPixels(): number;
  74087. set leftInPixels(value: number);
  74088. /**
  74089. * Gets or sets a value indicating the top coordinate of the control
  74090. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74091. */
  74092. get top(): string | number;
  74093. set top(value: string | number);
  74094. /**
  74095. * Gets or sets a value indicating the top coordinate in pixels of the control
  74096. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74097. */
  74098. get topInPixels(): number;
  74099. set topInPixels(value: number);
  74100. /**
  74101. * Gets or sets a value indicating the offset on X axis to the linked mesh
  74102. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74103. */
  74104. get linkOffsetX(): string | number;
  74105. set linkOffsetX(value: string | number);
  74106. /**
  74107. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  74108. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74109. */
  74110. get linkOffsetXInPixels(): number;
  74111. set linkOffsetXInPixels(value: number);
  74112. /**
  74113. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  74114. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74115. */
  74116. get linkOffsetY(): string | number;
  74117. set linkOffsetY(value: string | number);
  74118. /**
  74119. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  74120. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74121. */
  74122. get linkOffsetYInPixels(): number;
  74123. set linkOffsetYInPixels(value: number);
  74124. /** Gets the center coordinate on X axis */
  74125. get centerX(): number;
  74126. /** Gets the center coordinate on Y axis */
  74127. get centerY(): number;
  74128. /** Gets or sets if control is Enabled*/
  74129. get isEnabled(): boolean;
  74130. set isEnabled(value: boolean);
  74131. /** Gets or sets background color of control if it's disabled*/
  74132. get disabledColor(): string;
  74133. set disabledColor(value: string);
  74134. /** Gets or sets front color of control if it's disabled*/
  74135. get disabledColorItem(): string;
  74136. set disabledColorItem(value: string);
  74137. /**
  74138. * Creates a new control
  74139. * @param name defines the name of the control
  74140. */
  74141. constructor(
  74142. /** defines the name of the control */
  74143. name?: string | undefined);
  74144. /** @hidden */
  74145. protected _getTypeName(): string;
  74146. /**
  74147. * Gets the first ascendant in the hierarchy of the given type
  74148. * @param className defines the required type
  74149. * @returns the ascendant or null if not found
  74150. */
  74151. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  74152. /** @hidden */
  74153. _resetFontCache(): void;
  74154. /**
  74155. * Determines if a container is an ascendant of the current control
  74156. * @param container defines the container to look for
  74157. * @returns true if the container is one of the ascendant of the control
  74158. */
  74159. isAscendant(container: Control): boolean;
  74160. /**
  74161. * Gets coordinates in local control space
  74162. * @param globalCoordinates defines the coordinates to transform
  74163. * @returns the new coordinates in local space
  74164. */
  74165. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74166. /**
  74167. * Gets coordinates in local control space
  74168. * @param globalCoordinates defines the coordinates to transform
  74169. * @param result defines the target vector2 where to store the result
  74170. * @returns the current control
  74171. */
  74172. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  74173. /**
  74174. * Gets coordinates in parent local control space
  74175. * @param globalCoordinates defines the coordinates to transform
  74176. * @returns the new coordinates in parent local space
  74177. */
  74178. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74179. /**
  74180. * Move the current control to a vector3 position projected onto the screen.
  74181. * @param position defines the target position
  74182. * @param scene defines the hosting scene
  74183. */
  74184. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  74185. /**
  74186. * Will store all controls that have this control as ascendant in a given array
  74187. * @param results defines the array where to store the descendants
  74188. * @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
  74189. * @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
  74190. */
  74191. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  74192. /**
  74193. * Will return all controls that have this control as ascendant
  74194. * @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
  74195. * @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
  74196. * @return all child controls
  74197. */
  74198. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74199. /**
  74200. * Link current control with a target mesh
  74201. * @param mesh defines the mesh to link with
  74202. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74203. */
  74204. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  74205. /** @hidden */
  74206. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  74207. /** @hidden */
  74208. _offsetLeft(offset: number): void;
  74209. /** @hidden */
  74210. _offsetTop(offset: number): void;
  74211. /** @hidden */
  74212. _markMatrixAsDirty(): void;
  74213. /** @hidden */
  74214. _flagDescendantsAsMatrixDirty(): void;
  74215. /** @hidden */
  74216. _intersectsRect(rect: Measure): boolean;
  74217. /** @hidden */
  74218. protected invalidateRect(): void;
  74219. /** @hidden */
  74220. _markAsDirty(force?: boolean): void;
  74221. /** @hidden */
  74222. _markAllAsDirty(): void;
  74223. /** @hidden */
  74224. _link(host: AdvancedDynamicTexture): void;
  74225. /** @hidden */
  74226. protected _transform(context?: CanvasRenderingContext2D): void;
  74227. /** @hidden */
  74228. _renderHighlight(context: CanvasRenderingContext2D): void;
  74229. /** @hidden */
  74230. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74231. /** @hidden */
  74232. protected _applyStates(context: CanvasRenderingContext2D): void;
  74233. /** @hidden */
  74234. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74235. /** @hidden */
  74236. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74237. protected _evaluateClippingState(parentMeasure: Measure): void;
  74238. /** @hidden */
  74239. _measure(): void;
  74240. /** @hidden */
  74241. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74242. /** @hidden */
  74243. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74244. /** @hidden */
  74245. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74246. /** @hidden */
  74247. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74248. private static _ClipMeasure;
  74249. private _tmpMeasureA;
  74250. private _clip;
  74251. /** @hidden */
  74252. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  74253. /** @hidden */
  74254. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74255. /**
  74256. * Tests if a given coordinates belong to the current control
  74257. * @param x defines x coordinate to test
  74258. * @param y defines y coordinate to test
  74259. * @returns true if the coordinates are inside the control
  74260. */
  74261. contains(x: number, y: number): boolean;
  74262. /** @hidden */
  74263. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74264. /** @hidden */
  74265. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74266. /** @hidden */
  74267. _onPointerEnter(target: Control): boolean;
  74268. /** @hidden */
  74269. _onPointerOut(target: Control, force?: boolean): void;
  74270. /** @hidden */
  74271. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74272. /** @hidden */
  74273. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74274. /** @hidden */
  74275. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74276. /** @hidden */
  74277. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  74278. /** @hidden */
  74279. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74280. private _prepareFont;
  74281. /** Releases associated resources */
  74282. dispose(): void;
  74283. private static _HORIZONTAL_ALIGNMENT_LEFT;
  74284. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  74285. private static _HORIZONTAL_ALIGNMENT_CENTER;
  74286. private static _VERTICAL_ALIGNMENT_TOP;
  74287. private static _VERTICAL_ALIGNMENT_BOTTOM;
  74288. private static _VERTICAL_ALIGNMENT_CENTER;
  74289. /** HORIZONTAL_ALIGNMENT_LEFT */
  74290. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  74291. /** HORIZONTAL_ALIGNMENT_RIGHT */
  74292. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  74293. /** HORIZONTAL_ALIGNMENT_CENTER */
  74294. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  74295. /** VERTICAL_ALIGNMENT_TOP */
  74296. static get VERTICAL_ALIGNMENT_TOP(): number;
  74297. /** VERTICAL_ALIGNMENT_BOTTOM */
  74298. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  74299. /** VERTICAL_ALIGNMENT_CENTER */
  74300. static get VERTICAL_ALIGNMENT_CENTER(): number;
  74301. private static _FontHeightSizes;
  74302. /** @hidden */
  74303. static _GetFontOffset(font: string): {
  74304. ascent: number;
  74305. height: number;
  74306. descent: number;
  74307. };
  74308. /**
  74309. * Creates a stack panel that can be used to render headers
  74310. * @param control defines the control to associate with the header
  74311. * @param text defines the text of the header
  74312. * @param size defines the size of the header
  74313. * @param options defines options used to configure the header
  74314. * @returns a new StackPanel
  74315. * @ignore
  74316. * @hidden
  74317. */
  74318. static AddHeader: (control: Control, text: string, size: string | number, options: {
  74319. isHorizontal: boolean;
  74320. controlFirst: boolean;
  74321. }) => any;
  74322. /** @hidden */
  74323. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  74324. }
  74325. }
  74326. declare module BABYLON.GUI {
  74327. /**
  74328. * Root class for 2D containers
  74329. * @see http://doc.babylonjs.com/how_to/gui#containers
  74330. */
  74331. export class Container extends Control {
  74332. name?: string | undefined;
  74333. /** @hidden */
  74334. _children: Control[];
  74335. /** @hidden */
  74336. protected _measureForChildren: Measure;
  74337. /** @hidden */
  74338. protected _background: string;
  74339. /** @hidden */
  74340. protected _adaptWidthToChildren: boolean;
  74341. /** @hidden */
  74342. protected _adaptHeightToChildren: boolean;
  74343. /**
  74344. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  74345. */
  74346. logLayoutCycleErrors: boolean;
  74347. /**
  74348. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  74349. */
  74350. maxLayoutCycle: number;
  74351. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  74352. get adaptHeightToChildren(): boolean;
  74353. set adaptHeightToChildren(value: boolean);
  74354. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  74355. get adaptWidthToChildren(): boolean;
  74356. set adaptWidthToChildren(value: boolean);
  74357. /** Gets or sets background color */
  74358. get background(): string;
  74359. set background(value: string);
  74360. /** Gets the list of children */
  74361. get children(): Control[];
  74362. /**
  74363. * Creates a new Container
  74364. * @param name defines the name of the container
  74365. */
  74366. constructor(name?: string | undefined);
  74367. protected _getTypeName(): string;
  74368. _flagDescendantsAsMatrixDirty(): void;
  74369. /**
  74370. * Gets a child using its name
  74371. * @param name defines the child name to look for
  74372. * @returns the child control if found
  74373. */
  74374. getChildByName(name: string): BABYLON.Nullable<Control>;
  74375. /**
  74376. * Gets a child using its type and its name
  74377. * @param name defines the child name to look for
  74378. * @param type defines the child type to look for
  74379. * @returns the child control if found
  74380. */
  74381. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  74382. /**
  74383. * Search for a specific control in children
  74384. * @param control defines the control to look for
  74385. * @returns true if the control is in child list
  74386. */
  74387. containsControl(control: Control): boolean;
  74388. /**
  74389. * Adds a new control to the current container
  74390. * @param control defines the control to add
  74391. * @returns the current container
  74392. */
  74393. addControl(control: BABYLON.Nullable<Control>): Container;
  74394. /**
  74395. * Removes all controls from the current container
  74396. * @returns the current container
  74397. */
  74398. clearControls(): Container;
  74399. /**
  74400. * Removes a control from the current container
  74401. * @param control defines the control to remove
  74402. * @returns the current container
  74403. */
  74404. removeControl(control: Control): Container;
  74405. /** @hidden */
  74406. _reOrderControl(control: Control): void;
  74407. /** @hidden */
  74408. _offsetLeft(offset: number): void;
  74409. /** @hidden */
  74410. _offsetTop(offset: number): void;
  74411. /** @hidden */
  74412. _markAllAsDirty(): void;
  74413. /** @hidden */
  74414. protected _localDraw(context: CanvasRenderingContext2D): void;
  74415. /** @hidden */
  74416. _link(host: AdvancedDynamicTexture): void;
  74417. /** @hidden */
  74418. protected _beforeLayout(): void;
  74419. /** @hidden */
  74420. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74421. /** @hidden */
  74422. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74423. protected _postMeasure(): void;
  74424. /** @hidden */
  74425. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  74426. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  74427. /** @hidden */
  74428. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74429. /** @hidden */
  74430. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74431. /** Releases associated resources */
  74432. dispose(): void;
  74433. }
  74434. }
  74435. declare module BABYLON.GUI {
  74436. /** Class used to create rectangle container */
  74437. export class Rectangle extends Container {
  74438. name?: string | undefined;
  74439. private _thickness;
  74440. private _cornerRadius;
  74441. /** Gets or sets border thickness */
  74442. get thickness(): number;
  74443. set thickness(value: number);
  74444. /** Gets or sets the corner radius angle */
  74445. get cornerRadius(): number;
  74446. set cornerRadius(value: number);
  74447. /**
  74448. * Creates a new Rectangle
  74449. * @param name defines the control name
  74450. */
  74451. constructor(name?: string | undefined);
  74452. protected _getTypeName(): string;
  74453. protected _localDraw(context: CanvasRenderingContext2D): void;
  74454. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74455. private _drawRoundedRect;
  74456. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74457. }
  74458. }
  74459. declare module BABYLON.GUI {
  74460. /**
  74461. * Enum that determines the text-wrapping mode to use.
  74462. */
  74463. export enum TextWrapping {
  74464. /**
  74465. * Clip the text when it's larger than Control.width; this is the default mode.
  74466. */
  74467. Clip = 0,
  74468. /**
  74469. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  74470. */
  74471. WordWrap = 1,
  74472. /**
  74473. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  74474. */
  74475. Ellipsis = 2
  74476. }
  74477. /**
  74478. * Class used to create text block control
  74479. */
  74480. export class TextBlock extends Control {
  74481. /**
  74482. * Defines the name of the control
  74483. */
  74484. name?: string | undefined;
  74485. private _text;
  74486. private _textWrapping;
  74487. private _textHorizontalAlignment;
  74488. private _textVerticalAlignment;
  74489. private _lines;
  74490. private _resizeToFit;
  74491. private _lineSpacing;
  74492. private _outlineWidth;
  74493. private _outlineColor;
  74494. /**
  74495. * An event triggered after the text is changed
  74496. */
  74497. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  74498. /**
  74499. * An event triggered after the text was broken up into lines
  74500. */
  74501. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  74502. /**
  74503. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  74504. */
  74505. get lines(): any[];
  74506. /**
  74507. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  74508. */
  74509. get resizeToFit(): boolean;
  74510. /**
  74511. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  74512. */
  74513. set resizeToFit(value: boolean);
  74514. /**
  74515. * Gets or sets a boolean indicating if text must be wrapped
  74516. */
  74517. get textWrapping(): TextWrapping | boolean;
  74518. /**
  74519. * Gets or sets a boolean indicating if text must be wrapped
  74520. */
  74521. set textWrapping(value: TextWrapping | boolean);
  74522. /**
  74523. * Gets or sets text to display
  74524. */
  74525. get text(): string;
  74526. /**
  74527. * Gets or sets text to display
  74528. */
  74529. set text(value: string);
  74530. /**
  74531. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  74532. */
  74533. get textHorizontalAlignment(): number;
  74534. /**
  74535. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  74536. */
  74537. set textHorizontalAlignment(value: number);
  74538. /**
  74539. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  74540. */
  74541. get textVerticalAlignment(): number;
  74542. /**
  74543. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  74544. */
  74545. set textVerticalAlignment(value: number);
  74546. /**
  74547. * Gets or sets line spacing value
  74548. */
  74549. set lineSpacing(value: string | number);
  74550. /**
  74551. * Gets or sets line spacing value
  74552. */
  74553. get lineSpacing(): string | number;
  74554. /**
  74555. * Gets or sets outlineWidth of the text to display
  74556. */
  74557. get outlineWidth(): number;
  74558. /**
  74559. * Gets or sets outlineWidth of the text to display
  74560. */
  74561. set outlineWidth(value: number);
  74562. /**
  74563. * Gets or sets outlineColor of the text to display
  74564. */
  74565. get outlineColor(): string;
  74566. /**
  74567. * Gets or sets outlineColor of the text to display
  74568. */
  74569. set outlineColor(value: string);
  74570. /**
  74571. * Creates a new TextBlock object
  74572. * @param name defines the name of the control
  74573. * @param text defines the text to display (emptry string by default)
  74574. */
  74575. constructor(
  74576. /**
  74577. * Defines the name of the control
  74578. */
  74579. name?: string | undefined, text?: string);
  74580. protected _getTypeName(): string;
  74581. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74582. private _drawText;
  74583. /** @hidden */
  74584. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74585. protected _applyStates(context: CanvasRenderingContext2D): void;
  74586. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  74587. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  74588. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  74589. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  74590. protected _renderLines(context: CanvasRenderingContext2D): void;
  74591. /**
  74592. * Given a width constraint applied on the text block, find the expected height
  74593. * @returns expected height
  74594. */
  74595. computeExpectedHeight(): number;
  74596. dispose(): void;
  74597. }
  74598. }
  74599. declare module BABYLON.GUI {
  74600. /**
  74601. * Class used to create 2D images
  74602. */
  74603. export class Image extends Control {
  74604. name?: string | undefined;
  74605. private _workingCanvas;
  74606. private _domImage;
  74607. private _imageWidth;
  74608. private _imageHeight;
  74609. private _loaded;
  74610. private _stretch;
  74611. private _source;
  74612. private _autoScale;
  74613. private _sourceLeft;
  74614. private _sourceTop;
  74615. private _sourceWidth;
  74616. private _sourceHeight;
  74617. private _svgAttributesComputationCompleted;
  74618. private _isSVG;
  74619. private _cellWidth;
  74620. private _cellHeight;
  74621. private _cellId;
  74622. private _populateNinePatchSlicesFromImage;
  74623. private _sliceLeft;
  74624. private _sliceRight;
  74625. private _sliceTop;
  74626. private _sliceBottom;
  74627. private _detectPointerOnOpaqueOnly;
  74628. /**
  74629. * BABYLON.Observable notified when the content is loaded
  74630. */
  74631. onImageLoadedObservable: BABYLON.Observable<Image>;
  74632. /**
  74633. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  74634. */
  74635. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  74636. /**
  74637. * Gets a boolean indicating that the content is loaded
  74638. */
  74639. get isLoaded(): boolean;
  74640. /**
  74641. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  74642. */
  74643. get populateNinePatchSlicesFromImage(): boolean;
  74644. set populateNinePatchSlicesFromImage(value: boolean);
  74645. /**
  74646. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  74647. * Beware using this as this will comsume more memory as the image has to be stored twice
  74648. */
  74649. get detectPointerOnOpaqueOnly(): boolean;
  74650. set detectPointerOnOpaqueOnly(value: boolean);
  74651. /**
  74652. * Gets or sets the left value for slicing (9-patch)
  74653. */
  74654. get sliceLeft(): number;
  74655. set sliceLeft(value: number);
  74656. /**
  74657. * Gets or sets the right value for slicing (9-patch)
  74658. */
  74659. get sliceRight(): number;
  74660. set sliceRight(value: number);
  74661. /**
  74662. * Gets or sets the top value for slicing (9-patch)
  74663. */
  74664. get sliceTop(): number;
  74665. set sliceTop(value: number);
  74666. /**
  74667. * Gets or sets the bottom value for slicing (9-patch)
  74668. */
  74669. get sliceBottom(): number;
  74670. set sliceBottom(value: number);
  74671. /**
  74672. * Gets or sets the left coordinate in the source image
  74673. */
  74674. get sourceLeft(): number;
  74675. set sourceLeft(value: number);
  74676. /**
  74677. * Gets or sets the top coordinate in the source image
  74678. */
  74679. get sourceTop(): number;
  74680. set sourceTop(value: number);
  74681. /**
  74682. * Gets or sets the width to capture in the source image
  74683. */
  74684. get sourceWidth(): number;
  74685. set sourceWidth(value: number);
  74686. /**
  74687. * Gets or sets the height to capture in the source image
  74688. */
  74689. get sourceHeight(): number;
  74690. set sourceHeight(value: number);
  74691. /** Indicates if the format of the image is SVG */
  74692. get isSVG(): boolean;
  74693. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  74694. get svgAttributesComputationCompleted(): boolean;
  74695. /**
  74696. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  74697. * @see http://doc.babylonjs.com/how_to/gui#image
  74698. */
  74699. get autoScale(): boolean;
  74700. set autoScale(value: boolean);
  74701. /** Gets or sets the streching mode used by the image */
  74702. get stretch(): number;
  74703. set stretch(value: number);
  74704. /** @hidden */
  74705. _rotate90(n: number, preserveProperties?: boolean): Image;
  74706. private _handleRotationForSVGImage;
  74707. private _rotate90SourceProperties;
  74708. /**
  74709. * Gets or sets the internal DOM image used to render the control
  74710. */
  74711. set domImage(value: HTMLImageElement);
  74712. get domImage(): HTMLImageElement;
  74713. private _onImageLoaded;
  74714. private _extractNinePatchSliceDataFromImage;
  74715. /**
  74716. * Gets or sets image source url
  74717. */
  74718. set source(value: BABYLON.Nullable<string>);
  74719. /**
  74720. * Checks for svg document with icon id present
  74721. */
  74722. private _svgCheck;
  74723. /**
  74724. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  74725. * given external svg file and icon id
  74726. */
  74727. private _getSVGAttribs;
  74728. /**
  74729. * Gets or sets the cell width to use when animation sheet is enabled
  74730. * @see http://doc.babylonjs.com/how_to/gui#image
  74731. */
  74732. get cellWidth(): number;
  74733. set cellWidth(value: number);
  74734. /**
  74735. * Gets or sets the cell height to use when animation sheet is enabled
  74736. * @see http://doc.babylonjs.com/how_to/gui#image
  74737. */
  74738. get cellHeight(): number;
  74739. set cellHeight(value: number);
  74740. /**
  74741. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  74742. * @see http://doc.babylonjs.com/how_to/gui#image
  74743. */
  74744. get cellId(): number;
  74745. set cellId(value: number);
  74746. /**
  74747. * Creates a new Image
  74748. * @param name defines the control name
  74749. * @param url defines the image url
  74750. */
  74751. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  74752. /**
  74753. * Tests if a given coordinates belong to the current control
  74754. * @param x defines x coordinate to test
  74755. * @param y defines y coordinate to test
  74756. * @returns true if the coordinates are inside the control
  74757. */
  74758. contains(x: number, y: number): boolean;
  74759. protected _getTypeName(): string;
  74760. /** Force the control to synchronize with its content */
  74761. synchronizeSizeWithContent(): void;
  74762. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74763. private _prepareWorkingCanvasForOpaqueDetection;
  74764. private _drawImage;
  74765. _draw(context: CanvasRenderingContext2D): void;
  74766. private _renderCornerPatch;
  74767. private _renderNinePatch;
  74768. dispose(): void;
  74769. /** STRETCH_NONE */
  74770. static readonly STRETCH_NONE: number;
  74771. /** STRETCH_FILL */
  74772. static readonly STRETCH_FILL: number;
  74773. /** STRETCH_UNIFORM */
  74774. static readonly STRETCH_UNIFORM: number;
  74775. /** STRETCH_EXTEND */
  74776. static readonly STRETCH_EXTEND: number;
  74777. /** NINE_PATCH */
  74778. static readonly STRETCH_NINE_PATCH: number;
  74779. }
  74780. }
  74781. declare module BABYLON.GUI {
  74782. /**
  74783. * Class used to create 2D buttons
  74784. */
  74785. export class Button extends Rectangle {
  74786. name?: string | undefined;
  74787. /**
  74788. * Function called to generate a pointer enter animation
  74789. */
  74790. pointerEnterAnimation: () => void;
  74791. /**
  74792. * Function called to generate a pointer out animation
  74793. */
  74794. pointerOutAnimation: () => void;
  74795. /**
  74796. * Function called to generate a pointer down animation
  74797. */
  74798. pointerDownAnimation: () => void;
  74799. /**
  74800. * Function called to generate a pointer up animation
  74801. */
  74802. pointerUpAnimation: () => void;
  74803. /**
  74804. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  74805. */
  74806. delegatePickingToChildren: boolean;
  74807. private _image;
  74808. /**
  74809. * Returns the image part of the button (if any)
  74810. */
  74811. get image(): BABYLON.Nullable<Image>;
  74812. private _textBlock;
  74813. /**
  74814. * Returns the image part of the button (if any)
  74815. */
  74816. get textBlock(): BABYLON.Nullable<TextBlock>;
  74817. /**
  74818. * Creates a new Button
  74819. * @param name defines the name of the button
  74820. */
  74821. constructor(name?: string | undefined);
  74822. protected _getTypeName(): string;
  74823. /** @hidden */
  74824. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74825. /** @hidden */
  74826. _onPointerEnter(target: Control): boolean;
  74827. /** @hidden */
  74828. _onPointerOut(target: Control, force?: boolean): void;
  74829. /** @hidden */
  74830. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74831. /** @hidden */
  74832. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74833. /**
  74834. * Creates a new button made with an image and a text
  74835. * @param name defines the name of the button
  74836. * @param text defines the text of the button
  74837. * @param imageUrl defines the url of the image
  74838. * @returns a new Button
  74839. */
  74840. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  74841. /**
  74842. * Creates a new button made with an image
  74843. * @param name defines the name of the button
  74844. * @param imageUrl defines the url of the image
  74845. * @returns a new Button
  74846. */
  74847. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  74848. /**
  74849. * Creates a new button made with a text
  74850. * @param name defines the name of the button
  74851. * @param text defines the text of the button
  74852. * @returns a new Button
  74853. */
  74854. static CreateSimpleButton(name: string, text: string): Button;
  74855. /**
  74856. * Creates a new button made with an image and a centered text
  74857. * @param name defines the name of the button
  74858. * @param text defines the text of the button
  74859. * @param imageUrl defines the url of the image
  74860. * @returns a new Button
  74861. */
  74862. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  74863. }
  74864. }
  74865. declare module BABYLON.GUI {
  74866. /**
  74867. * Class used to create a 2D stack panel container
  74868. */
  74869. export class StackPanel extends Container {
  74870. name?: string | undefined;
  74871. private _isVertical;
  74872. private _manualWidth;
  74873. private _manualHeight;
  74874. private _doNotTrackManualChanges;
  74875. /**
  74876. * Gets or sets a boolean indicating that layou warnings should be ignored
  74877. */
  74878. ignoreLayoutWarnings: boolean;
  74879. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  74880. get isVertical(): boolean;
  74881. set isVertical(value: boolean);
  74882. /**
  74883. * Gets or sets panel width.
  74884. * This value should not be set when in horizontal mode as it will be computed automatically
  74885. */
  74886. set width(value: string | number);
  74887. get width(): string | number;
  74888. /**
  74889. * Gets or sets panel height.
  74890. * This value should not be set when in vertical mode as it will be computed automatically
  74891. */
  74892. set height(value: string | number);
  74893. get height(): string | number;
  74894. /**
  74895. * Creates a new StackPanel
  74896. * @param name defines control name
  74897. */
  74898. constructor(name?: string | undefined);
  74899. protected _getTypeName(): string;
  74900. /** @hidden */
  74901. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74902. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74903. protected _postMeasure(): void;
  74904. }
  74905. }
  74906. declare module BABYLON.GUI {
  74907. /**
  74908. * Class used to represent a 2D checkbox
  74909. */
  74910. export class Checkbox extends Control {
  74911. name?: string | undefined;
  74912. private _isChecked;
  74913. private _background;
  74914. private _checkSizeRatio;
  74915. private _thickness;
  74916. /** Gets or sets border thickness */
  74917. get thickness(): number;
  74918. set thickness(value: number);
  74919. /**
  74920. * BABYLON.Observable raised when isChecked property changes
  74921. */
  74922. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  74923. /** Gets or sets a value indicating the ratio between overall size and check size */
  74924. get checkSizeRatio(): number;
  74925. set checkSizeRatio(value: number);
  74926. /** Gets or sets background color */
  74927. get background(): string;
  74928. set background(value: string);
  74929. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  74930. get isChecked(): boolean;
  74931. set isChecked(value: boolean);
  74932. /**
  74933. * Creates a new CheckBox
  74934. * @param name defines the control name
  74935. */
  74936. constructor(name?: string | undefined);
  74937. protected _getTypeName(): string;
  74938. /** @hidden */
  74939. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74940. /** @hidden */
  74941. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74942. /**
  74943. * Utility function to easily create a checkbox with a header
  74944. * @param title defines the label to use for the header
  74945. * @param onValueChanged defines the callback to call when value changes
  74946. * @returns a StackPanel containing the checkbox and a textBlock
  74947. */
  74948. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  74949. }
  74950. }
  74951. declare module BABYLON.GUI {
  74952. /**
  74953. * Class used to store key control properties
  74954. */
  74955. export class KeyPropertySet {
  74956. /** Width */
  74957. width?: string;
  74958. /** Height */
  74959. height?: string;
  74960. /** Left padding */
  74961. paddingLeft?: string;
  74962. /** Right padding */
  74963. paddingRight?: string;
  74964. /** Top padding */
  74965. paddingTop?: string;
  74966. /** Bottom padding */
  74967. paddingBottom?: string;
  74968. /** Foreground color */
  74969. color?: string;
  74970. /** Background color */
  74971. background?: string;
  74972. }
  74973. /**
  74974. * Class used to create virtual keyboard
  74975. */
  74976. export class VirtualKeyboard extends StackPanel {
  74977. /** BABYLON.Observable raised when a key is pressed */
  74978. onKeyPressObservable: BABYLON.Observable<string>;
  74979. /** Gets or sets default key button width */
  74980. defaultButtonWidth: string;
  74981. /** Gets or sets default key button height */
  74982. defaultButtonHeight: string;
  74983. /** Gets or sets default key button left padding */
  74984. defaultButtonPaddingLeft: string;
  74985. /** Gets or sets default key button right padding */
  74986. defaultButtonPaddingRight: string;
  74987. /** Gets or sets default key button top padding */
  74988. defaultButtonPaddingTop: string;
  74989. /** Gets or sets default key button bottom padding */
  74990. defaultButtonPaddingBottom: string;
  74991. /** Gets or sets default key button foreground color */
  74992. defaultButtonColor: string;
  74993. /** Gets or sets default key button background color */
  74994. defaultButtonBackground: string;
  74995. /** Gets or sets shift button foreground color */
  74996. shiftButtonColor: string;
  74997. /** Gets or sets shift button thickness*/
  74998. selectedShiftThickness: number;
  74999. /** Gets shift key state */
  75000. shiftState: number;
  75001. protected _getTypeName(): string;
  75002. private _createKey;
  75003. /**
  75004. * Adds a new row of keys
  75005. * @param keys defines the list of keys to add
  75006. * @param propertySets defines the associated property sets
  75007. */
  75008. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  75009. /**
  75010. * Set the shift key to a specific state
  75011. * @param shiftState defines the new shift state
  75012. */
  75013. applyShiftState(shiftState: number): void;
  75014. private _currentlyConnectedInputText;
  75015. private _connectedInputTexts;
  75016. private _onKeyPressObserver;
  75017. /** Gets the input text control currently attached to the keyboard */
  75018. get connectedInputText(): BABYLON.Nullable<InputText>;
  75019. /**
  75020. * Connects the keyboard with an input text control
  75021. *
  75022. * @param input defines the target control
  75023. */
  75024. connect(input: InputText): void;
  75025. /**
  75026. * Disconnects the keyboard from connected InputText controls
  75027. *
  75028. * @param input optionally defines a target control, otherwise all are disconnected
  75029. */
  75030. disconnect(input?: InputText): void;
  75031. private _removeConnectedInputObservables;
  75032. /**
  75033. * Release all resources
  75034. */
  75035. dispose(): void;
  75036. /**
  75037. * Creates a new keyboard using a default layout
  75038. *
  75039. * @param name defines control name
  75040. * @returns a new VirtualKeyboard
  75041. */
  75042. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  75043. }
  75044. }
  75045. declare module BABYLON.GUI {
  75046. /**
  75047. * Class used to create input text control
  75048. */
  75049. export class InputText extends Control implements IFocusableControl {
  75050. name?: string | undefined;
  75051. private _text;
  75052. private _placeholderText;
  75053. private _background;
  75054. private _focusedBackground;
  75055. private _focusedColor;
  75056. private _placeholderColor;
  75057. private _thickness;
  75058. private _margin;
  75059. private _autoStretchWidth;
  75060. private _maxWidth;
  75061. private _isFocused;
  75062. private _blinkTimeout;
  75063. private _blinkIsEven;
  75064. private _cursorOffset;
  75065. private _scrollLeft;
  75066. private _textWidth;
  75067. private _clickedCoordinate;
  75068. private _deadKey;
  75069. private _addKey;
  75070. private _currentKey;
  75071. private _isTextHighlightOn;
  75072. private _textHighlightColor;
  75073. private _highligherOpacity;
  75074. private _highlightedText;
  75075. private _startHighlightIndex;
  75076. private _endHighlightIndex;
  75077. private _cursorIndex;
  75078. private _onFocusSelectAll;
  75079. private _isPointerDown;
  75080. private _onClipboardObserver;
  75081. private _onPointerDblTapObserver;
  75082. /** @hidden */
  75083. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  75084. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  75085. promptMessage: string;
  75086. /** Force disable prompt on mobile device */
  75087. disableMobilePrompt: boolean;
  75088. /** BABYLON.Observable raised when the text changes */
  75089. onTextChangedObservable: BABYLON.Observable<InputText>;
  75090. /** BABYLON.Observable raised just before an entered character is to be added */
  75091. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  75092. /** BABYLON.Observable raised when the control gets the focus */
  75093. onFocusObservable: BABYLON.Observable<InputText>;
  75094. /** BABYLON.Observable raised when the control loses the focus */
  75095. onBlurObservable: BABYLON.Observable<InputText>;
  75096. /**Observable raised when the text is highlighted */
  75097. onTextHighlightObservable: BABYLON.Observable<InputText>;
  75098. /**Observable raised when copy event is triggered */
  75099. onTextCopyObservable: BABYLON.Observable<InputText>;
  75100. /** BABYLON.Observable raised when cut event is triggered */
  75101. onTextCutObservable: BABYLON.Observable<InputText>;
  75102. /** BABYLON.Observable raised when paste event is triggered */
  75103. onTextPasteObservable: BABYLON.Observable<InputText>;
  75104. /** BABYLON.Observable raised when a key event was processed */
  75105. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  75106. /** Gets or sets the maximum width allowed by the control */
  75107. get maxWidth(): string | number;
  75108. /** Gets the maximum width allowed by the control in pixels */
  75109. get maxWidthInPixels(): number;
  75110. set maxWidth(value: string | number);
  75111. /** Gets or sets the text highlighter transparency; default: 0.4 */
  75112. get highligherOpacity(): number;
  75113. set highligherOpacity(value: number);
  75114. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  75115. get onFocusSelectAll(): boolean;
  75116. set onFocusSelectAll(value: boolean);
  75117. /** Gets or sets the text hightlight color */
  75118. get textHighlightColor(): string;
  75119. set textHighlightColor(value: string);
  75120. /** Gets or sets control margin */
  75121. get margin(): string;
  75122. /** Gets control margin in pixels */
  75123. get marginInPixels(): number;
  75124. set margin(value: string);
  75125. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  75126. get autoStretchWidth(): boolean;
  75127. set autoStretchWidth(value: boolean);
  75128. /** Gets or sets border thickness */
  75129. get thickness(): number;
  75130. set thickness(value: number);
  75131. /** Gets or sets the background color when focused */
  75132. get focusedBackground(): string;
  75133. set focusedBackground(value: string);
  75134. /** Gets or sets the background color when focused */
  75135. get focusedColor(): string;
  75136. set focusedColor(value: string);
  75137. /** Gets or sets the background color */
  75138. get background(): string;
  75139. set background(value: string);
  75140. /** Gets or sets the placeholder color */
  75141. get placeholderColor(): string;
  75142. set placeholderColor(value: string);
  75143. /** Gets or sets the text displayed when the control is empty */
  75144. get placeholderText(): string;
  75145. set placeholderText(value: string);
  75146. /** Gets or sets the dead key flag */
  75147. get deadKey(): boolean;
  75148. set deadKey(flag: boolean);
  75149. /** Gets or sets the highlight text */
  75150. get highlightedText(): string;
  75151. set highlightedText(text: string);
  75152. /** Gets or sets if the current key should be added */
  75153. get addKey(): boolean;
  75154. set addKey(flag: boolean);
  75155. /** Gets or sets the value of the current key being entered */
  75156. get currentKey(): string;
  75157. set currentKey(key: string);
  75158. /** Gets or sets the text displayed in the control */
  75159. get text(): string;
  75160. set text(value: string);
  75161. /** Gets or sets control width */
  75162. get width(): string | number;
  75163. set width(value: string | number);
  75164. /**
  75165. * Creates a new InputText
  75166. * @param name defines the control name
  75167. * @param text defines the text of the control
  75168. */
  75169. constructor(name?: string | undefined, text?: string);
  75170. /** @hidden */
  75171. onBlur(): void;
  75172. /** @hidden */
  75173. onFocus(): void;
  75174. protected _getTypeName(): string;
  75175. /**
  75176. * Function called to get the list of controls that should not steal the focus from this control
  75177. * @returns an array of controls
  75178. */
  75179. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75180. /** @hidden */
  75181. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  75182. /** @hidden */
  75183. private _updateValueFromCursorIndex;
  75184. /** @hidden */
  75185. private _processDblClick;
  75186. /** @hidden */
  75187. private _selectAllText;
  75188. /**
  75189. * Handles the keyboard event
  75190. * @param evt Defines the KeyboardEvent
  75191. */
  75192. processKeyboard(evt: KeyboardEvent): void;
  75193. /** @hidden */
  75194. private _onCopyText;
  75195. /** @hidden */
  75196. private _onCutText;
  75197. /** @hidden */
  75198. private _onPasteText;
  75199. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75200. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75201. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75202. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75203. protected _beforeRenderText(text: string): string;
  75204. dispose(): void;
  75205. }
  75206. }
  75207. declare module BABYLON.GUI {
  75208. /**
  75209. * Class used to create a 2D grid container
  75210. */
  75211. export class Grid extends Container {
  75212. name?: string | undefined;
  75213. private _rowDefinitions;
  75214. private _columnDefinitions;
  75215. private _cells;
  75216. private _childControls;
  75217. /**
  75218. * Gets the number of columns
  75219. */
  75220. get columnCount(): number;
  75221. /**
  75222. * Gets the number of rows
  75223. */
  75224. get rowCount(): number;
  75225. /** Gets the list of children */
  75226. get children(): Control[];
  75227. /** Gets the list of cells (e.g. the containers) */
  75228. get cells(): {
  75229. [key: string]: Container;
  75230. };
  75231. /**
  75232. * Gets the definition of a specific row
  75233. * @param index defines the index of the row
  75234. * @returns the row definition
  75235. */
  75236. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75237. /**
  75238. * Gets the definition of a specific column
  75239. * @param index defines the index of the column
  75240. * @returns the column definition
  75241. */
  75242. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75243. /**
  75244. * Adds a new row to the grid
  75245. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75246. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  75247. * @returns the current grid
  75248. */
  75249. addRowDefinition(height: number, isPixel?: boolean): Grid;
  75250. /**
  75251. * Adds a new column to the grid
  75252. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75253. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75254. * @returns the current grid
  75255. */
  75256. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  75257. /**
  75258. * Update a row definition
  75259. * @param index defines the index of the row to update
  75260. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75261. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  75262. * @returns the current grid
  75263. */
  75264. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  75265. /**
  75266. * Update a column definition
  75267. * @param index defines the index of the column to update
  75268. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75269. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75270. * @returns the current grid
  75271. */
  75272. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  75273. /**
  75274. * Gets the list of children stored in a specific cell
  75275. * @param row defines the row to check
  75276. * @param column defines the column to check
  75277. * @returns the list of controls
  75278. */
  75279. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  75280. /**
  75281. * Gets a string representing the child cell info (row x column)
  75282. * @param child defines the control to get info from
  75283. * @returns a string containing the child cell info (row x column)
  75284. */
  75285. getChildCellInfo(child: Control): string;
  75286. private _removeCell;
  75287. private _offsetCell;
  75288. /**
  75289. * Remove a column definition at specified index
  75290. * @param index defines the index of the column to remove
  75291. * @returns the current grid
  75292. */
  75293. removeColumnDefinition(index: number): Grid;
  75294. /**
  75295. * Remove a row definition at specified index
  75296. * @param index defines the index of the row to remove
  75297. * @returns the current grid
  75298. */
  75299. removeRowDefinition(index: number): Grid;
  75300. /**
  75301. * Adds a new control to the current grid
  75302. * @param control defines the control to add
  75303. * @param row defines the row where to add the control (0 by default)
  75304. * @param column defines the column where to add the control (0 by default)
  75305. * @returns the current grid
  75306. */
  75307. addControl(control: Control, row?: number, column?: number): Grid;
  75308. /**
  75309. * Removes a control from the current container
  75310. * @param control defines the control to remove
  75311. * @returns the current container
  75312. */
  75313. removeControl(control: Control): Container;
  75314. /**
  75315. * Creates a new Grid
  75316. * @param name defines control name
  75317. */
  75318. constructor(name?: string | undefined);
  75319. protected _getTypeName(): string;
  75320. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  75321. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75322. _flagDescendantsAsMatrixDirty(): void;
  75323. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75324. /** Releases associated resources */
  75325. dispose(): void;
  75326. }
  75327. }
  75328. declare module BABYLON.GUI {
  75329. /** Class used to create color pickers */
  75330. export class ColorPicker extends Control {
  75331. name?: string | undefined;
  75332. private static _Epsilon;
  75333. private _colorWheelCanvas;
  75334. private _value;
  75335. private _tmpColor;
  75336. private _pointerStartedOnSquare;
  75337. private _pointerStartedOnWheel;
  75338. private _squareLeft;
  75339. private _squareTop;
  75340. private _squareSize;
  75341. private _h;
  75342. private _s;
  75343. private _v;
  75344. private _lastPointerDownID;
  75345. /**
  75346. * BABYLON.Observable raised when the value changes
  75347. */
  75348. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  75349. /** Gets or sets the color of the color picker */
  75350. get value(): BABYLON.Color3;
  75351. set value(value: BABYLON.Color3);
  75352. /**
  75353. * Gets or sets control width
  75354. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75355. */
  75356. get width(): string | number;
  75357. set width(value: string | number);
  75358. /**
  75359. * Gets or sets control height
  75360. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75361. */
  75362. get height(): string | number;
  75363. /** Gets or sets control height */
  75364. set height(value: string | number);
  75365. /** Gets or sets control size */
  75366. get size(): string | number;
  75367. set size(value: string | number);
  75368. /**
  75369. * Creates a new ColorPicker
  75370. * @param name defines the control name
  75371. */
  75372. constructor(name?: string | undefined);
  75373. protected _getTypeName(): string;
  75374. /** @hidden */
  75375. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75376. private _updateSquareProps;
  75377. private _drawGradientSquare;
  75378. private _drawCircle;
  75379. private _createColorWheelCanvas;
  75380. /** @hidden */
  75381. _draw(context: CanvasRenderingContext2D): void;
  75382. private _pointerIsDown;
  75383. private _updateValueFromPointer;
  75384. private _isPointOnSquare;
  75385. private _isPointOnWheel;
  75386. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75387. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75388. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75389. /**
  75390. * This function expands the color picker by creating a color picker dialog with manual
  75391. * color value input and the ability to save colors into an array to be used later in
  75392. * subsequent launches of the dialogue.
  75393. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  75394. * @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.
  75395. * @returns picked color as a hex string and the saved colors array as hex strings.
  75396. */
  75397. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  75398. pickerWidth?: string;
  75399. pickerHeight?: string;
  75400. headerHeight?: string;
  75401. lastColor?: string;
  75402. swatchLimit?: number;
  75403. numSwatchesPerLine?: number;
  75404. savedColors?: Array<string>;
  75405. }): Promise<{
  75406. savedColors?: string[];
  75407. pickedColor: string;
  75408. }>;
  75409. }
  75410. }
  75411. declare module BABYLON.GUI {
  75412. /** Class used to create 2D ellipse containers */
  75413. export class Ellipse extends Container {
  75414. name?: string | undefined;
  75415. private _thickness;
  75416. /** Gets or sets border thickness */
  75417. get thickness(): number;
  75418. set thickness(value: number);
  75419. /**
  75420. * Creates a new Ellipse
  75421. * @param name defines the control name
  75422. */
  75423. constructor(name?: string | undefined);
  75424. protected _getTypeName(): string;
  75425. protected _localDraw(context: CanvasRenderingContext2D): void;
  75426. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75427. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75428. }
  75429. }
  75430. declare module BABYLON.GUI {
  75431. /**
  75432. * Class used to create a password control
  75433. */
  75434. export class InputPassword extends InputText {
  75435. protected _beforeRenderText(text: string): string;
  75436. }
  75437. }
  75438. declare module BABYLON.GUI {
  75439. /** Class used to render 2D lines */
  75440. export class Line extends Control {
  75441. name?: string | undefined;
  75442. private _lineWidth;
  75443. private _x1;
  75444. private _y1;
  75445. private _x2;
  75446. private _y2;
  75447. private _dash;
  75448. private _connectedControl;
  75449. private _connectedControlDirtyObserver;
  75450. /** Gets or sets the dash pattern */
  75451. get dash(): Array<number>;
  75452. set dash(value: Array<number>);
  75453. /** Gets or sets the control connected with the line end */
  75454. get connectedControl(): Control;
  75455. set connectedControl(value: Control);
  75456. /** Gets or sets start coordinates on X axis */
  75457. get x1(): string | number;
  75458. set x1(value: string | number);
  75459. /** Gets or sets start coordinates on Y axis */
  75460. get y1(): string | number;
  75461. set y1(value: string | number);
  75462. /** Gets or sets end coordinates on X axis */
  75463. get x2(): string | number;
  75464. set x2(value: string | number);
  75465. /** Gets or sets end coordinates on Y axis */
  75466. get y2(): string | number;
  75467. set y2(value: string | number);
  75468. /** Gets or sets line width */
  75469. get lineWidth(): number;
  75470. set lineWidth(value: number);
  75471. /** Gets or sets horizontal alignment */
  75472. set horizontalAlignment(value: number);
  75473. /** Gets or sets vertical alignment */
  75474. set verticalAlignment(value: number);
  75475. private get _effectiveX2();
  75476. private get _effectiveY2();
  75477. /**
  75478. * Creates a new Line
  75479. * @param name defines the control name
  75480. */
  75481. constructor(name?: string | undefined);
  75482. protected _getTypeName(): string;
  75483. _draw(context: CanvasRenderingContext2D): void;
  75484. _measure(): void;
  75485. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75486. /**
  75487. * Move one end of the line given 3D cartesian coordinates.
  75488. * @param position Targeted world position
  75489. * @param scene BABYLON.Scene
  75490. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  75491. */
  75492. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  75493. /**
  75494. * Move one end of the line to a position in screen absolute space.
  75495. * @param projectedPosition Position in screen absolute space (X, Y)
  75496. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  75497. */
  75498. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  75499. }
  75500. }
  75501. declare module BABYLON.GUI {
  75502. /**
  75503. * Class used to store a point for a MultiLine object.
  75504. * The point can be pure 2D coordinates, a mesh or a control
  75505. */
  75506. export class MultiLinePoint {
  75507. private _multiLine;
  75508. private _x;
  75509. private _y;
  75510. private _control;
  75511. private _mesh;
  75512. private _controlObserver;
  75513. private _meshObserver;
  75514. /** @hidden */
  75515. _point: BABYLON.Vector2;
  75516. /**
  75517. * Creates a new MultiLinePoint
  75518. * @param multiLine defines the source MultiLine object
  75519. */
  75520. constructor(multiLine: MultiLine);
  75521. /** Gets or sets x coordinate */
  75522. get x(): string | number;
  75523. set x(value: string | number);
  75524. /** Gets or sets y coordinate */
  75525. get y(): string | number;
  75526. set y(value: string | number);
  75527. /** Gets or sets the control associated with this point */
  75528. get control(): BABYLON.Nullable<Control>;
  75529. set control(value: BABYLON.Nullable<Control>);
  75530. /** Gets or sets the mesh associated with this point */
  75531. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75532. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  75533. /** Resets links */
  75534. resetLinks(): void;
  75535. /**
  75536. * Gets a translation vector
  75537. * @returns the translation vector
  75538. */
  75539. translate(): BABYLON.Vector2;
  75540. private _translatePoint;
  75541. /** Release associated resources */
  75542. dispose(): void;
  75543. }
  75544. }
  75545. declare module BABYLON.GUI {
  75546. /**
  75547. * Class used to create multi line control
  75548. */
  75549. export class MultiLine extends Control {
  75550. name?: string | undefined;
  75551. private _lineWidth;
  75552. private _dash;
  75553. private _points;
  75554. private _minX;
  75555. private _minY;
  75556. private _maxX;
  75557. private _maxY;
  75558. /**
  75559. * Creates a new MultiLine
  75560. * @param name defines the control name
  75561. */
  75562. constructor(name?: string | undefined);
  75563. /** Gets or sets dash pattern */
  75564. get dash(): Array<number>;
  75565. set dash(value: Array<number>);
  75566. /**
  75567. * Gets point stored at specified index
  75568. * @param index defines the index to look for
  75569. * @returns the requested point if found
  75570. */
  75571. getAt(index: number): MultiLinePoint;
  75572. /** Function called when a point is updated */
  75573. onPointUpdate: () => void;
  75574. /**
  75575. * Adds new points to the point collection
  75576. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  75577. * @returns the list of created MultiLinePoint
  75578. */
  75579. add(...items: (AbstractMesh | Control | {
  75580. x: string | number;
  75581. y: string | number;
  75582. })[]): MultiLinePoint[];
  75583. /**
  75584. * Adds a new point to the point collection
  75585. * @param item defines the item (mesh, control or 2d coordiantes) to add
  75586. * @returns the created MultiLinePoint
  75587. */
  75588. push(item?: (AbstractMesh | Control | {
  75589. x: string | number;
  75590. y: string | number;
  75591. })): MultiLinePoint;
  75592. /**
  75593. * Remove a specific value or point from the active point collection
  75594. * @param value defines the value or point to remove
  75595. */
  75596. remove(value: number | MultiLinePoint): void;
  75597. /**
  75598. * Resets this object to initial state (no point)
  75599. */
  75600. reset(): void;
  75601. /**
  75602. * Resets all links
  75603. */
  75604. resetLinks(): void;
  75605. /** Gets or sets line width */
  75606. get lineWidth(): number;
  75607. set lineWidth(value: number);
  75608. set horizontalAlignment(value: number);
  75609. set verticalAlignment(value: number);
  75610. protected _getTypeName(): string;
  75611. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75612. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75613. _measure(): void;
  75614. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75615. dispose(): void;
  75616. }
  75617. }
  75618. declare module BABYLON.GUI {
  75619. /**
  75620. * Class used to create radio button controls
  75621. */
  75622. export class RadioButton extends Control {
  75623. name?: string | undefined;
  75624. private _isChecked;
  75625. private _background;
  75626. private _checkSizeRatio;
  75627. private _thickness;
  75628. /** Gets or sets border thickness */
  75629. get thickness(): number;
  75630. set thickness(value: number);
  75631. /** Gets or sets group name */
  75632. group: string;
  75633. /** BABYLON.Observable raised when isChecked is changed */
  75634. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  75635. /** Gets or sets a value indicating the ratio between overall size and check size */
  75636. get checkSizeRatio(): number;
  75637. set checkSizeRatio(value: number);
  75638. /** Gets or sets background color */
  75639. get background(): string;
  75640. set background(value: string);
  75641. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  75642. get isChecked(): boolean;
  75643. set isChecked(value: boolean);
  75644. /**
  75645. * Creates a new RadioButton
  75646. * @param name defines the control name
  75647. */
  75648. constructor(name?: string | undefined);
  75649. protected _getTypeName(): string;
  75650. _draw(context: CanvasRenderingContext2D): void;
  75651. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75652. /**
  75653. * Utility function to easily create a radio button with a header
  75654. * @param title defines the label to use for the header
  75655. * @param group defines the group to use for the radio button
  75656. * @param isChecked defines the initial state of the radio button
  75657. * @param onValueChanged defines the callback to call when value changes
  75658. * @returns a StackPanel containing the radio button and a textBlock
  75659. */
  75660. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  75661. }
  75662. }
  75663. declare module BABYLON.GUI {
  75664. /**
  75665. * Class used to create slider controls
  75666. */
  75667. export class BaseSlider extends Control {
  75668. name?: string | undefined;
  75669. protected _thumbWidth: ValueAndUnit;
  75670. private _minimum;
  75671. private _maximum;
  75672. private _value;
  75673. private _isVertical;
  75674. protected _barOffset: ValueAndUnit;
  75675. private _isThumbClamped;
  75676. protected _displayThumb: boolean;
  75677. private _step;
  75678. private _lastPointerDownID;
  75679. protected _effectiveBarOffset: number;
  75680. protected _renderLeft: number;
  75681. protected _renderTop: number;
  75682. protected _renderWidth: number;
  75683. protected _renderHeight: number;
  75684. protected _backgroundBoxLength: number;
  75685. protected _backgroundBoxThickness: number;
  75686. protected _effectiveThumbThickness: number;
  75687. /** BABYLON.Observable raised when the sldier value changes */
  75688. onValueChangedObservable: BABYLON.Observable<number>;
  75689. /** Gets or sets a boolean indicating if the thumb must be rendered */
  75690. get displayThumb(): boolean;
  75691. set displayThumb(value: boolean);
  75692. /** Gets or sets a step to apply to values (0 by default) */
  75693. get step(): number;
  75694. set step(value: number);
  75695. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  75696. get barOffset(): string | number;
  75697. /** Gets main bar offset in pixels*/
  75698. get barOffsetInPixels(): number;
  75699. set barOffset(value: string | number);
  75700. /** Gets or sets thumb width */
  75701. get thumbWidth(): string | number;
  75702. /** Gets thumb width in pixels */
  75703. get thumbWidthInPixels(): number;
  75704. set thumbWidth(value: string | number);
  75705. /** Gets or sets minimum value */
  75706. get minimum(): number;
  75707. set minimum(value: number);
  75708. /** Gets or sets maximum value */
  75709. get maximum(): number;
  75710. set maximum(value: number);
  75711. /** Gets or sets current value */
  75712. get value(): number;
  75713. set value(value: number);
  75714. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  75715. get isVertical(): boolean;
  75716. set isVertical(value: boolean);
  75717. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  75718. get isThumbClamped(): boolean;
  75719. set isThumbClamped(value: boolean);
  75720. /**
  75721. * Creates a new BaseSlider
  75722. * @param name defines the control name
  75723. */
  75724. constructor(name?: string | undefined);
  75725. protected _getTypeName(): string;
  75726. protected _getThumbPosition(): number;
  75727. protected _getThumbThickness(type: string): number;
  75728. protected _prepareRenderingData(type: string): void;
  75729. private _pointerIsDown;
  75730. /** @hidden */
  75731. protected _updateValueFromPointer(x: number, y: number): void;
  75732. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75733. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75734. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75735. }
  75736. }
  75737. declare module BABYLON.GUI {
  75738. /**
  75739. * Class used to create slider controls
  75740. */
  75741. export class Slider extends BaseSlider {
  75742. name?: string | undefined;
  75743. private _background;
  75744. private _borderColor;
  75745. private _isThumbCircle;
  75746. protected _displayValueBar: boolean;
  75747. /** Gets or sets a boolean indicating if the value bar must be rendered */
  75748. get displayValueBar(): boolean;
  75749. set displayValueBar(value: boolean);
  75750. /** Gets or sets border color */
  75751. get borderColor(): string;
  75752. set borderColor(value: string);
  75753. /** Gets or sets background color */
  75754. get background(): string;
  75755. set background(value: string);
  75756. /** Gets or sets a boolean indicating if the thumb should be round or square */
  75757. get isThumbCircle(): boolean;
  75758. set isThumbCircle(value: boolean);
  75759. /**
  75760. * Creates a new Slider
  75761. * @param name defines the control name
  75762. */
  75763. constructor(name?: string | undefined);
  75764. protected _getTypeName(): string;
  75765. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75766. }
  75767. }
  75768. declare module BABYLON.GUI {
  75769. /** Class used to create a RadioGroup
  75770. * which contains groups of radio buttons
  75771. */
  75772. export class SelectorGroup {
  75773. /** name of SelectorGroup */
  75774. name: string;
  75775. private _groupPanel;
  75776. private _selectors;
  75777. private _groupHeader;
  75778. /**
  75779. * Creates a new SelectorGroup
  75780. * @param name of group, used as a group heading
  75781. */
  75782. constructor(
  75783. /** name of SelectorGroup */
  75784. name: string);
  75785. /** Gets the groupPanel of the SelectorGroup */
  75786. get groupPanel(): StackPanel;
  75787. /** Gets the selectors array */
  75788. get selectors(): StackPanel[];
  75789. /** Gets and sets the group header */
  75790. get header(): string;
  75791. set header(label: string);
  75792. /** @hidden */
  75793. private _addGroupHeader;
  75794. /** @hidden*/
  75795. _getSelector(selectorNb: number): StackPanel | undefined;
  75796. /** Removes the selector at the given position
  75797. * @param selectorNb the position of the selector within the group
  75798. */
  75799. removeSelector(selectorNb: number): void;
  75800. }
  75801. /** Class used to create a CheckboxGroup
  75802. * which contains groups of checkbox buttons
  75803. */
  75804. export class CheckboxGroup extends SelectorGroup {
  75805. /** Adds a checkbox as a control
  75806. * @param text is the label for the selector
  75807. * @param func is the function called when the Selector is checked
  75808. * @param checked is true when Selector is checked
  75809. */
  75810. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  75811. /** @hidden */
  75812. _setSelectorLabel(selectorNb: number, label: string): void;
  75813. /** @hidden */
  75814. _setSelectorLabelColor(selectorNb: number, color: string): void;
  75815. /** @hidden */
  75816. _setSelectorButtonColor(selectorNb: number, color: string): void;
  75817. /** @hidden */
  75818. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  75819. }
  75820. /** Class used to create a RadioGroup
  75821. * which contains groups of radio buttons
  75822. */
  75823. export class RadioGroup extends SelectorGroup {
  75824. private _selectNb;
  75825. /** Adds a radio button as a control
  75826. * @param label is the label for the selector
  75827. * @param func is the function called when the Selector is checked
  75828. * @param checked is true when Selector is checked
  75829. */
  75830. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  75831. /** @hidden */
  75832. _setSelectorLabel(selectorNb: number, label: string): void;
  75833. /** @hidden */
  75834. _setSelectorLabelColor(selectorNb: number, color: string): void;
  75835. /** @hidden */
  75836. _setSelectorButtonColor(selectorNb: number, color: string): void;
  75837. /** @hidden */
  75838. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  75839. }
  75840. /** Class used to create a SliderGroup
  75841. * which contains groups of slider buttons
  75842. */
  75843. export class SliderGroup extends SelectorGroup {
  75844. /**
  75845. * Adds a slider to the SelectorGroup
  75846. * @param label is the label for the SliderBar
  75847. * @param func is the function called when the Slider moves
  75848. * @param unit is a string describing the units used, eg degrees or metres
  75849. * @param min is the minimum value for the Slider
  75850. * @param max is the maximum value for the Slider
  75851. * @param value is the start value for the Slider between min and max
  75852. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  75853. */
  75854. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  75855. /** @hidden */
  75856. _setSelectorLabel(selectorNb: number, label: string): void;
  75857. /** @hidden */
  75858. _setSelectorLabelColor(selectorNb: number, color: string): void;
  75859. /** @hidden */
  75860. _setSelectorButtonColor(selectorNb: number, color: string): void;
  75861. /** @hidden */
  75862. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  75863. }
  75864. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  75865. * @see http://doc.babylonjs.com/how_to/selector
  75866. */
  75867. export class SelectionPanel extends Rectangle {
  75868. /** name of SelectionPanel */
  75869. name: string;
  75870. /** an array of SelectionGroups */
  75871. groups: SelectorGroup[];
  75872. private _panel;
  75873. private _buttonColor;
  75874. private _buttonBackground;
  75875. private _headerColor;
  75876. private _barColor;
  75877. private _barHeight;
  75878. private _spacerHeight;
  75879. private _labelColor;
  75880. private _groups;
  75881. private _bars;
  75882. /**
  75883. * Creates a new SelectionPanel
  75884. * @param name of SelectionPanel
  75885. * @param groups is an array of SelectionGroups
  75886. */
  75887. constructor(
  75888. /** name of SelectionPanel */
  75889. name: string,
  75890. /** an array of SelectionGroups */
  75891. groups?: SelectorGroup[]);
  75892. protected _getTypeName(): string;
  75893. /** Gets or sets the headerColor */
  75894. get headerColor(): string;
  75895. set headerColor(color: string);
  75896. private _setHeaderColor;
  75897. /** Gets or sets the button color */
  75898. get buttonColor(): string;
  75899. set buttonColor(color: string);
  75900. private _setbuttonColor;
  75901. /** Gets or sets the label color */
  75902. get labelColor(): string;
  75903. set labelColor(color: string);
  75904. private _setLabelColor;
  75905. /** Gets or sets the button background */
  75906. get buttonBackground(): string;
  75907. set buttonBackground(color: string);
  75908. private _setButtonBackground;
  75909. /** Gets or sets the color of separator bar */
  75910. get barColor(): string;
  75911. set barColor(color: string);
  75912. private _setBarColor;
  75913. /** Gets or sets the height of separator bar */
  75914. get barHeight(): string;
  75915. set barHeight(value: string);
  75916. private _setBarHeight;
  75917. /** Gets or sets the height of spacers*/
  75918. get spacerHeight(): string;
  75919. set spacerHeight(value: string);
  75920. private _setSpacerHeight;
  75921. /** Adds a bar between groups */
  75922. private _addSpacer;
  75923. /** Add a group to the selection panel
  75924. * @param group is the selector group to add
  75925. */
  75926. addGroup(group: SelectorGroup): void;
  75927. /** Remove the group from the given position
  75928. * @param groupNb is the position of the group in the list
  75929. */
  75930. removeGroup(groupNb: number): void;
  75931. /** Change a group header label
  75932. * @param label is the new group header label
  75933. * @param groupNb is the number of the group to relabel
  75934. * */
  75935. setHeaderName(label: string, groupNb: number): void;
  75936. /** Change selector label to the one given
  75937. * @param label is the new selector label
  75938. * @param groupNb is the number of the groupcontaining the selector
  75939. * @param selectorNb is the number of the selector within a group to relabel
  75940. * */
  75941. relabel(label: string, groupNb: number, selectorNb: number): void;
  75942. /** For a given group position remove the selector at the given position
  75943. * @param groupNb is the number of the group to remove the selector from
  75944. * @param selectorNb is the number of the selector within the group
  75945. */
  75946. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  75947. /** For a given group position of correct type add a checkbox button
  75948. * @param groupNb is the number of the group to remove the selector from
  75949. * @param label is the label for the selector
  75950. * @param func is the function called when the Selector is checked
  75951. * @param checked is true when Selector is checked
  75952. */
  75953. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  75954. /** For a given group position of correct type add a radio button
  75955. * @param groupNb is the number of the group to remove the selector from
  75956. * @param label is the label for the selector
  75957. * @param func is the function called when the Selector is checked
  75958. * @param checked is true when Selector is checked
  75959. */
  75960. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  75961. /**
  75962. * For a given slider group add a slider
  75963. * @param groupNb is the number of the group to add the slider to
  75964. * @param label is the label for the Slider
  75965. * @param func is the function called when the Slider moves
  75966. * @param unit is a string describing the units used, eg degrees or metres
  75967. * @param min is the minimum value for the Slider
  75968. * @param max is the maximum value for the Slider
  75969. * @param value is the start value for the Slider between min and max
  75970. * @param onVal is the function used to format the value displayed, eg radians to degrees
  75971. */
  75972. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  75973. }
  75974. }
  75975. declare module BABYLON.GUI {
  75976. /**
  75977. * Class used to hold a the container for ScrollViewer
  75978. * @hidden
  75979. */
  75980. export class _ScrollViewerWindow extends Container {
  75981. parentClientWidth: number;
  75982. parentClientHeight: number;
  75983. private _freezeControls;
  75984. private _parentMeasure;
  75985. private _oldLeft;
  75986. private _oldTop;
  75987. get freezeControls(): boolean;
  75988. set freezeControls(value: boolean);
  75989. private _bucketWidth;
  75990. private _bucketHeight;
  75991. private _buckets;
  75992. private _bucketLen;
  75993. get bucketWidth(): number;
  75994. get bucketHeight(): number;
  75995. setBucketSizes(width: number, height: number): void;
  75996. private _useBuckets;
  75997. private _makeBuckets;
  75998. private _dispatchInBuckets;
  75999. private _updateMeasures;
  76000. private _updateChildrenMeasures;
  76001. private _restoreMeasures;
  76002. /**
  76003. * Creates a new ScrollViewerWindow
  76004. * @param name of ScrollViewerWindow
  76005. */
  76006. constructor(name?: string);
  76007. protected _getTypeName(): string;
  76008. /** @hidden */
  76009. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76010. /** @hidden */
  76011. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76012. private _scrollChildren;
  76013. private _scrollChildrenWithBuckets;
  76014. /** @hidden */
  76015. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76016. protected _postMeasure(): void;
  76017. }
  76018. }
  76019. declare module BABYLON.GUI {
  76020. /**
  76021. * Class used to create slider controls
  76022. */
  76023. export class ScrollBar extends BaseSlider {
  76024. name?: string | undefined;
  76025. private _background;
  76026. private _borderColor;
  76027. private _tempMeasure;
  76028. /** Gets or sets border color */
  76029. get borderColor(): string;
  76030. set borderColor(value: string);
  76031. /** Gets or sets background color */
  76032. get background(): string;
  76033. set background(value: string);
  76034. /**
  76035. * Creates a new Slider
  76036. * @param name defines the control name
  76037. */
  76038. constructor(name?: string | undefined);
  76039. protected _getTypeName(): string;
  76040. protected _getThumbThickness(): number;
  76041. _draw(context: CanvasRenderingContext2D): void;
  76042. private _first;
  76043. private _originX;
  76044. private _originY;
  76045. /** @hidden */
  76046. protected _updateValueFromPointer(x: number, y: number): void;
  76047. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76048. }
  76049. }
  76050. declare module BABYLON.GUI {
  76051. /**
  76052. * Class used to create slider controls
  76053. */
  76054. export class ImageScrollBar extends BaseSlider {
  76055. name?: string | undefined;
  76056. private _backgroundBaseImage;
  76057. private _backgroundImage;
  76058. private _thumbImage;
  76059. private _thumbBaseImage;
  76060. private _thumbLength;
  76061. private _thumbHeight;
  76062. private _barImageHeight;
  76063. private _tempMeasure;
  76064. /** Number of 90° rotation to apply on the images when in vertical mode */
  76065. num90RotationInVerticalMode: number;
  76066. /**
  76067. * Gets or sets the image used to render the background for horizontal bar
  76068. */
  76069. get backgroundImage(): Image;
  76070. set backgroundImage(value: Image);
  76071. /**
  76072. * Gets or sets the image used to render the thumb
  76073. */
  76074. get thumbImage(): Image;
  76075. set thumbImage(value: Image);
  76076. /**
  76077. * Gets or sets the length of the thumb
  76078. */
  76079. get thumbLength(): number;
  76080. set thumbLength(value: number);
  76081. /**
  76082. * Gets or sets the height of the thumb
  76083. */
  76084. get thumbHeight(): number;
  76085. set thumbHeight(value: number);
  76086. /**
  76087. * Gets or sets the height of the bar image
  76088. */
  76089. get barImageHeight(): number;
  76090. set barImageHeight(value: number);
  76091. /**
  76092. * Creates a new ImageScrollBar
  76093. * @param name defines the control name
  76094. */
  76095. constructor(name?: string | undefined);
  76096. protected _getTypeName(): string;
  76097. protected _getThumbThickness(): number;
  76098. _draw(context: CanvasRenderingContext2D): void;
  76099. private _first;
  76100. private _originX;
  76101. private _originY;
  76102. /** @hidden */
  76103. protected _updateValueFromPointer(x: number, y: number): void;
  76104. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76105. }
  76106. }
  76107. declare module BABYLON.GUI {
  76108. /**
  76109. * Class used to hold a viewer window and sliders in a grid
  76110. */
  76111. export class ScrollViewer extends Rectangle {
  76112. private _grid;
  76113. private _horizontalBarSpace;
  76114. private _verticalBarSpace;
  76115. private _dragSpace;
  76116. private _horizontalBar;
  76117. private _verticalBar;
  76118. private _barColor;
  76119. private _barBackground;
  76120. private _barImage;
  76121. private _horizontalBarImage;
  76122. private _verticalBarImage;
  76123. private _barBackgroundImage;
  76124. private _horizontalBarBackgroundImage;
  76125. private _verticalBarBackgroundImage;
  76126. private _barSize;
  76127. private _window;
  76128. private _pointerIsOver;
  76129. private _wheelPrecision;
  76130. private _onWheelObserver;
  76131. private _clientWidth;
  76132. private _clientHeight;
  76133. private _useImageBar;
  76134. private _thumbLength;
  76135. private _thumbHeight;
  76136. private _barImageHeight;
  76137. private _horizontalBarImageHeight;
  76138. private _verticalBarImageHeight;
  76139. private _oldWindowContentsWidth;
  76140. private _oldWindowContentsHeight;
  76141. /**
  76142. * Gets the horizontal scrollbar
  76143. */
  76144. get horizontalBar(): ScrollBar | ImageScrollBar;
  76145. /**
  76146. * Gets the vertical scrollbar
  76147. */
  76148. get verticalBar(): ScrollBar | ImageScrollBar;
  76149. /**
  76150. * Adds a new control to the current container
  76151. * @param control defines the control to add
  76152. * @returns the current container
  76153. */
  76154. addControl(control: BABYLON.Nullable<Control>): Container;
  76155. /**
  76156. * Removes a control from the current container
  76157. * @param control defines the control to remove
  76158. * @returns the current container
  76159. */
  76160. removeControl(control: Control): Container;
  76161. /** Gets the list of children */
  76162. get children(): Control[];
  76163. _flagDescendantsAsMatrixDirty(): void;
  76164. /**
  76165. * Freezes or unfreezes the controls in the window.
  76166. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  76167. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  76168. */
  76169. get freezeControls(): boolean;
  76170. set freezeControls(value: boolean);
  76171. /** Gets the bucket width */
  76172. get bucketWidth(): number;
  76173. /** Gets the bucket height */
  76174. get bucketHeight(): number;
  76175. /**
  76176. * Sets the bucket sizes.
  76177. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  76178. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  76179. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  76180. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  76181. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  76182. * used), that's why it is not enabled by default.
  76183. * @param width width of the bucket
  76184. * @param height height of the bucket
  76185. */
  76186. setBucketSizes(width: number, height: number): void;
  76187. private _forceHorizontalBar;
  76188. private _forceVerticalBar;
  76189. /**
  76190. * Forces the horizontal scroll bar to be displayed
  76191. */
  76192. get forceHorizontalBar(): boolean;
  76193. set forceHorizontalBar(value: boolean);
  76194. /**
  76195. * Forces the vertical scroll bar to be displayed
  76196. */
  76197. get forceVerticalBar(): boolean;
  76198. set forceVerticalBar(value: boolean);
  76199. /**
  76200. * Creates a new ScrollViewer
  76201. * @param name of ScrollViewer
  76202. */
  76203. constructor(name?: string, isImageBased?: boolean);
  76204. /** Reset the scroll viewer window to initial size */
  76205. resetWindow(): void;
  76206. protected _getTypeName(): string;
  76207. private _buildClientSizes;
  76208. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76209. protected _postMeasure(): void;
  76210. /**
  76211. * Gets or sets the mouse wheel precision
  76212. * from 0 to 1 with a default value of 0.05
  76213. * */
  76214. get wheelPrecision(): number;
  76215. set wheelPrecision(value: number);
  76216. /** Gets or sets the scroll bar container background color */
  76217. get scrollBackground(): string;
  76218. set scrollBackground(color: string);
  76219. /** Gets or sets the bar color */
  76220. get barColor(): string;
  76221. set barColor(color: string);
  76222. /** Gets or sets the bar image */
  76223. get thumbImage(): Image;
  76224. set thumbImage(value: Image);
  76225. /** Gets or sets the horizontal bar image */
  76226. get horizontalThumbImage(): Image;
  76227. set horizontalThumbImage(value: Image);
  76228. /** Gets or sets the vertical bar image */
  76229. get verticalThumbImage(): Image;
  76230. set verticalThumbImage(value: Image);
  76231. /** Gets or sets the size of the bar */
  76232. get barSize(): number;
  76233. set barSize(value: number);
  76234. /** Gets or sets the length of the thumb */
  76235. get thumbLength(): number;
  76236. set thumbLength(value: number);
  76237. /** Gets or sets the height of the thumb */
  76238. get thumbHeight(): number;
  76239. set thumbHeight(value: number);
  76240. /** Gets or sets the height of the bar image */
  76241. get barImageHeight(): number;
  76242. set barImageHeight(value: number);
  76243. /** Gets or sets the height of the horizontal bar image */
  76244. get horizontalBarImageHeight(): number;
  76245. set horizontalBarImageHeight(value: number);
  76246. /** Gets or sets the height of the vertical bar image */
  76247. get verticalBarImageHeight(): number;
  76248. set verticalBarImageHeight(value: number);
  76249. /** Gets or sets the bar background */
  76250. get barBackground(): string;
  76251. set barBackground(color: string);
  76252. /** Gets or sets the bar background image */
  76253. get barImage(): Image;
  76254. set barImage(value: Image);
  76255. /** Gets or sets the horizontal bar background image */
  76256. get horizontalBarImage(): Image;
  76257. set horizontalBarImage(value: Image);
  76258. /** Gets or sets the vertical bar background image */
  76259. get verticalBarImage(): Image;
  76260. set verticalBarImage(value: Image);
  76261. private _setWindowPosition;
  76262. /** @hidden */
  76263. private _updateScroller;
  76264. _link(host: AdvancedDynamicTexture): void;
  76265. /** @hidden */
  76266. private _addBar;
  76267. /** @hidden */
  76268. private _attachWheel;
  76269. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76270. /** Releases associated resources */
  76271. dispose(): void;
  76272. }
  76273. }
  76274. declare module BABYLON.GUI {
  76275. /** Class used to render a grid */
  76276. export class DisplayGrid extends Control {
  76277. name?: string | undefined;
  76278. private _cellWidth;
  76279. private _cellHeight;
  76280. private _minorLineTickness;
  76281. private _minorLineColor;
  76282. private _majorLineTickness;
  76283. private _majorLineColor;
  76284. private _majorLineFrequency;
  76285. private _background;
  76286. private _displayMajorLines;
  76287. private _displayMinorLines;
  76288. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  76289. get displayMinorLines(): boolean;
  76290. set displayMinorLines(value: boolean);
  76291. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  76292. get displayMajorLines(): boolean;
  76293. set displayMajorLines(value: boolean);
  76294. /** Gets or sets background color (Black by default) */
  76295. get background(): string;
  76296. set background(value: string);
  76297. /** Gets or sets the width of each cell (20 by default) */
  76298. get cellWidth(): number;
  76299. set cellWidth(value: number);
  76300. /** Gets or sets the height of each cell (20 by default) */
  76301. get cellHeight(): number;
  76302. set cellHeight(value: number);
  76303. /** Gets or sets the tickness of minor lines (1 by default) */
  76304. get minorLineTickness(): number;
  76305. set minorLineTickness(value: number);
  76306. /** Gets or sets the color of minor lines (DarkGray by default) */
  76307. get minorLineColor(): string;
  76308. set minorLineColor(value: string);
  76309. /** Gets or sets the tickness of major lines (2 by default) */
  76310. get majorLineTickness(): number;
  76311. set majorLineTickness(value: number);
  76312. /** Gets or sets the color of major lines (White by default) */
  76313. get majorLineColor(): string;
  76314. set majorLineColor(value: string);
  76315. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  76316. get majorLineFrequency(): number;
  76317. set majorLineFrequency(value: number);
  76318. /**
  76319. * Creates a new GridDisplayRectangle
  76320. * @param name defines the control name
  76321. */
  76322. constructor(name?: string | undefined);
  76323. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76324. protected _getTypeName(): string;
  76325. }
  76326. }
  76327. declare module BABYLON.GUI {
  76328. /**
  76329. * Class used to create slider controls based on images
  76330. */
  76331. export class ImageBasedSlider extends BaseSlider {
  76332. name?: string | undefined;
  76333. private _backgroundImage;
  76334. private _thumbImage;
  76335. private _valueBarImage;
  76336. private _tempMeasure;
  76337. get displayThumb(): boolean;
  76338. set displayThumb(value: boolean);
  76339. /**
  76340. * Gets or sets the image used to render the background
  76341. */
  76342. get backgroundImage(): Image;
  76343. set backgroundImage(value: Image);
  76344. /**
  76345. * Gets or sets the image used to render the value bar
  76346. */
  76347. get valueBarImage(): Image;
  76348. set valueBarImage(value: Image);
  76349. /**
  76350. * Gets or sets the image used to render the thumb
  76351. */
  76352. get thumbImage(): Image;
  76353. set thumbImage(value: Image);
  76354. /**
  76355. * Creates a new ImageBasedSlider
  76356. * @param name defines the control name
  76357. */
  76358. constructor(name?: string | undefined);
  76359. protected _getTypeName(): string;
  76360. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76361. }
  76362. }
  76363. declare module BABYLON.GUI {
  76364. /**
  76365. * Forcing an export so that this code will execute
  76366. * @hidden
  76367. */
  76368. const name = "Statics";
  76369. }
  76370. declare module BABYLON.GUI {
  76371. /**
  76372. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  76373. */
  76374. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  76375. /**
  76376. * Define the instrumented AdvancedDynamicTexture.
  76377. */
  76378. texture: AdvancedDynamicTexture;
  76379. private _captureRenderTime;
  76380. private _renderTime;
  76381. private _captureLayoutTime;
  76382. private _layoutTime;
  76383. private _onBeginRenderObserver;
  76384. private _onEndRenderObserver;
  76385. private _onBeginLayoutObserver;
  76386. private _onEndLayoutObserver;
  76387. /**
  76388. * Gets the perf counter used to capture render time
  76389. */
  76390. get renderTimeCounter(): BABYLON.PerfCounter;
  76391. /**
  76392. * Gets the perf counter used to capture layout time
  76393. */
  76394. get layoutTimeCounter(): BABYLON.PerfCounter;
  76395. /**
  76396. * Enable or disable the render time capture
  76397. */
  76398. get captureRenderTime(): boolean;
  76399. set captureRenderTime(value: boolean);
  76400. /**
  76401. * Enable or disable the layout time capture
  76402. */
  76403. get captureLayoutTime(): boolean;
  76404. set captureLayoutTime(value: boolean);
  76405. /**
  76406. * Instantiates a new advanced dynamic texture instrumentation.
  76407. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  76408. * @param texture Defines the AdvancedDynamicTexture to instrument
  76409. */
  76410. constructor(
  76411. /**
  76412. * Define the instrumented AdvancedDynamicTexture.
  76413. */
  76414. texture: AdvancedDynamicTexture);
  76415. /**
  76416. * Dispose and release associated resources.
  76417. */
  76418. dispose(): void;
  76419. }
  76420. }
  76421. declare module BABYLON.GUI {
  76422. /**
  76423. * Class used to load GUI via XML.
  76424. */
  76425. export class XmlLoader {
  76426. private _nodes;
  76427. private _nodeTypes;
  76428. private _isLoaded;
  76429. private _objectAttributes;
  76430. private _parentClass;
  76431. /**
  76432. * Create a new xml loader
  76433. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  76434. */
  76435. constructor(parentClass?: null);
  76436. private _getChainElement;
  76437. private _getClassAttribute;
  76438. private _createGuiElement;
  76439. private _parseGrid;
  76440. private _parseElement;
  76441. private _prepareSourceElement;
  76442. private _parseElementsFromSource;
  76443. private _parseXml;
  76444. /**
  76445. * Gets if the loading has finished.
  76446. * @returns whether the loading has finished or not
  76447. */
  76448. isLoaded(): boolean;
  76449. /**
  76450. * Gets a loaded node / control by id.
  76451. * @param id the Controls id set in the xml
  76452. * @returns element of type Control
  76453. */
  76454. getNodeById(id: string): any;
  76455. /**
  76456. * Gets all loaded nodes / controls
  76457. * @returns Array of controls
  76458. */
  76459. getNodes(): any;
  76460. /**
  76461. * Initiates the xml layout loading
  76462. * @param xmlFile defines the xml layout to load
  76463. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  76464. * @param callback defines the callback called on layout load.
  76465. */
  76466. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  76467. }
  76468. }
  76469. declare module BABYLON.GUI {
  76470. /**
  76471. * Class used to create containers for controls
  76472. */
  76473. export class Container3D extends Control3D {
  76474. private _blockLayout;
  76475. /**
  76476. * Gets the list of child controls
  76477. */
  76478. protected _children: Control3D[];
  76479. /**
  76480. * Gets the list of child controls
  76481. */
  76482. get children(): Array<Control3D>;
  76483. /**
  76484. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  76485. * This is helpful to optimize layout operation when adding multiple children in a row
  76486. */
  76487. get blockLayout(): boolean;
  76488. set blockLayout(value: boolean);
  76489. /**
  76490. * Creates a new container
  76491. * @param name defines the container name
  76492. */
  76493. constructor(name?: string);
  76494. /**
  76495. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  76496. * @returns the current container
  76497. */
  76498. updateLayout(): Container3D;
  76499. /**
  76500. * Gets a boolean indicating if the given control is in the children of this control
  76501. * @param control defines the control to check
  76502. * @returns true if the control is in the child list
  76503. */
  76504. containsControl(control: Control3D): boolean;
  76505. /**
  76506. * Adds a control to the children of this control
  76507. * @param control defines the control to add
  76508. * @returns the current container
  76509. */
  76510. addControl(control: Control3D): Container3D;
  76511. /**
  76512. * This function will be called everytime a new control is added
  76513. */
  76514. protected _arrangeChildren(): void;
  76515. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  76516. /**
  76517. * Removes a control from the children of this control
  76518. * @param control defines the control to remove
  76519. * @returns the current container
  76520. */
  76521. removeControl(control: Control3D): Container3D;
  76522. protected _getTypeName(): string;
  76523. /**
  76524. * Releases all associated resources
  76525. */
  76526. dispose(): void;
  76527. /** Control rotation will remain unchanged */
  76528. static readonly UNSET_ORIENTATION: number;
  76529. /** Control will rotate to make it look at sphere central axis */
  76530. static readonly FACEORIGIN_ORIENTATION: number;
  76531. /** Control will rotate to make it look back at sphere central axis */
  76532. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  76533. /** Control will rotate to look at z axis (0, 0, 1) */
  76534. static readonly FACEFORWARD_ORIENTATION: number;
  76535. /** Control will rotate to look at negative z axis (0, 0, -1) */
  76536. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  76537. }
  76538. }
  76539. declare module BABYLON.GUI {
  76540. /**
  76541. * Class used to manage 3D user interface
  76542. * @see http://doc.babylonjs.com/how_to/gui3d
  76543. */
  76544. export class GUI3DManager implements BABYLON.IDisposable {
  76545. private _scene;
  76546. private _sceneDisposeObserver;
  76547. private _utilityLayer;
  76548. private _rootContainer;
  76549. private _pointerObserver;
  76550. private _pointerOutObserver;
  76551. /** @hidden */
  76552. _lastPickedControl: Control3D;
  76553. /** @hidden */
  76554. _lastControlOver: {
  76555. [pointerId: number]: Control3D;
  76556. };
  76557. /** @hidden */
  76558. _lastControlDown: {
  76559. [pointerId: number]: Control3D;
  76560. };
  76561. /**
  76562. * BABYLON.Observable raised when the point picked by the pointer events changed
  76563. */
  76564. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  76565. /** @hidden */
  76566. _sharedMaterials: {
  76567. [key: string]: BABYLON.Material;
  76568. };
  76569. /** Gets the hosting scene */
  76570. get scene(): BABYLON.Scene;
  76571. /** Gets associated utility layer */
  76572. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  76573. /**
  76574. * Creates a new GUI3DManager
  76575. * @param scene
  76576. */
  76577. constructor(scene?: BABYLON.Scene);
  76578. private _handlePointerOut;
  76579. private _doPicking;
  76580. /**
  76581. * Gets the root container
  76582. */
  76583. get rootContainer(): Container3D;
  76584. /**
  76585. * Gets a boolean indicating if the given control is in the root child list
  76586. * @param control defines the control to check
  76587. * @returns true if the control is in the root child list
  76588. */
  76589. containsControl(control: Control3D): boolean;
  76590. /**
  76591. * Adds a control to the root child list
  76592. * @param control defines the control to add
  76593. * @returns the current manager
  76594. */
  76595. addControl(control: Control3D): GUI3DManager;
  76596. /**
  76597. * Removes a control from the root child list
  76598. * @param control defines the control to remove
  76599. * @returns the current container
  76600. */
  76601. removeControl(control: Control3D): GUI3DManager;
  76602. /**
  76603. * Releases all associated resources
  76604. */
  76605. dispose(): void;
  76606. }
  76607. }
  76608. declare module BABYLON.GUI {
  76609. /**
  76610. * Class used to transport BABYLON.Vector3 information for pointer events
  76611. */
  76612. export class Vector3WithInfo extends BABYLON.Vector3 {
  76613. /** defines the current mouse button index */
  76614. buttonIndex: number;
  76615. /**
  76616. * Creates a new Vector3WithInfo
  76617. * @param source defines the vector3 data to transport
  76618. * @param buttonIndex defines the current mouse button index
  76619. */
  76620. constructor(source: BABYLON.Vector3,
  76621. /** defines the current mouse button index */
  76622. buttonIndex?: number);
  76623. }
  76624. }
  76625. declare module BABYLON.GUI {
  76626. /**
  76627. * Class used as base class for controls
  76628. */
  76629. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  76630. /** Defines the control name */
  76631. name?: string | undefined;
  76632. /** @hidden */
  76633. _host: GUI3DManager;
  76634. private _node;
  76635. private _downCount;
  76636. private _enterCount;
  76637. private _downPointerIds;
  76638. private _isVisible;
  76639. /** Gets or sets the control position in world space */
  76640. get position(): BABYLON.Vector3;
  76641. set position(value: BABYLON.Vector3);
  76642. /** Gets or sets the control scaling in world space */
  76643. get scaling(): BABYLON.Vector3;
  76644. set scaling(value: BABYLON.Vector3);
  76645. /** Callback used to start pointer enter animation */
  76646. pointerEnterAnimation: () => void;
  76647. /** Callback used to start pointer out animation */
  76648. pointerOutAnimation: () => void;
  76649. /** Callback used to start pointer down animation */
  76650. pointerDownAnimation: () => void;
  76651. /** Callback used to start pointer up animation */
  76652. pointerUpAnimation: () => void;
  76653. /**
  76654. * An event triggered when the pointer move over the control
  76655. */
  76656. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  76657. /**
  76658. * An event triggered when the pointer move out of the control
  76659. */
  76660. onPointerOutObservable: BABYLON.Observable<Control3D>;
  76661. /**
  76662. * An event triggered when the pointer taps the control
  76663. */
  76664. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  76665. /**
  76666. * An event triggered when pointer is up
  76667. */
  76668. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  76669. /**
  76670. * An event triggered when a control is clicked on (with a mouse)
  76671. */
  76672. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  76673. /**
  76674. * An event triggered when pointer enters the control
  76675. */
  76676. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  76677. /**
  76678. * Gets or sets the parent container
  76679. */
  76680. parent: BABYLON.Nullable<Container3D>;
  76681. private _behaviors;
  76682. /**
  76683. * Gets the list of attached behaviors
  76684. * @see http://doc.babylonjs.com/features/behaviour
  76685. */
  76686. get behaviors(): BABYLON.Behavior<Control3D>[];
  76687. /**
  76688. * Attach a behavior to the control
  76689. * @see http://doc.babylonjs.com/features/behaviour
  76690. * @param behavior defines the behavior to attach
  76691. * @returns the current control
  76692. */
  76693. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  76694. /**
  76695. * Remove an attached behavior
  76696. * @see http://doc.babylonjs.com/features/behaviour
  76697. * @param behavior defines the behavior to attach
  76698. * @returns the current control
  76699. */
  76700. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  76701. /**
  76702. * Gets an attached behavior by name
  76703. * @param name defines the name of the behavior to look for
  76704. * @see http://doc.babylonjs.com/features/behaviour
  76705. * @returns null if behavior was not found else the requested behavior
  76706. */
  76707. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  76708. /** Gets or sets a boolean indicating if the control is visible */
  76709. get isVisible(): boolean;
  76710. set isVisible(value: boolean);
  76711. /**
  76712. * Creates a new control
  76713. * @param name defines the control name
  76714. */
  76715. constructor(
  76716. /** Defines the control name */
  76717. name?: string | undefined);
  76718. /**
  76719. * Gets a string representing the class name
  76720. */
  76721. get typeName(): string;
  76722. /**
  76723. * Get the current class name of the control.
  76724. * @returns current class name
  76725. */
  76726. getClassName(): string;
  76727. protected _getTypeName(): string;
  76728. /**
  76729. * Gets the transform node used by this control
  76730. */
  76731. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  76732. /**
  76733. * Gets the mesh used to render this control
  76734. */
  76735. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76736. /**
  76737. * Link the control as child of the given node
  76738. * @param node defines the node to link to. Use null to unlink the control
  76739. * @returns the current control
  76740. */
  76741. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  76742. /** @hidden **/
  76743. _prepareNode(scene: BABYLON.Scene): void;
  76744. /**
  76745. * Node creation.
  76746. * Can be overriden by children
  76747. * @param scene defines the scene where the node must be attached
  76748. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  76749. */
  76750. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  76751. /**
  76752. * Affect a material to the given mesh
  76753. * @param mesh defines the mesh which will represent the control
  76754. */
  76755. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  76756. /** @hidden */
  76757. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  76758. /** @hidden */
  76759. _onPointerEnter(target: Control3D): boolean;
  76760. /** @hidden */
  76761. _onPointerOut(target: Control3D): void;
  76762. /** @hidden */
  76763. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  76764. /** @hidden */
  76765. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76766. /** @hidden */
  76767. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  76768. /** @hidden */
  76769. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  76770. /** @hidden */
  76771. _disposeNode(): void;
  76772. /**
  76773. * Releases all associated resources
  76774. */
  76775. dispose(): void;
  76776. }
  76777. }
  76778. declare module BABYLON.GUI {
  76779. /**
  76780. * Class used as a root to all buttons
  76781. */
  76782. export class AbstractButton3D extends Control3D {
  76783. /**
  76784. * Creates a new button
  76785. * @param name defines the control name
  76786. */
  76787. constructor(name?: string);
  76788. protected _getTypeName(): string;
  76789. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76790. }
  76791. }
  76792. declare module BABYLON.GUI {
  76793. /**
  76794. * Class used to create a button in 3D
  76795. */
  76796. export class Button3D extends AbstractButton3D {
  76797. /** @hidden */
  76798. protected _currentMaterial: BABYLON.Material;
  76799. private _facadeTexture;
  76800. private _content;
  76801. private _contentResolution;
  76802. private _contentScaleRatio;
  76803. /**
  76804. * Gets or sets the texture resolution used to render content (512 by default)
  76805. */
  76806. get contentResolution(): BABYLON.int;
  76807. set contentResolution(value: BABYLON.int);
  76808. /**
  76809. * Gets or sets the texture scale ratio used to render content (2 by default)
  76810. */
  76811. get contentScaleRatio(): number;
  76812. set contentScaleRatio(value: number);
  76813. protected _disposeFacadeTexture(): void;
  76814. protected _resetContent(): void;
  76815. /**
  76816. * Creates a new button
  76817. * @param name defines the control name
  76818. */
  76819. constructor(name?: string);
  76820. /**
  76821. * Gets or sets the GUI 2D content used to display the button's facade
  76822. */
  76823. get content(): Control;
  76824. set content(value: Control);
  76825. /**
  76826. * Apply the facade texture (created from the content property).
  76827. * This function can be overloaded by child classes
  76828. * @param facadeTexture defines the AdvancedDynamicTexture to use
  76829. */
  76830. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  76831. protected _getTypeName(): string;
  76832. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76833. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  76834. /**
  76835. * Releases all associated resources
  76836. */
  76837. dispose(): void;
  76838. }
  76839. }
  76840. declare module BABYLON.GUI {
  76841. /**
  76842. * Abstract class used to create a container panel deployed on the surface of a volume
  76843. */
  76844. export abstract class VolumeBasedPanel extends Container3D {
  76845. private _columns;
  76846. private _rows;
  76847. private _rowThenColum;
  76848. private _orientation;
  76849. protected _cellWidth: number;
  76850. protected _cellHeight: number;
  76851. /**
  76852. * Gets or sets the distance between elements
  76853. */
  76854. margin: number;
  76855. /**
  76856. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  76857. * | Value | Type | Description |
  76858. * | ----- | ----------------------------------- | ----------- |
  76859. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  76860. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  76861. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  76862. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  76863. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  76864. */
  76865. get orientation(): number;
  76866. set orientation(value: number);
  76867. /**
  76868. * Gets or sets the number of columns requested (10 by default).
  76869. * The panel will automatically compute the number of rows based on number of child controls.
  76870. */
  76871. get columns(): BABYLON.int;
  76872. set columns(value: BABYLON.int);
  76873. /**
  76874. * Gets or sets a the number of rows requested.
  76875. * The panel will automatically compute the number of columns based on number of child controls.
  76876. */
  76877. get rows(): BABYLON.int;
  76878. set rows(value: BABYLON.int);
  76879. /**
  76880. * Creates new VolumeBasedPanel
  76881. */
  76882. constructor();
  76883. protected _arrangeChildren(): void;
  76884. /** Child classes must implement this function to provide correct control positioning */
  76885. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76886. /** Child classes can implement this function to provide additional processing */
  76887. protected _finalProcessing(): void;
  76888. }
  76889. }
  76890. declare module BABYLON.GUI {
  76891. /**
  76892. * Class used to create a container panel deployed on the surface of a cylinder
  76893. */
  76894. export class CylinderPanel extends VolumeBasedPanel {
  76895. private _radius;
  76896. /**
  76897. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  76898. */
  76899. get radius(): BABYLON.float;
  76900. set radius(value: BABYLON.float);
  76901. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76902. private _cylindricalMapping;
  76903. }
  76904. }
  76905. declare module BABYLON.GUI {
  76906. /** @hidden */
  76907. export var fluentVertexShader: {
  76908. name: string;
  76909. shader: string;
  76910. };
  76911. }
  76912. declare module BABYLON.GUI {
  76913. /** @hidden */
  76914. export var fluentPixelShader: {
  76915. name: string;
  76916. shader: string;
  76917. };
  76918. }
  76919. declare module BABYLON.GUI {
  76920. /** @hidden */
  76921. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  76922. INNERGLOW: boolean;
  76923. BORDER: boolean;
  76924. HOVERLIGHT: boolean;
  76925. TEXTURE: boolean;
  76926. constructor();
  76927. }
  76928. /**
  76929. * Class used to render controls with fluent desgin
  76930. */
  76931. export class FluentMaterial extends BABYLON.PushMaterial {
  76932. /**
  76933. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  76934. */
  76935. innerGlowColorIntensity: number;
  76936. /**
  76937. * Gets or sets the inner glow color (white by default)
  76938. */
  76939. innerGlowColor: BABYLON.Color3;
  76940. /**
  76941. * Gets or sets alpha value (default is 1.0)
  76942. */
  76943. alpha: number;
  76944. /**
  76945. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  76946. */
  76947. albedoColor: BABYLON.Color3;
  76948. /**
  76949. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  76950. */
  76951. renderBorders: boolean;
  76952. /**
  76953. * Gets or sets border width (default is 0.5)
  76954. */
  76955. borderWidth: number;
  76956. /**
  76957. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  76958. */
  76959. edgeSmoothingValue: number;
  76960. /**
  76961. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  76962. */
  76963. borderMinValue: number;
  76964. /**
  76965. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  76966. */
  76967. renderHoverLight: boolean;
  76968. /**
  76969. * Gets or sets the radius used to render the hover light (default is 1.0)
  76970. */
  76971. hoverRadius: number;
  76972. /**
  76973. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  76974. */
  76975. hoverColor: BABYLON.Color4;
  76976. /**
  76977. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  76978. */
  76979. hoverPosition: BABYLON.Vector3;
  76980. private _albedoTexture;
  76981. /** Gets or sets the texture to use for albedo color */
  76982. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  76983. /**
  76984. * Creates a new Fluent material
  76985. * @param name defines the name of the material
  76986. * @param scene defines the hosting scene
  76987. */
  76988. constructor(name: string, scene: BABYLON.Scene);
  76989. needAlphaBlending(): boolean;
  76990. needAlphaTesting(): boolean;
  76991. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76992. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76993. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76994. getActiveTextures(): BABYLON.BaseTexture[];
  76995. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76996. dispose(forceDisposeEffect?: boolean): void;
  76997. clone(name: string): FluentMaterial;
  76998. serialize(): any;
  76999. getClassName(): string;
  77000. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  77001. }
  77002. }
  77003. declare module BABYLON.GUI {
  77004. /**
  77005. * Class used to create a holographic button in 3D
  77006. */
  77007. export class HolographicButton extends Button3D {
  77008. private _backPlate;
  77009. private _textPlate;
  77010. private _frontPlate;
  77011. private _text;
  77012. private _imageUrl;
  77013. private _shareMaterials;
  77014. private _frontMaterial;
  77015. private _backMaterial;
  77016. private _plateMaterial;
  77017. private _pickedPointObserver;
  77018. private _tooltipFade;
  77019. private _tooltipTextBlock;
  77020. private _tooltipTexture;
  77021. private _tooltipMesh;
  77022. private _tooltipHoverObserver;
  77023. private _tooltipOutObserver;
  77024. private _disposeTooltip;
  77025. /**
  77026. * Rendering ground id of all the mesh in the button
  77027. */
  77028. set renderingGroupId(id: number);
  77029. get renderingGroupId(): number;
  77030. /**
  77031. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  77032. */
  77033. set tooltipText(text: BABYLON.Nullable<string>);
  77034. get tooltipText(): BABYLON.Nullable<string>;
  77035. /**
  77036. * Gets or sets text for the button
  77037. */
  77038. get text(): string;
  77039. set text(value: string);
  77040. /**
  77041. * Gets or sets the image url for the button
  77042. */
  77043. get imageUrl(): string;
  77044. set imageUrl(value: string);
  77045. /**
  77046. * Gets the back material used by this button
  77047. */
  77048. get backMaterial(): FluentMaterial;
  77049. /**
  77050. * Gets the front material used by this button
  77051. */
  77052. get frontMaterial(): FluentMaterial;
  77053. /**
  77054. * Gets the plate material used by this button
  77055. */
  77056. get plateMaterial(): BABYLON.StandardMaterial;
  77057. /**
  77058. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  77059. */
  77060. get shareMaterials(): boolean;
  77061. /**
  77062. * Creates a new button
  77063. * @param name defines the control name
  77064. */
  77065. constructor(name?: string, shareMaterials?: boolean);
  77066. protected _getTypeName(): string;
  77067. private _rebuildContent;
  77068. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77069. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77070. private _createBackMaterial;
  77071. private _createFrontMaterial;
  77072. private _createPlateMaterial;
  77073. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  77074. /**
  77075. * Releases all associated resources
  77076. */
  77077. dispose(): void;
  77078. }
  77079. }
  77080. declare module BABYLON.GUI {
  77081. /**
  77082. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  77083. */
  77084. export class MeshButton3D extends Button3D {
  77085. /** @hidden */
  77086. protected _currentMesh: BABYLON.Mesh;
  77087. /**
  77088. * Creates a new 3D button based on a mesh
  77089. * @param mesh mesh to become a 3D button
  77090. * @param name defines the control name
  77091. */
  77092. constructor(mesh: BABYLON.Mesh, name?: string);
  77093. protected _getTypeName(): string;
  77094. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77095. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77096. }
  77097. }
  77098. declare module BABYLON.GUI {
  77099. /**
  77100. * Class used to create a container panel deployed on the surface of a plane
  77101. */
  77102. export class PlanePanel extends VolumeBasedPanel {
  77103. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77104. }
  77105. }
  77106. declare module BABYLON.GUI {
  77107. /**
  77108. * Class used to create a container panel where items get randomized planar mapping
  77109. */
  77110. export class ScatterPanel extends VolumeBasedPanel {
  77111. private _iteration;
  77112. /**
  77113. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  77114. */
  77115. get iteration(): BABYLON.float;
  77116. set iteration(value: BABYLON.float);
  77117. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77118. private _scatterMapping;
  77119. protected _finalProcessing(): void;
  77120. }
  77121. }
  77122. declare module BABYLON.GUI {
  77123. /**
  77124. * Class used to create a container panel deployed on the surface of a sphere
  77125. */
  77126. export class SpherePanel extends VolumeBasedPanel {
  77127. private _radius;
  77128. /**
  77129. * Gets or sets the radius of the sphere where to project controls (5 by default)
  77130. */
  77131. get radius(): BABYLON.float;
  77132. set radius(value: BABYLON.float);
  77133. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77134. private _sphericalMapping;
  77135. }
  77136. }
  77137. declare module BABYLON.GUI {
  77138. /**
  77139. * Class used to create a stack panel in 3D on XY plane
  77140. */
  77141. export class StackPanel3D extends Container3D {
  77142. private _isVertical;
  77143. /**
  77144. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  77145. */
  77146. get isVertical(): boolean;
  77147. set isVertical(value: boolean);
  77148. /**
  77149. * Gets or sets the distance between elements
  77150. */
  77151. margin: number;
  77152. /**
  77153. * Creates new StackPanel
  77154. * @param isVertical
  77155. */
  77156. constructor(isVertical?: boolean);
  77157. protected _arrangeChildren(): void;
  77158. }
  77159. }
  77160. declare module BABYLON {
  77161. /**
  77162. * Configuration for glTF validation
  77163. */
  77164. export interface IGLTFValidationConfiguration {
  77165. /**
  77166. * The url of the glTF validator.
  77167. */
  77168. url: string;
  77169. }
  77170. /**
  77171. * glTF validation
  77172. */
  77173. export class GLTFValidation {
  77174. /**
  77175. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  77176. */
  77177. static Configuration: IGLTFValidationConfiguration;
  77178. private static _LoadScriptPromise;
  77179. /**
  77180. * Validate a glTF asset using the glTF-Validator.
  77181. * @param data The JSON of a glTF or the array buffer of a binary glTF
  77182. * @param rootUrl The root url for the glTF
  77183. * @param fileName The file name for the glTF
  77184. * @param getExternalResource The callback to get external resources for the glTF validator
  77185. * @returns A promise that resolves with the glTF validation results once complete
  77186. */
  77187. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  77188. }
  77189. }
  77190. declare module BABYLON {
  77191. /**
  77192. * Mode that determines the coordinate system to use.
  77193. */
  77194. export enum GLTFLoaderCoordinateSystemMode {
  77195. /**
  77196. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  77197. */
  77198. AUTO = 0,
  77199. /**
  77200. * Sets the useRightHandedSystem flag on the scene.
  77201. */
  77202. FORCE_RIGHT_HANDED = 1
  77203. }
  77204. /**
  77205. * Mode that determines what animations will start.
  77206. */
  77207. export enum GLTFLoaderAnimationStartMode {
  77208. /**
  77209. * No animation will start.
  77210. */
  77211. NONE = 0,
  77212. /**
  77213. * The first animation will start.
  77214. */
  77215. FIRST = 1,
  77216. /**
  77217. * All animations will start.
  77218. */
  77219. ALL = 2
  77220. }
  77221. /**
  77222. * Interface that contains the data for the glTF asset.
  77223. */
  77224. export interface IGLTFLoaderData {
  77225. /**
  77226. * The object that represents the glTF JSON.
  77227. */
  77228. json: Object;
  77229. /**
  77230. * The BIN chunk of a binary glTF.
  77231. */
  77232. bin: Nullable<IDataBuffer>;
  77233. }
  77234. /**
  77235. * Interface for extending the loader.
  77236. */
  77237. export interface IGLTFLoaderExtension {
  77238. /**
  77239. * The name of this extension.
  77240. */
  77241. readonly name: string;
  77242. /**
  77243. * Defines whether this extension is enabled.
  77244. */
  77245. enabled: boolean;
  77246. /**
  77247. * Defines the order of this extension.
  77248. * The loader sorts the extensions using these values when loading.
  77249. */
  77250. order?: number;
  77251. }
  77252. /**
  77253. * Loader state.
  77254. */
  77255. export enum GLTFLoaderState {
  77256. /**
  77257. * The asset is loading.
  77258. */
  77259. LOADING = 0,
  77260. /**
  77261. * The asset is ready for rendering.
  77262. */
  77263. READY = 1,
  77264. /**
  77265. * The asset is completely loaded.
  77266. */
  77267. COMPLETE = 2
  77268. }
  77269. /** @hidden */
  77270. export interface IImportMeshAsyncOutput {
  77271. meshes: AbstractMesh[];
  77272. particleSystems: IParticleSystem[];
  77273. skeletons: Skeleton[];
  77274. animationGroups: AnimationGroup[];
  77275. lights: Light[];
  77276. transformNodes: TransformNode[];
  77277. }
  77278. /** @hidden */
  77279. export interface IGLTFLoader extends IDisposable {
  77280. readonly state: Nullable<GLTFLoaderState>;
  77281. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  77282. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  77283. }
  77284. /**
  77285. * File loader for loading glTF files into a scene.
  77286. */
  77287. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77288. /** @hidden */
  77289. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77290. /** @hidden */
  77291. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77292. /**
  77293. * Raised when the asset has been parsed
  77294. */
  77295. onParsedObservable: Observable<IGLTFLoaderData>;
  77296. private _onParsedObserver;
  77297. /**
  77298. * Raised when the asset has been parsed
  77299. */
  77300. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  77301. /**
  77302. * 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.
  77303. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  77304. * Defaults to true.
  77305. * @hidden
  77306. */
  77307. static IncrementalLoading: boolean;
  77308. /**
  77309. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  77310. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  77311. * @hidden
  77312. */
  77313. static HomogeneousCoordinates: boolean;
  77314. /**
  77315. * The coordinate system mode. Defaults to AUTO.
  77316. */
  77317. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  77318. /**
  77319. * The animation start mode. Defaults to FIRST.
  77320. */
  77321. animationStartMode: GLTFLoaderAnimationStartMode;
  77322. /**
  77323. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  77324. */
  77325. compileMaterials: boolean;
  77326. /**
  77327. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  77328. */
  77329. useClipPlane: boolean;
  77330. /**
  77331. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  77332. */
  77333. compileShadowGenerators: boolean;
  77334. /**
  77335. * Defines if the Alpha blended materials are only applied as coverage.
  77336. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  77337. * If true, no extra effects are applied to transparent pixels.
  77338. */
  77339. transparencyAsCoverage: boolean;
  77340. /**
  77341. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  77342. * Enabling will disable offline support and glTF validator.
  77343. * Defaults to false.
  77344. */
  77345. useRangeRequests: boolean;
  77346. /**
  77347. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  77348. */
  77349. createInstances: boolean;
  77350. /**
  77351. * Function called before loading a url referenced by the asset.
  77352. */
  77353. preprocessUrlAsync: (url: string) => Promise<string>;
  77354. /**
  77355. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  77356. */
  77357. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  77358. private _onMeshLoadedObserver;
  77359. /**
  77360. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  77361. */
  77362. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  77363. /**
  77364. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  77365. */
  77366. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  77367. private _onTextureLoadedObserver;
  77368. /**
  77369. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  77370. */
  77371. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  77372. /**
  77373. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  77374. */
  77375. readonly onMaterialLoadedObservable: Observable<Material>;
  77376. private _onMaterialLoadedObserver;
  77377. /**
  77378. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  77379. */
  77380. set onMaterialLoaded(callback: (material: Material) => void);
  77381. /**
  77382. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  77383. */
  77384. readonly onCameraLoadedObservable: Observable<Camera>;
  77385. private _onCameraLoadedObserver;
  77386. /**
  77387. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  77388. */
  77389. set onCameraLoaded(callback: (camera: Camera) => void);
  77390. /**
  77391. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  77392. * For assets with LODs, raised when all of the LODs are complete.
  77393. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  77394. */
  77395. readonly onCompleteObservable: Observable<void>;
  77396. private _onCompleteObserver;
  77397. /**
  77398. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  77399. * For assets with LODs, raised when all of the LODs are complete.
  77400. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  77401. */
  77402. set onComplete(callback: () => void);
  77403. /**
  77404. * Observable raised when an error occurs.
  77405. */
  77406. readonly onErrorObservable: Observable<any>;
  77407. private _onErrorObserver;
  77408. /**
  77409. * Callback raised when an error occurs.
  77410. */
  77411. set onError(callback: (reason: any) => void);
  77412. /**
  77413. * Observable raised after the loader is disposed.
  77414. */
  77415. readonly onDisposeObservable: Observable<void>;
  77416. private _onDisposeObserver;
  77417. /**
  77418. * Callback raised after the loader is disposed.
  77419. */
  77420. set onDispose(callback: () => void);
  77421. /**
  77422. * Observable raised after a loader extension is created.
  77423. * Set additional options for a loader extension in this event.
  77424. */
  77425. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  77426. private _onExtensionLoadedObserver;
  77427. /**
  77428. * Callback raised after a loader extension is created.
  77429. */
  77430. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  77431. /**
  77432. * Defines if the loader logging is enabled.
  77433. */
  77434. get loggingEnabled(): boolean;
  77435. set loggingEnabled(value: boolean);
  77436. /**
  77437. * Defines if the loader should capture performance counters.
  77438. */
  77439. get capturePerformanceCounters(): boolean;
  77440. set capturePerformanceCounters(value: boolean);
  77441. /**
  77442. * Defines if the loader should validate the asset.
  77443. */
  77444. validate: boolean;
  77445. /**
  77446. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  77447. */
  77448. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  77449. private _onValidatedObserver;
  77450. /**
  77451. * Callback raised after a loader extension is created.
  77452. */
  77453. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  77454. private _loader;
  77455. /**
  77456. * Name of the loader ("gltf")
  77457. */
  77458. name: string;
  77459. /** @hidden */
  77460. extensions: ISceneLoaderPluginExtensions;
  77461. /**
  77462. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  77463. */
  77464. dispose(): void;
  77465. /** @hidden */
  77466. _clear(): void;
  77467. /** @hidden */
  77468. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  77469. /** @hidden */
  77470. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  77471. /** @hidden */
  77472. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77473. meshes: AbstractMesh[];
  77474. particleSystems: IParticleSystem[];
  77475. skeletons: Skeleton[];
  77476. animationGroups: AnimationGroup[];
  77477. }>;
  77478. /** @hidden */
  77479. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77480. /** @hidden */
  77481. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77482. /** @hidden */
  77483. canDirectLoad(data: string): boolean;
  77484. /** @hidden */
  77485. directLoad(scene: Scene, data: string): any;
  77486. /**
  77487. * The callback that allows custom handling of the root url based on the response url.
  77488. * @param rootUrl the original root url
  77489. * @param responseURL the response url if available
  77490. * @returns the new root url
  77491. */
  77492. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  77493. /** @hidden */
  77494. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  77495. /**
  77496. * The loader state or null if the loader is not active.
  77497. */
  77498. get loaderState(): Nullable<GLTFLoaderState>;
  77499. /**
  77500. * Returns a promise that resolves when the asset is completely loaded.
  77501. * @returns a promise that resolves when the asset is completely loaded.
  77502. */
  77503. whenCompleteAsync(): Promise<void>;
  77504. private _validate;
  77505. private _getLoader;
  77506. private _parseJson;
  77507. private _unpackBinaryAsync;
  77508. private _unpackBinaryV1Async;
  77509. private _unpackBinaryV2Async;
  77510. private static _parseVersion;
  77511. private static _compareVersion;
  77512. private static readonly _logSpaces;
  77513. private _logIndentLevel;
  77514. private _loggingEnabled;
  77515. /** @hidden */
  77516. _log: (message: string) => void;
  77517. /** @hidden */
  77518. _logOpen(message: string): void;
  77519. /** @hidden */
  77520. _logClose(): void;
  77521. private _logEnabled;
  77522. private _logDisabled;
  77523. private _capturePerformanceCounters;
  77524. /** @hidden */
  77525. _startPerformanceCounter: (counterName: string) => void;
  77526. /** @hidden */
  77527. _endPerformanceCounter: (counterName: string) => void;
  77528. private _startPerformanceCounterEnabled;
  77529. private _startPerformanceCounterDisabled;
  77530. private _endPerformanceCounterEnabled;
  77531. private _endPerformanceCounterDisabled;
  77532. }
  77533. }
  77534. declare module BABYLON.GLTF1 {
  77535. /**
  77536. * Enums
  77537. * @hidden
  77538. */
  77539. export enum EComponentType {
  77540. BYTE = 5120,
  77541. UNSIGNED_BYTE = 5121,
  77542. SHORT = 5122,
  77543. UNSIGNED_SHORT = 5123,
  77544. FLOAT = 5126
  77545. }
  77546. /** @hidden */
  77547. export enum EShaderType {
  77548. FRAGMENT = 35632,
  77549. VERTEX = 35633
  77550. }
  77551. /** @hidden */
  77552. export enum EParameterType {
  77553. BYTE = 5120,
  77554. UNSIGNED_BYTE = 5121,
  77555. SHORT = 5122,
  77556. UNSIGNED_SHORT = 5123,
  77557. INT = 5124,
  77558. UNSIGNED_INT = 5125,
  77559. FLOAT = 5126,
  77560. FLOAT_VEC2 = 35664,
  77561. FLOAT_VEC3 = 35665,
  77562. FLOAT_VEC4 = 35666,
  77563. INT_VEC2 = 35667,
  77564. INT_VEC3 = 35668,
  77565. INT_VEC4 = 35669,
  77566. BOOL = 35670,
  77567. BOOL_VEC2 = 35671,
  77568. BOOL_VEC3 = 35672,
  77569. BOOL_VEC4 = 35673,
  77570. FLOAT_MAT2 = 35674,
  77571. FLOAT_MAT3 = 35675,
  77572. FLOAT_MAT4 = 35676,
  77573. SAMPLER_2D = 35678
  77574. }
  77575. /** @hidden */
  77576. export enum ETextureWrapMode {
  77577. CLAMP_TO_EDGE = 33071,
  77578. MIRRORED_REPEAT = 33648,
  77579. REPEAT = 10497
  77580. }
  77581. /** @hidden */
  77582. export enum ETextureFilterType {
  77583. NEAREST = 9728,
  77584. LINEAR = 9728,
  77585. NEAREST_MIPMAP_NEAREST = 9984,
  77586. LINEAR_MIPMAP_NEAREST = 9985,
  77587. NEAREST_MIPMAP_LINEAR = 9986,
  77588. LINEAR_MIPMAP_LINEAR = 9987
  77589. }
  77590. /** @hidden */
  77591. export enum ETextureFormat {
  77592. ALPHA = 6406,
  77593. RGB = 6407,
  77594. RGBA = 6408,
  77595. LUMINANCE = 6409,
  77596. LUMINANCE_ALPHA = 6410
  77597. }
  77598. /** @hidden */
  77599. export enum ECullingType {
  77600. FRONT = 1028,
  77601. BACK = 1029,
  77602. FRONT_AND_BACK = 1032
  77603. }
  77604. /** @hidden */
  77605. export enum EBlendingFunction {
  77606. ZERO = 0,
  77607. ONE = 1,
  77608. SRC_COLOR = 768,
  77609. ONE_MINUS_SRC_COLOR = 769,
  77610. DST_COLOR = 774,
  77611. ONE_MINUS_DST_COLOR = 775,
  77612. SRC_ALPHA = 770,
  77613. ONE_MINUS_SRC_ALPHA = 771,
  77614. DST_ALPHA = 772,
  77615. ONE_MINUS_DST_ALPHA = 773,
  77616. CONSTANT_COLOR = 32769,
  77617. ONE_MINUS_CONSTANT_COLOR = 32770,
  77618. CONSTANT_ALPHA = 32771,
  77619. ONE_MINUS_CONSTANT_ALPHA = 32772,
  77620. SRC_ALPHA_SATURATE = 776
  77621. }
  77622. /** @hidden */
  77623. export interface IGLTFProperty {
  77624. extensions?: {
  77625. [key: string]: any;
  77626. };
  77627. extras?: Object;
  77628. }
  77629. /** @hidden */
  77630. export interface IGLTFChildRootProperty extends IGLTFProperty {
  77631. name?: string;
  77632. }
  77633. /** @hidden */
  77634. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  77635. bufferView: string;
  77636. byteOffset: number;
  77637. byteStride: number;
  77638. count: number;
  77639. type: string;
  77640. componentType: EComponentType;
  77641. max?: number[];
  77642. min?: number[];
  77643. name?: string;
  77644. }
  77645. /** @hidden */
  77646. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  77647. buffer: string;
  77648. byteOffset: number;
  77649. byteLength: number;
  77650. byteStride: number;
  77651. target?: number;
  77652. }
  77653. /** @hidden */
  77654. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  77655. uri: string;
  77656. byteLength?: number;
  77657. type?: string;
  77658. }
  77659. /** @hidden */
  77660. export interface IGLTFShader extends IGLTFChildRootProperty {
  77661. uri: string;
  77662. type: EShaderType;
  77663. }
  77664. /** @hidden */
  77665. export interface IGLTFProgram extends IGLTFChildRootProperty {
  77666. attributes: string[];
  77667. fragmentShader: string;
  77668. vertexShader: string;
  77669. }
  77670. /** @hidden */
  77671. export interface IGLTFTechniqueParameter {
  77672. type: number;
  77673. count?: number;
  77674. semantic?: string;
  77675. node?: string;
  77676. value?: number | boolean | string | Array<any>;
  77677. source?: string;
  77678. babylonValue?: any;
  77679. }
  77680. /** @hidden */
  77681. export interface IGLTFTechniqueCommonProfile {
  77682. lightingModel: string;
  77683. texcoordBindings: Object;
  77684. parameters?: Array<any>;
  77685. }
  77686. /** @hidden */
  77687. export interface IGLTFTechniqueStatesFunctions {
  77688. blendColor?: number[];
  77689. blendEquationSeparate?: number[];
  77690. blendFuncSeparate?: number[];
  77691. colorMask: boolean[];
  77692. cullFace: number[];
  77693. }
  77694. /** @hidden */
  77695. export interface IGLTFTechniqueStates {
  77696. enable: number[];
  77697. functions: IGLTFTechniqueStatesFunctions;
  77698. }
  77699. /** @hidden */
  77700. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  77701. parameters: {
  77702. [key: string]: IGLTFTechniqueParameter;
  77703. };
  77704. program: string;
  77705. attributes: {
  77706. [key: string]: string;
  77707. };
  77708. uniforms: {
  77709. [key: string]: string;
  77710. };
  77711. states: IGLTFTechniqueStates;
  77712. }
  77713. /** @hidden */
  77714. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  77715. technique?: string;
  77716. values: string[];
  77717. }
  77718. /** @hidden */
  77719. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  77720. attributes: {
  77721. [key: string]: string;
  77722. };
  77723. indices: string;
  77724. material: string;
  77725. mode?: number;
  77726. }
  77727. /** @hidden */
  77728. export interface IGLTFMesh extends IGLTFChildRootProperty {
  77729. primitives: IGLTFMeshPrimitive[];
  77730. }
  77731. /** @hidden */
  77732. export interface IGLTFImage extends IGLTFChildRootProperty {
  77733. uri: string;
  77734. }
  77735. /** @hidden */
  77736. export interface IGLTFSampler extends IGLTFChildRootProperty {
  77737. magFilter?: number;
  77738. minFilter?: number;
  77739. wrapS?: number;
  77740. wrapT?: number;
  77741. }
  77742. /** @hidden */
  77743. export interface IGLTFTexture extends IGLTFChildRootProperty {
  77744. sampler: string;
  77745. source: string;
  77746. format?: ETextureFormat;
  77747. internalFormat?: ETextureFormat;
  77748. target?: number;
  77749. type?: number;
  77750. babylonTexture?: Texture;
  77751. }
  77752. /** @hidden */
  77753. export interface IGLTFAmbienLight {
  77754. color?: number[];
  77755. }
  77756. /** @hidden */
  77757. export interface IGLTFDirectionalLight {
  77758. color?: number[];
  77759. }
  77760. /** @hidden */
  77761. export interface IGLTFPointLight {
  77762. color?: number[];
  77763. constantAttenuation?: number;
  77764. linearAttenuation?: number;
  77765. quadraticAttenuation?: number;
  77766. }
  77767. /** @hidden */
  77768. export interface IGLTFSpotLight {
  77769. color?: number[];
  77770. constantAttenuation?: number;
  77771. fallOfAngle?: number;
  77772. fallOffExponent?: number;
  77773. linearAttenuation?: number;
  77774. quadraticAttenuation?: number;
  77775. }
  77776. /** @hidden */
  77777. export interface IGLTFLight extends IGLTFChildRootProperty {
  77778. type: string;
  77779. }
  77780. /** @hidden */
  77781. export interface IGLTFCameraOrthographic {
  77782. xmag: number;
  77783. ymag: number;
  77784. zfar: number;
  77785. znear: number;
  77786. }
  77787. /** @hidden */
  77788. export interface IGLTFCameraPerspective {
  77789. aspectRatio: number;
  77790. yfov: number;
  77791. zfar: number;
  77792. znear: number;
  77793. }
  77794. /** @hidden */
  77795. export interface IGLTFCamera extends IGLTFChildRootProperty {
  77796. type: string;
  77797. }
  77798. /** @hidden */
  77799. export interface IGLTFAnimationChannelTarget {
  77800. id: string;
  77801. path: string;
  77802. }
  77803. /** @hidden */
  77804. export interface IGLTFAnimationChannel {
  77805. sampler: string;
  77806. target: IGLTFAnimationChannelTarget;
  77807. }
  77808. /** @hidden */
  77809. export interface IGLTFAnimationSampler {
  77810. input: string;
  77811. output: string;
  77812. interpolation?: string;
  77813. }
  77814. /** @hidden */
  77815. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  77816. channels?: IGLTFAnimationChannel[];
  77817. parameters?: {
  77818. [key: string]: string;
  77819. };
  77820. samplers?: {
  77821. [key: string]: IGLTFAnimationSampler;
  77822. };
  77823. }
  77824. /** @hidden */
  77825. export interface IGLTFNodeInstanceSkin {
  77826. skeletons: string[];
  77827. skin: string;
  77828. meshes: string[];
  77829. }
  77830. /** @hidden */
  77831. export interface IGLTFSkins extends IGLTFChildRootProperty {
  77832. bindShapeMatrix: number[];
  77833. inverseBindMatrices: string;
  77834. jointNames: string[];
  77835. babylonSkeleton?: Skeleton;
  77836. }
  77837. /** @hidden */
  77838. export interface IGLTFNode extends IGLTFChildRootProperty {
  77839. camera?: string;
  77840. children: string[];
  77841. skin?: string;
  77842. jointName?: string;
  77843. light?: string;
  77844. matrix: number[];
  77845. mesh?: string;
  77846. meshes?: string[];
  77847. rotation?: number[];
  77848. scale?: number[];
  77849. translation?: number[];
  77850. babylonNode?: Node;
  77851. }
  77852. /** @hidden */
  77853. export interface IGLTFScene extends IGLTFChildRootProperty {
  77854. nodes: string[];
  77855. }
  77856. /** @hidden */
  77857. export interface IGLTFRuntime {
  77858. extensions: {
  77859. [key: string]: any;
  77860. };
  77861. accessors: {
  77862. [key: string]: IGLTFAccessor;
  77863. };
  77864. buffers: {
  77865. [key: string]: IGLTFBuffer;
  77866. };
  77867. bufferViews: {
  77868. [key: string]: IGLTFBufferView;
  77869. };
  77870. meshes: {
  77871. [key: string]: IGLTFMesh;
  77872. };
  77873. lights: {
  77874. [key: string]: IGLTFLight;
  77875. };
  77876. cameras: {
  77877. [key: string]: IGLTFCamera;
  77878. };
  77879. nodes: {
  77880. [key: string]: IGLTFNode;
  77881. };
  77882. images: {
  77883. [key: string]: IGLTFImage;
  77884. };
  77885. textures: {
  77886. [key: string]: IGLTFTexture;
  77887. };
  77888. shaders: {
  77889. [key: string]: IGLTFShader;
  77890. };
  77891. programs: {
  77892. [key: string]: IGLTFProgram;
  77893. };
  77894. samplers: {
  77895. [key: string]: IGLTFSampler;
  77896. };
  77897. techniques: {
  77898. [key: string]: IGLTFTechnique;
  77899. };
  77900. materials: {
  77901. [key: string]: IGLTFMaterial;
  77902. };
  77903. animations: {
  77904. [key: string]: IGLTFAnimation;
  77905. };
  77906. skins: {
  77907. [key: string]: IGLTFSkins;
  77908. };
  77909. currentScene?: Object;
  77910. scenes: {
  77911. [key: string]: IGLTFScene;
  77912. };
  77913. extensionsUsed: string[];
  77914. extensionsRequired?: string[];
  77915. buffersCount: number;
  77916. shaderscount: number;
  77917. scene: Scene;
  77918. rootUrl: string;
  77919. loadedBufferCount: number;
  77920. loadedBufferViews: {
  77921. [name: string]: ArrayBufferView;
  77922. };
  77923. loadedShaderCount: number;
  77924. importOnlyMeshes: boolean;
  77925. importMeshesNames?: string[];
  77926. dummyNodes: Node[];
  77927. forAssetContainer: boolean;
  77928. }
  77929. /** @hidden */
  77930. export interface INodeToRoot {
  77931. bone: Bone;
  77932. node: IGLTFNode;
  77933. id: string;
  77934. }
  77935. /** @hidden */
  77936. export interface IJointNode {
  77937. node: IGLTFNode;
  77938. id: string;
  77939. }
  77940. }
  77941. declare module BABYLON.GLTF1 {
  77942. /**
  77943. * Utils functions for GLTF
  77944. * @hidden
  77945. */
  77946. export class GLTFUtils {
  77947. /**
  77948. * Sets the given "parameter" matrix
  77949. * @param scene: the Scene object
  77950. * @param source: the source node where to pick the matrix
  77951. * @param parameter: the GLTF technique parameter
  77952. * @param uniformName: the name of the shader's uniform
  77953. * @param shaderMaterial: the shader material
  77954. */
  77955. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  77956. /**
  77957. * Sets the given "parameter" matrix
  77958. * @param shaderMaterial: the shader material
  77959. * @param uniform: the name of the shader's uniform
  77960. * @param value: the value of the uniform
  77961. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  77962. */
  77963. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  77964. /**
  77965. * Returns the wrap mode of the texture
  77966. * @param mode: the mode value
  77967. */
  77968. static GetWrapMode(mode: number): number;
  77969. /**
  77970. * Returns the byte stride giving an accessor
  77971. * @param accessor: the GLTF accessor objet
  77972. */
  77973. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  77974. /**
  77975. * Returns the texture filter mode giving a mode value
  77976. * @param mode: the filter mode value
  77977. */
  77978. static GetTextureFilterMode(mode: number): ETextureFilterType;
  77979. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  77980. /**
  77981. * Returns a buffer from its accessor
  77982. * @param gltfRuntime: the GLTF runtime
  77983. * @param accessor: the GLTF accessor
  77984. */
  77985. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  77986. /**
  77987. * Decodes a buffer view into a string
  77988. * @param view: the buffer view
  77989. */
  77990. static DecodeBufferToText(view: ArrayBufferView): string;
  77991. /**
  77992. * Returns the default material of gltf. Related to
  77993. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  77994. * @param scene: the Babylon.js scene
  77995. */
  77996. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  77997. private static _DefaultMaterial;
  77998. }
  77999. }
  78000. declare module BABYLON.GLTF1 {
  78001. /**
  78002. * Implementation of the base glTF spec
  78003. * @hidden
  78004. */
  78005. export class GLTFLoaderBase {
  78006. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  78007. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78008. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  78009. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78010. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  78011. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78012. }
  78013. /**
  78014. * glTF V1 Loader
  78015. * @hidden
  78016. */
  78017. export class GLTFLoader implements IGLTFLoader {
  78018. static Extensions: {
  78019. [name: string]: GLTFLoaderExtension;
  78020. };
  78021. static RegisterExtension(extension: GLTFLoaderExtension): void;
  78022. state: Nullable<GLTFLoaderState>;
  78023. dispose(): void;
  78024. private _importMeshAsync;
  78025. /**
  78026. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  78027. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  78028. * @param scene the scene the meshes should be added to
  78029. * @param forAssetContainer defines if the entities must be stored in the scene
  78030. * @param data gltf data containing information of the meshes in a loaded file
  78031. * @param rootUrl root url to load from
  78032. * @param onProgress event that fires when loading progress has occured
  78033. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  78034. */
  78035. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  78036. private _loadAsync;
  78037. /**
  78038. * Imports all objects from a loaded gltf file and adds them to the scene
  78039. * @param scene the scene the objects should be added to
  78040. * @param data gltf data containing information of the meshes in a loaded file
  78041. * @param rootUrl root url to load from
  78042. * @param onProgress event that fires when loading progress has occured
  78043. * @returns a promise which completes when objects have been loaded to the scene
  78044. */
  78045. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  78046. private _loadShadersAsync;
  78047. private _loadBuffersAsync;
  78048. private _createNodes;
  78049. }
  78050. /** @hidden */
  78051. export abstract class GLTFLoaderExtension {
  78052. private _name;
  78053. constructor(name: string);
  78054. get name(): string;
  78055. /**
  78056. * Defines an override for loading the runtime
  78057. * Return true to stop further extensions from loading the runtime
  78058. */
  78059. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  78060. /**
  78061. * Defines an onverride for creating gltf runtime
  78062. * Return true to stop further extensions from creating the runtime
  78063. */
  78064. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  78065. /**
  78066. * Defines an override for loading buffers
  78067. * Return true to stop further extensions from loading this buffer
  78068. */
  78069. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  78070. /**
  78071. * Defines an override for loading texture buffers
  78072. * Return true to stop further extensions from loading this texture data
  78073. */
  78074. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78075. /**
  78076. * Defines an override for creating textures
  78077. * Return true to stop further extensions from loading this texture
  78078. */
  78079. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  78080. /**
  78081. * Defines an override for loading shader strings
  78082. * Return true to stop further extensions from loading this shader data
  78083. */
  78084. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78085. /**
  78086. * Defines an override for loading materials
  78087. * Return true to stop further extensions from loading this material
  78088. */
  78089. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78090. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  78091. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  78092. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78093. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78094. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  78095. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78096. private static LoadTextureBufferAsync;
  78097. private static CreateTextureAsync;
  78098. private static ApplyExtensions;
  78099. }
  78100. }
  78101. declare module BABYLON.GLTF1 {
  78102. /** @hidden */
  78103. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  78104. private _bin;
  78105. constructor();
  78106. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  78107. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78108. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78109. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78110. }
  78111. }
  78112. declare module BABYLON.GLTF1 {
  78113. /** @hidden */
  78114. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  78115. constructor();
  78116. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  78117. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78118. private _loadTexture;
  78119. }
  78120. }
  78121. declare module BABYLON.GLTF2.Loader {
  78122. /**
  78123. * Loader interface with an index field.
  78124. */
  78125. export interface IArrayItem {
  78126. /**
  78127. * The index of this item in the array.
  78128. */
  78129. index: number;
  78130. }
  78131. /**
  78132. * Loader interface with additional members.
  78133. */
  78134. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  78135. /** @hidden */
  78136. _data?: Promise<ArrayBufferView>;
  78137. /** @hidden */
  78138. _babylonVertexBuffer?: Promise<VertexBuffer>;
  78139. }
  78140. /**
  78141. * Loader interface with additional members.
  78142. */
  78143. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  78144. }
  78145. /** @hidden */
  78146. export interface _IAnimationSamplerData {
  78147. input: Float32Array;
  78148. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  78149. output: Float32Array;
  78150. }
  78151. /**
  78152. * Loader interface with additional members.
  78153. */
  78154. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  78155. /** @hidden */
  78156. _data?: Promise<_IAnimationSamplerData>;
  78157. }
  78158. /**
  78159. * Loader interface with additional members.
  78160. */
  78161. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  78162. channels: IAnimationChannel[];
  78163. samplers: IAnimationSampler[];
  78164. /** @hidden */
  78165. _babylonAnimationGroup?: AnimationGroup;
  78166. }
  78167. /**
  78168. * Loader interface with additional members.
  78169. */
  78170. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  78171. /** @hidden */
  78172. _data?: Promise<ArrayBufferView>;
  78173. }
  78174. /**
  78175. * Loader interface with additional members.
  78176. */
  78177. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  78178. /** @hidden */
  78179. _data?: Promise<ArrayBufferView>;
  78180. /** @hidden */
  78181. _babylonBuffer?: Promise<Buffer>;
  78182. }
  78183. /**
  78184. * Loader interface with additional members.
  78185. */
  78186. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  78187. }
  78188. /**
  78189. * Loader interface with additional members.
  78190. */
  78191. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  78192. /** @hidden */
  78193. _data?: Promise<ArrayBufferView>;
  78194. }
  78195. /**
  78196. * Loader interface with additional members.
  78197. */
  78198. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  78199. }
  78200. /**
  78201. * Loader interface with additional members.
  78202. */
  78203. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  78204. }
  78205. /**
  78206. * Loader interface with additional members.
  78207. */
  78208. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  78209. baseColorTexture?: ITextureInfo;
  78210. metallicRoughnessTexture?: ITextureInfo;
  78211. }
  78212. /**
  78213. * Loader interface with additional members.
  78214. */
  78215. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  78216. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78217. normalTexture?: IMaterialNormalTextureInfo;
  78218. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78219. emissiveTexture?: ITextureInfo;
  78220. /** @hidden */
  78221. _data?: {
  78222. [babylonDrawMode: number]: {
  78223. babylonMaterial: Material;
  78224. babylonMeshes: AbstractMesh[];
  78225. promise: Promise<void>;
  78226. };
  78227. };
  78228. }
  78229. /**
  78230. * Loader interface with additional members.
  78231. */
  78232. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  78233. primitives: IMeshPrimitive[];
  78234. }
  78235. /**
  78236. * Loader interface with additional members.
  78237. */
  78238. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  78239. /** @hidden */
  78240. _instanceData?: {
  78241. babylonSourceMesh: Mesh;
  78242. promise: Promise<any>;
  78243. };
  78244. }
  78245. /**
  78246. * Loader interface with additional members.
  78247. */
  78248. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  78249. /**
  78250. * The parent glTF node.
  78251. */
  78252. parent?: INode;
  78253. /** @hidden */
  78254. _babylonTransformNode?: TransformNode;
  78255. /** @hidden */
  78256. _primitiveBabylonMeshes?: AbstractMesh[];
  78257. /** @hidden */
  78258. _babylonBones?: Bone[];
  78259. /** @hidden */
  78260. _numMorphTargets?: number;
  78261. }
  78262. /** @hidden */
  78263. export interface _ISamplerData {
  78264. noMipMaps: boolean;
  78265. samplingMode: number;
  78266. wrapU: number;
  78267. wrapV: number;
  78268. }
  78269. /**
  78270. * Loader interface with additional members.
  78271. */
  78272. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  78273. /** @hidden */
  78274. _data?: _ISamplerData;
  78275. }
  78276. /**
  78277. * Loader interface with additional members.
  78278. */
  78279. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  78280. }
  78281. /**
  78282. * Loader interface with additional members.
  78283. */
  78284. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  78285. /** @hidden */
  78286. _data?: {
  78287. babylonSkeleton: Skeleton;
  78288. promise: Promise<void>;
  78289. };
  78290. }
  78291. /**
  78292. * Loader interface with additional members.
  78293. */
  78294. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  78295. }
  78296. /**
  78297. * Loader interface with additional members.
  78298. */
  78299. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  78300. }
  78301. /**
  78302. * Loader interface with additional members.
  78303. */
  78304. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  78305. accessors?: IAccessor[];
  78306. animations?: IAnimation[];
  78307. buffers?: IBuffer[];
  78308. bufferViews?: IBufferView[];
  78309. cameras?: ICamera[];
  78310. images?: IImage[];
  78311. materials?: IMaterial[];
  78312. meshes?: IMesh[];
  78313. nodes?: INode[];
  78314. samplers?: ISampler[];
  78315. scenes?: IScene[];
  78316. skins?: ISkin[];
  78317. textures?: ITexture[];
  78318. }
  78319. }
  78320. declare module BABYLON.GLTF2 {
  78321. /**
  78322. * Interface for a glTF loader extension.
  78323. */
  78324. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  78325. /**
  78326. * Called after the loader state changes to LOADING.
  78327. */
  78328. onLoading?(): void;
  78329. /**
  78330. * Called after the loader state changes to READY.
  78331. */
  78332. onReady?(): void;
  78333. /**
  78334. * Define this method to modify the default behavior when loading scenes.
  78335. * @param context The context when loading the asset
  78336. * @param scene The glTF scene property
  78337. * @returns A promise that resolves when the load is complete or null if not handled
  78338. */
  78339. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  78340. /**
  78341. * Define this method to modify the default behavior when loading nodes.
  78342. * @param context The context when loading the asset
  78343. * @param node The glTF node property
  78344. * @param assign A function called synchronously after parsing the glTF properties
  78345. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  78346. */
  78347. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78348. /**
  78349. * Define this method to modify the default behavior when loading cameras.
  78350. * @param context The context when loading the asset
  78351. * @param camera The glTF camera property
  78352. * @param assign A function called synchronously after parsing the glTF properties
  78353. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  78354. */
  78355. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  78356. /**
  78357. * @hidden
  78358. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  78359. * @param context The context when loading the asset
  78360. * @param primitive The glTF mesh primitive property
  78361. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  78362. */
  78363. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  78364. /**
  78365. * @hidden
  78366. * Define this method to modify the default behavior when loading data for mesh primitives.
  78367. * @param context The context when loading the asset
  78368. * @param name The mesh name when loading the asset
  78369. * @param node The glTF node when loading the asset
  78370. * @param mesh The glTF mesh when loading the asset
  78371. * @param primitive The glTF mesh primitive property
  78372. * @param assign A function called synchronously after parsing the glTF properties
  78373. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  78374. */
  78375. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  78376. /**
  78377. * @hidden
  78378. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  78379. * @param context The context when loading the asset
  78380. * @param material The glTF material property
  78381. * @param assign A function called synchronously after parsing the glTF properties
  78382. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  78383. */
  78384. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  78385. /**
  78386. * Define this method to modify the default behavior when creating materials.
  78387. * @param context The context when loading the asset
  78388. * @param material The glTF material property
  78389. * @param babylonDrawMode The draw mode for the Babylon material
  78390. * @returns The Babylon material or null if not handled
  78391. */
  78392. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  78393. /**
  78394. * Define this method to modify the default behavior when loading material properties.
  78395. * @param context The context when loading the asset
  78396. * @param material The glTF material property
  78397. * @param babylonMaterial The Babylon material
  78398. * @returns A promise that resolves when the load is complete or null if not handled
  78399. */
  78400. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78401. /**
  78402. * Define this method to modify the default behavior when loading texture infos.
  78403. * @param context The context when loading the asset
  78404. * @param textureInfo The glTF texture info property
  78405. * @param assign A function called synchronously after parsing the glTF properties
  78406. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  78407. */
  78408. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78409. /**
  78410. * @hidden
  78411. * Define this method to modify the default behavior when loading textures.
  78412. * @param context The context when loading the asset
  78413. * @param texture The glTF texture property
  78414. * @param assign A function called synchronously after parsing the glTF properties
  78415. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  78416. */
  78417. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78418. /**
  78419. * Define this method to modify the default behavior when loading animations.
  78420. * @param context The context when loading the asset
  78421. * @param animation The glTF animation property
  78422. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  78423. */
  78424. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  78425. /**
  78426. * @hidden
  78427. * Define this method to modify the default behavior when loading skins.
  78428. * @param context The context when loading the asset
  78429. * @param node The glTF node property
  78430. * @param skin The glTF skin property
  78431. * @returns A promise that resolves when the load is complete or null if not handled
  78432. */
  78433. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  78434. /**
  78435. * @hidden
  78436. * Define this method to modify the default behavior when loading uris.
  78437. * @param context The context when loading the asset
  78438. * @param property The glTF property associated with the uri
  78439. * @param uri The uri to load
  78440. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78441. */
  78442. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  78443. /**
  78444. * Define this method to modify the default behavior when loading buffer views.
  78445. * @param context The context when loading the asset
  78446. * @param bufferView The glTF buffer view property
  78447. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78448. */
  78449. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  78450. /**
  78451. * Define this method to modify the default behavior when loading buffers.
  78452. * @param context The context when loading the asset
  78453. * @param buffer The glTF buffer property
  78454. * @param byteOffset The byte offset to load
  78455. * @param byteLength The byte length to load
  78456. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78457. */
  78458. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  78459. }
  78460. }
  78461. declare module BABYLON.GLTF2 {
  78462. /**
  78463. * Helper class for working with arrays when loading the glTF asset
  78464. */
  78465. export class ArrayItem {
  78466. /**
  78467. * Gets an item from the given array.
  78468. * @param context The context when loading the asset
  78469. * @param array The array to get the item from
  78470. * @param index The index to the array
  78471. * @returns The array item
  78472. */
  78473. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  78474. /**
  78475. * Assign an `index` field to each item of the given array.
  78476. * @param array The array of items
  78477. */
  78478. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  78479. }
  78480. /**
  78481. * The glTF 2.0 loader
  78482. */
  78483. export class GLTFLoader implements IGLTFLoader {
  78484. /** @hidden */
  78485. _completePromises: Promise<any>[];
  78486. /** @hidden */
  78487. _forAssetContainer: boolean;
  78488. /** Storage */
  78489. _babylonLights: Light[];
  78490. private _disposed;
  78491. private _parent;
  78492. private _state;
  78493. private _extensions;
  78494. private _rootUrl;
  78495. private _fileName;
  78496. private _uniqueRootUrl;
  78497. private _gltf;
  78498. private _bin;
  78499. private _babylonScene;
  78500. private _rootBabylonMesh;
  78501. private _defaultBabylonMaterialData;
  78502. private _progressCallback?;
  78503. private _requests;
  78504. private static _RegisteredExtensions;
  78505. /**
  78506. * The default glTF sampler.
  78507. */
  78508. static readonly DefaultSampler: ISampler;
  78509. /**
  78510. * Registers a loader extension.
  78511. * @param name The name of the loader extension.
  78512. * @param factory The factory function that creates the loader extension.
  78513. */
  78514. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  78515. /**
  78516. * Unregisters a loader extension.
  78517. * @param name The name of the loader extension.
  78518. * @returns A boolean indicating whether the extension has been unregistered
  78519. */
  78520. static UnregisterExtension(name: string): boolean;
  78521. /**
  78522. * The loader state.
  78523. */
  78524. get state(): Nullable<GLTFLoaderState>;
  78525. /**
  78526. * The object that represents the glTF JSON.
  78527. */
  78528. get gltf(): IGLTF;
  78529. /**
  78530. * The BIN chunk of a binary glTF.
  78531. */
  78532. get bin(): Nullable<IDataBuffer>;
  78533. /**
  78534. * The parent file loader.
  78535. */
  78536. get parent(): GLTFFileLoader;
  78537. /**
  78538. * The Babylon scene when loading the asset.
  78539. */
  78540. get babylonScene(): Scene;
  78541. /**
  78542. * The root Babylon mesh when loading the asset.
  78543. */
  78544. get rootBabylonMesh(): Mesh;
  78545. /** @hidden */
  78546. constructor(parent: GLTFFileLoader);
  78547. /** @hidden */
  78548. dispose(): void;
  78549. /** @hidden */
  78550. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  78551. /** @hidden */
  78552. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78553. private _loadAsync;
  78554. private _loadData;
  78555. private _setupData;
  78556. private _loadExtensions;
  78557. private _checkExtensions;
  78558. private _setState;
  78559. private _createRootNode;
  78560. /**
  78561. * Loads a glTF scene.
  78562. * @param context The context when loading the asset
  78563. * @param scene The glTF scene property
  78564. * @returns A promise that resolves when the load is complete
  78565. */
  78566. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  78567. private _forEachPrimitive;
  78568. private _getMeshes;
  78569. private _getTransformNodes;
  78570. private _getSkeletons;
  78571. private _getAnimationGroups;
  78572. private _startAnimations;
  78573. /**
  78574. * Loads a glTF node.
  78575. * @param context The context when loading the asset
  78576. * @param node The glTF node property
  78577. * @param assign A function called synchronously after parsing the glTF properties
  78578. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  78579. */
  78580. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  78581. private _loadMeshAsync;
  78582. /**
  78583. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  78584. * @param context The context when loading the asset
  78585. * @param name The mesh name when loading the asset
  78586. * @param node The glTF node when loading the asset
  78587. * @param mesh The glTF mesh when loading the asset
  78588. * @param primitive The glTF mesh primitive property
  78589. * @param assign A function called synchronously after parsing the glTF properties
  78590. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  78591. */
  78592. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  78593. private _loadVertexDataAsync;
  78594. private _createMorphTargets;
  78595. private _loadMorphTargetsAsync;
  78596. private _loadMorphTargetVertexDataAsync;
  78597. private static _LoadTransform;
  78598. private _loadSkinAsync;
  78599. private _loadBones;
  78600. private _loadBone;
  78601. private _loadSkinInverseBindMatricesDataAsync;
  78602. private _updateBoneMatrices;
  78603. private _getNodeMatrix;
  78604. /**
  78605. * Loads a glTF camera.
  78606. * @param context The context when loading the asset
  78607. * @param camera The glTF camera property
  78608. * @param assign A function called synchronously after parsing the glTF properties
  78609. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  78610. */
  78611. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  78612. private _loadAnimationsAsync;
  78613. /**
  78614. * Loads a glTF animation.
  78615. * @param context The context when loading the asset
  78616. * @param animation The glTF animation property
  78617. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  78618. */
  78619. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  78620. /**
  78621. * @hidden Loads a glTF animation channel.
  78622. * @param context The context when loading the asset
  78623. * @param animationContext The context of the animation when loading the asset
  78624. * @param animation The glTF animation property
  78625. * @param channel The glTF animation channel property
  78626. * @param babylonAnimationGroup The babylon animation group property
  78627. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  78628. * @returns A void promise when the channel load is complete
  78629. */
  78630. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  78631. private _loadAnimationSamplerAsync;
  78632. private _loadBufferAsync;
  78633. /**
  78634. * Loads a glTF buffer view.
  78635. * @param context The context when loading the asset
  78636. * @param bufferView The glTF buffer view property
  78637. * @returns A promise that resolves with the loaded data when the load is complete
  78638. */
  78639. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  78640. private _loadAccessorAsync;
  78641. /** @hidden */
  78642. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  78643. private _loadIndicesAccessorAsync;
  78644. private _loadVertexBufferViewAsync;
  78645. private _loadVertexAccessorAsync;
  78646. private _loadMaterialMetallicRoughnessPropertiesAsync;
  78647. /** @hidden */
  78648. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  78649. private _createDefaultMaterial;
  78650. /**
  78651. * Creates a Babylon material from a glTF material.
  78652. * @param context The context when loading the asset
  78653. * @param material The glTF material property
  78654. * @param babylonDrawMode The draw mode for the Babylon material
  78655. * @returns The Babylon material
  78656. */
  78657. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  78658. /**
  78659. * Loads properties from a glTF material into a Babylon material.
  78660. * @param context The context when loading the asset
  78661. * @param material The glTF material property
  78662. * @param babylonMaterial The Babylon material
  78663. * @returns A promise that resolves when the load is complete
  78664. */
  78665. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  78666. /**
  78667. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  78668. * @param context The context when loading the asset
  78669. * @param material The glTF material property
  78670. * @param babylonMaterial The Babylon material
  78671. * @returns A promise that resolves when the load is complete
  78672. */
  78673. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  78674. /**
  78675. * Loads the alpha properties from a glTF material into a Babylon material.
  78676. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  78677. * @param context The context when loading the asset
  78678. * @param material The glTF material property
  78679. * @param babylonMaterial The Babylon material
  78680. */
  78681. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  78682. /**
  78683. * Loads a glTF texture info.
  78684. * @param context The context when loading the asset
  78685. * @param textureInfo The glTF texture info property
  78686. * @param assign A function called synchronously after parsing the glTF properties
  78687. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  78688. */
  78689. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  78690. /** @hidden */
  78691. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  78692. /** @hidden */
  78693. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  78694. private _loadSampler;
  78695. /**
  78696. * Loads a glTF image.
  78697. * @param context The context when loading the asset
  78698. * @param image The glTF image property
  78699. * @returns A promise that resolves with the loaded data when the load is complete
  78700. */
  78701. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  78702. /**
  78703. * Loads a glTF uri.
  78704. * @param context The context when loading the asset
  78705. * @param property The glTF property associated with the uri
  78706. * @param uri The base64 or relative uri
  78707. * @returns A promise that resolves with the loaded data when the load is complete
  78708. */
  78709. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  78710. private _onProgress;
  78711. /**
  78712. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  78713. * @param babylonObject the Babylon object with metadata
  78714. * @param pointer the JSON pointer
  78715. */
  78716. static AddPointerMetadata(babylonObject: {
  78717. metadata: any;
  78718. }, pointer: string): void;
  78719. private static _GetTextureWrapMode;
  78720. private static _GetTextureSamplingMode;
  78721. private static _GetTypedArrayConstructor;
  78722. private static _GetTypedArray;
  78723. private static _GetNumComponents;
  78724. private static _ValidateUri;
  78725. private static _GetDrawMode;
  78726. private _compileMaterialsAsync;
  78727. private _compileShadowGeneratorsAsync;
  78728. private _forEachExtensions;
  78729. private _applyExtensions;
  78730. private _extensionsOnLoading;
  78731. private _extensionsOnReady;
  78732. private _extensionsLoadSceneAsync;
  78733. private _extensionsLoadNodeAsync;
  78734. private _extensionsLoadCameraAsync;
  78735. private _extensionsLoadVertexDataAsync;
  78736. private _extensionsLoadMeshPrimitiveAsync;
  78737. private _extensionsLoadMaterialAsync;
  78738. private _extensionsCreateMaterial;
  78739. private _extensionsLoadMaterialPropertiesAsync;
  78740. private _extensionsLoadTextureInfoAsync;
  78741. private _extensionsLoadTextureAsync;
  78742. private _extensionsLoadAnimationAsync;
  78743. private _extensionsLoadSkinAsync;
  78744. private _extensionsLoadUriAsync;
  78745. private _extensionsLoadBufferViewAsync;
  78746. private _extensionsLoadBufferAsync;
  78747. /**
  78748. * Helper method called by a loader extension to load an glTF extension.
  78749. * @param context The context when loading the asset
  78750. * @param property The glTF property to load the extension from
  78751. * @param extensionName The name of the extension to load
  78752. * @param actionAsync The action to run
  78753. * @returns The promise returned by actionAsync or null if the extension does not exist
  78754. */
  78755. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  78756. /**
  78757. * Helper method called by a loader extension to load a glTF extra.
  78758. * @param context The context when loading the asset
  78759. * @param property The glTF property to load the extra from
  78760. * @param extensionName The name of the extension to load
  78761. * @param actionAsync The action to run
  78762. * @returns The promise returned by actionAsync or null if the extra does not exist
  78763. */
  78764. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  78765. /**
  78766. * Checks for presence of an extension.
  78767. * @param name The name of the extension to check
  78768. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  78769. */
  78770. isExtensionUsed(name: string): boolean;
  78771. /**
  78772. * Increments the indentation level and logs a message.
  78773. * @param message The message to log
  78774. */
  78775. logOpen(message: string): void;
  78776. /**
  78777. * Decrements the indentation level.
  78778. */
  78779. logClose(): void;
  78780. /**
  78781. * Logs a message
  78782. * @param message The message to log
  78783. */
  78784. log(message: string): void;
  78785. /**
  78786. * Starts a performance counter.
  78787. * @param counterName The name of the performance counter
  78788. */
  78789. startPerformanceCounter(counterName: string): void;
  78790. /**
  78791. * Ends a performance counter.
  78792. * @param counterName The name of the performance counter
  78793. */
  78794. endPerformanceCounter(counterName: string): void;
  78795. }
  78796. }
  78797. declare module BABYLON.GLTF2.Loader.Extensions {
  78798. /**
  78799. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  78800. */
  78801. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  78802. /**
  78803. * The name of this extension.
  78804. */
  78805. readonly name: string;
  78806. /**
  78807. * Defines whether this extension is enabled.
  78808. */
  78809. enabled: boolean;
  78810. private _loader;
  78811. private _lights?;
  78812. /** @hidden */
  78813. constructor(loader: GLTFLoader);
  78814. /** @hidden */
  78815. dispose(): void;
  78816. /** @hidden */
  78817. onLoading(): void;
  78818. /** @hidden */
  78819. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  78820. private _loadLightAsync;
  78821. }
  78822. }
  78823. declare module BABYLON.GLTF2.Loader.Extensions {
  78824. /**
  78825. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  78826. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  78827. * !!! Experimental Extension Subject to Changes !!!
  78828. */
  78829. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  78830. /**
  78831. * The name of this extension.
  78832. */
  78833. readonly name: string;
  78834. /**
  78835. * Defines whether this extension is enabled.
  78836. */
  78837. enabled: boolean;
  78838. private _loader;
  78839. /** @hidden */
  78840. constructor(loader: GLTFLoader);
  78841. /** @hidden */
  78842. dispose(): void;
  78843. /** @hidden */
  78844. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78845. }
  78846. }
  78847. declare module BABYLON.GLTF2.Loader.Extensions {
  78848. /**
  78849. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  78850. */
  78851. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  78852. /**
  78853. * The name of this extension.
  78854. */
  78855. readonly name: string;
  78856. /**
  78857. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  78858. */
  78859. dracoCompression?: DracoCompression;
  78860. /**
  78861. * Defines whether this extension is enabled.
  78862. */
  78863. enabled: boolean;
  78864. private _loader;
  78865. /** @hidden */
  78866. constructor(loader: GLTFLoader);
  78867. /** @hidden */
  78868. dispose(): void;
  78869. /** @hidden */
  78870. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  78871. }
  78872. }
  78873. declare module BABYLON.GLTF2.Loader.Extensions {
  78874. /**
  78875. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  78876. */
  78877. export class KHR_lights implements IGLTFLoaderExtension {
  78878. /**
  78879. * The name of this extension.
  78880. */
  78881. readonly name: string;
  78882. /**
  78883. * Defines whether this extension is enabled.
  78884. */
  78885. enabled: boolean;
  78886. private _loader;
  78887. private _lights?;
  78888. /** @hidden */
  78889. constructor(loader: GLTFLoader);
  78890. /** @hidden */
  78891. dispose(): void;
  78892. /** @hidden */
  78893. onLoading(): void;
  78894. /** @hidden */
  78895. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78896. }
  78897. }
  78898. declare module BABYLON.GLTF2.Loader.Extensions {
  78899. /**
  78900. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  78901. */
  78902. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  78903. /**
  78904. * The name of this extension.
  78905. */
  78906. readonly name: string;
  78907. /**
  78908. * Defines whether this extension is enabled.
  78909. */
  78910. enabled: boolean;
  78911. /**
  78912. * Defines a number that determines the order the extensions are applied.
  78913. */
  78914. order: number;
  78915. private _loader;
  78916. /** @hidden */
  78917. constructor(loader: GLTFLoader);
  78918. /** @hidden */
  78919. dispose(): void;
  78920. /** @hidden */
  78921. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78922. private _loadSpecularGlossinessPropertiesAsync;
  78923. }
  78924. }
  78925. declare module BABYLON.GLTF2.Loader.Extensions {
  78926. /**
  78927. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  78928. */
  78929. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  78930. /**
  78931. * The name of this extension.
  78932. */
  78933. readonly name: string;
  78934. /**
  78935. * Defines whether this extension is enabled.
  78936. */
  78937. enabled: boolean;
  78938. /**
  78939. * Defines a number that determines the order the extensions are applied.
  78940. */
  78941. order: number;
  78942. private _loader;
  78943. /** @hidden */
  78944. constructor(loader: GLTFLoader);
  78945. /** @hidden */
  78946. dispose(): void;
  78947. /** @hidden */
  78948. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78949. private _loadUnlitPropertiesAsync;
  78950. }
  78951. }
  78952. declare module BABYLON.GLTF2.Loader.Extensions {
  78953. /**
  78954. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  78955. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  78956. * !!! Experimental Extension Subject to Changes !!!
  78957. */
  78958. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  78959. /**
  78960. * The name of this extension.
  78961. */
  78962. readonly name: string;
  78963. /**
  78964. * Defines whether this extension is enabled.
  78965. */
  78966. enabled: boolean;
  78967. /**
  78968. * Defines a number that determines the order the extensions are applied.
  78969. */
  78970. order: number;
  78971. private _loader;
  78972. /** @hidden */
  78973. constructor(loader: GLTFLoader);
  78974. /** @hidden */
  78975. dispose(): void;
  78976. /** @hidden */
  78977. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78978. private _loadClearCoatPropertiesAsync;
  78979. }
  78980. }
  78981. declare module BABYLON.GLTF2.Loader.Extensions {
  78982. /**
  78983. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  78984. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  78985. * !!! Experimental Extension Subject to Changes !!!
  78986. */
  78987. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  78988. /**
  78989. * The name of this extension.
  78990. */
  78991. readonly name: string;
  78992. /**
  78993. * Defines whether this extension is enabled.
  78994. */
  78995. enabled: boolean;
  78996. /**
  78997. * Defines a number that determines the order the extensions are applied.
  78998. */
  78999. order: number;
  79000. private _loader;
  79001. /** @hidden */
  79002. constructor(loader: GLTFLoader);
  79003. /** @hidden */
  79004. dispose(): void;
  79005. /** @hidden */
  79006. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79007. private _loadSheenPropertiesAsync;
  79008. }
  79009. }
  79010. declare module BABYLON.GLTF2.Loader.Extensions {
  79011. /**
  79012. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  79013. * !!! Experimental Extension Subject to Changes !!!
  79014. */
  79015. export class KHR_materials_specular implements IGLTFLoaderExtension {
  79016. /**
  79017. * The name of this extension.
  79018. */
  79019. readonly name: string;
  79020. /**
  79021. * Defines whether this extension is enabled.
  79022. */
  79023. enabled: boolean;
  79024. /**
  79025. * Defines a number that determines the order the extensions are applied.
  79026. */
  79027. order: number;
  79028. private _loader;
  79029. /** @hidden */
  79030. constructor(loader: GLTFLoader);
  79031. /** @hidden */
  79032. dispose(): void;
  79033. /** @hidden */
  79034. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79035. private _loadSpecularPropertiesAsync;
  79036. }
  79037. }
  79038. declare module BABYLON.GLTF2.Loader.Extensions {
  79039. /**
  79040. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  79041. * !!! Experimental Extension Subject to Changes !!!
  79042. */
  79043. export class KHR_materials_ior implements IGLTFLoaderExtension {
  79044. /**
  79045. * Default ior Value from the spec.
  79046. */
  79047. private static readonly _DEFAULT_IOR;
  79048. /**
  79049. * The name of this extension.
  79050. */
  79051. readonly name: string;
  79052. /**
  79053. * Defines whether this extension is enabled.
  79054. */
  79055. enabled: boolean;
  79056. /**
  79057. * Defines a number that determines the order the extensions are applied.
  79058. */
  79059. order: number;
  79060. private _loader;
  79061. /** @hidden */
  79062. constructor(loader: GLTFLoader);
  79063. /** @hidden */
  79064. dispose(): void;
  79065. /** @hidden */
  79066. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79067. private _loadIorPropertiesAsync;
  79068. }
  79069. }
  79070. declare module BABYLON.GLTF2.Loader.Extensions {
  79071. /**
  79072. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  79073. */
  79074. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  79075. /**
  79076. * The name of this extension.
  79077. */
  79078. readonly name: string;
  79079. /**
  79080. * Defines whether this extension is enabled.
  79081. */
  79082. enabled: boolean;
  79083. /** @hidden */
  79084. constructor(loader: GLTFLoader);
  79085. /** @hidden */
  79086. dispose(): void;
  79087. }
  79088. }
  79089. declare module BABYLON.GLTF2.Loader.Extensions {
  79090. /**
  79091. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  79092. * !!! Experimental Extension Subject to Changes !!!
  79093. */
  79094. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  79095. /** The name of this extension. */
  79096. readonly name: string;
  79097. /** Defines whether this extension is enabled. */
  79098. enabled: boolean;
  79099. private _loader;
  79100. /** @hidden */
  79101. constructor(loader: GLTFLoader);
  79102. /** @hidden */
  79103. dispose(): void;
  79104. /** @hidden */
  79105. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79106. }
  79107. }
  79108. declare module BABYLON.GLTF2.Loader.Extensions {
  79109. /**
  79110. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  79111. */
  79112. export class KHR_texture_transform implements IGLTFLoaderExtension {
  79113. /**
  79114. * The name of this extension.
  79115. */
  79116. readonly name: string;
  79117. /**
  79118. * Defines whether this extension is enabled.
  79119. */
  79120. enabled: boolean;
  79121. private _loader;
  79122. /** @hidden */
  79123. constructor(loader: GLTFLoader);
  79124. /** @hidden */
  79125. dispose(): void;
  79126. /** @hidden */
  79127. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79128. }
  79129. }
  79130. declare module BABYLON.GLTF2.Loader.Extensions {
  79131. /**
  79132. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  79133. */
  79134. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  79135. /**
  79136. * The name of this extension.
  79137. */
  79138. readonly name: string;
  79139. /**
  79140. * Defines whether this extension is enabled.
  79141. */
  79142. enabled: boolean;
  79143. private _loader;
  79144. private _clips;
  79145. private _emitters;
  79146. /** @hidden */
  79147. constructor(loader: GLTFLoader);
  79148. /** @hidden */
  79149. dispose(): void;
  79150. /** @hidden */
  79151. onLoading(): void;
  79152. /** @hidden */
  79153. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79154. /** @hidden */
  79155. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79156. /** @hidden */
  79157. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79158. private _loadClipAsync;
  79159. private _loadEmitterAsync;
  79160. private _getEventAction;
  79161. private _loadAnimationEventAsync;
  79162. }
  79163. }
  79164. declare module BABYLON.GLTF2.Loader.Extensions {
  79165. /**
  79166. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  79167. */
  79168. export class MSFT_lod implements IGLTFLoaderExtension {
  79169. /**
  79170. * The name of this extension.
  79171. */
  79172. readonly name: string;
  79173. /**
  79174. * Defines whether this extension is enabled.
  79175. */
  79176. enabled: boolean;
  79177. /**
  79178. * Defines a number that determines the order the extensions are applied.
  79179. */
  79180. order: number;
  79181. /**
  79182. * Maximum number of LODs to load, starting from the lowest LOD.
  79183. */
  79184. maxLODsToLoad: number;
  79185. /**
  79186. * Observable raised when all node LODs of one level are loaded.
  79187. * The event data is the index of the loaded LOD starting from zero.
  79188. * Dispose the loader to cancel the loading of the next level of LODs.
  79189. */
  79190. onNodeLODsLoadedObservable: Observable<number>;
  79191. /**
  79192. * Observable raised when all material LODs of one level are loaded.
  79193. * The event data is the index of the loaded LOD starting from zero.
  79194. * Dispose the loader to cancel the loading of the next level of LODs.
  79195. */
  79196. onMaterialLODsLoadedObservable: Observable<number>;
  79197. private _loader;
  79198. private _nodeIndexLOD;
  79199. private _nodeSignalLODs;
  79200. private _nodePromiseLODs;
  79201. private _materialIndexLOD;
  79202. private _materialSignalLODs;
  79203. private _materialPromiseLODs;
  79204. private _indexLOD;
  79205. private _bufferLODs;
  79206. /** @hidden */
  79207. constructor(loader: GLTFLoader);
  79208. /** @hidden */
  79209. dispose(): void;
  79210. /** @hidden */
  79211. onReady(): void;
  79212. /** @hidden */
  79213. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79214. /** @hidden */
  79215. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79216. /** @hidden */
  79217. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79218. /** @hidden */
  79219. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79220. /** @hidden */
  79221. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79222. private _loadBufferLOD;
  79223. /**
  79224. * Gets an array of LOD properties from lowest to highest.
  79225. */
  79226. private _getLODs;
  79227. private _disposeTransformNode;
  79228. private _disposeMaterials;
  79229. }
  79230. }
  79231. declare module BABYLON.GLTF2.Loader.Extensions {
  79232. /** @hidden */
  79233. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  79234. readonly name: string;
  79235. enabled: boolean;
  79236. private _loader;
  79237. constructor(loader: GLTFLoader);
  79238. dispose(): void;
  79239. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79240. }
  79241. }
  79242. declare module BABYLON.GLTF2.Loader.Extensions {
  79243. /** @hidden */
  79244. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  79245. readonly name: string;
  79246. enabled: boolean;
  79247. private _loader;
  79248. constructor(loader: GLTFLoader);
  79249. dispose(): void;
  79250. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79251. }
  79252. }
  79253. declare module BABYLON.GLTF2.Loader.Extensions {
  79254. /**
  79255. * Store glTF extras (if present) in BJS objects' metadata
  79256. */
  79257. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  79258. /**
  79259. * The name of this extension.
  79260. */
  79261. readonly name: string;
  79262. /**
  79263. * Defines whether this extension is enabled.
  79264. */
  79265. enabled: boolean;
  79266. private _loader;
  79267. private _assignExtras;
  79268. /** @hidden */
  79269. constructor(loader: GLTFLoader);
  79270. /** @hidden */
  79271. dispose(): void;
  79272. /** @hidden */
  79273. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79274. /** @hidden */
  79275. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79276. /** @hidden */
  79277. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79278. }
  79279. }
  79280. declare module BABYLON {
  79281. /**
  79282. * Class reading and parsing the MTL file bundled with the obj file.
  79283. */
  79284. export class MTLFileLoader {
  79285. /**
  79286. * Invert Y-Axis of referenced textures on load
  79287. */
  79288. static INVERT_TEXTURE_Y: boolean;
  79289. /**
  79290. * All material loaded from the mtl will be set here
  79291. */
  79292. materials: StandardMaterial[];
  79293. /**
  79294. * This function will read the mtl file and create each material described inside
  79295. * This function could be improve by adding :
  79296. * -some component missing (Ni, Tf...)
  79297. * -including the specific options available
  79298. *
  79299. * @param scene defines the scene the material will be created in
  79300. * @param data defines the mtl data to parse
  79301. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  79302. * @param forAssetContainer defines if the material should be registered in the scene
  79303. */
  79304. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  79305. /**
  79306. * Gets the texture for the material.
  79307. *
  79308. * If the material is imported from input file,
  79309. * We sanitize the url to ensure it takes the textre from aside the material.
  79310. *
  79311. * @param rootUrl The root url to load from
  79312. * @param value The value stored in the mtl
  79313. * @return The Texture
  79314. */
  79315. private static _getTexture;
  79316. }
  79317. }
  79318. declare module BABYLON {
  79319. /**
  79320. * Options for loading OBJ/MTL files
  79321. */
  79322. type MeshLoadOptions = {
  79323. /**
  79324. * Defines if UVs are optimized by default during load.
  79325. */
  79326. OptimizeWithUV: boolean;
  79327. /**
  79328. * Defines custom scaling of UV coordinates of loaded meshes.
  79329. */
  79330. UVScaling: Vector2;
  79331. /**
  79332. * Invert model on y-axis (does a model scaling inversion)
  79333. */
  79334. InvertY: boolean;
  79335. /**
  79336. * Invert Y-Axis of referenced textures on load
  79337. */
  79338. InvertTextureY: boolean;
  79339. /**
  79340. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  79341. */
  79342. ImportVertexColors: boolean;
  79343. /**
  79344. * Compute the normals for the model, even if normals are present in the file.
  79345. */
  79346. ComputeNormals: boolean;
  79347. /**
  79348. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  79349. */
  79350. SkipMaterials: boolean;
  79351. /**
  79352. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  79353. */
  79354. MaterialLoadingFailsSilently: boolean;
  79355. };
  79356. /**
  79357. * OBJ file type loader.
  79358. * This is a babylon scene loader plugin.
  79359. */
  79360. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79361. /**
  79362. * Defines if UVs are optimized by default during load.
  79363. */
  79364. static OPTIMIZE_WITH_UV: boolean;
  79365. /**
  79366. * Invert model on y-axis (does a model scaling inversion)
  79367. */
  79368. static INVERT_Y: boolean;
  79369. /**
  79370. * Invert Y-Axis of referenced textures on load
  79371. */
  79372. static get INVERT_TEXTURE_Y(): boolean;
  79373. static set INVERT_TEXTURE_Y(value: boolean);
  79374. /**
  79375. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  79376. */
  79377. static IMPORT_VERTEX_COLORS: boolean;
  79378. /**
  79379. * Compute the normals for the model, even if normals are present in the file.
  79380. */
  79381. static COMPUTE_NORMALS: boolean;
  79382. /**
  79383. * Defines custom scaling of UV coordinates of loaded meshes.
  79384. */
  79385. static UV_SCALING: Vector2;
  79386. /**
  79387. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  79388. */
  79389. static SKIP_MATERIALS: boolean;
  79390. /**
  79391. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  79392. *
  79393. * Defaults to true for backwards compatibility.
  79394. */
  79395. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  79396. /**
  79397. * Defines the name of the plugin.
  79398. */
  79399. name: string;
  79400. /**
  79401. * Defines the extension the plugin is able to load.
  79402. */
  79403. extensions: string;
  79404. /** @hidden */
  79405. obj: RegExp;
  79406. /** @hidden */
  79407. group: RegExp;
  79408. /** @hidden */
  79409. mtllib: RegExp;
  79410. /** @hidden */
  79411. usemtl: RegExp;
  79412. /** @hidden */
  79413. smooth: RegExp;
  79414. /** @hidden */
  79415. vertexPattern: RegExp;
  79416. /** @hidden */
  79417. normalPattern: RegExp;
  79418. /** @hidden */
  79419. uvPattern: RegExp;
  79420. /** @hidden */
  79421. facePattern1: RegExp;
  79422. /** @hidden */
  79423. facePattern2: RegExp;
  79424. /** @hidden */
  79425. facePattern3: RegExp;
  79426. /** @hidden */
  79427. facePattern4: RegExp;
  79428. /** @hidden */
  79429. facePattern5: RegExp;
  79430. private _forAssetContainer;
  79431. private _meshLoadOptions;
  79432. /**
  79433. * Creates loader for .OBJ files
  79434. *
  79435. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  79436. */
  79437. constructor(meshLoadOptions?: MeshLoadOptions);
  79438. private static get currentMeshLoadOptions();
  79439. /**
  79440. * Calls synchronously the MTL file attached to this obj.
  79441. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  79442. * Without this function materials are not displayed in the first frame (but displayed after).
  79443. * In consequence it is impossible to get material information in your HTML file
  79444. *
  79445. * @param url The URL of the MTL file
  79446. * @param rootUrl
  79447. * @param onSuccess Callback function to be called when the MTL file is loaded
  79448. * @private
  79449. */
  79450. private _loadMTL;
  79451. /**
  79452. * Instantiates a OBJ file loader plugin.
  79453. * @returns the created plugin
  79454. */
  79455. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  79456. /**
  79457. * If the data string can be loaded directly.
  79458. *
  79459. * @param data string containing the file data
  79460. * @returns if the data can be loaded directly
  79461. */
  79462. canDirectLoad(data: string): boolean;
  79463. /**
  79464. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  79465. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79466. * @param scene the scene the meshes should be added to
  79467. * @param data the OBJ data to load
  79468. * @param rootUrl root url to load from
  79469. * @param onProgress event that fires when loading progress has occured
  79470. * @param fileName Defines the name of the file to load
  79471. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79472. */
  79473. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79474. meshes: AbstractMesh[];
  79475. particleSystems: IParticleSystem[];
  79476. skeletons: Skeleton[];
  79477. animationGroups: AnimationGroup[];
  79478. }>;
  79479. /**
  79480. * Imports all objects from the loaded OBJ data and adds them to the scene
  79481. * @param scene the scene the objects should be added to
  79482. * @param data the OBJ data to load
  79483. * @param rootUrl root url to load from
  79484. * @param onProgress event that fires when loading progress has occured
  79485. * @param fileName Defines the name of the file to load
  79486. * @returns a promise which completes when objects have been loaded to the scene
  79487. */
  79488. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79489. /**
  79490. * Load into an asset container.
  79491. * @param scene The scene to load into
  79492. * @param data The data to import
  79493. * @param rootUrl The root url for scene and resources
  79494. * @param onProgress The callback when the load progresses
  79495. * @param fileName Defines the name of the file to load
  79496. * @returns The loaded asset container
  79497. */
  79498. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79499. /**
  79500. * Read the OBJ file and create an Array of meshes.
  79501. * Each mesh contains all information given by the OBJ and the MTL file.
  79502. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  79503. *
  79504. * @param meshesNames
  79505. * @param scene Scene The scene where are displayed the data
  79506. * @param data String The content of the obj file
  79507. * @param rootUrl String The path to the folder
  79508. * @returns Array<AbstractMesh>
  79509. * @private
  79510. */
  79511. private _parseSolid;
  79512. }
  79513. }
  79514. declare module BABYLON {
  79515. /**
  79516. * STL file type loader.
  79517. * This is a babylon scene loader plugin.
  79518. */
  79519. export class STLFileLoader implements ISceneLoaderPlugin {
  79520. /** @hidden */
  79521. solidPattern: RegExp;
  79522. /** @hidden */
  79523. facetsPattern: RegExp;
  79524. /** @hidden */
  79525. normalPattern: RegExp;
  79526. /** @hidden */
  79527. vertexPattern: RegExp;
  79528. /**
  79529. * Defines the name of the plugin.
  79530. */
  79531. name: string;
  79532. /**
  79533. * Defines the extensions the stl loader is able to load.
  79534. * force data to come in as an ArrayBuffer
  79535. * we'll convert to string if it looks like it's an ASCII .stl
  79536. */
  79537. extensions: ISceneLoaderPluginExtensions;
  79538. /**
  79539. * Import meshes into a scene.
  79540. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  79541. * @param scene The scene to import into
  79542. * @param data The data to import
  79543. * @param rootUrl The root url for scene and resources
  79544. * @param meshes The meshes array to import into
  79545. * @param particleSystems The particle systems array to import into
  79546. * @param skeletons The skeletons array to import into
  79547. * @param onError The callback when import fails
  79548. * @returns True if successful or false otherwise
  79549. */
  79550. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  79551. /**
  79552. * Load into a scene.
  79553. * @param scene The scene to load into
  79554. * @param data The data to import
  79555. * @param rootUrl The root url for scene and resources
  79556. * @param onError The callback when import fails
  79557. * @returns true if successful or false otherwise
  79558. */
  79559. load(scene: Scene, data: any, rootUrl: string): boolean;
  79560. /**
  79561. * Load into an asset container.
  79562. * @param scene The scene to load into
  79563. * @param data The data to import
  79564. * @param rootUrl The root url for scene and resources
  79565. * @param onError The callback when import fails
  79566. * @returns The loaded asset container
  79567. */
  79568. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  79569. private _isBinary;
  79570. private _parseBinary;
  79571. private _parseASCII;
  79572. }
  79573. }
  79574. declare module BABYLON {
  79575. /**
  79576. * Class for generating OBJ data from a Babylon scene.
  79577. */
  79578. export class OBJExport {
  79579. /**
  79580. * Exports the geometry of a Mesh array in .OBJ file format (text)
  79581. * @param mesh defines the list of meshes to serialize
  79582. * @param materials defines if materials should be exported
  79583. * @param matlibname defines the name of the associated mtl file
  79584. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  79585. * @returns the OBJ content
  79586. */
  79587. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  79588. /**
  79589. * Exports the material(s) of a mesh in .MTL file format (text)
  79590. * @param mesh defines the mesh to extract the material from
  79591. * @returns the mtl content
  79592. */
  79593. static MTL(mesh: Mesh): string;
  79594. }
  79595. }
  79596. declare module BABYLON {
  79597. /** @hidden */
  79598. export var __IGLTFExporterExtension: number;
  79599. /**
  79600. * Interface for extending the exporter
  79601. * @hidden
  79602. */
  79603. export interface IGLTFExporterExtension {
  79604. /**
  79605. * The name of this extension
  79606. */
  79607. readonly name: string;
  79608. /**
  79609. * Defines whether this extension is enabled
  79610. */
  79611. enabled: boolean;
  79612. /**
  79613. * Defines whether this extension is required
  79614. */
  79615. required: boolean;
  79616. }
  79617. }
  79618. declare module BABYLON.GLTF2.Exporter {
  79619. /** @hidden */
  79620. export var __IGLTFExporterExtensionV2: number;
  79621. /**
  79622. * Interface for a glTF exporter extension
  79623. * @hidden
  79624. */
  79625. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  79626. /**
  79627. * Define this method to modify the default behavior before exporting a texture
  79628. * @param context The context when loading the asset
  79629. * @param babylonTexture The Babylon.js texture
  79630. * @param mimeType The mime-type of the generated image
  79631. * @returns A promise that resolves with the exported texture
  79632. */
  79633. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  79634. /**
  79635. * Define this method to get notified when a texture info is created
  79636. * @param context The context when loading the asset
  79637. * @param textureInfo The glTF texture info
  79638. * @param babylonTexture The Babylon.js texture
  79639. */
  79640. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  79641. /**
  79642. * Define this method to modify the default behavior when exporting texture info
  79643. * @param context The context when loading the asset
  79644. * @param meshPrimitive glTF mesh primitive
  79645. * @param babylonSubMesh Babylon submesh
  79646. * @param binaryWriter glTF serializer binary writer instance
  79647. * @returns nullable IMeshPrimitive promise
  79648. */
  79649. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  79650. /**
  79651. * Define this method to modify the default behavior when exporting a node
  79652. * @param context The context when exporting the node
  79653. * @param node glTF node
  79654. * @param babylonNode BabylonJS node
  79655. * @returns nullable INode promise
  79656. */
  79657. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  79658. [key: number]: number;
  79659. }): Promise<Nullable<INode>>;
  79660. /**
  79661. * Define this method to modify the default behavior when exporting a material
  79662. * @param material glTF material
  79663. * @param babylonMaterial BabylonJS material
  79664. * @returns nullable IMaterial promise
  79665. */
  79666. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  79667. /**
  79668. * Define this method to return additional textures to export from a material
  79669. * @param material glTF material
  79670. * @param babylonMaterial BabylonJS material
  79671. * @returns List of textures
  79672. */
  79673. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  79674. /** Gets a boolean indicating that this extension was used */
  79675. wasUsed: boolean;
  79676. /** Gets a boolean indicating that this extension is required for the file to work */
  79677. required: boolean;
  79678. /**
  79679. * Called after the exporter state changes to EXPORTING
  79680. */
  79681. onExporting?(): void;
  79682. }
  79683. }
  79684. declare module BABYLON.GLTF2.Exporter {
  79685. /**
  79686. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  79687. * @hidden
  79688. */
  79689. export class _GLTFMaterialExporter {
  79690. /**
  79691. * Represents the dielectric specular values for R, G and B
  79692. */
  79693. private static readonly _DielectricSpecular;
  79694. /**
  79695. * Allows the maximum specular power to be defined for material calculations
  79696. */
  79697. private static readonly _MaxSpecularPower;
  79698. /**
  79699. * Mapping to store textures
  79700. */
  79701. private _textureMap;
  79702. /**
  79703. * Numeric tolerance value
  79704. */
  79705. private static readonly _Epsilon;
  79706. /**
  79707. * Reference to the glTF Exporter
  79708. */
  79709. private _exporter;
  79710. constructor(exporter: _Exporter);
  79711. /**
  79712. * Specifies if two colors are approximately equal in value
  79713. * @param color1 first color to compare to
  79714. * @param color2 second color to compare to
  79715. * @param epsilon threshold value
  79716. */
  79717. private static FuzzyEquals;
  79718. /**
  79719. * Gets the materials from a Babylon scene and converts them to glTF materials
  79720. * @param scene babylonjs scene
  79721. * @param mimeType texture mime type
  79722. * @param images array of images
  79723. * @param textures array of textures
  79724. * @param materials array of materials
  79725. * @param imageData mapping of texture names to base64 textures
  79726. * @param hasTextureCoords specifies if texture coordinates are present on the material
  79727. */
  79728. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  79729. /**
  79730. * Makes a copy of the glTF material without the texture parameters
  79731. * @param originalMaterial original glTF material
  79732. * @returns glTF material without texture parameters
  79733. */
  79734. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  79735. /**
  79736. * Specifies if the material has any texture parameters present
  79737. * @param material glTF Material
  79738. * @returns boolean specifying if texture parameters are present
  79739. */
  79740. _hasTexturesPresent(material: IMaterial): boolean;
  79741. /**
  79742. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  79743. * @param babylonStandardMaterial
  79744. * @returns glTF Metallic Roughness Material representation
  79745. */
  79746. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  79747. /**
  79748. * Computes the metallic factor
  79749. * @param diffuse diffused value
  79750. * @param specular specular value
  79751. * @param oneMinusSpecularStrength one minus the specular strength
  79752. * @returns metallic value
  79753. */
  79754. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  79755. /**
  79756. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  79757. * @param glTFMaterial glTF material
  79758. * @param babylonMaterial Babylon material
  79759. */
  79760. private static _SetAlphaMode;
  79761. /**
  79762. * Converts a Babylon Standard Material to a glTF Material
  79763. * @param babylonStandardMaterial BJS Standard Material
  79764. * @param mimeType mime type to use for the textures
  79765. * @param images array of glTF image interfaces
  79766. * @param textures array of glTF texture interfaces
  79767. * @param materials array of glTF material interfaces
  79768. * @param imageData map of image file name to data
  79769. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79770. */
  79771. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  79772. private _finishMaterial;
  79773. /**
  79774. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  79775. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  79776. * @param mimeType mime type to use for the textures
  79777. * @param images array of glTF image interfaces
  79778. * @param textures array of glTF texture interfaces
  79779. * @param materials array of glTF material interfaces
  79780. * @param imageData map of image file name to data
  79781. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79782. */
  79783. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  79784. /**
  79785. * Converts an image typed array buffer to a base64 image
  79786. * @param buffer typed array buffer
  79787. * @param width width of the image
  79788. * @param height height of the image
  79789. * @param mimeType mimetype of the image
  79790. * @returns base64 image string
  79791. */
  79792. private _createBase64FromCanvasAsync;
  79793. /**
  79794. * Generates a white texture based on the specified width and height
  79795. * @param width width of the texture in pixels
  79796. * @param height height of the texture in pixels
  79797. * @param scene babylonjs scene
  79798. * @returns white texture
  79799. */
  79800. private _createWhiteTexture;
  79801. /**
  79802. * 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
  79803. * @param texture1 first texture to resize
  79804. * @param texture2 second texture to resize
  79805. * @param scene babylonjs scene
  79806. * @returns resized textures or null
  79807. */
  79808. private _resizeTexturesToSameDimensions;
  79809. /**
  79810. * Converts an array of pixels to a Float32Array
  79811. * Throws an error if the pixel format is not supported
  79812. * @param pixels - array buffer containing pixel values
  79813. * @returns Float32 of pixels
  79814. */
  79815. private _convertPixelArrayToFloat32;
  79816. /**
  79817. * Convert Specular Glossiness Textures to Metallic Roughness
  79818. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  79819. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  79820. * @param diffuseTexture texture used to store diffuse information
  79821. * @param specularGlossinessTexture texture used to store specular and glossiness information
  79822. * @param factors specular glossiness material factors
  79823. * @param mimeType the mime type to use for the texture
  79824. * @returns pbr metallic roughness interface or null
  79825. */
  79826. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  79827. /**
  79828. * Converts specular glossiness material properties to metallic roughness
  79829. * @param specularGlossiness interface with specular glossiness material properties
  79830. * @returns interface with metallic roughness material properties
  79831. */
  79832. private _convertSpecularGlossinessToMetallicRoughness;
  79833. /**
  79834. * Calculates the surface reflectance, independent of lighting conditions
  79835. * @param color Color source to calculate brightness from
  79836. * @returns number representing the perceived brightness, or zero if color is undefined
  79837. */
  79838. private _getPerceivedBrightness;
  79839. /**
  79840. * Returns the maximum color component value
  79841. * @param color
  79842. * @returns maximum color component value, or zero if color is null or undefined
  79843. */
  79844. private _getMaxComponent;
  79845. /**
  79846. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  79847. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  79848. * @param mimeType mime type to use for the textures
  79849. * @param images array of glTF image interfaces
  79850. * @param textures array of glTF texture interfaces
  79851. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  79852. * @param imageData map of image file name to data
  79853. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79854. * @returns glTF PBR Metallic Roughness factors
  79855. */
  79856. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  79857. private _getGLTFTextureSampler;
  79858. private _getGLTFTextureWrapMode;
  79859. private _getGLTFTextureWrapModesSampler;
  79860. /**
  79861. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  79862. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  79863. * @param mimeType mime type to use for the textures
  79864. * @param images array of glTF image interfaces
  79865. * @param textures array of glTF texture interfaces
  79866. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  79867. * @param imageData map of image file name to data
  79868. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79869. * @returns glTF PBR Metallic Roughness factors
  79870. */
  79871. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  79872. /**
  79873. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  79874. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  79875. * @param mimeType mime type to use for the textures
  79876. * @param images array of glTF image interfaces
  79877. * @param textures array of glTF texture interfaces
  79878. * @param materials array of glTF material interfaces
  79879. * @param imageData map of image file name to data
  79880. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79881. */
  79882. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  79883. private setMetallicRoughnessPbrMaterial;
  79884. private getPixelsFromTexture;
  79885. /**
  79886. * Extracts a texture from a Babylon texture into file data and glTF data
  79887. * @param babylonTexture Babylon texture to extract
  79888. * @param mimeType Mime Type of the babylonTexture
  79889. * @return glTF texture info, or null if the texture format is not supported
  79890. */
  79891. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  79892. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  79893. /**
  79894. * Builds a texture from base64 string
  79895. * @param base64Texture base64 texture string
  79896. * @param baseTextureName Name to use for the texture
  79897. * @param mimeType image mime type for the texture
  79898. * @param images array of images
  79899. * @param textures array of textures
  79900. * @param imageData map of image data
  79901. * @returns glTF texture info, or null if the texture format is not supported
  79902. */
  79903. private _getTextureInfoFromBase64;
  79904. }
  79905. }
  79906. declare module BABYLON {
  79907. /**
  79908. * Class for holding and downloading glTF file data
  79909. */
  79910. export class GLTFData {
  79911. /**
  79912. * Object which contains the file name as the key and its data as the value
  79913. */
  79914. glTFFiles: {
  79915. [fileName: string]: string | Blob;
  79916. };
  79917. /**
  79918. * Initializes the glTF file object
  79919. */
  79920. constructor();
  79921. /**
  79922. * Downloads the glTF data as files based on their names and data
  79923. */
  79924. downloadFiles(): void;
  79925. }
  79926. }
  79927. declare module BABYLON {
  79928. /**
  79929. * Holds a collection of exporter options and parameters
  79930. */
  79931. export interface IExportOptions {
  79932. /**
  79933. * Function which indicates whether a babylon node should be exported or not
  79934. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  79935. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  79936. */
  79937. shouldExportNode?(node: Node): boolean;
  79938. /**
  79939. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  79940. * @param metadata source metadata to read from
  79941. * @returns the data to store to glTF node extras
  79942. */
  79943. metadataSelector?(metadata: any): any;
  79944. /**
  79945. * The sample rate to bake animation curves
  79946. */
  79947. animationSampleRate?: number;
  79948. /**
  79949. * Begin serialization without waiting for the scene to be ready
  79950. */
  79951. exportWithoutWaitingForScene?: boolean;
  79952. /**
  79953. * Indicates if coordinate system swapping root nodes should be included in export
  79954. */
  79955. includeCoordinateSystemConversionNodes?: boolean;
  79956. }
  79957. /**
  79958. * Class for generating glTF data from a Babylon scene.
  79959. */
  79960. export class GLTF2Export {
  79961. /**
  79962. * Exports the geometry of the scene to .gltf file format asynchronously
  79963. * @param scene Babylon scene with scene hierarchy information
  79964. * @param filePrefix File prefix to use when generating the glTF file
  79965. * @param options Exporter options
  79966. * @returns Returns an object with a .gltf file and associates texture names
  79967. * as keys and their data and paths as values
  79968. */
  79969. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  79970. private static _PreExportAsync;
  79971. private static _PostExportAsync;
  79972. /**
  79973. * Exports the geometry of the scene to .glb file format asychronously
  79974. * @param scene Babylon scene with scene hierarchy information
  79975. * @param filePrefix File prefix to use when generating glb file
  79976. * @param options Exporter options
  79977. * @returns Returns an object with a .glb filename as key and data as value
  79978. */
  79979. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  79980. }
  79981. }
  79982. declare module BABYLON.GLTF2.Exporter {
  79983. /**
  79984. * @hidden
  79985. */
  79986. export class _GLTFUtilities {
  79987. /**
  79988. * Creates a buffer view based on the supplied arguments
  79989. * @param bufferIndex index value of the specified buffer
  79990. * @param byteOffset byte offset value
  79991. * @param byteLength byte length of the bufferView
  79992. * @param byteStride byte distance between conequential elements
  79993. * @param name name of the buffer view
  79994. * @returns bufferView for glTF
  79995. */
  79996. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  79997. /**
  79998. * Creates an accessor based on the supplied arguments
  79999. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  80000. * @param name The name of the accessor
  80001. * @param type The type of the accessor
  80002. * @param componentType The datatype of components in the attribute
  80003. * @param count The number of attributes referenced by this accessor
  80004. * @param byteOffset The offset relative to the start of the bufferView in bytes
  80005. * @param min Minimum value of each component in this attribute
  80006. * @param max Maximum value of each component in this attribute
  80007. * @returns accessor for glTF
  80008. */
  80009. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  80010. /**
  80011. * Calculates the minimum and maximum values of an array of position floats
  80012. * @param positions Positions array of a mesh
  80013. * @param vertexStart Starting vertex offset to calculate min and max values
  80014. * @param vertexCount Number of vertices to check for min and max values
  80015. * @returns min number array and max number array
  80016. */
  80017. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  80018. min: number[];
  80019. max: number[];
  80020. };
  80021. /**
  80022. * Converts a new right-handed Vector3
  80023. * @param vector vector3 array
  80024. * @returns right-handed Vector3
  80025. */
  80026. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  80027. /**
  80028. * Converts a Vector3 to right-handed
  80029. * @param vector Vector3 to convert to right-handed
  80030. */
  80031. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  80032. /**
  80033. * Converts a three element number array to right-handed
  80034. * @param vector number array to convert to right-handed
  80035. */
  80036. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  80037. /**
  80038. * Converts a new right-handed Vector3
  80039. * @param vector vector3 array
  80040. * @returns right-handed Vector3
  80041. */
  80042. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  80043. /**
  80044. * Converts a Vector3 to right-handed
  80045. * @param vector Vector3 to convert to right-handed
  80046. */
  80047. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  80048. /**
  80049. * Converts a three element number array to right-handed
  80050. * @param vector number array to convert to right-handed
  80051. */
  80052. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  80053. /**
  80054. * Converts a Vector4 to right-handed
  80055. * @param vector Vector4 to convert to right-handed
  80056. */
  80057. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  80058. /**
  80059. * Converts a Vector4 to right-handed
  80060. * @param vector Vector4 to convert to right-handed
  80061. */
  80062. static _GetRightHandedArray4FromRef(vector: number[]): void;
  80063. /**
  80064. * Converts a Quaternion to right-handed
  80065. * @param quaternion Source quaternion to convert to right-handed
  80066. */
  80067. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  80068. /**
  80069. * Converts a Quaternion to right-handed
  80070. * @param quaternion Source quaternion to convert to right-handed
  80071. */
  80072. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  80073. static _NormalizeTangentFromRef(tangent: Vector4): void;
  80074. }
  80075. }
  80076. declare module BABYLON.GLTF2.Exporter {
  80077. /**
  80078. * Converts Babylon Scene into glTF 2.0.
  80079. * @hidden
  80080. */
  80081. export class _Exporter {
  80082. /**
  80083. * Stores the glTF to export
  80084. */
  80085. _glTF: IGLTF;
  80086. /**
  80087. * Stores all generated buffer views, which represents views into the main glTF buffer data
  80088. */
  80089. _bufferViews: IBufferView[];
  80090. /**
  80091. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  80092. */
  80093. _accessors: IAccessor[];
  80094. /**
  80095. * Stores all the generated nodes, which contains transform and/or mesh information per node
  80096. */
  80097. _nodes: INode[];
  80098. /**
  80099. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  80100. */
  80101. private _scenes;
  80102. /**
  80103. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  80104. */
  80105. private _meshes;
  80106. /**
  80107. * Stores all the generated material information, which represents the appearance of each primitive
  80108. */
  80109. _materials: IMaterial[];
  80110. _materialMap: {
  80111. [materialID: number]: number;
  80112. };
  80113. /**
  80114. * Stores all the generated texture information, which is referenced by glTF materials
  80115. */
  80116. _textures: ITexture[];
  80117. /**
  80118. * Stores all the generated image information, which is referenced by glTF textures
  80119. */
  80120. _images: IImage[];
  80121. /**
  80122. * Stores all the texture samplers
  80123. */
  80124. _samplers: ISampler[];
  80125. /**
  80126. * Stores all the generated animation samplers, which is referenced by glTF animations
  80127. */
  80128. /**
  80129. * Stores the animations for glTF models
  80130. */
  80131. private _animations;
  80132. /**
  80133. * Stores the total amount of bytes stored in the glTF buffer
  80134. */
  80135. private _totalByteLength;
  80136. /**
  80137. * Stores a reference to the Babylon scene containing the source geometry and material information
  80138. */
  80139. _babylonScene: Scene;
  80140. /**
  80141. * Stores a map of the image data, where the key is the file name and the value
  80142. * is the image data
  80143. */
  80144. _imageData: {
  80145. [fileName: string]: {
  80146. data: Uint8Array;
  80147. mimeType: ImageMimeType;
  80148. };
  80149. };
  80150. /**
  80151. * Stores a map of the unique id of a node to its index in the node array
  80152. */
  80153. _nodeMap: {
  80154. [key: number]: number;
  80155. };
  80156. /**
  80157. * Specifies if the source Babylon scene was left handed, and needed conversion.
  80158. */
  80159. _convertToRightHandedSystem: boolean;
  80160. /**
  80161. * Specifies if a Babylon node should be converted to right-handed on export
  80162. */
  80163. _convertToRightHandedSystemMap: {
  80164. [nodeId: number]: boolean;
  80165. };
  80166. _includeCoordinateSystemConversionNodes: boolean;
  80167. /**
  80168. * Baked animation sample rate
  80169. */
  80170. private _animationSampleRate;
  80171. private _options;
  80172. private _localEngine;
  80173. _glTFMaterialExporter: _GLTFMaterialExporter;
  80174. private _extensions;
  80175. private static _ExtensionNames;
  80176. private static _ExtensionFactories;
  80177. private _applyExtension;
  80178. private _applyExtensions;
  80179. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  80180. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  80181. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80182. [key: number]: number;
  80183. }): Promise<Nullable<INode>>;
  80184. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  80185. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  80186. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80187. private _forEachExtensions;
  80188. private _extensionsOnExporting;
  80189. /**
  80190. * Load glTF serializer extensions
  80191. */
  80192. private _loadExtensions;
  80193. /**
  80194. * Creates a glTF Exporter instance, which can accept optional exporter options
  80195. * @param babylonScene Babylon scene object
  80196. * @param options Options to modify the behavior of the exporter
  80197. */
  80198. constructor(babylonScene: Scene, options?: IExportOptions);
  80199. dispose(): void;
  80200. /**
  80201. * Registers a glTF exporter extension
  80202. * @param name Name of the extension to export
  80203. * @param factory The factory function that creates the exporter extension
  80204. */
  80205. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  80206. /**
  80207. * Un-registers an exporter extension
  80208. * @param name The name fo the exporter extension
  80209. * @returns A boolean indicating whether the extension has been un-registered
  80210. */
  80211. static UnregisterExtension(name: string): boolean;
  80212. /**
  80213. * Lazy load a local engine
  80214. */
  80215. _getLocalEngine(): Engine;
  80216. private reorderIndicesBasedOnPrimitiveMode;
  80217. /**
  80218. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  80219. * clock-wise during export to glTF
  80220. * @param submesh BabylonJS submesh
  80221. * @param primitiveMode Primitive mode of the mesh
  80222. * @param sideOrientation the winding order of the submesh
  80223. * @param vertexBufferKind The type of vertex attribute
  80224. * @param meshAttributeArray The vertex attribute data
  80225. * @param byteOffset The offset to the binary data
  80226. * @param binaryWriter The binary data for the glTF file
  80227. * @param convertToRightHandedSystem Converts the values to right-handed
  80228. */
  80229. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  80230. /**
  80231. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  80232. * clock-wise during export to glTF
  80233. * @param submesh BabylonJS submesh
  80234. * @param primitiveMode Primitive mode of the mesh
  80235. * @param sideOrientation the winding order of the submesh
  80236. * @param vertexBufferKind The type of vertex attribute
  80237. * @param meshAttributeArray The vertex attribute data
  80238. * @param byteOffset The offset to the binary data
  80239. * @param binaryWriter The binary data for the glTF file
  80240. * @param convertToRightHandedSystem Converts the values to right-handed
  80241. */
  80242. private reorderTriangleFillMode;
  80243. /**
  80244. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  80245. * clock-wise during export to glTF
  80246. * @param submesh BabylonJS submesh
  80247. * @param primitiveMode Primitive mode of the mesh
  80248. * @param sideOrientation the winding order of the submesh
  80249. * @param vertexBufferKind The type of vertex attribute
  80250. * @param meshAttributeArray The vertex attribute data
  80251. * @param byteOffset The offset to the binary data
  80252. * @param binaryWriter The binary data for the glTF file
  80253. * @param convertToRightHandedSystem Converts the values to right-handed
  80254. */
  80255. private reorderTriangleStripDrawMode;
  80256. /**
  80257. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  80258. * clock-wise during export to glTF
  80259. * @param submesh BabylonJS submesh
  80260. * @param primitiveMode Primitive mode of the mesh
  80261. * @param sideOrientation the winding order of the submesh
  80262. * @param vertexBufferKind The type of vertex attribute
  80263. * @param meshAttributeArray The vertex attribute data
  80264. * @param byteOffset The offset to the binary data
  80265. * @param binaryWriter The binary data for the glTF file
  80266. * @param convertToRightHandedSystem Converts the values to right-handed
  80267. */
  80268. private reorderTriangleFanMode;
  80269. /**
  80270. * Writes the vertex attribute data to binary
  80271. * @param vertices The vertices to write to the binary writer
  80272. * @param byteOffset The offset into the binary writer to overwrite binary data
  80273. * @param vertexAttributeKind The vertex attribute type
  80274. * @param meshAttributeArray The vertex attribute data
  80275. * @param binaryWriter The writer containing the binary data
  80276. * @param convertToRightHandedSystem Converts the values to right-handed
  80277. */
  80278. private writeVertexAttributeData;
  80279. /**
  80280. * Writes mesh attribute data to a data buffer
  80281. * Returns the bytelength of the data
  80282. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  80283. * @param meshAttributeArray Array containing the attribute data
  80284. * @param binaryWriter The buffer to write the binary data to
  80285. * @param indices Used to specify the order of the vertex data
  80286. * @param convertToRightHandedSystem Converts the values to right-handed
  80287. */
  80288. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  80289. /**
  80290. * Generates glTF json data
  80291. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  80292. * @param glTFPrefix Text to use when prefixing a glTF file
  80293. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  80294. * @returns json data as string
  80295. */
  80296. private generateJSON;
  80297. /**
  80298. * Generates data for .gltf and .bin files based on the glTF prefix string
  80299. * @param glTFPrefix Text to use when prefixing a glTF file
  80300. * @param dispose Dispose the exporter
  80301. * @returns GLTFData with glTF file data
  80302. */
  80303. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  80304. /**
  80305. * Creates a binary buffer for glTF
  80306. * @returns array buffer for binary data
  80307. */
  80308. private _generateBinaryAsync;
  80309. /**
  80310. * Pads the number to a multiple of 4
  80311. * @param num number to pad
  80312. * @returns padded number
  80313. */
  80314. private _getPadding;
  80315. /**
  80316. * @hidden
  80317. */
  80318. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  80319. /**
  80320. * Sets the TRS for each node
  80321. * @param node glTF Node for storing the transformation data
  80322. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  80323. * @param convertToRightHandedSystem Converts the values to right-handed
  80324. */
  80325. private setNodeTransformation;
  80326. private getVertexBufferFromMesh;
  80327. /**
  80328. * Creates a bufferview based on the vertices type for the Babylon mesh
  80329. * @param kind Indicates the type of vertices data
  80330. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  80331. * @param binaryWriter The buffer to write the bufferview data to
  80332. * @param convertToRightHandedSystem Converts the values to right-handed
  80333. */
  80334. private createBufferViewKind;
  80335. /**
  80336. * The primitive mode of the Babylon mesh
  80337. * @param babylonMesh The BabylonJS mesh
  80338. */
  80339. private getMeshPrimitiveMode;
  80340. /**
  80341. * Sets the primitive mode of the glTF mesh primitive
  80342. * @param meshPrimitive glTF mesh primitive
  80343. * @param primitiveMode The primitive mode
  80344. */
  80345. private setPrimitiveMode;
  80346. /**
  80347. * Sets the vertex attribute accessor based of the glTF mesh primitive
  80348. * @param meshPrimitive glTF mesh primitive
  80349. * @param attributeKind vertex attribute
  80350. * @returns boolean specifying if uv coordinates are present
  80351. */
  80352. private setAttributeKind;
  80353. /**
  80354. * Sets data for the primitive attributes of each submesh
  80355. * @param mesh glTF Mesh object to store the primitive attribute information
  80356. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  80357. * @param binaryWriter Buffer to write the attribute data to
  80358. * @param convertToRightHandedSystem Converts the values to right-handed
  80359. */
  80360. private setPrimitiveAttributesAsync;
  80361. /**
  80362. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  80363. * @param node The node to check
  80364. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  80365. */
  80366. private isBabylonCoordinateSystemConvertingNode;
  80367. /**
  80368. * Creates a glTF scene based on the array of meshes
  80369. * Returns the the total byte offset
  80370. * @param babylonScene Babylon scene to get the mesh data from
  80371. * @param binaryWriter Buffer to write binary data to
  80372. */
  80373. private createSceneAsync;
  80374. /**
  80375. * Creates a mapping of Node unique id to node index and handles animations
  80376. * @param babylonScene Babylon Scene
  80377. * @param nodes Babylon transform nodes
  80378. * @param binaryWriter Buffer to write binary data to
  80379. * @returns Node mapping of unique id to index
  80380. */
  80381. private createNodeMapAndAnimationsAsync;
  80382. /**
  80383. * Creates a glTF node from a Babylon mesh
  80384. * @param babylonMesh Source Babylon mesh
  80385. * @param binaryWriter Buffer for storing geometry data
  80386. * @param convertToRightHandedSystem Converts the values to right-handed
  80387. * @param nodeMap Node mapping of unique id to glTF node index
  80388. * @returns glTF node
  80389. */
  80390. private createNodeAsync;
  80391. }
  80392. /**
  80393. * @hidden
  80394. *
  80395. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  80396. */
  80397. export class _BinaryWriter {
  80398. /**
  80399. * Array buffer which stores all binary data
  80400. */
  80401. private _arrayBuffer;
  80402. /**
  80403. * View of the array buffer
  80404. */
  80405. private _dataView;
  80406. /**
  80407. * byte offset of data in array buffer
  80408. */
  80409. private _byteOffset;
  80410. /**
  80411. * Initialize binary writer with an initial byte length
  80412. * @param byteLength Initial byte length of the array buffer
  80413. */
  80414. constructor(byteLength: number);
  80415. /**
  80416. * Resize the array buffer to the specified byte length
  80417. * @param byteLength
  80418. */
  80419. private resizeBuffer;
  80420. /**
  80421. * Get an array buffer with the length of the byte offset
  80422. * @returns ArrayBuffer resized to the byte offset
  80423. */
  80424. getArrayBuffer(): ArrayBuffer;
  80425. /**
  80426. * Get the byte offset of the array buffer
  80427. * @returns byte offset
  80428. */
  80429. getByteOffset(): number;
  80430. /**
  80431. * Stores an UInt8 in the array buffer
  80432. * @param entry
  80433. * @param byteOffset If defined, specifies where to set the value as an offset.
  80434. */
  80435. setUInt8(entry: number, byteOffset?: number): void;
  80436. /**
  80437. * Gets an UInt32 in the array buffer
  80438. * @param entry
  80439. * @param byteOffset If defined, specifies where to set the value as an offset.
  80440. */
  80441. getUInt32(byteOffset: number): number;
  80442. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  80443. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  80444. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  80445. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  80446. /**
  80447. * Stores a Float32 in the array buffer
  80448. * @param entry
  80449. */
  80450. setFloat32(entry: number, byteOffset?: number): void;
  80451. /**
  80452. * Stores an UInt32 in the array buffer
  80453. * @param entry
  80454. * @param byteOffset If defined, specifies where to set the value as an offset.
  80455. */
  80456. setUInt32(entry: number, byteOffset?: number): void;
  80457. }
  80458. }
  80459. declare module BABYLON.GLTF2.Exporter {
  80460. /**
  80461. * @hidden
  80462. * Interface to store animation data.
  80463. */
  80464. export interface _IAnimationData {
  80465. /**
  80466. * Keyframe data.
  80467. */
  80468. inputs: number[];
  80469. /**
  80470. * Value data.
  80471. */
  80472. outputs: number[][];
  80473. /**
  80474. * Animation interpolation data.
  80475. */
  80476. samplerInterpolation: AnimationSamplerInterpolation;
  80477. /**
  80478. * Minimum keyframe value.
  80479. */
  80480. inputsMin: number;
  80481. /**
  80482. * Maximum keyframe value.
  80483. */
  80484. inputsMax: number;
  80485. }
  80486. /**
  80487. * @hidden
  80488. */
  80489. export interface _IAnimationInfo {
  80490. /**
  80491. * The target channel for the animation
  80492. */
  80493. animationChannelTargetPath: AnimationChannelTargetPath;
  80494. /**
  80495. * The glTF accessor type for the data.
  80496. */
  80497. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  80498. /**
  80499. * Specifies if quaternions should be used.
  80500. */
  80501. useQuaternion: boolean;
  80502. }
  80503. /**
  80504. * @hidden
  80505. * Utility class for generating glTF animation data from BabylonJS.
  80506. */
  80507. export class _GLTFAnimation {
  80508. /**
  80509. * @ignore
  80510. *
  80511. * Creates glTF channel animation from BabylonJS animation.
  80512. * @param babylonTransformNode - BabylonJS mesh.
  80513. * @param animation - animation.
  80514. * @param animationChannelTargetPath - The target animation channel.
  80515. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  80516. * @param useQuaternion - Specifies if quaternions are used.
  80517. * @returns nullable IAnimationData
  80518. */
  80519. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  80520. private static _DeduceAnimationInfo;
  80521. /**
  80522. * @ignore
  80523. * Create node animations from the transform node animations
  80524. * @param babylonNode
  80525. * @param runtimeGLTFAnimation
  80526. * @param idleGLTFAnimations
  80527. * @param nodeMap
  80528. * @param nodes
  80529. * @param binaryWriter
  80530. * @param bufferViews
  80531. * @param accessors
  80532. * @param convertToRightHandedSystem
  80533. * @param animationSampleRate
  80534. */
  80535. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  80536. [key: number]: number;
  80537. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  80538. /**
  80539. * @ignore
  80540. * Create node animations from the animation groups
  80541. * @param babylonScene
  80542. * @param glTFAnimations
  80543. * @param nodeMap
  80544. * @param nodes
  80545. * @param binaryWriter
  80546. * @param bufferViews
  80547. * @param accessors
  80548. * @param convertToRightHandedSystemMap
  80549. * @param animationSampleRate
  80550. */
  80551. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  80552. [key: number]: number;
  80553. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  80554. [nodeId: number]: boolean;
  80555. }, animationSampleRate: number): void;
  80556. private static AddAnimation;
  80557. /**
  80558. * Create a baked animation
  80559. * @param babylonTransformNode BabylonJS mesh
  80560. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  80561. * @param animationChannelTargetPath animation target channel
  80562. * @param minFrame minimum animation frame
  80563. * @param maxFrame maximum animation frame
  80564. * @param fps frames per second of the animation
  80565. * @param inputs input key frames of the animation
  80566. * @param outputs output key frame data of the animation
  80567. * @param convertToRightHandedSystem converts the values to right-handed
  80568. * @param useQuaternion specifies if quaternions should be used
  80569. */
  80570. private static _CreateBakedAnimation;
  80571. private static _ConvertFactorToVector3OrQuaternion;
  80572. private static _SetInterpolatedValue;
  80573. /**
  80574. * Creates linear animation from the animation key frames
  80575. * @param babylonTransformNode BabylonJS mesh
  80576. * @param animation BabylonJS animation
  80577. * @param animationChannelTargetPath The target animation channel
  80578. * @param frameDelta The difference between the last and first frame of the animation
  80579. * @param inputs Array to store the key frame times
  80580. * @param outputs Array to store the key frame data
  80581. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  80582. * @param useQuaternion Specifies if quaternions are used in the animation
  80583. */
  80584. private static _CreateLinearOrStepAnimation;
  80585. /**
  80586. * Creates cubic spline animation from the animation key frames
  80587. * @param babylonTransformNode BabylonJS mesh
  80588. * @param animation BabylonJS animation
  80589. * @param animationChannelTargetPath The target animation channel
  80590. * @param frameDelta The difference between the last and first frame of the animation
  80591. * @param inputs Array to store the key frame times
  80592. * @param outputs Array to store the key frame data
  80593. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  80594. * @param useQuaternion Specifies if quaternions are used in the animation
  80595. */
  80596. private static _CreateCubicSplineAnimation;
  80597. private static _GetBasePositionRotationOrScale;
  80598. /**
  80599. * Adds a key frame value
  80600. * @param keyFrame
  80601. * @param animation
  80602. * @param outputs
  80603. * @param animationChannelTargetPath
  80604. * @param basePositionRotationOrScale
  80605. * @param convertToRightHandedSystem
  80606. * @param useQuaternion
  80607. */
  80608. private static _AddKeyframeValue;
  80609. /**
  80610. * Determine the interpolation based on the key frames
  80611. * @param keyFrames
  80612. * @param animationChannelTargetPath
  80613. * @param useQuaternion
  80614. */
  80615. private static _DeduceInterpolation;
  80616. /**
  80617. * Adds an input tangent or output tangent to the output data
  80618. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  80619. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  80620. * @param outputs The animation data by keyframe
  80621. * @param animationChannelTargetPath The target animation channel
  80622. * @param interpolation The interpolation type
  80623. * @param keyFrame The key frame with the animation data
  80624. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  80625. * @param useQuaternion Specifies if quaternions are used
  80626. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  80627. */
  80628. private static AddSplineTangent;
  80629. /**
  80630. * Get the minimum and maximum key frames' frame values
  80631. * @param keyFrames animation key frames
  80632. * @returns the minimum and maximum key frame value
  80633. */
  80634. private static calculateMinMaxKeyFrames;
  80635. }
  80636. }
  80637. declare module BABYLON.GLTF2.Exporter {
  80638. /** @hidden */
  80639. export var textureTransformPixelShader: {
  80640. name: string;
  80641. shader: string;
  80642. };
  80643. }
  80644. declare module BABYLON.GLTF2.Exporter.Extensions {
  80645. /**
  80646. * @hidden
  80647. */
  80648. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  80649. private _recordedTextures;
  80650. /** Name of this extension */
  80651. readonly name: string;
  80652. /** Defines whether this extension is enabled */
  80653. enabled: boolean;
  80654. /** Defines whether this extension is required */
  80655. required: boolean;
  80656. /** Reference to the glTF exporter */
  80657. private _wasUsed;
  80658. constructor(exporter: _Exporter);
  80659. dispose(): void;
  80660. /** @hidden */
  80661. get wasUsed(): boolean;
  80662. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  80663. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  80664. /**
  80665. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  80666. * @param babylonTexture
  80667. * @param offset
  80668. * @param rotation
  80669. * @param scale
  80670. * @param scene
  80671. */
  80672. private _textureTransformTextureAsync;
  80673. }
  80674. }
  80675. declare module BABYLON.GLTF2.Exporter.Extensions {
  80676. /**
  80677. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  80678. */
  80679. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  80680. /** The name of this extension. */
  80681. readonly name: string;
  80682. /** Defines whether this extension is enabled. */
  80683. enabled: boolean;
  80684. /** Defines whether this extension is required */
  80685. required: boolean;
  80686. /** Reference to the glTF exporter */
  80687. private _exporter;
  80688. private _lights;
  80689. /** @hidden */
  80690. constructor(exporter: _Exporter);
  80691. /** @hidden */
  80692. dispose(): void;
  80693. /** @hidden */
  80694. get wasUsed(): boolean;
  80695. /** @hidden */
  80696. onExporting(): void;
  80697. /**
  80698. * Define this method to modify the default behavior when exporting a node
  80699. * @param context The context when exporting the node
  80700. * @param node glTF node
  80701. * @param babylonNode BabylonJS node
  80702. * @param nodeMap Node mapping of unique id to glTF node index
  80703. * @returns nullable INode promise
  80704. */
  80705. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80706. [key: number]: number;
  80707. }): Promise<Nullable<INode>>;
  80708. }
  80709. }
  80710. declare module BABYLON.GLTF2.Exporter.Extensions {
  80711. /**
  80712. * @hidden
  80713. */
  80714. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  80715. /** Name of this extension */
  80716. readonly name: string;
  80717. /** Defines whether this extension is enabled */
  80718. enabled: boolean;
  80719. /** Defines whether this extension is required */
  80720. required: boolean;
  80721. /** Reference to the glTF exporter */
  80722. private _textureInfos;
  80723. private _exportedTextures;
  80724. private _wasUsed;
  80725. constructor(exporter: _Exporter);
  80726. dispose(): void;
  80727. /** @hidden */
  80728. get wasUsed(): boolean;
  80729. private _getTextureIndex;
  80730. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  80731. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80732. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  80733. }
  80734. }
  80735. declare module BABYLON {
  80736. /**
  80737. * Class for generating STL data from a Babylon scene.
  80738. */
  80739. export class STLExport {
  80740. /**
  80741. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  80742. * @param meshes list defines the mesh to serialize
  80743. * @param download triggers the automatic download of the file.
  80744. * @param fileName changes the downloads fileName.
  80745. * @param binary changes the STL to a binary type.
  80746. * @param isLittleEndian toggle for binary type exporter.
  80747. * @returns the STL as UTF8 string
  80748. */
  80749. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  80750. }
  80751. }
  80752. declare module "babylonjs-gltf2interface" {
  80753. export = BABYLON.GLTF2;
  80754. }
  80755. /**
  80756. * Module for glTF 2.0 Interface
  80757. */
  80758. declare module BABYLON.GLTF2 {
  80759. /**
  80760. * The datatype of the components in the attribute
  80761. */
  80762. const enum AccessorComponentType {
  80763. /**
  80764. * Byte
  80765. */
  80766. BYTE = 5120,
  80767. /**
  80768. * Unsigned Byte
  80769. */
  80770. UNSIGNED_BYTE = 5121,
  80771. /**
  80772. * Short
  80773. */
  80774. SHORT = 5122,
  80775. /**
  80776. * Unsigned Short
  80777. */
  80778. UNSIGNED_SHORT = 5123,
  80779. /**
  80780. * Unsigned Int
  80781. */
  80782. UNSIGNED_INT = 5125,
  80783. /**
  80784. * Float
  80785. */
  80786. FLOAT = 5126,
  80787. }
  80788. /**
  80789. * Specifies if the attirbute is a scalar, vector, or matrix
  80790. */
  80791. const enum AccessorType {
  80792. /**
  80793. * Scalar
  80794. */
  80795. SCALAR = "SCALAR",
  80796. /**
  80797. * Vector2
  80798. */
  80799. VEC2 = "VEC2",
  80800. /**
  80801. * Vector3
  80802. */
  80803. VEC3 = "VEC3",
  80804. /**
  80805. * Vector4
  80806. */
  80807. VEC4 = "VEC4",
  80808. /**
  80809. * Matrix2x2
  80810. */
  80811. MAT2 = "MAT2",
  80812. /**
  80813. * Matrix3x3
  80814. */
  80815. MAT3 = "MAT3",
  80816. /**
  80817. * Matrix4x4
  80818. */
  80819. MAT4 = "MAT4",
  80820. }
  80821. /**
  80822. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  80823. */
  80824. const enum AnimationChannelTargetPath {
  80825. /**
  80826. * Translation
  80827. */
  80828. TRANSLATION = "translation",
  80829. /**
  80830. * Rotation
  80831. */
  80832. ROTATION = "rotation",
  80833. /**
  80834. * Scale
  80835. */
  80836. SCALE = "scale",
  80837. /**
  80838. * Weights
  80839. */
  80840. WEIGHTS = "weights",
  80841. }
  80842. /**
  80843. * Interpolation algorithm
  80844. */
  80845. const enum AnimationSamplerInterpolation {
  80846. /**
  80847. * The animated values are linearly interpolated between keyframes
  80848. */
  80849. LINEAR = "LINEAR",
  80850. /**
  80851. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  80852. */
  80853. STEP = "STEP",
  80854. /**
  80855. * The animation's interpolation is computed using a cubic spline with specified tangents
  80856. */
  80857. CUBICSPLINE = "CUBICSPLINE",
  80858. }
  80859. /**
  80860. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  80861. */
  80862. const enum CameraType {
  80863. /**
  80864. * A perspective camera containing properties to create a perspective projection matrix
  80865. */
  80866. PERSPECTIVE = "perspective",
  80867. /**
  80868. * An orthographic camera containing properties to create an orthographic projection matrix
  80869. */
  80870. ORTHOGRAPHIC = "orthographic",
  80871. }
  80872. /**
  80873. * The mime-type of the image
  80874. */
  80875. const enum ImageMimeType {
  80876. /**
  80877. * JPEG Mime-type
  80878. */
  80879. JPEG = "image/jpeg",
  80880. /**
  80881. * PNG Mime-type
  80882. */
  80883. PNG = "image/png",
  80884. }
  80885. /**
  80886. * The alpha rendering mode of the material
  80887. */
  80888. const enum MaterialAlphaMode {
  80889. /**
  80890. * The alpha value is ignored and the rendered output is fully opaque
  80891. */
  80892. OPAQUE = "OPAQUE",
  80893. /**
  80894. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  80895. */
  80896. MASK = "MASK",
  80897. /**
  80898. * 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)
  80899. */
  80900. BLEND = "BLEND",
  80901. }
  80902. /**
  80903. * The type of the primitives to render
  80904. */
  80905. const enum MeshPrimitiveMode {
  80906. /**
  80907. * Points
  80908. */
  80909. POINTS = 0,
  80910. /**
  80911. * Lines
  80912. */
  80913. LINES = 1,
  80914. /**
  80915. * Line Loop
  80916. */
  80917. LINE_LOOP = 2,
  80918. /**
  80919. * Line Strip
  80920. */
  80921. LINE_STRIP = 3,
  80922. /**
  80923. * Triangles
  80924. */
  80925. TRIANGLES = 4,
  80926. /**
  80927. * Triangle Strip
  80928. */
  80929. TRIANGLE_STRIP = 5,
  80930. /**
  80931. * Triangle Fan
  80932. */
  80933. TRIANGLE_FAN = 6,
  80934. }
  80935. /**
  80936. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  80937. */
  80938. const enum TextureMagFilter {
  80939. /**
  80940. * Nearest
  80941. */
  80942. NEAREST = 9728,
  80943. /**
  80944. * Linear
  80945. */
  80946. LINEAR = 9729,
  80947. }
  80948. /**
  80949. * Minification filter. All valid values correspond to WebGL enums
  80950. */
  80951. const enum TextureMinFilter {
  80952. /**
  80953. * Nearest
  80954. */
  80955. NEAREST = 9728,
  80956. /**
  80957. * Linear
  80958. */
  80959. LINEAR = 9729,
  80960. /**
  80961. * Nearest Mip-Map Nearest
  80962. */
  80963. NEAREST_MIPMAP_NEAREST = 9984,
  80964. /**
  80965. * Linear Mipmap Nearest
  80966. */
  80967. LINEAR_MIPMAP_NEAREST = 9985,
  80968. /**
  80969. * Nearest Mipmap Linear
  80970. */
  80971. NEAREST_MIPMAP_LINEAR = 9986,
  80972. /**
  80973. * Linear Mipmap Linear
  80974. */
  80975. LINEAR_MIPMAP_LINEAR = 9987,
  80976. }
  80977. /**
  80978. * S (U) wrapping mode. All valid values correspond to WebGL enums
  80979. */
  80980. const enum TextureWrapMode {
  80981. /**
  80982. * Clamp to Edge
  80983. */
  80984. CLAMP_TO_EDGE = 33071,
  80985. /**
  80986. * Mirrored Repeat
  80987. */
  80988. MIRRORED_REPEAT = 33648,
  80989. /**
  80990. * Repeat
  80991. */
  80992. REPEAT = 10497,
  80993. }
  80994. /**
  80995. * glTF Property
  80996. */
  80997. interface IProperty {
  80998. /**
  80999. * Dictionary object with extension-specific objects
  81000. */
  81001. extensions?: {
  81002. [key: string]: any;
  81003. };
  81004. /**
  81005. * Application-Specific data
  81006. */
  81007. extras?: any;
  81008. }
  81009. /**
  81010. * glTF Child of Root Property
  81011. */
  81012. interface IChildRootProperty extends IProperty {
  81013. /**
  81014. * The user-defined name of this object
  81015. */
  81016. name?: string;
  81017. }
  81018. /**
  81019. * Indices of those attributes that deviate from their initialization value
  81020. */
  81021. interface IAccessorSparseIndices extends IProperty {
  81022. /**
  81023. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81024. */
  81025. bufferView: number;
  81026. /**
  81027. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81028. */
  81029. byteOffset?: number;
  81030. /**
  81031. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  81032. */
  81033. componentType: AccessorComponentType;
  81034. }
  81035. /**
  81036. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  81037. */
  81038. interface IAccessorSparseValues extends IProperty {
  81039. /**
  81040. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81041. */
  81042. bufferView: number;
  81043. /**
  81044. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81045. */
  81046. byteOffset?: number;
  81047. }
  81048. /**
  81049. * Sparse storage of attributes that deviate from their initialization value
  81050. */
  81051. interface IAccessorSparse extends IProperty {
  81052. /**
  81053. * The number of attributes encoded in this sparse accessor
  81054. */
  81055. count: number;
  81056. /**
  81057. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  81058. */
  81059. indices: IAccessorSparseIndices;
  81060. /**
  81061. * 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
  81062. */
  81063. values: IAccessorSparseValues;
  81064. }
  81065. /**
  81066. * 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
  81067. */
  81068. interface IAccessor extends IChildRootProperty {
  81069. /**
  81070. * The index of the bufferview
  81071. */
  81072. bufferView?: number;
  81073. /**
  81074. * The offset relative to the start of the bufferView in bytes
  81075. */
  81076. byteOffset?: number;
  81077. /**
  81078. * The datatype of components in the attribute
  81079. */
  81080. componentType: AccessorComponentType;
  81081. /**
  81082. * Specifies whether integer data values should be normalized
  81083. */
  81084. normalized?: boolean;
  81085. /**
  81086. * The number of attributes referenced by this accessor
  81087. */
  81088. count: number;
  81089. /**
  81090. * Specifies if the attribute is a scalar, vector, or matrix
  81091. */
  81092. type: AccessorType;
  81093. /**
  81094. * Maximum value of each component in this attribute
  81095. */
  81096. max?: number[];
  81097. /**
  81098. * Minimum value of each component in this attribute
  81099. */
  81100. min?: number[];
  81101. /**
  81102. * Sparse storage of attributes that deviate from their initialization value
  81103. */
  81104. sparse?: IAccessorSparse;
  81105. }
  81106. /**
  81107. * Targets an animation's sampler at a node's property
  81108. */
  81109. interface IAnimationChannel extends IProperty {
  81110. /**
  81111. * The index of a sampler in this animation used to compute the value for the target
  81112. */
  81113. sampler: number;
  81114. /**
  81115. * The index of the node and TRS property to target
  81116. */
  81117. target: IAnimationChannelTarget;
  81118. }
  81119. /**
  81120. * The index of the node and TRS property that an animation channel targets
  81121. */
  81122. interface IAnimationChannelTarget extends IProperty {
  81123. /**
  81124. * The index of the node to target
  81125. */
  81126. node: number;
  81127. /**
  81128. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81129. */
  81130. path: AnimationChannelTargetPath;
  81131. }
  81132. /**
  81133. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81134. */
  81135. interface IAnimationSampler extends IProperty {
  81136. /**
  81137. * The index of an accessor containing keyframe input values, e.g., time
  81138. */
  81139. input: number;
  81140. /**
  81141. * Interpolation algorithm
  81142. */
  81143. interpolation?: AnimationSamplerInterpolation;
  81144. /**
  81145. * The index of an accessor, containing keyframe output values
  81146. */
  81147. output: number;
  81148. }
  81149. /**
  81150. * A keyframe animation
  81151. */
  81152. interface IAnimation extends IChildRootProperty {
  81153. /**
  81154. * An array of channels, each of which targets an animation's sampler at a node's property
  81155. */
  81156. channels: IAnimationChannel[];
  81157. /**
  81158. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81159. */
  81160. samplers: IAnimationSampler[];
  81161. }
  81162. /**
  81163. * Metadata about the glTF asset
  81164. */
  81165. interface IAsset extends IChildRootProperty {
  81166. /**
  81167. * A copyright message suitable for display to credit the content creator
  81168. */
  81169. copyright?: string;
  81170. /**
  81171. * Tool that generated this glTF model. Useful for debugging
  81172. */
  81173. generator?: string;
  81174. /**
  81175. * The glTF version that this asset targets
  81176. */
  81177. version: string;
  81178. /**
  81179. * The minimum glTF version that this asset targets
  81180. */
  81181. minVersion?: string;
  81182. }
  81183. /**
  81184. * A buffer points to binary geometry, animation, or skins
  81185. */
  81186. interface IBuffer extends IChildRootProperty {
  81187. /**
  81188. * 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
  81189. */
  81190. uri?: string;
  81191. /**
  81192. * The length of the buffer in bytes
  81193. */
  81194. byteLength: number;
  81195. }
  81196. /**
  81197. * A view into a buffer generally representing a subset of the buffer
  81198. */
  81199. interface IBufferView extends IChildRootProperty {
  81200. /**
  81201. * The index of the buffer
  81202. */
  81203. buffer: number;
  81204. /**
  81205. * The offset into the buffer in bytes
  81206. */
  81207. byteOffset?: number;
  81208. /**
  81209. * The lenth of the bufferView in bytes
  81210. */
  81211. byteLength: number;
  81212. /**
  81213. * The stride, in bytes
  81214. */
  81215. byteStride?: number;
  81216. }
  81217. /**
  81218. * An orthographic camera containing properties to create an orthographic projection matrix
  81219. */
  81220. interface ICameraOrthographic extends IProperty {
  81221. /**
  81222. * The floating-point horizontal magnification of the view. Must not be zero
  81223. */
  81224. xmag: number;
  81225. /**
  81226. * The floating-point vertical magnification of the view. Must not be zero
  81227. */
  81228. ymag: number;
  81229. /**
  81230. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  81231. */
  81232. zfar: number;
  81233. /**
  81234. * The floating-point distance to the near clipping plane
  81235. */
  81236. znear: number;
  81237. }
  81238. /**
  81239. * A perspective camera containing properties to create a perspective projection matrix
  81240. */
  81241. interface ICameraPerspective extends IProperty {
  81242. /**
  81243. * The floating-point aspect ratio of the field of view
  81244. */
  81245. aspectRatio?: number;
  81246. /**
  81247. * The floating-point vertical field of view in radians
  81248. */
  81249. yfov: number;
  81250. /**
  81251. * The floating-point distance to the far clipping plane
  81252. */
  81253. zfar?: number;
  81254. /**
  81255. * The floating-point distance to the near clipping plane
  81256. */
  81257. znear: number;
  81258. }
  81259. /**
  81260. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81261. */
  81262. interface ICamera extends IChildRootProperty {
  81263. /**
  81264. * An orthographic camera containing properties to create an orthographic projection matrix
  81265. */
  81266. orthographic?: ICameraOrthographic;
  81267. /**
  81268. * A perspective camera containing properties to create a perspective projection matrix
  81269. */
  81270. perspective?: ICameraPerspective;
  81271. /**
  81272. * Specifies if the camera uses a perspective or orthographic projection
  81273. */
  81274. type: CameraType;
  81275. }
  81276. /**
  81277. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  81278. */
  81279. interface IImage extends IChildRootProperty {
  81280. /**
  81281. * 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
  81282. */
  81283. uri?: string;
  81284. /**
  81285. * The image's MIME type
  81286. */
  81287. mimeType?: ImageMimeType;
  81288. /**
  81289. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  81290. */
  81291. bufferView?: number;
  81292. }
  81293. /**
  81294. * Material Normal Texture Info
  81295. */
  81296. interface IMaterialNormalTextureInfo extends ITextureInfo {
  81297. /**
  81298. * The scalar multiplier applied to each normal vector of the normal texture
  81299. */
  81300. scale?: number;
  81301. }
  81302. /**
  81303. * Material Occlusion Texture Info
  81304. */
  81305. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  81306. /**
  81307. * A scalar multiplier controlling the amount of occlusion applied
  81308. */
  81309. strength?: number;
  81310. }
  81311. /**
  81312. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  81313. */
  81314. interface IMaterialPbrMetallicRoughness {
  81315. /**
  81316. * The material's base color factor
  81317. */
  81318. baseColorFactor?: number[];
  81319. /**
  81320. * The base color texture
  81321. */
  81322. baseColorTexture?: ITextureInfo;
  81323. /**
  81324. * The metalness of the material
  81325. */
  81326. metallicFactor?: number;
  81327. /**
  81328. * The roughness of the material
  81329. */
  81330. roughnessFactor?: number;
  81331. /**
  81332. * The metallic-roughness texture
  81333. */
  81334. metallicRoughnessTexture?: ITextureInfo;
  81335. }
  81336. /**
  81337. * The material appearance of a primitive
  81338. */
  81339. interface IMaterial extends IChildRootProperty {
  81340. /**
  81341. * 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
  81342. */
  81343. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81344. /**
  81345. * The normal map texture
  81346. */
  81347. normalTexture?: IMaterialNormalTextureInfo;
  81348. /**
  81349. * The occlusion map texture
  81350. */
  81351. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81352. /**
  81353. * The emissive map texture
  81354. */
  81355. emissiveTexture?: ITextureInfo;
  81356. /**
  81357. * 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
  81358. */
  81359. emissiveFactor?: number[];
  81360. /**
  81361. * The alpha rendering mode of the material
  81362. */
  81363. alphaMode?: MaterialAlphaMode;
  81364. /**
  81365. * The alpha cutoff value of the material
  81366. */
  81367. alphaCutoff?: number;
  81368. /**
  81369. * Specifies whether the material is double sided
  81370. */
  81371. doubleSided?: boolean;
  81372. }
  81373. /**
  81374. * Geometry to be rendered with the given material
  81375. */
  81376. interface IMeshPrimitive extends IProperty {
  81377. /**
  81378. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  81379. */
  81380. attributes: {
  81381. [name: string]: number;
  81382. };
  81383. /**
  81384. * The index of the accessor that contains the indices
  81385. */
  81386. indices?: number;
  81387. /**
  81388. * The index of the material to apply to this primitive when rendering
  81389. */
  81390. material?: number;
  81391. /**
  81392. * The type of primitives to render. All valid values correspond to WebGL enums
  81393. */
  81394. mode?: MeshPrimitiveMode;
  81395. /**
  81396. * 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
  81397. */
  81398. targets?: {
  81399. [name: string]: number;
  81400. }[];
  81401. }
  81402. /**
  81403. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  81404. */
  81405. interface IMesh extends IChildRootProperty {
  81406. /**
  81407. * An array of primitives, each defining geometry to be rendered with a material
  81408. */
  81409. primitives: IMeshPrimitive[];
  81410. /**
  81411. * Array of weights to be applied to the Morph Targets
  81412. */
  81413. weights?: number[];
  81414. }
  81415. /**
  81416. * A node in the node hierarchy
  81417. */
  81418. interface INode extends IChildRootProperty {
  81419. /**
  81420. * The index of the camera referenced by this node
  81421. */
  81422. camera?: number;
  81423. /**
  81424. * The indices of this node's children
  81425. */
  81426. children?: number[];
  81427. /**
  81428. * The index of the skin referenced by this node
  81429. */
  81430. skin?: number;
  81431. /**
  81432. * A floating-point 4x4 transformation matrix stored in column-major order
  81433. */
  81434. matrix?: number[];
  81435. /**
  81436. * The index of the mesh in this node
  81437. */
  81438. mesh?: number;
  81439. /**
  81440. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  81441. */
  81442. rotation?: number[];
  81443. /**
  81444. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  81445. */
  81446. scale?: number[];
  81447. /**
  81448. * The node's translation along the x, y, and z axes
  81449. */
  81450. translation?: number[];
  81451. /**
  81452. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  81453. */
  81454. weights?: number[];
  81455. }
  81456. /**
  81457. * Texture sampler properties for filtering and wrapping modes
  81458. */
  81459. interface ISampler extends IChildRootProperty {
  81460. /**
  81461. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  81462. */
  81463. magFilter?: TextureMagFilter;
  81464. /**
  81465. * Minification filter. All valid values correspond to WebGL enums
  81466. */
  81467. minFilter?: TextureMinFilter;
  81468. /**
  81469. * S (U) wrapping mode. All valid values correspond to WebGL enums
  81470. */
  81471. wrapS?: TextureWrapMode;
  81472. /**
  81473. * T (V) wrapping mode. All valid values correspond to WebGL enums
  81474. */
  81475. wrapT?: TextureWrapMode;
  81476. }
  81477. /**
  81478. * The root nodes of a scene
  81479. */
  81480. interface IScene extends IChildRootProperty {
  81481. /**
  81482. * The indices of each root node
  81483. */
  81484. nodes: number[];
  81485. }
  81486. /**
  81487. * Joints and matrices defining a skin
  81488. */
  81489. interface ISkin extends IChildRootProperty {
  81490. /**
  81491. * 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
  81492. */
  81493. inverseBindMatrices?: number;
  81494. /**
  81495. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  81496. */
  81497. skeleton?: number;
  81498. /**
  81499. * 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)
  81500. */
  81501. joints: number[];
  81502. }
  81503. /**
  81504. * A texture and its sampler
  81505. */
  81506. interface ITexture extends IChildRootProperty {
  81507. /**
  81508. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  81509. */
  81510. sampler?: number;
  81511. /**
  81512. * The index of the image used by this texture
  81513. */
  81514. source: number;
  81515. }
  81516. /**
  81517. * Reference to a texture
  81518. */
  81519. interface ITextureInfo extends IProperty {
  81520. /**
  81521. * The index of the texture
  81522. */
  81523. index: number;
  81524. /**
  81525. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  81526. */
  81527. texCoord?: number;
  81528. }
  81529. /**
  81530. * The root object for a glTF asset
  81531. */
  81532. interface IGLTF extends IProperty {
  81533. /**
  81534. * An array of accessors. An accessor is a typed view into a bufferView
  81535. */
  81536. accessors?: IAccessor[];
  81537. /**
  81538. * An array of keyframe animations
  81539. */
  81540. animations?: IAnimation[];
  81541. /**
  81542. * Metadata about the glTF asset
  81543. */
  81544. asset: IAsset;
  81545. /**
  81546. * An array of buffers. A buffer points to binary geometry, animation, or skins
  81547. */
  81548. buffers?: IBuffer[];
  81549. /**
  81550. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  81551. */
  81552. bufferViews?: IBufferView[];
  81553. /**
  81554. * An array of cameras
  81555. */
  81556. cameras?: ICamera[];
  81557. /**
  81558. * Names of glTF extensions used somewhere in this asset
  81559. */
  81560. extensionsUsed?: string[];
  81561. /**
  81562. * Names of glTF extensions required to properly load this asset
  81563. */
  81564. extensionsRequired?: string[];
  81565. /**
  81566. * An array of images. An image defines data used to create a texture
  81567. */
  81568. images?: IImage[];
  81569. /**
  81570. * An array of materials. A material defines the appearance of a primitive
  81571. */
  81572. materials?: IMaterial[];
  81573. /**
  81574. * An array of meshes. A mesh is a set of primitives to be rendered
  81575. */
  81576. meshes?: IMesh[];
  81577. /**
  81578. * An array of nodes
  81579. */
  81580. nodes?: INode[];
  81581. /**
  81582. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  81583. */
  81584. samplers?: ISampler[];
  81585. /**
  81586. * The index of the default scene
  81587. */
  81588. scene?: number;
  81589. /**
  81590. * An array of scenes
  81591. */
  81592. scenes?: IScene[];
  81593. /**
  81594. * An array of skins. A skin is defined by joints and matrices
  81595. */
  81596. skins?: ISkin[];
  81597. /**
  81598. * An array of textures
  81599. */
  81600. textures?: ITexture[];
  81601. }
  81602. /**
  81603. * The glTF validation results
  81604. * @ignore
  81605. */
  81606. interface IGLTFValidationResults {
  81607. info: {
  81608. generator: string;
  81609. hasAnimations: boolean;
  81610. hasDefaultScene: boolean;
  81611. hasMaterials: boolean;
  81612. hasMorphTargets: boolean;
  81613. hasSkins: boolean;
  81614. hasTextures: boolean;
  81615. maxAttributesUsed: number;
  81616. primitivesCount: number
  81617. };
  81618. issues: {
  81619. messages: Array<string>;
  81620. numErrors: number;
  81621. numHints: number;
  81622. numInfos: number;
  81623. numWarnings: number;
  81624. truncated: boolean
  81625. };
  81626. mimeType: string;
  81627. uri: string;
  81628. validatedAt: string;
  81629. validatorVersion: string;
  81630. }
  81631. /**
  81632. * The glTF validation options
  81633. */
  81634. interface IGLTFValidationOptions {
  81635. /** Uri to use */
  81636. uri?: string;
  81637. /** Function used to load external resources */
  81638. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  81639. /** Boolean indicating that we need to validate accessor data */
  81640. validateAccessorData?: boolean;
  81641. /** max number of issues allowed */
  81642. maxIssues?: number;
  81643. /** Ignored issues */
  81644. ignoredIssues?: Array<string>;
  81645. /** Value to override severy settings */
  81646. severityOverrides?: Object;
  81647. }
  81648. /**
  81649. * The glTF validator object
  81650. * @ignore
  81651. */
  81652. interface IGLTFValidator {
  81653. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  81654. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  81655. }
  81656. }
  81657. declare module BABYLON {
  81658. /** @hidden */
  81659. export var cellPixelShader: {
  81660. name: string;
  81661. shader: string;
  81662. };
  81663. }
  81664. declare module BABYLON {
  81665. /** @hidden */
  81666. export var cellVertexShader: {
  81667. name: string;
  81668. shader: string;
  81669. };
  81670. }
  81671. declare module BABYLON {
  81672. export class CellMaterial extends BABYLON.PushMaterial {
  81673. private _diffuseTexture;
  81674. diffuseTexture: BABYLON.BaseTexture;
  81675. diffuseColor: BABYLON.Color3;
  81676. _computeHighLevel: boolean;
  81677. computeHighLevel: boolean;
  81678. private _disableLighting;
  81679. disableLighting: boolean;
  81680. private _maxSimultaneousLights;
  81681. maxSimultaneousLights: number;
  81682. constructor(name: string, scene: BABYLON.Scene);
  81683. needAlphaBlending(): boolean;
  81684. needAlphaTesting(): boolean;
  81685. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81686. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81687. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81688. getAnimatables(): BABYLON.IAnimatable[];
  81689. getActiveTextures(): BABYLON.BaseTexture[];
  81690. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81691. dispose(forceDisposeEffect?: boolean): void;
  81692. getClassName(): string;
  81693. clone(name: string): CellMaterial;
  81694. serialize(): any;
  81695. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  81696. }
  81697. }
  81698. declare module BABYLON {
  81699. export class CustomShaderStructure {
  81700. FragmentStore: string;
  81701. VertexStore: string;
  81702. constructor();
  81703. }
  81704. export class ShaderSpecialParts {
  81705. constructor();
  81706. Fragment_Begin: string;
  81707. Fragment_Definitions: string;
  81708. Fragment_MainBegin: string;
  81709. Fragment_Custom_Diffuse: string;
  81710. Fragment_Before_Lights: string;
  81711. Fragment_Before_Fog: string;
  81712. Fragment_Custom_Alpha: string;
  81713. Fragment_Before_FragColor: string;
  81714. Vertex_Begin: string;
  81715. Vertex_Definitions: string;
  81716. Vertex_MainBegin: string;
  81717. Vertex_Before_PositionUpdated: string;
  81718. Vertex_Before_NormalUpdated: string;
  81719. Vertex_After_WorldPosComputed: string;
  81720. Vertex_MainEnd: string;
  81721. }
  81722. export class CustomMaterial extends BABYLON.StandardMaterial {
  81723. static ShaderIndexer: number;
  81724. CustomParts: ShaderSpecialParts;
  81725. _isCreatedShader: boolean;
  81726. _createdShaderName: string;
  81727. _customUniform: string[];
  81728. _newUniforms: string[];
  81729. _newUniformInstances: {
  81730. [name: string]: any;
  81731. };
  81732. _newSamplerInstances: {
  81733. [name: string]: BABYLON.Texture;
  81734. };
  81735. _customAttributes: string[];
  81736. FragmentShader: string;
  81737. VertexShader: string;
  81738. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  81739. ReviewUniform(name: string, arr: string[]): string[];
  81740. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  81741. constructor(name: string, scene: BABYLON.Scene);
  81742. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  81743. AddAttribute(name: string): CustomMaterial;
  81744. Fragment_Begin(shaderPart: string): CustomMaterial;
  81745. Fragment_Definitions(shaderPart: string): CustomMaterial;
  81746. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  81747. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  81748. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  81749. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  81750. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  81751. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  81752. Vertex_Begin(shaderPart: string): CustomMaterial;
  81753. Vertex_Definitions(shaderPart: string): CustomMaterial;
  81754. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  81755. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  81756. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  81757. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  81758. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  81759. }
  81760. }
  81761. declare module BABYLON {
  81762. export class ShaderAlebdoParts {
  81763. constructor();
  81764. Fragment_Begin: string;
  81765. Fragment_Definitions: string;
  81766. Fragment_MainBegin: string;
  81767. Fragment_Custom_Albedo: string;
  81768. Fragment_Before_Lights: string;
  81769. Fragment_Custom_MetallicRoughness: string;
  81770. Fragment_Custom_MicroSurface: string;
  81771. Fragment_Before_Fog: string;
  81772. Fragment_Custom_Alpha: string;
  81773. Fragment_Before_FragColor: string;
  81774. Vertex_Begin: string;
  81775. Vertex_Definitions: string;
  81776. Vertex_MainBegin: string;
  81777. Vertex_Before_PositionUpdated: string;
  81778. Vertex_Before_NormalUpdated: string;
  81779. Vertex_After_WorldPosComputed: string;
  81780. Vertex_MainEnd: string;
  81781. }
  81782. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  81783. static ShaderIndexer: number;
  81784. CustomParts: ShaderAlebdoParts;
  81785. _isCreatedShader: boolean;
  81786. _createdShaderName: string;
  81787. _customUniform: string[];
  81788. _newUniforms: string[];
  81789. _newUniformInstances: {
  81790. [name: string]: any;
  81791. };
  81792. _newSamplerInstances: {
  81793. [name: string]: BABYLON.Texture;
  81794. };
  81795. _customAttributes: string[];
  81796. FragmentShader: string;
  81797. VertexShader: string;
  81798. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  81799. ReviewUniform(name: string, arr: string[]): string[];
  81800. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  81801. constructor(name: string, scene: BABYLON.Scene);
  81802. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  81803. AddAttribute(name: string): PBRCustomMaterial;
  81804. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  81805. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  81806. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  81807. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  81808. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  81809. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  81810. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  81811. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  81812. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  81813. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  81814. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  81815. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  81816. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  81817. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  81818. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  81819. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  81820. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  81821. }
  81822. }
  81823. declare module BABYLON {
  81824. /** @hidden */
  81825. export var firePixelShader: {
  81826. name: string;
  81827. shader: string;
  81828. };
  81829. }
  81830. declare module BABYLON {
  81831. /** @hidden */
  81832. export var fireVertexShader: {
  81833. name: string;
  81834. shader: string;
  81835. };
  81836. }
  81837. declare module BABYLON {
  81838. export class FireMaterial extends BABYLON.PushMaterial {
  81839. private _diffuseTexture;
  81840. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81841. private _distortionTexture;
  81842. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81843. private _opacityTexture;
  81844. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81845. diffuseColor: BABYLON.Color3;
  81846. speed: number;
  81847. private _scaledDiffuse;
  81848. private _lastTime;
  81849. constructor(name: string, scene: BABYLON.Scene);
  81850. needAlphaBlending(): boolean;
  81851. needAlphaTesting(): boolean;
  81852. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81853. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81854. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81855. getAnimatables(): BABYLON.IAnimatable[];
  81856. getActiveTextures(): BABYLON.BaseTexture[];
  81857. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81858. getClassName(): string;
  81859. dispose(forceDisposeEffect?: boolean): void;
  81860. clone(name: string): FireMaterial;
  81861. serialize(): any;
  81862. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  81863. }
  81864. }
  81865. declare module BABYLON {
  81866. /** @hidden */
  81867. export var furPixelShader: {
  81868. name: string;
  81869. shader: string;
  81870. };
  81871. }
  81872. declare module BABYLON {
  81873. /** @hidden */
  81874. export var furVertexShader: {
  81875. name: string;
  81876. shader: string;
  81877. };
  81878. }
  81879. declare module BABYLON {
  81880. export class FurMaterial extends BABYLON.PushMaterial {
  81881. private _diffuseTexture;
  81882. diffuseTexture: BABYLON.BaseTexture;
  81883. private _heightTexture;
  81884. heightTexture: BABYLON.BaseTexture;
  81885. diffuseColor: BABYLON.Color3;
  81886. furLength: number;
  81887. furAngle: number;
  81888. furColor: BABYLON.Color3;
  81889. furOffset: number;
  81890. furSpacing: number;
  81891. furGravity: BABYLON.Vector3;
  81892. furSpeed: number;
  81893. furDensity: number;
  81894. furOcclusion: number;
  81895. furTexture: BABYLON.DynamicTexture;
  81896. private _disableLighting;
  81897. disableLighting: boolean;
  81898. private _maxSimultaneousLights;
  81899. maxSimultaneousLights: number;
  81900. highLevelFur: boolean;
  81901. _meshes: BABYLON.AbstractMesh[];
  81902. private _furTime;
  81903. constructor(name: string, scene: BABYLON.Scene);
  81904. get furTime(): number;
  81905. set furTime(furTime: number);
  81906. needAlphaBlending(): boolean;
  81907. needAlphaTesting(): boolean;
  81908. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81909. updateFur(): void;
  81910. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81911. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81912. getAnimatables(): BABYLON.IAnimatable[];
  81913. getActiveTextures(): BABYLON.BaseTexture[];
  81914. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81915. dispose(forceDisposeEffect?: boolean): void;
  81916. clone(name: string): FurMaterial;
  81917. serialize(): any;
  81918. getClassName(): string;
  81919. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  81920. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  81921. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  81922. }
  81923. }
  81924. declare module BABYLON {
  81925. /** @hidden */
  81926. export var gradientPixelShader: {
  81927. name: string;
  81928. shader: string;
  81929. };
  81930. }
  81931. declare module BABYLON {
  81932. /** @hidden */
  81933. export var gradientVertexShader: {
  81934. name: string;
  81935. shader: string;
  81936. };
  81937. }
  81938. declare module BABYLON {
  81939. export class GradientMaterial extends BABYLON.PushMaterial {
  81940. private _maxSimultaneousLights;
  81941. maxSimultaneousLights: number;
  81942. topColor: BABYLON.Color3;
  81943. topColorAlpha: number;
  81944. bottomColor: BABYLON.Color3;
  81945. bottomColorAlpha: number;
  81946. offset: number;
  81947. scale: number;
  81948. smoothness: number;
  81949. private _disableLighting;
  81950. disableLighting: boolean;
  81951. constructor(name: string, scene: BABYLON.Scene);
  81952. needAlphaBlending(): boolean;
  81953. needAlphaTesting(): boolean;
  81954. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81955. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81956. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81957. getAnimatables(): BABYLON.IAnimatable[];
  81958. dispose(forceDisposeEffect?: boolean): void;
  81959. clone(name: string): GradientMaterial;
  81960. serialize(): any;
  81961. getClassName(): string;
  81962. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  81963. }
  81964. }
  81965. declare module BABYLON {
  81966. /** @hidden */
  81967. export var gridPixelShader: {
  81968. name: string;
  81969. shader: string;
  81970. };
  81971. }
  81972. declare module BABYLON {
  81973. /** @hidden */
  81974. export var gridVertexShader: {
  81975. name: string;
  81976. shader: string;
  81977. };
  81978. }
  81979. declare module BABYLON {
  81980. /**
  81981. * The grid materials allows you to wrap any shape with a grid.
  81982. * Colors are customizable.
  81983. */
  81984. export class GridMaterial extends BABYLON.PushMaterial {
  81985. /**
  81986. * Main color of the grid (e.g. between lines)
  81987. */
  81988. mainColor: BABYLON.Color3;
  81989. /**
  81990. * Color of the grid lines.
  81991. */
  81992. lineColor: BABYLON.Color3;
  81993. /**
  81994. * The scale of the grid compared to unit.
  81995. */
  81996. gridRatio: number;
  81997. /**
  81998. * Allows setting an offset for the grid lines.
  81999. */
  82000. gridOffset: BABYLON.Vector3;
  82001. /**
  82002. * The frequency of thicker lines.
  82003. */
  82004. majorUnitFrequency: number;
  82005. /**
  82006. * The visibility of minor units in the grid.
  82007. */
  82008. minorUnitVisibility: number;
  82009. /**
  82010. * The grid opacity outside of the lines.
  82011. */
  82012. opacity: number;
  82013. /**
  82014. * Determine RBG output is premultiplied by alpha value.
  82015. */
  82016. preMultiplyAlpha: boolean;
  82017. private _opacityTexture;
  82018. opacityTexture: BABYLON.BaseTexture;
  82019. private _gridControl;
  82020. /**
  82021. * constructor
  82022. * @param name The name given to the material in order to identify it afterwards.
  82023. * @param scene The scene the material is used in.
  82024. */
  82025. constructor(name: string, scene: BABYLON.Scene);
  82026. /**
  82027. * Returns wehter or not the grid requires alpha blending.
  82028. */
  82029. needAlphaBlending(): boolean;
  82030. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  82031. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82032. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82033. /**
  82034. * Dispose the material and its associated resources.
  82035. * @param forceDisposeEffect will also dispose the used effect when true
  82036. */
  82037. dispose(forceDisposeEffect?: boolean): void;
  82038. clone(name: string): GridMaterial;
  82039. serialize(): any;
  82040. getClassName(): string;
  82041. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  82042. }
  82043. }
  82044. declare module BABYLON {
  82045. /** @hidden */
  82046. export var lavaPixelShader: {
  82047. name: string;
  82048. shader: string;
  82049. };
  82050. }
  82051. declare module BABYLON {
  82052. /** @hidden */
  82053. export var lavaVertexShader: {
  82054. name: string;
  82055. shader: string;
  82056. };
  82057. }
  82058. declare module BABYLON {
  82059. export class LavaMaterial extends BABYLON.PushMaterial {
  82060. private _diffuseTexture;
  82061. diffuseTexture: BABYLON.BaseTexture;
  82062. noiseTexture: BABYLON.BaseTexture;
  82063. fogColor: BABYLON.Color3;
  82064. speed: number;
  82065. movingSpeed: number;
  82066. lowFrequencySpeed: number;
  82067. fogDensity: number;
  82068. private _lastTime;
  82069. diffuseColor: BABYLON.Color3;
  82070. private _disableLighting;
  82071. disableLighting: boolean;
  82072. private _unlit;
  82073. unlit: boolean;
  82074. private _maxSimultaneousLights;
  82075. maxSimultaneousLights: number;
  82076. private _scaledDiffuse;
  82077. constructor(name: string, scene: BABYLON.Scene);
  82078. needAlphaBlending(): boolean;
  82079. needAlphaTesting(): boolean;
  82080. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82081. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82082. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82083. getAnimatables(): BABYLON.IAnimatable[];
  82084. getActiveTextures(): BABYLON.BaseTexture[];
  82085. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82086. dispose(forceDisposeEffect?: boolean): void;
  82087. clone(name: string): LavaMaterial;
  82088. serialize(): any;
  82089. getClassName(): string;
  82090. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  82091. }
  82092. }
  82093. declare module BABYLON {
  82094. /** @hidden */
  82095. export var mixPixelShader: {
  82096. name: string;
  82097. shader: string;
  82098. };
  82099. }
  82100. declare module BABYLON {
  82101. /** @hidden */
  82102. export var mixVertexShader: {
  82103. name: string;
  82104. shader: string;
  82105. };
  82106. }
  82107. declare module BABYLON {
  82108. export class MixMaterial extends BABYLON.PushMaterial {
  82109. /**
  82110. * Mix textures
  82111. */
  82112. private _mixTexture1;
  82113. mixTexture1: BABYLON.BaseTexture;
  82114. private _mixTexture2;
  82115. mixTexture2: BABYLON.BaseTexture;
  82116. /**
  82117. * Diffuse textures
  82118. */
  82119. private _diffuseTexture1;
  82120. diffuseTexture1: BABYLON.Texture;
  82121. private _diffuseTexture2;
  82122. diffuseTexture2: BABYLON.Texture;
  82123. private _diffuseTexture3;
  82124. diffuseTexture3: BABYLON.Texture;
  82125. private _diffuseTexture4;
  82126. diffuseTexture4: BABYLON.Texture;
  82127. private _diffuseTexture5;
  82128. diffuseTexture5: BABYLON.Texture;
  82129. private _diffuseTexture6;
  82130. diffuseTexture6: BABYLON.Texture;
  82131. private _diffuseTexture7;
  82132. diffuseTexture7: BABYLON.Texture;
  82133. private _diffuseTexture8;
  82134. diffuseTexture8: BABYLON.Texture;
  82135. /**
  82136. * Uniforms
  82137. */
  82138. diffuseColor: BABYLON.Color3;
  82139. specularColor: BABYLON.Color3;
  82140. specularPower: number;
  82141. private _disableLighting;
  82142. disableLighting: boolean;
  82143. private _maxSimultaneousLights;
  82144. maxSimultaneousLights: number;
  82145. constructor(name: string, scene: BABYLON.Scene);
  82146. needAlphaBlending(): boolean;
  82147. needAlphaTesting(): boolean;
  82148. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82149. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82150. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82151. getAnimatables(): BABYLON.IAnimatable[];
  82152. getActiveTextures(): BABYLON.BaseTexture[];
  82153. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82154. dispose(forceDisposeEffect?: boolean): void;
  82155. clone(name: string): MixMaterial;
  82156. serialize(): any;
  82157. getClassName(): string;
  82158. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  82159. }
  82160. }
  82161. declare module BABYLON {
  82162. /** @hidden */
  82163. export var normalPixelShader: {
  82164. name: string;
  82165. shader: string;
  82166. };
  82167. }
  82168. declare module BABYLON {
  82169. /** @hidden */
  82170. export var normalVertexShader: {
  82171. name: string;
  82172. shader: string;
  82173. };
  82174. }
  82175. declare module BABYLON {
  82176. export class NormalMaterial extends BABYLON.PushMaterial {
  82177. private _diffuseTexture;
  82178. diffuseTexture: BABYLON.BaseTexture;
  82179. diffuseColor: BABYLON.Color3;
  82180. private _disableLighting;
  82181. disableLighting: boolean;
  82182. private _maxSimultaneousLights;
  82183. maxSimultaneousLights: number;
  82184. constructor(name: string, scene: BABYLON.Scene);
  82185. needAlphaBlending(): boolean;
  82186. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  82187. needAlphaTesting(): boolean;
  82188. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82189. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82190. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82191. getAnimatables(): BABYLON.IAnimatable[];
  82192. getActiveTextures(): BABYLON.BaseTexture[];
  82193. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82194. dispose(forceDisposeEffect?: boolean): void;
  82195. clone(name: string): NormalMaterial;
  82196. serialize(): any;
  82197. getClassName(): string;
  82198. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  82199. }
  82200. }
  82201. declare module BABYLON {
  82202. /** @hidden */
  82203. export var shadowOnlyPixelShader: {
  82204. name: string;
  82205. shader: string;
  82206. };
  82207. }
  82208. declare module BABYLON {
  82209. /** @hidden */
  82210. export var shadowOnlyVertexShader: {
  82211. name: string;
  82212. shader: string;
  82213. };
  82214. }
  82215. declare module BABYLON {
  82216. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  82217. private _activeLight;
  82218. constructor(name: string, scene: BABYLON.Scene);
  82219. shadowColor: BABYLON.Color3;
  82220. needAlphaBlending(): boolean;
  82221. needAlphaTesting(): boolean;
  82222. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82223. get activeLight(): BABYLON.IShadowLight;
  82224. set activeLight(light: BABYLON.IShadowLight);
  82225. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82226. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82227. clone(name: string): ShadowOnlyMaterial;
  82228. serialize(): any;
  82229. getClassName(): string;
  82230. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  82231. }
  82232. }
  82233. declare module BABYLON {
  82234. /** @hidden */
  82235. export var simplePixelShader: {
  82236. name: string;
  82237. shader: string;
  82238. };
  82239. }
  82240. declare module BABYLON {
  82241. /** @hidden */
  82242. export var simpleVertexShader: {
  82243. name: string;
  82244. shader: string;
  82245. };
  82246. }
  82247. declare module BABYLON {
  82248. export class SimpleMaterial extends BABYLON.PushMaterial {
  82249. private _diffuseTexture;
  82250. diffuseTexture: BABYLON.BaseTexture;
  82251. diffuseColor: BABYLON.Color3;
  82252. private _disableLighting;
  82253. disableLighting: boolean;
  82254. private _maxSimultaneousLights;
  82255. maxSimultaneousLights: number;
  82256. constructor(name: string, scene: BABYLON.Scene);
  82257. needAlphaBlending(): boolean;
  82258. needAlphaTesting(): boolean;
  82259. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82260. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82261. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82262. getAnimatables(): BABYLON.IAnimatable[];
  82263. getActiveTextures(): BABYLON.BaseTexture[];
  82264. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82265. dispose(forceDisposeEffect?: boolean): void;
  82266. clone(name: string): SimpleMaterial;
  82267. serialize(): any;
  82268. getClassName(): string;
  82269. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  82270. }
  82271. }
  82272. declare module BABYLON {
  82273. /** @hidden */
  82274. export var skyPixelShader: {
  82275. name: string;
  82276. shader: string;
  82277. };
  82278. }
  82279. declare module BABYLON {
  82280. /** @hidden */
  82281. export var skyVertexShader: {
  82282. name: string;
  82283. shader: string;
  82284. };
  82285. }
  82286. declare module BABYLON {
  82287. /**
  82288. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  82289. * @see https://doc.babylonjs.com/extensions/sky
  82290. */
  82291. export class SkyMaterial extends BABYLON.PushMaterial {
  82292. /**
  82293. * Defines the overall luminance of sky in interval ]0, 1[.
  82294. */
  82295. luminance: number;
  82296. /**
  82297. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  82298. */
  82299. turbidity: number;
  82300. /**
  82301. * Defines the sky appearance (light intensity).
  82302. */
  82303. rayleigh: number;
  82304. /**
  82305. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  82306. */
  82307. mieCoefficient: number;
  82308. /**
  82309. * Defines the amount of haze particles following the Mie scattering theory.
  82310. */
  82311. mieDirectionalG: number;
  82312. /**
  82313. * Defines the distance of the sun according to the active scene camera.
  82314. */
  82315. distance: number;
  82316. /**
  82317. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  82318. * "inclined".
  82319. */
  82320. inclination: number;
  82321. /**
  82322. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  82323. * an object direction and a reference direction.
  82324. */
  82325. azimuth: number;
  82326. /**
  82327. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  82328. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  82329. */
  82330. sunPosition: BABYLON.Vector3;
  82331. /**
  82332. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  82333. * .sunPosition property.
  82334. */
  82335. useSunPosition: boolean;
  82336. /**
  82337. * Defines an offset vector used to get a horizon offset.
  82338. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  82339. */
  82340. cameraOffset: BABYLON.Vector3;
  82341. private _cameraPosition;
  82342. /**
  82343. * Instantiates a new sky material.
  82344. * This material allows to create dynamic and texture free
  82345. * effects for skyboxes by taking care of the atmosphere state.
  82346. * @see https://doc.babylonjs.com/extensions/sky
  82347. * @param name Define the name of the material in the scene
  82348. * @param scene Define the scene the material belong to
  82349. */
  82350. constructor(name: string, scene: BABYLON.Scene);
  82351. /**
  82352. * Specifies if the material will require alpha blending
  82353. * @returns a boolean specifying if alpha blending is needed
  82354. */
  82355. needAlphaBlending(): boolean;
  82356. /**
  82357. * Specifies if this material should be rendered in alpha test mode
  82358. * @returns false as the sky material doesn't need alpha testing.
  82359. */
  82360. needAlphaTesting(): boolean;
  82361. /**
  82362. * Get the texture used for alpha test purpose.
  82363. * @returns null as the sky material has no texture.
  82364. */
  82365. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82366. /**
  82367. * Get if the submesh is ready to be used and all its information available.
  82368. * Child classes can use it to update shaders
  82369. * @param mesh defines the mesh to check
  82370. * @param subMesh defines which submesh to check
  82371. * @param useInstances specifies that instances should be used
  82372. * @returns a boolean indicating that the submesh is ready or not
  82373. */
  82374. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82375. /**
  82376. * Binds the submesh to this material by preparing the effect and shader to draw
  82377. * @param world defines the world transformation matrix
  82378. * @param mesh defines the mesh containing the submesh
  82379. * @param subMesh defines the submesh to bind the material to
  82380. */
  82381. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82382. /**
  82383. * Get the list of animatables in the material.
  82384. * @returns the list of animatables object used in the material
  82385. */
  82386. getAnimatables(): BABYLON.IAnimatable[];
  82387. /**
  82388. * Disposes the material
  82389. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82390. */
  82391. dispose(forceDisposeEffect?: boolean): void;
  82392. /**
  82393. * Makes a duplicate of the material, and gives it a new name
  82394. * @param name defines the new name for the duplicated material
  82395. * @returns the cloned material
  82396. */
  82397. clone(name: string): SkyMaterial;
  82398. /**
  82399. * Serializes this material in a JSON representation
  82400. * @returns the serialized material object
  82401. */
  82402. serialize(): any;
  82403. /**
  82404. * Gets the current class name of the material e.g. "SkyMaterial"
  82405. * Mainly use in serialization.
  82406. * @returns the class name
  82407. */
  82408. getClassName(): string;
  82409. /**
  82410. * Creates a sky material from parsed material data
  82411. * @param source defines the JSON representation of the material
  82412. * @param scene defines the hosting scene
  82413. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  82414. * @returns a new sky material
  82415. */
  82416. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  82417. }
  82418. }
  82419. declare module BABYLON {
  82420. /** @hidden */
  82421. export var terrainPixelShader: {
  82422. name: string;
  82423. shader: string;
  82424. };
  82425. }
  82426. declare module BABYLON {
  82427. /** @hidden */
  82428. export var terrainVertexShader: {
  82429. name: string;
  82430. shader: string;
  82431. };
  82432. }
  82433. declare module BABYLON {
  82434. export class TerrainMaterial extends BABYLON.PushMaterial {
  82435. private _mixTexture;
  82436. mixTexture: BABYLON.BaseTexture;
  82437. private _diffuseTexture1;
  82438. diffuseTexture1: BABYLON.Texture;
  82439. private _diffuseTexture2;
  82440. diffuseTexture2: BABYLON.Texture;
  82441. private _diffuseTexture3;
  82442. diffuseTexture3: BABYLON.Texture;
  82443. private _bumpTexture1;
  82444. bumpTexture1: BABYLON.Texture;
  82445. private _bumpTexture2;
  82446. bumpTexture2: BABYLON.Texture;
  82447. private _bumpTexture3;
  82448. bumpTexture3: BABYLON.Texture;
  82449. diffuseColor: BABYLON.Color3;
  82450. specularColor: BABYLON.Color3;
  82451. specularPower: number;
  82452. private _disableLighting;
  82453. disableLighting: boolean;
  82454. private _maxSimultaneousLights;
  82455. maxSimultaneousLights: number;
  82456. constructor(name: string, scene: BABYLON.Scene);
  82457. needAlphaBlending(): boolean;
  82458. needAlphaTesting(): boolean;
  82459. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82460. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82461. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82462. getAnimatables(): BABYLON.IAnimatable[];
  82463. getActiveTextures(): BABYLON.BaseTexture[];
  82464. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82465. dispose(forceDisposeEffect?: boolean): void;
  82466. clone(name: string): TerrainMaterial;
  82467. serialize(): any;
  82468. getClassName(): string;
  82469. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  82470. }
  82471. }
  82472. declare module BABYLON {
  82473. /** @hidden */
  82474. export var triplanarPixelShader: {
  82475. name: string;
  82476. shader: string;
  82477. };
  82478. }
  82479. declare module BABYLON {
  82480. /** @hidden */
  82481. export var triplanarVertexShader: {
  82482. name: string;
  82483. shader: string;
  82484. };
  82485. }
  82486. declare module BABYLON {
  82487. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  82488. mixTexture: BABYLON.BaseTexture;
  82489. private _diffuseTextureX;
  82490. diffuseTextureX: BABYLON.BaseTexture;
  82491. private _diffuseTextureY;
  82492. diffuseTextureY: BABYLON.BaseTexture;
  82493. private _diffuseTextureZ;
  82494. diffuseTextureZ: BABYLON.BaseTexture;
  82495. private _normalTextureX;
  82496. normalTextureX: BABYLON.BaseTexture;
  82497. private _normalTextureY;
  82498. normalTextureY: BABYLON.BaseTexture;
  82499. private _normalTextureZ;
  82500. normalTextureZ: BABYLON.BaseTexture;
  82501. tileSize: number;
  82502. diffuseColor: BABYLON.Color3;
  82503. specularColor: BABYLON.Color3;
  82504. specularPower: number;
  82505. private _disableLighting;
  82506. disableLighting: boolean;
  82507. private _maxSimultaneousLights;
  82508. maxSimultaneousLights: number;
  82509. constructor(name: string, scene: BABYLON.Scene);
  82510. needAlphaBlending(): boolean;
  82511. needAlphaTesting(): boolean;
  82512. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82513. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82514. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82515. getAnimatables(): BABYLON.IAnimatable[];
  82516. getActiveTextures(): BABYLON.BaseTexture[];
  82517. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82518. dispose(forceDisposeEffect?: boolean): void;
  82519. clone(name: string): TriPlanarMaterial;
  82520. serialize(): any;
  82521. getClassName(): string;
  82522. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  82523. }
  82524. }
  82525. declare module BABYLON {
  82526. /** @hidden */
  82527. export var waterPixelShader: {
  82528. name: string;
  82529. shader: string;
  82530. };
  82531. }
  82532. declare module BABYLON {
  82533. /** @hidden */
  82534. export var waterVertexShader: {
  82535. name: string;
  82536. shader: string;
  82537. };
  82538. }
  82539. declare module BABYLON {
  82540. export class WaterMaterial extends BABYLON.PushMaterial {
  82541. renderTargetSize: BABYLON.Vector2;
  82542. private _bumpTexture;
  82543. bumpTexture: BABYLON.BaseTexture;
  82544. diffuseColor: BABYLON.Color3;
  82545. specularColor: BABYLON.Color3;
  82546. specularPower: number;
  82547. private _disableLighting;
  82548. disableLighting: boolean;
  82549. private _maxSimultaneousLights;
  82550. maxSimultaneousLights: number;
  82551. /**
  82552. * @param {number}: Represents the wind force
  82553. */
  82554. windForce: number;
  82555. /**
  82556. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  82557. */
  82558. windDirection: BABYLON.Vector2;
  82559. /**
  82560. * @param {number}: Wave height, represents the height of the waves
  82561. */
  82562. waveHeight: number;
  82563. /**
  82564. * @param {number}: Bump height, represents the bump height related to the bump map
  82565. */
  82566. bumpHeight: number;
  82567. /**
  82568. * @param {boolean}: Add a smaller moving bump to less steady waves.
  82569. */
  82570. private _bumpSuperimpose;
  82571. bumpSuperimpose: boolean;
  82572. /**
  82573. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  82574. */
  82575. private _fresnelSeparate;
  82576. fresnelSeparate: boolean;
  82577. /**
  82578. * @param {boolean}: bump Waves modify the reflection.
  82579. */
  82580. private _bumpAffectsReflection;
  82581. bumpAffectsReflection: boolean;
  82582. /**
  82583. * @param {number}: The water color blended with the refraction (near)
  82584. */
  82585. waterColor: BABYLON.Color3;
  82586. /**
  82587. * @param {number}: The blend factor related to the water color
  82588. */
  82589. colorBlendFactor: number;
  82590. /**
  82591. * @param {number}: The water color blended with the reflection (far)
  82592. */
  82593. waterColor2: BABYLON.Color3;
  82594. /**
  82595. * @param {number}: The blend factor related to the water color (reflection, far)
  82596. */
  82597. colorBlendFactor2: number;
  82598. /**
  82599. * @param {number}: Represents the maximum length of a wave
  82600. */
  82601. waveLength: number;
  82602. /**
  82603. * @param {number}: Defines the waves speed
  82604. */
  82605. waveSpeed: number;
  82606. /**
  82607. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  82608. * will avoid calculating useless pixels in the pixel shader of the water material.
  82609. */
  82610. disableClipPlane: boolean;
  82611. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  82612. private _mesh;
  82613. private _refractionRTT;
  82614. private _reflectionRTT;
  82615. private _reflectionTransform;
  82616. private _lastTime;
  82617. private _lastDeltaTime;
  82618. private _useLogarithmicDepth;
  82619. private _waitingRenderList;
  82620. private _imageProcessingConfiguration;
  82621. private _imageProcessingObserver;
  82622. /**
  82623. * Gets a boolean indicating that current material needs to register RTT
  82624. */
  82625. get hasRenderTargetTextures(): boolean;
  82626. /**
  82627. * Constructor
  82628. */
  82629. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  82630. get useLogarithmicDepth(): boolean;
  82631. set useLogarithmicDepth(value: boolean);
  82632. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  82633. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  82634. addToRenderList(node: any): void;
  82635. enableRenderTargets(enable: boolean): void;
  82636. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  82637. get renderTargetsEnabled(): boolean;
  82638. needAlphaBlending(): boolean;
  82639. needAlphaTesting(): boolean;
  82640. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82641. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82642. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82643. private _createRenderTargets;
  82644. getAnimatables(): BABYLON.IAnimatable[];
  82645. getActiveTextures(): BABYLON.BaseTexture[];
  82646. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82647. dispose(forceDisposeEffect?: boolean): void;
  82648. clone(name: string): WaterMaterial;
  82649. serialize(): any;
  82650. getClassName(): string;
  82651. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  82652. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  82653. }
  82654. }
  82655. declare module BABYLON {
  82656. /** @hidden */
  82657. export var asciiartPixelShader: {
  82658. name: string;
  82659. shader: string;
  82660. };
  82661. }
  82662. declare module BABYLON {
  82663. /**
  82664. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  82665. *
  82666. * It basically takes care rendering the font front the given font size to a texture.
  82667. * This is used later on in the postprocess.
  82668. */
  82669. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  82670. private _font;
  82671. private _text;
  82672. private _charSize;
  82673. /**
  82674. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  82675. */
  82676. get charSize(): number;
  82677. /**
  82678. * Create a new instance of the Ascii Art FontTexture class
  82679. * @param name the name of the texture
  82680. * @param font the font to use, use the W3C CSS notation
  82681. * @param text the caracter set to use in the rendering.
  82682. * @param scene the scene that owns the texture
  82683. */
  82684. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  82685. /**
  82686. * Gets the max char width of a font.
  82687. * @param font the font to use, use the W3C CSS notation
  82688. * @return the max char width
  82689. */
  82690. private getFontWidth;
  82691. /**
  82692. * Gets the max char height of a font.
  82693. * @param font the font to use, use the W3C CSS notation
  82694. * @return the max char height
  82695. */
  82696. private getFontHeight;
  82697. /**
  82698. * Clones the current AsciiArtTexture.
  82699. * @return the clone of the texture.
  82700. */
  82701. clone(): AsciiArtFontTexture;
  82702. /**
  82703. * Parses a json object representing the texture and returns an instance of it.
  82704. * @param source the source JSON representation
  82705. * @param scene the scene to create the texture for
  82706. * @return the parsed texture
  82707. */
  82708. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  82709. }
  82710. /**
  82711. * Option available in the Ascii Art Post Process.
  82712. */
  82713. export interface IAsciiArtPostProcessOptions {
  82714. /**
  82715. * The font to use following the w3c font definition.
  82716. */
  82717. font?: string;
  82718. /**
  82719. * The character set to use in the postprocess.
  82720. */
  82721. characterSet?: string;
  82722. /**
  82723. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  82724. * This number is defined between 0 and 1;
  82725. */
  82726. mixToTile?: number;
  82727. /**
  82728. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  82729. * This number is defined between 0 and 1;
  82730. */
  82731. mixToNormal?: number;
  82732. }
  82733. /**
  82734. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  82735. *
  82736. * Simmply add it to your scene and let the nerd that lives in you have fun.
  82737. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  82738. */
  82739. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  82740. /**
  82741. * The font texture used to render the char in the post process.
  82742. */
  82743. private _asciiArtFontTexture;
  82744. /**
  82745. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  82746. * This number is defined between 0 and 1;
  82747. */
  82748. mixToTile: number;
  82749. /**
  82750. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  82751. * This number is defined between 0 and 1;
  82752. */
  82753. mixToNormal: number;
  82754. /**
  82755. * Instantiates a new Ascii Art Post Process.
  82756. * @param name the name to give to the postprocess
  82757. * @camera the camera to apply the post process to.
  82758. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  82759. */
  82760. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  82761. }
  82762. }
  82763. declare module BABYLON {
  82764. /** @hidden */
  82765. export var digitalrainPixelShader: {
  82766. name: string;
  82767. shader: string;
  82768. };
  82769. }
  82770. declare module BABYLON {
  82771. /**
  82772. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  82773. *
  82774. * It basically takes care rendering the font front the given font size to a texture.
  82775. * This is used later on in the postprocess.
  82776. */
  82777. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  82778. private _font;
  82779. private _text;
  82780. private _charSize;
  82781. /**
  82782. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  82783. */
  82784. get charSize(): number;
  82785. /**
  82786. * Create a new instance of the Digital Rain FontTexture class
  82787. * @param name the name of the texture
  82788. * @param font the font to use, use the W3C CSS notation
  82789. * @param text the caracter set to use in the rendering.
  82790. * @param scene the scene that owns the texture
  82791. */
  82792. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  82793. /**
  82794. * Gets the max char width of a font.
  82795. * @param font the font to use, use the W3C CSS notation
  82796. * @return the max char width
  82797. */
  82798. private getFontWidth;
  82799. /**
  82800. * Gets the max char height of a font.
  82801. * @param font the font to use, use the W3C CSS notation
  82802. * @return the max char height
  82803. */
  82804. private getFontHeight;
  82805. /**
  82806. * Clones the current DigitalRainFontTexture.
  82807. * @return the clone of the texture.
  82808. */
  82809. clone(): DigitalRainFontTexture;
  82810. /**
  82811. * Parses a json object representing the texture and returns an instance of it.
  82812. * @param source the source JSON representation
  82813. * @param scene the scene to create the texture for
  82814. * @return the parsed texture
  82815. */
  82816. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  82817. }
  82818. /**
  82819. * Option available in the Digital Rain Post Process.
  82820. */
  82821. export interface IDigitalRainPostProcessOptions {
  82822. /**
  82823. * The font to use following the w3c font definition.
  82824. */
  82825. font?: string;
  82826. /**
  82827. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  82828. * This number is defined between 0 and 1;
  82829. */
  82830. mixToTile?: number;
  82831. /**
  82832. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  82833. * This number is defined between 0 and 1;
  82834. */
  82835. mixToNormal?: number;
  82836. }
  82837. /**
  82838. * DigitalRainPostProcess helps rendering everithing in digital rain.
  82839. *
  82840. * Simmply add it to your scene and let the nerd that lives in you have fun.
  82841. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  82842. */
  82843. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  82844. /**
  82845. * The font texture used to render the char in the post process.
  82846. */
  82847. private _digitalRainFontTexture;
  82848. /**
  82849. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  82850. * This number is defined between 0 and 1;
  82851. */
  82852. mixToTile: number;
  82853. /**
  82854. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  82855. * This number is defined between 0 and 1;
  82856. */
  82857. mixToNormal: number;
  82858. /**
  82859. * Instantiates a new Digital Rain Post Process.
  82860. * @param name the name to give to the postprocess
  82861. * @camera the camera to apply the post process to.
  82862. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  82863. */
  82864. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  82865. }
  82866. }
  82867. declare module BABYLON {
  82868. /** @hidden */
  82869. export var brickProceduralTexturePixelShader: {
  82870. name: string;
  82871. shader: string;
  82872. };
  82873. }
  82874. declare module BABYLON {
  82875. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  82876. private _numberOfBricksHeight;
  82877. private _numberOfBricksWidth;
  82878. private _jointColor;
  82879. private _brickColor;
  82880. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82881. updateShaderUniforms(): void;
  82882. get numberOfBricksHeight(): number;
  82883. set numberOfBricksHeight(value: number);
  82884. get numberOfBricksWidth(): number;
  82885. set numberOfBricksWidth(value: number);
  82886. get jointColor(): BABYLON.Color3;
  82887. set jointColor(value: BABYLON.Color3);
  82888. get brickColor(): BABYLON.Color3;
  82889. set brickColor(value: BABYLON.Color3);
  82890. /**
  82891. * Serializes this brick procedural texture
  82892. * @returns a serialized brick procedural texture object
  82893. */
  82894. serialize(): any;
  82895. /**
  82896. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  82897. * @param parsedTexture defines parsed texture data
  82898. * @param scene defines the current scene
  82899. * @param rootUrl defines the root URL containing brick procedural texture information
  82900. * @returns a parsed Brick Procedural BABYLON.Texture
  82901. */
  82902. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  82903. }
  82904. }
  82905. declare module BABYLON {
  82906. /** @hidden */
  82907. export var cloudProceduralTexturePixelShader: {
  82908. name: string;
  82909. shader: string;
  82910. };
  82911. }
  82912. declare module BABYLON {
  82913. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  82914. private _skyColor;
  82915. private _cloudColor;
  82916. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82917. updateShaderUniforms(): void;
  82918. get skyColor(): BABYLON.Color4;
  82919. set skyColor(value: BABYLON.Color4);
  82920. get cloudColor(): BABYLON.Color4;
  82921. set cloudColor(value: BABYLON.Color4);
  82922. /**
  82923. * Serializes this cloud procedural texture
  82924. * @returns a serialized cloud procedural texture object
  82925. */
  82926. serialize(): any;
  82927. /**
  82928. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  82929. * @param parsedTexture defines parsed texture data
  82930. * @param scene defines the current scene
  82931. * @param rootUrl defines the root URL containing cloud procedural texture information
  82932. * @returns a parsed Cloud Procedural BABYLON.Texture
  82933. */
  82934. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  82935. }
  82936. }
  82937. declare module BABYLON {
  82938. /** @hidden */
  82939. export var fireProceduralTexturePixelShader: {
  82940. name: string;
  82941. shader: string;
  82942. };
  82943. }
  82944. declare module BABYLON {
  82945. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  82946. private _time;
  82947. private _speed;
  82948. private _autoGenerateTime;
  82949. private _fireColors;
  82950. private _alphaThreshold;
  82951. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82952. updateShaderUniforms(): void;
  82953. render(useCameraPostProcess?: boolean): void;
  82954. static get PurpleFireColors(): BABYLON.Color3[];
  82955. static get GreenFireColors(): BABYLON.Color3[];
  82956. static get RedFireColors(): BABYLON.Color3[];
  82957. static get BlueFireColors(): BABYLON.Color3[];
  82958. get autoGenerateTime(): boolean;
  82959. set autoGenerateTime(value: boolean);
  82960. get fireColors(): BABYLON.Color3[];
  82961. set fireColors(value: BABYLON.Color3[]);
  82962. get time(): number;
  82963. set time(value: number);
  82964. get speed(): BABYLON.Vector2;
  82965. set speed(value: BABYLON.Vector2);
  82966. get alphaThreshold(): number;
  82967. set alphaThreshold(value: number);
  82968. /**
  82969. * Serializes this fire procedural texture
  82970. * @returns a serialized fire procedural texture object
  82971. */
  82972. serialize(): any;
  82973. /**
  82974. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  82975. * @param parsedTexture defines parsed texture data
  82976. * @param scene defines the current scene
  82977. * @param rootUrl defines the root URL containing fire procedural texture information
  82978. * @returns a parsed Fire Procedural BABYLON.Texture
  82979. */
  82980. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  82981. }
  82982. }
  82983. declare module BABYLON {
  82984. /** @hidden */
  82985. export var grassProceduralTexturePixelShader: {
  82986. name: string;
  82987. shader: string;
  82988. };
  82989. }
  82990. declare module BABYLON {
  82991. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  82992. private _grassColors;
  82993. private _groundColor;
  82994. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82995. updateShaderUniforms(): void;
  82996. get grassColors(): BABYLON.Color3[];
  82997. set grassColors(value: BABYLON.Color3[]);
  82998. get groundColor(): BABYLON.Color3;
  82999. set groundColor(value: BABYLON.Color3);
  83000. /**
  83001. * Serializes this grass procedural texture
  83002. * @returns a serialized grass procedural texture object
  83003. */
  83004. serialize(): any;
  83005. /**
  83006. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  83007. * @param parsedTexture defines parsed texture data
  83008. * @param scene defines the current scene
  83009. * @param rootUrl defines the root URL containing grass procedural texture information
  83010. * @returns a parsed Grass Procedural BABYLON.Texture
  83011. */
  83012. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  83013. }
  83014. }
  83015. declare module BABYLON {
  83016. /** @hidden */
  83017. export var marbleProceduralTexturePixelShader: {
  83018. name: string;
  83019. shader: string;
  83020. };
  83021. }
  83022. declare module BABYLON {
  83023. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  83024. private _numberOfTilesHeight;
  83025. private _numberOfTilesWidth;
  83026. private _amplitude;
  83027. private _jointColor;
  83028. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83029. updateShaderUniforms(): void;
  83030. get numberOfTilesHeight(): number;
  83031. set numberOfTilesHeight(value: number);
  83032. get amplitude(): number;
  83033. set amplitude(value: number);
  83034. get numberOfTilesWidth(): number;
  83035. set numberOfTilesWidth(value: number);
  83036. get jointColor(): BABYLON.Color3;
  83037. set jointColor(value: BABYLON.Color3);
  83038. /**
  83039. * Serializes this marble procedural texture
  83040. * @returns a serialized marble procedural texture object
  83041. */
  83042. serialize(): any;
  83043. /**
  83044. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  83045. * @param parsedTexture defines parsed texture data
  83046. * @param scene defines the current scene
  83047. * @param rootUrl defines the root URL containing marble procedural texture information
  83048. * @returns a parsed Marble Procedural BABYLON.Texture
  83049. */
  83050. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  83051. }
  83052. }
  83053. declare module BABYLON {
  83054. /** @hidden */
  83055. export var normalMapProceduralTexturePixelShader: {
  83056. name: string;
  83057. shader: string;
  83058. };
  83059. }
  83060. declare module BABYLON {
  83061. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  83062. private _baseTexture;
  83063. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83064. updateShaderUniforms(): void;
  83065. render(useCameraPostProcess?: boolean): void;
  83066. resize(size: any, generateMipMaps: any): void;
  83067. get baseTexture(): BABYLON.Texture;
  83068. set baseTexture(texture: BABYLON.Texture);
  83069. /**
  83070. * Serializes this normal map procedural texture
  83071. * @returns a serialized normal map procedural texture object
  83072. */
  83073. serialize(): any;
  83074. /**
  83075. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  83076. * @param parsedTexture defines parsed texture data
  83077. * @param scene defines the current scene
  83078. * @param rootUrl defines the root URL containing normal map procedural texture information
  83079. * @returns a parsed Normal Map Procedural BABYLON.Texture
  83080. */
  83081. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  83082. }
  83083. }
  83084. declare module BABYLON {
  83085. /** @hidden */
  83086. export var perlinNoiseProceduralTexturePixelShader: {
  83087. name: string;
  83088. shader: string;
  83089. };
  83090. }
  83091. declare module BABYLON {
  83092. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  83093. time: number;
  83094. timeScale: number;
  83095. translationSpeed: number;
  83096. private _currentTranslation;
  83097. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83098. updateShaderUniforms(): void;
  83099. render(useCameraPostProcess?: boolean): void;
  83100. resize(size: any, generateMipMaps: any): void;
  83101. /**
  83102. * Serializes this perlin noise procedural texture
  83103. * @returns a serialized perlin noise procedural texture object
  83104. */
  83105. serialize(): any;
  83106. /**
  83107. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  83108. * @param parsedTexture defines parsed texture data
  83109. * @param scene defines the current scene
  83110. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  83111. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  83112. */
  83113. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  83114. }
  83115. }
  83116. declare module BABYLON {
  83117. /** @hidden */
  83118. export var roadProceduralTexturePixelShader: {
  83119. name: string;
  83120. shader: string;
  83121. };
  83122. }
  83123. declare module BABYLON {
  83124. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  83125. private _roadColor;
  83126. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83127. updateShaderUniforms(): void;
  83128. get roadColor(): BABYLON.Color3;
  83129. set roadColor(value: BABYLON.Color3);
  83130. /**
  83131. * Serializes this road procedural texture
  83132. * @returns a serialized road procedural texture object
  83133. */
  83134. serialize(): any;
  83135. /**
  83136. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  83137. * @param parsedTexture defines parsed texture data
  83138. * @param scene defines the current scene
  83139. * @param rootUrl defines the root URL containing road procedural texture information
  83140. * @returns a parsed Road Procedural BABYLON.Texture
  83141. */
  83142. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  83143. }
  83144. }
  83145. declare module BABYLON {
  83146. /** @hidden */
  83147. export var starfieldProceduralTexturePixelShader: {
  83148. name: string;
  83149. shader: string;
  83150. };
  83151. }
  83152. declare module BABYLON {
  83153. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  83154. private _time;
  83155. private _alpha;
  83156. private _beta;
  83157. private _zoom;
  83158. private _formuparam;
  83159. private _stepsize;
  83160. private _tile;
  83161. private _brightness;
  83162. private _darkmatter;
  83163. private _distfading;
  83164. private _saturation;
  83165. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83166. updateShaderUniforms(): void;
  83167. get time(): number;
  83168. set time(value: number);
  83169. get alpha(): number;
  83170. set alpha(value: number);
  83171. get beta(): number;
  83172. set beta(value: number);
  83173. get formuparam(): number;
  83174. set formuparam(value: number);
  83175. get stepsize(): number;
  83176. set stepsize(value: number);
  83177. get zoom(): number;
  83178. set zoom(value: number);
  83179. get tile(): number;
  83180. set tile(value: number);
  83181. get brightness(): number;
  83182. set brightness(value: number);
  83183. get darkmatter(): number;
  83184. set darkmatter(value: number);
  83185. get distfading(): number;
  83186. set distfading(value: number);
  83187. get saturation(): number;
  83188. set saturation(value: number);
  83189. /**
  83190. * Serializes this starfield procedural texture
  83191. * @returns a serialized starfield procedural texture object
  83192. */
  83193. serialize(): any;
  83194. /**
  83195. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  83196. * @param parsedTexture defines parsed texture data
  83197. * @param scene defines the current scene
  83198. * @param rootUrl defines the root URL containing startfield procedural texture information
  83199. * @returns a parsed Starfield Procedural BABYLON.Texture
  83200. */
  83201. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  83202. }
  83203. }
  83204. declare module BABYLON {
  83205. /** @hidden */
  83206. export var woodProceduralTexturePixelShader: {
  83207. name: string;
  83208. shader: string;
  83209. };
  83210. }
  83211. declare module BABYLON {
  83212. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  83213. private _ampScale;
  83214. private _woodColor;
  83215. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83216. updateShaderUniforms(): void;
  83217. get ampScale(): number;
  83218. set ampScale(value: number);
  83219. get woodColor(): BABYLON.Color3;
  83220. set woodColor(value: BABYLON.Color3);
  83221. /**
  83222. * Serializes this wood procedural texture
  83223. * @returns a serialized wood procedural texture object
  83224. */
  83225. serialize(): any;
  83226. /**
  83227. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  83228. * @param parsedTexture defines parsed texture data
  83229. * @param scene defines the current scene
  83230. * @param rootUrl defines the root URL containing wood procedural texture information
  83231. * @returns a parsed Wood Procedural BABYLON.Texture
  83232. */
  83233. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  83234. }
  83235. }